[seam-dev] What's the purpose of the method context?

Norman Richards orb at nostacktrace.com
Mon Jun 9 16:55:02 EDT 2008


I'm looking at a support issue, and I've found a problem with  
MethodContextInterceptor.  The interceptor puts the calling component,  
by name, in the method context so that future calls to getInstance()  
will find that version of the component.  However, it sets the raw,  
unproxied object so that calls to that object will not go through the  
interceptor chain.  (so, an annotation like @CreateProcess won't be  
triggered).  This seems wrong to me, but since I don't understand the  
purpose of MethodContextInterceptor, I can't say for sure.

In case the description above isn't clear, consider a simple component  
like this:

...
@Name("foo")
public class Foo {
    @RaiseEvent("myEvent")
    public void actionOne() { }

    @CreateProcess(...)
    @Observe("myEvent")
    public void actionTwo() { }
}


When #{foo.one} is invoked, the unproxied Foo instance is put in the  
method context under "foo".  When the event is raised, Events tries to  
lookup "foo" but instead of finding the correct instance in it's  
normal context, it finds the raw instance in the method context.   
actionTwo() is called, but there are no proxies involved and thus  
@CreateProcess isn't triggered.

So, what in the world is the MethodContextInterceptor doing there?   
Should it really be storing the unproxied instance there?







More information about the seam-dev mailing list