This content has been marked as final.
Show 3 replies
-
1. Re: Programatic injection inside an interceptor
lightguard Aug 15, 2011 12:53 PM (in response to tsweeney56)You can do it, but it's messy :) If you still want the code let us know. Also curious as to why you'd want to do it this way.
-
2. Re: Programatic injection inside an interceptor
tsweeney56 Aug 16, 2011 4:02 PM (in response to tsweeney56)I am converting a seam 2 app to seam 3, there are a few cases that we intercept method calls to cache the result or move along a state machine.
I would love the code regardless how messy it is.
-
3. Re: Programatic injection inside an interceptor
lightguard Aug 16, 2011 4:25 PM (in response to tsweeney56)If you're doing interception, why not write interceptors and use injection that way?
Creating an interceptor and doing injection into the interceptor would be a much better solution though.
It's not perfectly documented, but you can use this method:
@SuppressWarnings("unchecked") public static <T> T getContextualInstance(final BeanManager manager, final Class<T> type) { T result = null; Bean<T> bean = (Bean<T>) manager.resolve(manager.getBeans(type)); if (bean != null) { CreationalContext<T> context = manager.createCreationalContext(bean); if (context != null) { result = (T) manager.getReference(bean, type, context); } } return result; }