Skip to content
/ cs4j Public

Cron scheduler for Java

License

MIT, Apache-2.0 licenses found

Licenses found

MIT
LICENSE
Apache-2.0
LICENSE.txt
Notifications You must be signed in to change notification settings

cs4j/cs4j

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CS4j (Cron Scheduler for Java) - is a small Cron style task scheduler for Java compatible with Spring version.

Build Status

Maven

<dependency>
    <groupId>com.github.cs4j</groupId>
    <artifactId>cs4j</artifactId>
    <version>1.1.1</version>
</dependency

Usage

// Create scheduler with a pool of 10 threads with 1 second initial delay and 3 seconds check interval. 
// The name of the scheduler thread will be set to 'T1'
Scheduler scheduler = new Scheduler(Executors.newFixedThreadPool(10), 1, 3, TimeUnit.SECONDS, "T1") ;
 // get service instance. This can be any Java object with @Scheduled methods.
Service service = ...; 
// enable scheduling for all methods with @Scheduled annotation
scheduler.schedule(service); 
...
scheduler.shutdown(); // shutdown the scheduler.

Example of Service class:

public class Service {
    // Cron format: second, minute, hour, day, month, day of the week
    // The method runs every first second each minute
    @Scheduled(cron = "1 * * * * * *")   
    void ping() {
        log.info("pong")
    }
}

Implementation details

The scheduler is based on Spring's CronSequenceGenerator class. It uses compatible syntax, inherits and successfully passes all original Spring tests.

The package is recommended when you can't use original Spring implementation for some reason. CS4J has no additional runtime dependencies and it's JAR file size is about 11kb.

Requirements

Java 7+

License

Apache License 2.0

Related projects

About

Cron scheduler for Java

Resources

License

MIT, Apache-2.0 licenses found

Licenses found

MIT
LICENSE
Apache-2.0
LICENSE.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages