Help

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

The MethodContextInterceptor, which is wrapped around all Seam components, puts the calling component, by name, in the method context so that future calls to getInstance() from inside the method will find that version of the component. Note, however, that it sets the raw, unproxied object so that calls to that object will not go through the interceptor chain. For instance, an annotation like @CreateProcess won't be triggered when the method is invoked from another method on the same component.

Consider the following example:

@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. The actionTwo() method is called, but there are no proxies involved and thus @CreateProcess isn't triggered.

In the same example, consider the following two calls to understand how to work around this behavior:

public void actionOne() {
    // interceptors not applied (MethodContextInterceptor in the way)
    ((Foo) Component.getInstance("foo")).actionTwo()

    // interceptors applied
    ((Foo) Component.getInstance("foo", ScopeType.EVENT)).actionTwo();
}

The point of the MethodContextInterceptor is to circumvent some very incorrect behavior dealing with recursive calls. So you have to tell Seam explicitly when this is the desired behavior. Please see issue JBSEAM3094 for possible enhancements to Seam to accommodate this use case.