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.

Bijection is implemented as a method interceptor. Method interceptors are applied around method calls that are invoked on proxy objects. When you ask the Seam container for a component instance—perhaps through an EL expression or an injection—what you get back is a proxy of the instance. Therefore, any method call invoked on that proxy is going to pass through the method interceptors and, in turn, trigger bijection (as long as interceptors are not disabled).

However, method interceptors are blind to what goes on within the target method. As far as the interceptor is concerned, the target method is a black box. Inside of the intercepted method, you’re dealing with the raw instance of the component when you refer to the implicit variable this. Local method calls (i.e., methods on the same class) aren’t observed by the method interceptors, and therefore, bijection isn’t wrapped around them.

If you want to call a method on the current object, but also want interceptors to run, what you need to do is retrieve the instance of the current component from the Seam container. This will give you a reference to the proxy again. When you invoke a method on the reference, interceptors will run. However, because of the mythical method context in Seam, when you retrieve the component, you will need to specify the scope explicitly when looking up the component. Otherwise, you will not get back the proxy but rather the underlying instance.

((SampleBean) Component.getInstance("sampleBean", ScopeType.EVENT)).someMethodName()

Excerpts borrowed by author from Chapter 6 of Seam in Action, Manning 2008