Author: cziegeler
Date: Fri Sep 6 08:35:47 2013
New Revision: 1520511
URL: http://svn.apache.org/r1520511
Log:
SLING-3028 : Support for progress tracking of jobs - prototype of an API
Modified:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutionContext.java
Modified:
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=1520511&r1=1520510&r2=1520511&view=diff
==============================================================================
---
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutionContext.java
(original)
+++
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutionContext.java
Fri Sep 6 08:35:47 2013
@@ -20,9 +20,6 @@ package org.apache.sling.event.jobs.cons
import aQute.bnd.annotation.ProviderType;
-
-
-
/**
*
* @since 1.1
@@ -30,22 +27,53 @@ import aQute.bnd.annotation.ProviderType
@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);
-
+ /**
+ * Report an async result.
+ * @throws IllegalStateException If the job is not processed asynchronously
+ */
+ void asyncProcessingFinished(final JobStatus status);
+
+ /**
+ * Indicate that the job executor is able to report the progress
+ * by providing a step count.
+ * This method should only be called once, consecutive calls
+ * or a call to {@link #startProgress(long)} have no effect.
+ * @param steps Number of total steps or -1 if the number of
+ * steps is unknown.
+ */
+ void startProgress(final int steps);
+
+ /**
+ * Indicate that the job executor is able to report the progress
+ * by providing an ETA.
+ * This method should only be called once, consecutive calls
+ * or a call to {@link #startProgress(int)} have no effect.
+ * @param eta Number of seconds the process should take or
+ * -1 of it's not known now.
+ */
+ void startProgress(final long eta);
+
+ /**
+ * Update the progress to the current finished step.
+ * This method has only effect if {@link #startProgress(int)}
+ * has been called first.
+ * @param step The current step.
+ */
void setProgress(final int step);
+
+ /**
+ * Update the progress to the new ETA.
+ * This method has only effect if {@link #startProgress(long)}
+ * has been called first.
+ * @param eta The new ETA
+ */
+ void update(final long eta);
+
+ /**
+ * Log a message.
+ * The message might contain place holders for additional arguments.
+ * @param message A message
+ * @param args Additional arguments
+ */
+ void log(final String message, final Object...args);
}