-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add possibility for deferred scheduling
This feature is a first attempt to solve the problems described in #7: When methods are auto-scheduled, the Executor and ThreadPools are eagerly set up while the Injector is being created. If an error occurs during Injector creation those Threads are left dangling in nirvana and might prevent the JVM from properly shutting down. Using @ManuallyStarted now marks a scheduled method as deferred. It will first be scheduled by the time SchedulingService.startManualScheduling() is called.
- Loading branch information
Showing
5 changed files
with
108 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/de/skuzzle/inject/async/schedule/annotation/ManuallyStarted.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package de.skuzzle.inject.async.schedule.annotation; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import de.skuzzle.inject.async.schedule.SchedulingService; | ||
|
||
/** | ||
* Disables auto-scheduling of the annotated method. By default, if a method is annotated | ||
* with {@link Scheduled}, it will be scheduled by the time its type/instance is | ||
* encountered/created by the Guice framework. Using this annotation you can defer the | ||
* actual scheduling until {@link SchedulingService#startManualScheduling()} is called. | ||
* | ||
* @author Simon Taddiken | ||
* @since 2.0.0 | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.METHOD) | ||
public @interface ManuallyStarted { | ||
|
||
} |