Java Reference
In-Depth Information
Listing 3.7. BillingService
Now that you have a handle on a simple example, let's look at the annotation and then the
Future interface.
3.5.4. Using the @Asynchronous annotation
The @Asynchronous annotation is one of the simplest annotations covered in this
chapter. It has no parameters and can be placed either on the class or on individual methods.
If it's placed on the class, all of the methods within the class are invoked asynchronously.
Placing the annotation on individual methods enables fine-grained control over which
methods are invoked asynchronously. This annotation can be used with any of the bean
types described in this chapter: stateless, stateful, and singleton. The annotation is defined
as follows:
@Target(value = {ElementType.METHOD, ElementType.TYPE})
@Retention(value = RetentionPolicy.RUNTIME)
public @interface Asynchronous {
}
The use of this annotation on a class was demonstrated in listing 3.5 and on individual
methods in listing 3.6 . The annotation is the simple part; things start to get complicated
when we look at the Future interface.
 
Search WWH ::




Custom Search