-
Notifications
You must be signed in to change notification settings - Fork 4
Injected Parameters
Simon Taddiken edited this page Aug 21, 2016
·
2 revisions
Scheduled methods can have their parameters injected. The actual instances that will be passed will be obtained from the Injector
prior to each invocation. Thus if you pass unscoped types you end up with a new instance each time the method is called.
@Scheduled
@DelayedTrigger(2000)
public void scheduledMethod(SomeService someService, @Named("sample") OtherService) {
}
Please note that all instances passed to a scheduled method must be thread safe.
If you want to reuse the mechanism of injecting parameters have a look at the class InjectedMethodInvocation
contained in de.skuzzle.inject.async.util
.