Java Reference
In-Depth Information
Notice that the only change we had to make to our session bean was to add the
@Interceptors annotation to its echo() method. In this particular case, the class
array attribute has a single value, which is the LoggingInterceptor class we
defined earlier. In our example, we are using a single interceptor for our bean's
method. If we need our method to be intercepted by more than one interceptor, we
can do that by adding additional interceptor classes between the curly braces in the
@Interceptors annotation. The list of interceptors between the curly braces must
be separated by commas.
At this point, we are ready to test our interceptor. In NetBeans, we can simply right-
click on the project in the Projects window and select Run . After doing so, we should
see the output of the interceptor's logMethodCall() method in NetBean's GlassFish
output window.
The EJB Timer service
Stateless session beans and message-driven beans (another type of EJB discussed
later in the topic) can have a method that is executed automatically at regular
intervals. This functionality is useful if we want to execute some logic periodically
(once a week, every day, every other hour, and so on) without having to explicitly
call any methods. This functionality is achieved by the EJB Timer service.
Search WWH ::

Custom Search