Issue 258: [Patch] custom annotation based injection points
http://code.google.com/p/google-guice/issues/detail?id=258

New issue report by james.strachan:
There are lots of standards and frameworks which define their own custom  
injection points.
Here's a few off the top of my head; I'm sure there's many more out there...

JSR 250 & EJB3 defines @Resouce for injecting objects from JNDI
JPA defines @PersistenceContext for injecting JPA resources usually  
prebound to a transaction
context etc
JAX-RS defines a number of them such as @PathParam, @HeaderParam, @Context  
etc
WebBeans defines @In
Stripes defines @SpringBean
Apache Camel defines @EndpointInject and @Produces


This patch makes it easy to implement these custom injection points in  
frameworks as follows;
this example supports @Resource from JSR 250

{{{
@InjectionAnnotation(Resource.class)
public class ResourceProviderFactory<T> implements  
AnnotationProviderFactory<T> {
   private final Context context;

   @Inject
   public ResourceProviderFactory(Context context) {
     this.context = context;
   }

   public Provider<T> createProvider(AnnotatedElement member) {
     Resource resource = member.getAnnotation(Resource.class);
     Objects.nonNull(resource, "@Resource is missing!");
     String name = getJndiName(resource, member);
     return new Provider<T>() {...}
   }
}}}}

Rather than going into a long discussion in this issue, I'll bring it up on  
the mailing list and post
a link here shortly...

Note that this patch also includes these patches...
http://code.google.com/p/google-guice/issues/detail?id=62
http://code.google.com/p/google-guice/issues/detail?id=78

given the amount of code I've changed for these 3 patches its been a bit  
tricky separating them
out into different patches.

Mostly this patch involves changes to InjectionPoint and InjectorImpl along  
with the new interface AnnotationProviderFactory and annotation  
InjectionAnnotation along with a new test case in the
jsr250 module called ResourceTest that tests out the injection of @Resource  
for field and
method injection

Attachments:
        custom_annotation_injections.patch  121 KB


Issue attributes:
        Status: New
        Owner: ----
        Labels: Type-Defect Priority-Medium

-- 
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-guice-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to