Move Sling to new TLP location
git-svn-id: https://svn.eu.apache.org/repos/asf/sling/tags/org.apache.sling.commons.scheduler-2.0.2-incubator@785979 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..accd896
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,9 @@
+Apache Sling Commons Scheduler
+Copyright 2008 The Apache Software Foundation
+
+Apache Sling is based on source code originally developed
+by Day Software (http://www.day.com/).
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..4decb94
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,37 @@
+Apache Sling Commons Scheduler
+
+The commons scheduler provides a scheduling services which allows to schedule
+tasks periodically.
+
+Disclaimer
+==========
+Apache Sling is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Jackrabbit PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other
+successful ASF projects. While incubation status is not necessarily a reflection of
+the completeness or stability of the code, it does indicate that the project has yet
+to be fully endorsed by the ASF.
+
+Getting Started
+===============
+
+This component uses a Maven 2 (http://maven.apache.org/) build
+environment. It requires a Java 5 JDK (or higher) and Maven (http://maven.apache.org/)
+2.0.7 or later. We recommend to use the latest Maven version.
+
+If you have Maven 2 installed, you can compile and
+package the jar using the following command:
+
+ mvn package
+
+See the Maven 2 documentation for other build features.
+
+The latest source code for this component is available in the
+Subversion (http://subversion.tigris.org/) source repository of
+the Apache Software Foundation. If you have Subversion installed,
+you can checkout the latest source using the following command:
+
+ svn checkout http://svn.apache.org/repos/asf/incubator/sling/trunk/commons/scheduler
+
+See the Subversion documentation for other source control features.
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..8cd6933
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>sling</artifactId>
+ <version>3-incubator</version>
+ <relativePath>../../parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>org.apache.sling.commons.scheduler</artifactId>
+ <packaging>bundle</packaging>
+ <version>2.0.2-incubator</version>
+
+ <name>Sling - Scheduler Support</name>
+ <description>
+ Support for scheduling.
+ </description>
+
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/sling/tags/org.apache.sling.commons.scheduler-2.0.2-incubator</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/sling/tags/org.apache.sling.commons.scheduler-2.0.2-incubator</developerConnection>
+ <url>http://svn.apache.org/viewvc/incubator/sling/tags/org.apache.sling.commons.scheduler-2.0.2-incubator</url>
+ </scm>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Import-Package>
+ org.apache.commons.collections,*
+ </Import-Package>
+ <Export-Package>
+ org.apache.sling.commons.scheduler;version=${pom.version}
+ </Export-Package>
+ <Private-Package>
+ org.apache.sling.commons.scheduler.impl,
+ org.apache.commons.modeler,
+ org.apache.commons.modeler.mbeans,
+ org.apache.commons.modeler.modules,
+ org.apache.commons.modeler.util
+ </Private-Package>
+ <DynamicImport-Package>
+ javax.ejb,org.apache.commons.logging.impl,javax.jms
+ </DynamicImport-Package>
+ <Embed-Dependency>
+ quartz,commons-pool,commons-dbcp,commons-beanutils,commons-digester
+ </Embed-Dependency>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <excludePackageNames>
+ org.apache.sling.commons.scheduler.impl
+ </excludePackageNames>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.threads</artifactId>
+ <version>2.0.2-incubator</version>
+ </dependency>
+ <!-- The following dependencies will be replaced by using the quartz wrapper bundle -->
+ <dependency>
+ <groupId>opensymphony</groupId>
+ <artifactId>quartz</artifactId>
+ <version>1.6.0</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-pool</groupId>
+ <artifactId>commons-pool</artifactId>
+ <version>1.3</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-modeler</groupId>
+ <artifactId>commons-modeler</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <version>1.2.2</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <version>1.7.0</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-digester</groupId>
+ <artifactId>commons-digester</artifactId>
+ <version>1.8</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/src/main/java/org/apache/sling/commons/scheduler/Job.java b/src/main/java/org/apache/sling/commons/scheduler/Job.java
new file mode 100644
index 0000000..8b0fc39
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/scheduler/Job.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.commons.scheduler;
+
+/**
+ * A job is executed by the {@link Scheduler} service.
+ * If the implementation of the job requires certain environment information
+ * it can implement this interface to get additional information
+ * through the provided {@link JobContext}.
+ * If no additional information is required, implementing {@link Runnable} is
+ * sufficient.
+ */
+public interface Job {
+
+ /**
+ * Execute this job.
+ * @param context The context of the job.
+ */
+ void execute(JobContext context);
+}
diff --git a/src/main/java/org/apache/sling/commons/scheduler/JobContext.java b/src/main/java/org/apache/sling/commons/scheduler/JobContext.java
new file mode 100644
index 0000000..075041d
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/scheduler/JobContext.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.commons.scheduler;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * The context for a {@link Job}.
+ */
+public interface JobContext {
+
+ /**
+ * Get the name of the scheduled job.
+ * @return The name of the job.
+ */
+ String getName();
+
+ /**
+ * Get the configuration provided when the job was scheduled.
+ * @return A non-null map of values.
+ */
+ Map<String, Serializable> getConfiguration();
+}
diff --git a/src/main/java/org/apache/sling/commons/scheduler/Scheduler.java b/src/main/java/org/apache/sling/commons/scheduler/Scheduler.java
new file mode 100644
index 0000000..2efdc80
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/scheduler/Scheduler.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.commons.scheduler;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+/**
+ * A scheduler to schedule time/cron based jobs.
+ * A job is an object which is executed/fired by the scheduler. The object
+ * should either implement the {@link Job} interface or the {@link Runnable}
+ * interface.
+ */
+public interface Scheduler {
+
+ /** Name of the configuration property to define the period for a job. */
+ String PROPERTY_SCHEDULER_PERIOD = "scheduler.period";
+
+ /** Name of the configuration property to define the cron expression for a job. */
+ String PROPERTY_SCHEDULER_EXPRESSION = "scheduler.expression";
+
+ /** Name of the configuration property to define if the job can be run concurrently. */
+ String PROPERTY_SCHEDULER_CONCURRENT = "scheduler.concurrent";
+
+ /** Name of the configuration property to define the job name. */
+ String PROPERTY_SCHEDULER_NAME = "scheduler.name";
+
+
+ /**
+ * Schedule a time based job.
+ * Note that if a job with the same name has already beed added, the old job is cancelled and this new job replaces
+ * the old job.
+ *
+ * @param name The name of the job - or null. If no name is specified it can't be cancelled.
+ * @param job The job to execute (either {@link Job} or {@link Runnable}).
+ * @param config An optional configuration object - this configuration is only passed to the job the job implements {@link Job}.
+ * @param schedulingExpression The time specification using a scheduling expression.
+ * @param canRunConcurrently Whether this job can run even if previous scheduled runs are still running.
+ */
+ void addJob(String name, Object job, Map<String, Serializable> config, String schedulingExpression, boolean canRunConcurrently)
+ throws Exception;
+
+ /**
+ * Schedule a periodic job.
+ * The job is started the first time when the period has passed.
+ * Note that if a job with the same name has already beed added, the old job is cancelled and this new job replaces
+ * the old job.
+ *
+ * @param name The name of the job - or null. If no name is specified it can't be cancelled.
+ * @param job The job to execute (either {@link Job} or {@link Runnable}).
+ * @param config An optional configuration object - this configuration is only passed to the job the job implements {@link Job}.
+ * @param period Every period seconds this job is started.
+ * @param canRunConcurrently Whether this job can run even if previous scheduled runs are still running.
+ */
+ void addPeriodicJob(String name, Object job, Map<String, Serializable> config, long period, boolean canRunConcurrently)
+ throws Exception;
+
+ /**
+ * Fire a job immediately and only once.
+ *
+ * @param job The job to execute (either {@link Job} or {@link Runnable}).
+ * @param config An optional configuration object - this configuration is only passed to the job the job implements {@link Job}.
+ */
+ void fireJob(Object job, Map<String, Serializable> config)
+ throws Exception;
+
+ /**
+ * Fire a job once at a specific date
+ * Note that if a job with the same name has already beed added, the old job is cancelled and this new job replaces
+ * the old job.
+ *
+ * @param name The name of the job - or null. If no name is specified it can't be cancelled.
+ * @param job The job to execute (either {@link Job} or {@link Runnable}).
+ * @param config An optional configuration object - this configuration is only passed to the job the job implements {@link Job}.
+ * @param date The date this job should be run.
+ */
+ void fireJobAt(String name, Object job, Map<String, Serializable> config, Date date)
+ throws Exception;
+
+ /**
+ * Remove a scheduled job by name.
+ *
+ * @param name The name of the job.
+ */
+ void removeJob(String name)
+ throws NoSuchElementException;
+}
diff --git a/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzJobExecutor.java b/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzJobExecutor.java
new file mode 100644
index 0000000..4454e60
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzJobExecutor.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.commons.scheduler.impl;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import org.apache.sling.commons.scheduler.JobContext;
+import org.quartz.Job;
+import org.quartz.JobDataMap;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.slf4j.Logger;
+
+/**
+ * This component is resposible to launch a {@link org.apache.sling.commons.scheduler.Job}
+ * or {@link Runnable} in a Quartz Scheduler.
+ *
+ */
+public class QuartzJobExecutor implements Job {
+
+ /**
+ * @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
+ */
+ public void execute(final JobExecutionContext context) throws JobExecutionException {
+
+ final JobDataMap data = context.getJobDetail().getJobDataMap();
+
+ final Boolean canRunConcurrentlyB = ((Boolean) data.get(QuartzScheduler.DATA_MAP_RUN_CONCURRENT));
+ final boolean canRunConcurrently = ((canRunConcurrentlyB == null) ? true : canRunConcurrentlyB.booleanValue());
+
+ if (!canRunConcurrently) {
+ Boolean isRunning = (Boolean) data.get(QuartzScheduler.DATA_MAP_KEY_ISRUNNING);
+ if (Boolean.TRUE.equals(isRunning)) {
+ return;
+ }
+ }
+
+ this.setup(data);
+
+ final Object job = data.get(QuartzScheduler.DATA_MAP_OBJECT);
+ final Logger logger = (Logger)data.get(QuartzScheduler.DATA_MAP_LOGGER);
+
+ try {
+ logger.debug("Executing job {} with name {}", job, data.get(QuartzScheduler.DATA_MAP_NAME));
+ if (job instanceof org.apache.sling.commons.scheduler.Job) {
+ @SuppressWarnings("unchecked")
+ final Map<String, Serializable> configuration = (Map<String, Serializable>) data.get(QuartzScheduler.DATA_MAP_CONFIGURATION);
+ final String name = (String) data.get(QuartzScheduler.DATA_MAP_NAME);
+
+ final JobContext jobCtx = new JobContextImpl(name, configuration);
+ ((org.apache.sling.commons.scheduler.Job) job).execute(jobCtx);
+ } else if (job instanceof Runnable) {
+ ((Runnable) job).run();
+ } else {
+ logger.error("Scheduled job {} is neither a job nor a runnable.", job);
+ }
+ } catch (final Throwable t) {
+ // if this is a quartz exception, rethrow it
+ if (t instanceof JobExecutionException) {
+ throw (JobExecutionException) t;
+ }
+ // there is nothing we can do here, so we just log
+ logger.error("Exception during job execution of " + job + " : " + t.getMessage(), t);
+ } finally {
+
+ this.release(data);
+ }
+ }
+
+ protected void setup(JobDataMap data) throws JobExecutionException {
+ data.put(QuartzScheduler.DATA_MAP_KEY_ISRUNNING, Boolean.TRUE);
+ }
+
+ protected void release(JobDataMap data) {
+ data.put(QuartzScheduler.DATA_MAP_KEY_ISRUNNING, Boolean.FALSE);
+ }
+
+ public static final class JobContextImpl implements JobContext {
+
+ protected final Map<String, Serializable> configuration;
+ protected final String name;
+
+ public JobContextImpl(String name, Map<String, Serializable> config) {
+ this.name = name;
+ this.configuration = config;
+ }
+
+ /**
+ * @see org.apache.sling.commons.scheduler.JobContext#getConfiguration()
+ */
+ public Map<String, Serializable> getConfiguration() {
+ return this.configuration;
+ }
+
+ /**
+ * @see org.apache.sling.commons.scheduler.JobContext#getName()
+ */
+ public String getName() {
+ return this.name;
+ }
+ }
+}
diff --git a/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzScheduler.java b/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzScheduler.java
new file mode 100644
index 0000000..516783f
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzScheduler.java
@@ -0,0 +1,468 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.commons.scheduler.impl;
+
+import java.io.Serializable;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.UUID;
+
+import org.apache.sling.commons.scheduler.Job;
+import org.apache.sling.commons.scheduler.Scheduler;
+import org.apache.sling.commons.threads.ThreadPool;
+import org.apache.sling.commons.threads.ThreadPoolManager;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.component.ComponentContext;
+import org.quartz.CronTrigger;
+import org.quartz.JobDataMap;
+import org.quartz.JobDetail;
+import org.quartz.SchedulerException;
+import org.quartz.SchedulerFactory;
+import org.quartz.SimpleTrigger;
+import org.quartz.Trigger;
+import org.quartz.impl.DirectSchedulerFactory;
+import org.quartz.impl.StdSchedulerFactory;
+import org.quartz.simpl.RAMJobStore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The quartz based implementation of the scheduler.
+ *
+ * @scr.component metatype="no" immediate="true"
+ * @scr.service interface="org.apache.sling.commons.scheduler.Scheduler"
+ * @scr.reference name="job" interface="org.apache.sling.commons.scheduler.Job" cardinality="0..n" policy="dynamic"
+ * @scr.reference name="task" interface="java.lang.Runnable" cardinality="0..n" policy="dynamic"
+ */
+public class QuartzScheduler implements Scheduler {
+
+ /** Default log. */
+ protected final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ protected static final String DEFAULT_QUARTZ_JOB_GROUP = "Sling";
+
+ protected static final String THREAD_POOL_NAME = "SLING_SCHEDULER";
+
+ /** Map key for the job object */
+ static final String DATA_MAP_OBJECT = "QuartzJobScheduler.Object";
+
+ /** Map key for the job name */
+ static final String DATA_MAP_NAME = "QuartzJobScheduler.JobName";
+
+ /** Map key for the concurrent run property */
+ static final String DATA_MAP_RUN_CONCURRENT = "QuartzJobScheduler.RunConcurrently";
+
+ /** Map key for the run status */
+ static final String DATA_MAP_KEY_ISRUNNING = "QuartzJobExecutor.isRunning";
+
+ /** Map key for the configuration. */
+ static final String DATA_MAP_CONFIGURATION = "QuartzJobScheduler.Configuration";
+
+ /** Map key for the logger. */
+ static final String DATA_MAP_LOGGER = "QuartzJobScheduler.Logger";
+
+ protected org.quartz.Scheduler scheduler;
+
+ protected final List<Object[]> registeredJobs = new ArrayList<Object[]>();
+
+ protected ComponentContext context;
+
+ /** @scr.reference */
+ protected ThreadPoolManager threadPoolManager;
+
+ /**
+ * Activate this component.
+ * Start the scheduler.
+ * @param ctx The component context.
+ * @throws Exception
+ */
+ protected void activate(ComponentContext ctx) throws Exception {
+ this.context = ctx;
+ synchronized ( this.registeredJobs ) {
+ this.init();
+ for( Object[] arr : this.registeredJobs ) {
+ try {
+ this.register((String)arr[0], (ServiceReference)arr[1]);
+ } catch (Exception e) {
+ // we don't want that one malicious service brings down the scheduler, so we just log
+ // the exception and continue
+ this.logger.error("Exception during registering job service {}.", arr[1], e);
+ }
+ }
+ this.registeredJobs.clear();
+ }
+ }
+
+ /**
+ * Deactivate this component.
+ * Stop the scheduler.
+ * @param ctx The component context.
+ */
+ protected void deactivate(ComponentContext ctx) {
+ synchronized (this.registeredJobs ) {
+ this.dispose();
+ }
+ this.context = null;
+ }
+
+ protected void init() throws SchedulerException {
+ // if we don't have a thread pool manager, we use the default thread pool
+ final ThreadPoolManager tpm = this.threadPoolManager;
+ if ( tpm == null ) {
+ final SchedulerFactory factory = new StdSchedulerFactory();
+ this.scheduler = factory.getScheduler();
+ } else {
+ final ThreadPool pool = tpm.get(THREAD_POOL_NAME);
+ final QuartzThreadPool quartzPool = new QuartzThreadPool(pool);
+ final DirectSchedulerFactory factory = DirectSchedulerFactory.getInstance();
+ factory.createScheduler(quartzPool, new RAMJobStore());
+ this.scheduler = factory.getScheduler();
+ }
+ this.scheduler.start();
+ if ( this.logger.isDebugEnabled() ) {
+ this.logger.debug("Scheduler started.");
+ }
+ }
+
+ protected void dispose() {
+ if ( this.scheduler != null ) {
+ try {
+ this.scheduler.shutdown();
+ } catch (SchedulerException e) {
+ this.logger.debug("Exception during shutdown of scheduler.", e);
+ }
+ if ( this.logger.isDebugEnabled() ) {
+ this.logger.debug("Scheduler stopped.");
+ }
+ this.scheduler = null;
+ }
+ }
+
+ /**
+ * Add a job to the scheduler
+ *
+ * @param name The name of the job to add (or null)
+ * @param Tje jopb
+ * @param trigger a Trigger
+ * @param canRunConcurrently whether this job can be run concurrently
+ *
+ * @throws Exception thrown in case of errors
+ */
+ protected void scheduleJob(String name,
+ final Object job,
+ final Map<String, Serializable> config,
+ final Trigger trigger,
+ final boolean canRunConcurrently)
+ throws Exception {
+ // check if the supplied object is valid
+ this.checkJob(job);
+
+ // if there is already a job with the name, remove it first
+ if ( name != null ) {
+ try {
+ final JobDetail jobdetail = this.scheduler.getJobDetail(name, DEFAULT_QUARTZ_JOB_GROUP);
+ if (jobdetail != null) {
+ this.removeJob(name);
+ }
+ } catch (final SchedulerException ignored) {
+ }
+ } else {
+ name = "Sling Quartz Scheduler " + UUID.randomUUID().toString();
+ }
+
+ // create the data map
+ final JobDataMap jobDataMap = this.initDataMap(name, job, config, canRunConcurrently);
+
+ final JobDetail detail = this.createJobDetail(name, jobDataMap);
+
+ this.logger.debug("Scheduling job {} with name {} and trigger {}", new Object[] {job, name, trigger});
+ this.scheduler.scheduleJob(detail, trigger);
+ }
+
+ /**
+ * Initialize the data map for the job executor.
+ * @param jobName
+ * @param job
+ * @param config
+ * @param concurent
+ * @return
+ */
+ protected JobDataMap initDataMap(String jobName,
+ Object job,
+ Map<String, Serializable> config,
+ boolean concurent) {
+ final JobDataMap jobDataMap = new JobDataMap();
+
+ jobDataMap.put(DATA_MAP_OBJECT, job);
+
+ jobDataMap.put(DATA_MAP_NAME, jobName);
+ jobDataMap.put(DATA_MAP_RUN_CONCURRENT, (concurent? Boolean.TRUE: Boolean.FALSE));
+ jobDataMap.put(DATA_MAP_LOGGER, this.logger);
+ if ( config != null ) {
+ jobDataMap.put(DATA_MAP_CONFIGURATION, config);
+ }
+
+ return jobDataMap;
+ }
+
+ /**
+ * Create the job detail.
+ * @param name
+ * @param jobDataMap
+ * @return
+ */
+ protected JobDetail createJobDetail(String name, JobDataMap jobDataMap) {
+ final JobDetail detail = new JobDetail(name, DEFAULT_QUARTZ_JOB_GROUP, QuartzJobExecutor.class);
+ detail.setJobDataMap(jobDataMap);
+ return detail;
+ }
+
+ /**
+ * Check the job object, either runnable or job is allowed
+ */
+ protected void checkJob(Object job)
+ throws Exception {
+ if (!(job instanceof Runnable) && !(job instanceof Job)) {
+ throw new Exception("Job object is neither an instance of " + Runnable.class.getName() + " nor " + Job.class.getName());
+ }
+ }
+
+ /**
+ * @see org.apache.sling.commons.scheduler.Scheduler#addJob(java.lang.String, java.lang.Object, java.util.Map, java.lang.String, boolean)
+ */
+ public void addJob(String name,
+ Object job,
+ Map<String, Serializable> config,
+ String schedulingExpression,
+ boolean canRunConcurrently)
+ throws Exception {
+ final CronTrigger cronJobEntry = new CronTrigger(name, DEFAULT_QUARTZ_JOB_GROUP);
+
+ try {
+ cronJobEntry.setCronExpression(schedulingExpression);
+ } catch (final ParseException pe) {
+ throw new Exception(pe.getMessage(), pe);
+ }
+ this.scheduleJob(name, job, config, cronJobEntry, canRunConcurrently);
+ }
+
+ /**
+ * @see org.apache.sling.commons.scheduler.Scheduler#addPeriodicJob(java.lang.String, java.lang.Object, java.util.Map, long, boolean)
+ */
+ public void addPeriodicJob(String name, Object job, Map<String, Serializable> config, long period, boolean canRunConcurrently)
+ throws Exception {
+ final long ms = period * 1000;
+ if ( name == null ) {
+ name = "Sling Quartz Scheduler " + UUID.randomUUID().toString();
+ }
+ final SimpleTrigger timeEntry =
+ new SimpleTrigger(name, DEFAULT_QUARTZ_JOB_GROUP, new Date(System.currentTimeMillis() + ms), null,
+ SimpleTrigger.REPEAT_INDEFINITELY, ms);
+
+ this.scheduleJob(name, job, config, timeEntry, canRunConcurrently);
+ }
+
+ /**
+ * @see org.apache.sling.commons.scheduler.Scheduler#fireJob(java.lang.Object, java.util.Map)
+ */
+ public void fireJob(Object job, Map<String, Serializable> config)
+ throws Exception {
+ this.checkJob(job);
+ final String name = job.getClass().getName();
+ final JobDataMap dataMap = this.initDataMap(name, job, config, true);
+
+ final JobDetail detail = this.createJobDetail(name, dataMap);
+
+ final Trigger trigger = new SimpleTrigger(name, DEFAULT_QUARTZ_JOB_GROUP);
+ this.scheduler.scheduleJob(detail, trigger);
+ }
+
+ /**
+ * @see org.apache.sling.commons.scheduler.Scheduler#fireJobAt(java.lang.String, java.lang.Object, java.util.Map, java.util.Date)
+ */
+ public void fireJobAt(String name, Object job, Map<String, Serializable> config, Date date) throws Exception {
+ if ( name == null ) {
+ name = "Sling Quartz Scheduler " + UUID.randomUUID().toString();
+ }
+ final SimpleTrigger trigger = new SimpleTrigger(name, DEFAULT_QUARTZ_JOB_GROUP, date);
+ this.scheduleJob(name, job, config, trigger, true);
+ }
+
+ /**
+ * @see org.apache.sling.commons.scheduler.Scheduler#removeJob(java.lang.String)
+ */
+ public void removeJob(String name) throws NoSuchElementException {
+ try {
+ this.scheduler.deleteJob(name, DEFAULT_QUARTZ_JOB_GROUP);
+ } catch (final SchedulerException se) {
+ throw new NoSuchElementException(se.getMessage());
+ }
+ }
+
+ protected void register(String type, ServiceReference ref)
+ throws Exception {
+ final Object job = this.context.locateService(type, ref);
+ if ( ref != null ) {
+ this.checkJob(job);
+ String name = (String)ref.getProperty(Scheduler.PROPERTY_SCHEDULER_NAME);
+ if ( name == null ) {
+ name = (String)ref.getProperty(Constants.SERVICE_PID);
+ }
+ if ( name != null ) {
+ final Boolean concurrent = (Boolean)ref.getProperty(Scheduler.PROPERTY_SCHEDULER_CONCURRENT);
+ final String expression = (String)ref.getProperty(Scheduler.PROPERTY_SCHEDULER_EXPRESSION);
+ if ( expression != null ) {
+ this.addJob(name, job, null, expression, (concurrent != null ? concurrent : true));
+ } else {
+ final Long period = (Long)ref.getProperty(Scheduler.PROPERTY_SCHEDULER_PERIOD);
+ if ( period != null ) {
+ this.addPeriodicJob(name, job, null, period, (concurrent != null ? concurrent : true));
+ }
+ }
+ } else {
+ throw new Exception("Job service must either have a PID or a configured property 'scheduler.name'.");
+ }
+ }
+ }
+
+ protected void unregister(ServiceReference ref) {
+ String name = (String)ref.getProperty(Scheduler.PROPERTY_SCHEDULER_NAME);
+ if ( name == null ) {
+ name = (String)ref.getProperty(Constants.SERVICE_PID);
+ }
+ if ( name != null ) {
+ this.removeJob(name);
+ }
+ }
+
+ /**
+ * Bind a new job.
+ * @param ref
+ * @throws Exception
+ */
+ protected void bindJob(ServiceReference ref)
+ throws Exception {
+ synchronized ( this.registeredJobs ) {
+ if ( this.scheduler != null ) {
+ this.register("job", ref);
+ } else {
+ this.registeredJobs.add(new Object[] {"job", ref});
+ }
+ }
+ }
+
+ /**
+ * Unbind a job.
+ * @param ref
+ */
+ protected void unbindJob(ServiceReference ref) {
+ synchronized ( this.registeredJobs ) {
+ if ( this.scheduler != null ) {
+ this.unregister(ref);
+ }
+ }
+ }
+
+ /**
+ * Bind a new job.
+ * @param ref
+ * @throws Exception
+ */
+ protected void bindTask(ServiceReference ref)
+ throws Exception {
+ synchronized ( this.registeredJobs ) {
+ if ( this.scheduler != null ) {
+ this.register("task", ref);
+ } else {
+ this.registeredJobs.add(new Object[] {"task", ref});
+ }
+ }
+ }
+
+ /**
+ * Unbind a job.
+ * @param ref
+ */
+ protected void unbindTask(ServiceReference ref) {
+ synchronized ( this.registeredJobs ) {
+ if ( this.scheduler != null ) {
+ this.unregister(ref);
+ }
+ }
+ }
+
+ private static final class QuartzThreadPool implements org.quartz.spi.ThreadPool {
+
+ /** Default log. */
+ protected final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ /** Our executor thread pool */
+ private ThreadPool executor;
+
+ /**
+ * Create a new wrapper implementation for Quartz.
+ */
+ public QuartzThreadPool(final ThreadPool executor) {
+ this.executor = executor;
+ }
+
+ /* (non-Javadoc)
+ * @see org.quartz.spi.QuartzThreadPool#getPoolSize()
+ */
+ public int getPoolSize() {
+ return this.executor.getConfiguration().getMaxPoolSize();
+ }
+
+ /* (non-Javadoc)
+ * @see org.quartz.spi.QuartzThreadPool#initialize()
+ */
+ public void initialize() {
+ // nothing to do
+ }
+
+ /* (non-Javadoc)
+ * @see org.quartz.spi.QuartzThreadPool#runInThread(java.lang.Runnable)
+ */
+ public boolean runInThread(final Runnable job) {
+ this.executor.execute(job);
+
+ return true;
+ }
+
+ /**
+ * @see org.quartz.spi.ThreadPool#blockForAvailableThreads()
+ */
+ public int blockForAvailableThreads() {
+ return this.executor.getConfiguration().getMaxPoolSize() - this.executor.getConfiguration().getQueueSize();
+ }
+
+ /* (non-Javadoc)
+ * @see org.quartz.spi.QuartzThreadPool#shutdown(boolean)
+ */
+ public void shutdown(final boolean waitForJobsToComplete) {
+ // the pool is managed by the thread pool manager,
+ // so we can just return
+ this.executor = null;
+ }
+ }
+
+}
diff --git a/src/main/resources/META-INF/DISCLAIMER b/src/main/resources/META-INF/DISCLAIMER
new file mode 100644
index 0000000..90850c2
--- /dev/null
+++ b/src/main/resources/META-INF/DISCLAIMER
@@ -0,0 +1,7 @@
+Apache Sling is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Jackrabbit PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other
+successful ASF projects. While incubation status is not necessarily a reflection of
+the completeness or stability of the code, it does indicate that the project has yet
+to be fully endorsed by the ASF.
\ No newline at end of file
diff --git a/src/main/resources/META-INF/LICENSE b/src/main/resources/META-INF/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/src/main/resources/META-INF/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/src/main/resources/META-INF/NOTICE b/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000..2f14eff
--- /dev/null
+++ b/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,12 @@
+Apache Sling Commons Scheduler
+Copyright 2008 The Apache Software Foundation
+
+Apache Sling is based on source code originally developed
+by Day Software (http://www.day.com/).
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+This product includes the Quartz scheduler library
+(http://www.opensymphony.com/quartz/).
+Copyright 2004-2005 OpenSymphony