Differences
This shows you the differences between two versions of the page.
osgi_task_scheduler [2014/03/13 13:25] |
osgi_task_scheduler [2021/04/05 11:23] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== OSGi Task Scheduler ====== | ||
+ | Java EE introduced the Timer and Scheduling API and support some time ago. At the moment there is no specification for OSGi. But some projects have made an implementation on their own, like the [[http:// | ||
+ | ===== Requirements ===== | ||
+ | * OSGi container | ||
+ | * Apache Felix SCR | ||
+ | * Apache Sling Commons Threads bundle | ||
+ | * Apache Sling Commons Scheduler bundle | ||
+ | |||
+ | |||
+ | ===== Test Environment ===== | ||
+ | This has been tested with Apache Karaf 3.1.0 and Sling 6. | ||
+ | |||
+ | * org.apache.felix.scr 1.8.2 | ||
+ | * org.apache.felix.scr.ds-annotations 1.2.4 | ||
+ | * org.apache.felix.scr.annotations 1.9.6 | ||
+ | * org.apache.sling.commons.threads 3.2.0 | ||
+ | * org.apache.sling.commons.scheduler 2.4.2 | ||
+ | |||
+ | The bundles have been dropped into the //deploy// folder. The log file // | ||
+ | |||
+ | ===== Tasks ===== | ||
+ | Internally the Sling Scheduler uses the [[http:// | ||
+ | |||
+ | ==== Task Example ==== | ||
+ | For a task to run every minute declared with a crontab style scheduling expression the following Java class needs to be created. | ||
+ | |||
+ | <sxh java; title: HelloTask.java> | ||
+ | import org.apache.log4j.Logger; | ||
+ | |||
+ | public class HelloTask implements Runnable { | ||
+ | |||
+ | private static final Logger logger = Logger.getLogger(HelloTask.class); | ||
+ | | ||
+ | @Override | ||
+ | public void run() { | ||
+ | logger.info(" | ||
+ | } | ||
+ | |||
+ | } | ||
+ | </ | ||
+ | |||
+ | <sxh xml; title: OSGI-INF/ | ||
+ | <?xml version=" | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | <provide interface=" | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | <sxh title: MANIFEST.MF> | ||
+ | Service-Component: | ||
+ | </ | ||
+ | |||
+ | ===== Links ===== | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | |||
+ | {{tag> |