Hey,
If you read the blog post I made on the @Inject spec and the comment
thread there is one thing that I think is interesting, and that we
should consider.
Right now we only have scoping annotations for injections, such as
@Service, @Uses and @This. For some scopes, such as @Service it would
make sense to add additional qualifiers, as outlined in the @Inject
spec. Specifically these could replace some of the use of
ServiceSelectors, which is a manual process.
Today:
public class Some
{
public Some(@Service Iterable<ServiceReference<EntityStore>>
entityStores)
{
EntityStore store = service(entityStores, withTags("configuration"));
}
}
In the above there's no way for Qi4j to tell whether Some is going to be
happy or not, and you have to read the code to see what tags are
expected from the implementation.
Example using qualifiers:
public class Some
{
public Some(@Service @Tagged("configuration") EntityStore entityStore)
{
...
}
}
With this Qi4j could statically deduce what EntityStore to inject at
startup, and if none is available then initialization of the app could
abort early. It also becomes possible to see in the Javadoc or Envisage
what is expected from the injected service.
As this is only relevant for @Service (AFAICT) I would prefer to be able
to specify it within the @Service annotation itself with
"@Service(@Tagged("persistence"))" but unfortunately the Java syntax
does not allow this, as annotation variables *can* be annotations, just
not Annotation itself, which is what would be appropriate here!
Suggestion:
Introduce @Qualifier annotation and create a number of well-known
annotations such as @Tagged that can be used to statically limit the
possible bindings for injection points.
/Rickard
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev