Author: cziegeler
Date: Wed Sep 4 08:32:27 2013
New Revision: 1519939
URL: http://svn.apache.org/r1519939
Log:
SLING-3028 : Support for progress tracking of jobs - prototype of an API
Added:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutionContext.java
(with props)
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutor.java
(with props)
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/JobStatus.java
(with props)
Modified:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/package-info.java
Added:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutionContext.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutionContext.java?rev=1519939&view=auto
==============================================================================
---
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutionContext.java
(added)
+++
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutionContext.java
Wed Sep 4 08:32:27 2013
@@ -0,0 +1,51 @@
+/*
+ * 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.event.jobs.consumer;
+
+import aQute.bnd.annotation.ProviderType;
+
+
+
+
+/**
+ *
+ * @since 1.1
+ */
+@ProviderType
+public interface JobExecutionContext {
+
+ interface AsyncHandler {
+
+ void failed();
+
+ void ok();
+
+ void cancel();
+ }
+
+ AsyncHandler getAsyncHandler();
+
+ void log(final String message);
+
+ void start(final int steps);
+
+ void start(final int steps, final long eta);
+
+ void setProgress(final int step);
+}
Propchange:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutionContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutionContext.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutor.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutor.java?rev=1519939&view=auto
==============================================================================
---
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutor.java
(added)
+++
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutor.java
Wed Sep 4 08:32:27 2013
@@ -0,0 +1,42 @@
+/*
+ * 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.event.jobs.consumer;
+
+import org.apache.sling.event.jobs.Job;
+
+import aQute.bnd.annotation.ConsumerType;
+
+
+
+/**
+ *
+ * @since 1.1
+ */
+@ConsumerType
+public interface JobExecutor {
+
+ /**
+ * Service registration property defining the jobs this consumer is able
to process.
+ * The value is either a string or an array of strings.
+ */
+ String PROPERTY_TOPICS = "job.topics";
+
+
+ JobStatus process(Job job, JobExecutionContext context);
+}
Propchange:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutor.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/JobStatus.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/JobStatus.java?rev=1519939&view=auto
==============================================================================
---
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/JobStatus.java
(added)
+++
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/JobStatus.java
Wed Sep 4 08:32:27 2013
@@ -0,0 +1,72 @@
+/*
+ * 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.event.jobs.consumer;
+
+import aQute.bnd.annotation.ProviderType;
+
+
+
+/**
+ *
+ * @since 1.1
+ */
+@ProviderType
+public final class JobStatus {
+
+ enum JobState {
+ OK, // processing finished
+ FAILED, // processing failed, can be retried
+ CANCEL, // processing failed permanently
+ ASYNC // processing will be done async
+ }
+
+ private final JobState state;
+
+ private final String message;
+
+ private Long retryDelay;
+
+ public JobStatus(final JobState result) {
+ this(result, null);
+ }
+
+ public JobStatus(final JobState result, final String message) {
+ this.state = result;
+ this.message = message;
+ }
+
+ public JobState getState() {
+ return this.state;
+ }
+
+ public String getMessage() {
+ return this.message;
+ }
+
+ /**
+ * Return the retry delay in ms
+ */
+ public Long getRetryDelayInMs() {
+ return this.retryDelay;
+ }
+
+ public void setRetryDelayInMs(final Long value) {
+ this.retryDelay = value;
+ }
+}
Propchange:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/JobStatus.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/JobStatus.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Modified:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/package-info.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/package-info.java?rev=1519939&r1=1519938&r2=1519939&view=diff
==============================================================================
---
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/package-info.java
(original)
+++
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/package-info.java
Wed Sep 4 08:32:27 2013
@@ -17,7 +17,7 @@
* under the License.
*/
-@Version("1.0.0")
+@Version("1.1.0")
package org.apache.sling.event.jobs.consumer;
import aQute.bnd.annotation.Version;