-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- extract Constants - constant for default name - constants for names expressions - servicePropery cron -> cronjob.cron and String[] - fallback for old servicePropery cron - hold tests of old servicePropery cron - add test of old servicePropery cronjob.cron - servicePropery name -> cronjob.name and define in api - fallback for old servicePropery name - use osgi converter in scheduler - add Requirement and Capability annotation - make corePoolSize configurable - make shutdownTimeout(soft/hard) configurable - fix fieldNames and javadoc - add duration methods to Scheduler - make parameterNames more expressiv Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
- Loading branch information
Showing
16 changed files
with
298 additions
and
69 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
83 changes: 83 additions & 0 deletions
83
biz.aQute.api/src/main/java/biz/aQute/scheduler/api/Constants.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,83 @@ | ||
package biz.aQute.scheduler.api; | ||
|
||
public final class Constants { | ||
|
||
private Constants() { | ||
// Constants | ||
} | ||
|
||
/** | ||
* Specification Name | ||
*/ | ||
public static final String SPECIFICATION_NAME = "aqute.scheduler"; | ||
|
||
/** | ||
* Specification Version | ||
*/ | ||
public static final String SPECIFICATION_VERSION = "1.1.0"; | ||
|
||
/** | ||
* The service property Prefix for cronjobs | ||
*/ | ||
public static final String SERVICE_PROPERTY_CRONJOB_PREFIX = "cronjob"; | ||
|
||
/** | ||
* The service property that specifies the cron schedule. The type is String+. | ||
*/ | ||
public static final String SERVICE_PROPERTY_CRONJOB_CRON = SERVICE_PROPERTY_CRONJOB_PREFIX+".cron"; | ||
|
||
/** | ||
* The service property that specifies the name of the cron job. The type is | ||
* String. | ||
*/ | ||
public static final String SERVICE_PROPERTY_CRONJOB_NAME = SERVICE_PROPERTY_CRONJOB_PREFIX+".name"; | ||
|
||
/** | ||
* Default name of the cron job. | ||
*/ | ||
public static final String CRONJOB_NAME_DEFAULT = "unknown"; | ||
|
||
/** | ||
* the named cron expression for annually execution. | ||
*/ | ||
public static final String CRON_EXPRESSION_ANNUALLY = "@annually"; | ||
|
||
/** | ||
* the named cron expression for yearly execution. | ||
*/ | ||
public static final String CRON_EXPRESSION_YEARLY = "@yearly"; | ||
|
||
/** | ||
* the named cron expression for monthly execution. | ||
*/ | ||
public static final String CRON_EXPRESSION_MONTHLY = "@monthly"; | ||
/** | ||
* the named cron expression for weekly execution. | ||
*/ | ||
public static final String CRON_EXPRESSION_WEEKLY = "@weekly"; | ||
|
||
/** | ||
* the named cron expression for daily execution. | ||
*/ | ||
public static final String CRON_EXPRESSION_DAYLY = "@daily"; | ||
|
||
/** | ||
* the named cron expression for hourly execution. | ||
*/ | ||
public static final String CRON_EXPRESSION_HOURLY = "@hourly"; | ||
|
||
/** | ||
* the named cron expression for minutely execution. | ||
*/ | ||
public static final String CRON_EXPRESSION_MINUTLY = "@minutely"; | ||
|
||
/** | ||
* the named cron expression for secondly execution. | ||
*/ | ||
public static final String CRON_EXPRESSION_SECUNDLY = "@secondly"; | ||
|
||
/** | ||
* the named cron expression for execution onreboot. | ||
*/ | ||
public static final String CRON_EXPRESSION_REBOOT = "@reboot"; | ||
} |
18 changes: 16 additions & 2 deletions
18
biz.aQute.api/src/main/java/biz/aQute/scheduler/api/CronExpression.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 |
---|---|---|
@@ -1,18 +1,32 @@ | ||
package biz.aQute.scheduler.api; | ||
|
||
import org.osgi.service.component.annotations.ComponentPropertyType; | ||
import org.osgi.service.metatype.annotations.AttributeDefinition; | ||
import org.osgi.service.metatype.annotations.ObjectClassDefinition; | ||
|
||
/** | ||
* An annotation to simplify using a CronJob | ||
*/ | ||
@ComponentPropertyType | ||
@ObjectClassDefinition | ||
@RequireSchedulerImplementation | ||
public @interface CronExpression { | ||
|
||
public static final String PREFIX_ = Constants.SERVICE_PROPERTY_CRONJOB_PREFIX; | ||
/** | ||
* The 'cron.expression' service property | ||
* The 'cronjob.cron' service property as defines in {@link Constants#SERVICE_PROPERTY_CRONJOB_CRON} | ||
* @return | ||
*/ | ||
String cron(); | ||
@AttributeDefinition(name="cronJobCronExpression", description = "Cron Expression according the Cron Spec. see http://en.wikipedia.org/wiki/Cron") | ||
String[] cron(); | ||
|
||
/** | ||
* The 'cronjob.name' service property as defines in {@link Constants#SERVIC_PROPERTY_CRON_NAME()()} | ||
* @return | ||
*/ | ||
@AttributeDefinition(name="cronJobName", description = "Human readable name of the cronjob") | ||
String name() default Constants.CRONJOB_NAME_DEFAULT; | ||
|
||
|
||
} | ||
|
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
17 changes: 17 additions & 0 deletions
17
biz.aQute.api/src/main/java/biz/aQute/scheduler/api/RequireSchedulerImplementation.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,17 @@ | ||
package biz.aQute.scheduler.api; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
|
||
import org.osgi.annotation.bundle.Requirement; | ||
import org.osgi.namespace.implementation.ImplementationNamespace; | ||
|
||
/** | ||
* Require an implementation for the this specification | ||
*/ | ||
@Requirement(namespace = ImplementationNamespace.IMPLEMENTATION_NAMESPACE, filter = "(&(" | ||
+ ImplementationNamespace.IMPLEMENTATION_NAMESPACE + "=" | ||
+ Constants.SPECIFICATION_NAME + ")${frange;${version;==;" | ||
+ Constants.SPECIFICATION_VERSION + "}})") | ||
@Retention(RetentionPolicy.CLASS) | ||
public @interface RequireSchedulerImplementation {} |
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
2 changes: 1 addition & 1 deletion
2
biz.aQute.api/src/main/java/biz/aQute/scheduler/api/package-info.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
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
27 changes: 17 additions & 10 deletions
27
...eduler.basic.provider/src/main/java/biz/aQute/scheduler/basic/config/SchedulerConfig.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 |
---|---|---|
@@ -1,20 +1,27 @@ | ||
package biz.aQute.scheduler.basic.config; | ||
|
||
import org.osgi.service.metatype.annotations.AttributeDefinition; | ||
import org.osgi.service.metatype.annotations.ObjectClassDefinition; | ||
|
||
/** | ||
* Configuration for the scheduler. The scheduler is a singleton | ||
*/ | ||
|
||
@ObjectClassDefinition | ||
@ObjectClassDefinition( description = "Configuration for the scheduler. The scheduler is a singleton") | ||
public @interface SchedulerConfig { | ||
String PID = "biz.aQute.scheduler.basic"; | ||
String SYSTEM_DEFAULT_TIMEZONE = "system.default.timezone"; | ||
String DESCRIPTION = "Set the time zone. The default is the system default time zone. " | ||
+ "If the time zone does not exist, an error is logged and the system default time zone is used."; | ||
int COREPOOLSIZE_DEFAUL = 50; | ||
int SHUTDOWNTIMEOUT_SOFT_DEFAUL = 500; | ||
int SHUTDOWNTIMEOUT_HARD_DEFAUL = 5000; | ||
|
||
/** | ||
* Set the time zone. The default is the system default time zone. If the | ||
* time zone does not exist, an error is logged and the system default time zone is | ||
* used. | ||
*/ | ||
@AttributeDefinition(description = DESCRIPTION) | ||
String timeZone() default SYSTEM_DEFAULT_TIMEZONE; | ||
|
||
@AttributeDefinition(description = "corePoolSize of ScheduledThreadPoolExecutor") | ||
int corePoolSize() default COREPOOLSIZE_DEFAUL; | ||
|
||
@AttributeDefinition(description = "Expected shutdownTimeout of ScheduledThreadPoolExecutor") | ||
int shutdownTimeoutSoft() default SHUTDOWNTIMEOUT_SOFT_DEFAUL; | ||
|
||
@AttributeDefinition(description = "Expected shutdownTimeout after the shutdownTimeoutSoft befor the shutdown of ScheduledThreadPoolExecutor is forced") | ||
int shutdownTimeoutHard() default SHUTDOWNTIMEOUT_HARD_DEFAUL; | ||
} |
2 changes: 1 addition & 1 deletion
2
...scheduler.basic.provider/src/main/java/biz/aQute/scheduler/basic/config/package-info.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
Oops, something went wrong.