Java Reference
In-Depth Information
If a bean class is annotated with
@Remote
, then any interfaces that it implements are assumed to be remote.
For instance, the following bean class implements two interfaces, and both are assumed to be remote although
they do not contain any annotation to indicate as such:
@Remote
@Stateless
public class AcmeSession implements interfaceA, interfaceB {
...
}
If a bean class contains the
@Local
annotation, then any interfaces that it implements are assumed to be local.
For instance, the following bean class implements two interfaces, and both are assumed to be local although they
do not contain any annotation to indicate as such:
@Local
@Stateless
public class AcmeSession implements interfaceA, interfaceB {
...
}
If a bean class contains the
@Local
or
@Remote
annotation and specifies an interface name within the annotation,
then the specified interface is designated the same designation as the annotated bean. For instance, the following
bean is annotated to include a local business interface, and the name of the interface is specified in the annotation,
thereby making the interface local:
@Local(interfaceA.class)
@Stateless
public class AcmeSession implements interfaceA {
...
}
These new designation rules make it easier to designate and determine the type of business interface that
is implemented by a bean.
Extended TimerService API
The TimerService API has been extended to include a new convenience method that allows you to obtain information
about all active timers. The TimerService API is a facility that allows time-based method invocations to occur within
a session bean. Using the API, it is possible to create scheduled tasks, programmatically timed tasks, and automated
tasks based upon a specified time and/or date. In this section, you'll take a brief look at creating a couple of timers,
and then you will see how to utilize the newly added
getAllTimers
method to return all active timers within the
same bean.
Utilize dependency injection to obtain an instance of the
TimerService
for use within your bean. A
TimerService
can be an injected using the
@Resource
annotation, as follows:
@Resource
TimerService timerService;
As mentioned, you can create different types of timers, depending upon the use case. To programmatically create
a timer, use the TimerService API to return the type of timer desired. Table
5-2
describes the types of programmatic
timers that can be created by the TimerService API .