| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| <html> |
| <body> |
| <h2>Service Qualifiers.</h2> |
| <p> |
| The @Service injection is only able to specify the type of the service to be injected. If any other type of |
| qualification has to be done it has to be done manually but for common cases it's more convenient to use |
| annotations to do this filtering. This package contains annotations to perform this qualification. |
| </p> |
| <p>Example:</p> |
| <blockquote> |
| <pre>@Service @Tagged( "sometag" ) MyService service;</pre> |
| </blockquote> |
| <p> |
| This will only inject instances of MyService that have been tagged with "sometag". If none exist an |
| exception will occur at injection time since it is not optional. |
| </p> |
| <p>It also works with iterables:</p> |
| <blockquote> |
| <pre>@Service @Tagged( "sometag" ) Iterable<MyService> services;</pre> |
| </blockquote> |
| <p> |
| The qualification will be evaluated upon each call to iterator(), and since the qualifier has access to a |
| ServiceReference, which contains the isActive() method, it can even provide some dynamicity. |
| </p> |
| <blockquote> |
| <pre>@Service @Active Iterable<SomeImportedService> importedServices;</pre> |
| </blockquote> |
| <p> |
| Let's say these SomeImportedService are only sometimes available. Then whenever iterator() is called the |
| {@link org.qi4j.api.service.qualifier.Active} tag can kick in and filter out those whose |
| ServiceReference.isActive() returns false. |
| </p> |
| <p>Standard ones defined in the API are:</p> |
| <ul> |
| <li>{@link org.qi4j.api.service.qualifier.Active}</li> |
| <li>{@link org.qi4j.api.service.qualifier.Available}</li> |
| <li>{@link org.qi4j.api.service.qualifier.HasMetaInfo}</li> |
| <li>{@link org.qi4j.api.service.qualifier.IdentifiedBy}</li> |
| <li>{@link org.qi4j.api.service.qualifier.Tagged}</li> |
| </ul> |
| <p>See tests and API for more examples, and how to implement your own qualifiers.</p> |
| </body> |
| </html> |