[jboss-user] [EJB 3.0 Development] - Deferring instance creation/injection to CDI

Marius Bogoevici do-not-reply at jboss.com
Wed Aug 11 15:09:13 EDT 2010


Marius Bogoevici [http://community.jboss.org/people/marius.bogoevici] replied to the discussion

"Deferring instance creation/injection to CDI"

To view the discussion, visit: http://community.jboss.org/message/556962#556962

--------------------------------------------------------------
> 
> > Marius Bogoevici wrote:
> > 
> > 2) EJB container provides a hook for preprocessing interceptors after instantiation. The main reason is that EJB interceptors may be CDI-injected 
> > (note: could we reuse the same mechanism as for EJB instantiation, since it boils down to producing an instance of the class? )
> 
> I'm pretty sure we could do this too.  We have this bit of code, though I haven't verified if it's currently used or cruft:
> 
> 
> *public* Object createInterceptor(Class<?> interceptorClass) *throws* InstantiationException, IllegalAccessException
>    {
>       Object instance = interceptorClass.newInstance();
>       InterceptorInjector interceptorInjector = interceptorInjectors.get(interceptorClass);
>       *assert* interceptorInjector != *null* : "interceptorInjector not found for " + interceptorClass;
>       interceptorInjector.inject(null, instance);
>       *return* instance;
>    }
> 
> 
> 
> 
> 
> 
> Plenty of room in there to both abstract away the instantiation or give some post-instantiation callback before the instance is returned.
> 
> 
> 
This looks good, and I see that is currently being used for @Resource injection in the least. The main challenge seems to be that interceptorInjectors is encapsulated and initialized inside org.jboss.ejb3.EJBContainer. 

I am wondering if we could provide a mechanism similar to the instantiator for passing a custom interceptor injector at deployment time. 

--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/556962#556962]

Start a new discussion in EJB 3.0 Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2030]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100811/cd39502f/attachment-0001.html 


More information about the jboss-user mailing list