-
1. Re: Is it possible to access the outer instance of a Seam Co
pmuir Jun 14, 2007 7:03 PM (in response to youngm)AFAIK calls to this. aren't intercepted so you can't. You need to put the async method on separate component, inject the component and call cmp.sendAnEmail() - though this does seem quite convoluted. Hmmm.
-
2. Re: Is it possible to access the outer instance of a Seam Co
youngm Jun 14, 2007 7:10 PM (in response to youngm)EJB provides the context.getThis() method....perhaps ther e is some kind of Seam execution context we can make available somehow?
-
3. Re: Is it possible to access the outer instance of a Seam Co
pmuir Jun 14, 2007 7:13 PM (in response to youngm)Does it apply interceptors to getThis() - if so then the Seam interceptors will be applied and you are there...
-
4. Re: Is it possible to access the outer instance of a Seam Co
youngm Jun 14, 2007 7:15 PM (in response to youngm)I believe it does apply interceptors, however, my bean isn't an EJB. :)
-
5. Re: Is it possible to access the outer instance of a Seam Co
youngm Jun 14, 2007 7:17 PM (in response to youngm)I was just mentioning that as an idea. Perhaps Seam could provide an invocation context in ThreadLocal so I could do something like:
InvocationContext.getContext().sendAnEmail();
Just a thought. -
6. Re: Is it possible to access the outer instance of a Seam Co
pmuir Jun 14, 2007 7:22 PM (in response to youngm)Ask Gavin what he thinks, I think that we can improve on where we are at now :)
-
7. Re: Is it possible to access the outer instance of a Seam Co
gavin.king Jun 14, 2007 10:09 PM (in response to youngm)@Name("someClass") public class SomeClass { @In SomeClass someClass; public void createSomething() { someClass.sendAnEmail(); } @Asynchronous public void sendAnEmail() { //Send an email asynchronously } }
I *think* that should work.... -
8. Re: Is it possible to access the outer instance of a Seam Co
youngm Jul 9, 2007 6:46 PM (in response to youngm)Actually it doesn't work. It appears that MethodContextInterceptor is unwrapping the component and placing it in the method context so when you attempt to inject SomeClass it is an unwrapped instance. This is also going to cause problems if you try to do:
@Name("someClass") public class SomeClass { @In SomeClass someClass; public void createSomething() { someOtherClass.createSomething(); } @Asynchronous public void sendAnEmail() { //Send an email asynchronously } } @Name("someOtherClass") public class SomeOtherClass { @In SomeClass someClass; public void createSomething() { someClass.sendAnEmail(); } }
Is this MethodContextInterceptor necessary for all component types or just Session Beans? It's currently being applied to all components except ENTITY. -
9. Re: Is it possible to access the outer instance of a Seam Co
gavin.king Jul 11, 2007 2:48 AM (in response to youngm)Ahyes, that's true, didn't think of that.
I dunno, tough problem to solve then. Report it in JIRA I guess.