how many instances of the FooInterceptor class will be used?

A developer writes an interceptor class containing an AroundInvoke method, and applies it to the
local business interface method of a stateless session bean:
11. @Interceptors(FooInterceptor.class)
12. public void bar() ()
A client obtains a reference to the beans local business interface, and calls the method bar two
times from the same thread. Assuming that the container dispatches both cell to the same
stateless session bean instance, how many instances of the FooInterceptor class will be used?

A developer writes an interceptor class containing an AroundInvoke method, and applies it to the
local business interface method of a stateless session bean:
11. @Interceptors(FooInterceptor.class)
12. public void bar() ()
A client obtains a reference to the beans local business interface, and calls the method bar two
times from the same thread. Assuming that the container dispatches both cell to the same
stateless session bean instance, how many instances of the FooInterceptor class will be used?

A.
0

B.
2

C.
1

D.
Either 1 or 2

Explanation:
You can specify one nonbusiness method as the interceptor method for a stateless
or stateful session bean. Each time a client invokes a session bean business method, OC4J
intercepts the invocation and invokes the interceptor method.
Reference:Configuring an Around Invoke Interceptor Method on an EJB 3.0 Session Bean



Leave a Reply 4

Your email address will not be published. Required fields are marked *


Alex

Alex

C
Enterprise JavaBeans 3.1, Final Release: 12.2 Interceptor Life Cycle
The lifecycle of an interceptor instance is the same as that of the bean instance with which it is associated. In the case of interceptors associated with stateful session beans, the interceptor instances are passivated upon bean instance passivation, and activated when the bean instance is activated.

nAvy

nAvy

Interceptor Lifecycle
Interceptor classes have the same lifecycle as their associated target class. When a target class instance is created, an interceptor class instance is also created for each declared interceptor class in the target class. That is, if the target class declares multiple interceptor classes, an instance of each class is created when the target class instance is created. The target class instance and all interceptor class instances are fully instantiated before any @PostConstruct callbacks are invoked, and any @PreDestroy callbacks are invoked before the target class and interceptor class instances are destroyed.