-
Notifications
You must be signed in to change notification settings - Fork 4
Choosing the ExecutorService
Simon Taddiken edited this page Aug 20, 2016
·
1 revision
Methods are called asynchronously using an ExecutorService
. If not further specified (see below) a default executor will be used for running the annotated method.
The framework does allow to customize which executor will be used. For each annotated method you can define a Key
that is used to look up the actual Executor implementation from the Injector. You can use the @Executor
annotation for specifying the Executor type. Optionally you can put a binding annotation to further refine the Key
.
@Async
@Executor(MyVerySpecialCustomExecutor.class)
@Named("firstVerySpecialCustomExecutor")
public void sendMail(MailOptions options) {
// Executor will be retrieved using Key.get(MyVerySpecialCustomExecutor.class,
// Names.named("firstVerySpecialCustomExecutor"))
}
@Async
@Named("sendMailThread")
public void sendMailAlternatively(MailOptions options) {
// Executor will be retrieved using Key.get(ExecutorService.class,
// Names.named("sendMailThread"))
}
}