incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r689750 - in /incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event: JobStatusProvider.java impl/JobEventHandler.java
Date Thu, 28 Aug 2008 07:55:26 GMT
Author: cziegeler
Date: Thu Aug 28 00:55:25 2008
New Revision: 689750

URL: http://svn.apache.org/viewvc?rev=689750&view=rev
Log:
SLING-616 : Allow to query all jobs (running and queued)

Modified:
    incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/JobStatusProvider.java
    incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java

Modified: incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/JobStatusProvider.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/JobStatusProvider.java?rev=689750&r1=689749&r2=689750&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/JobStatusProvider.java
(original)
+++ incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/JobStatusProvider.java
Thu Aug 28 00:55:25 2008
@@ -65,4 +65,14 @@
      * @return A non null collection.
      */
     Collection<Event> getCurrentJobs(String topic, Map<String, Object> filterProps);
+
+    /**
+     * Return all jobs either running or scheduled.
+     * This is actually a convenience method and collects the results from {@link #getScheduledJobs(String,
Map)}
+     * and {@link #getCurrentJobs(String, Map)}
+     * @param topic Topic can be used as a filter, if it is non-null, only jobs with this
topic will be returned.
+     * @param filterProps An optional map of filter props that act like a template.
+     * @return A non null collection.
+     */
+    Collection<Event> getAllJobs(String topic, Map<String, Object> filterProps);
 }

Modified: incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java?rev=689750&r1=689749&r2=689750&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
(original)
+++ incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
Thu Aug 28 00:55:25 2008
@@ -48,6 +48,7 @@
 import org.apache.sling.commons.osgi.OsgiUtil;
 import org.apache.sling.commons.scheduler.Scheduler;
 import org.apache.sling.commons.threads.ThreadPool;
+import org.apache.sling.event.EventPropertiesMap;
 import org.apache.sling.event.EventUtil;
 import org.apache.sling.event.JobStatusProvider;
 import org.osgi.service.component.ComponentContext;
@@ -959,13 +960,7 @@
             }
             if ( reschedule ) {
                 // update event with retry count and retries
-                final Dictionary<String, Object> newProperties;
-                // create a new dictionary
-                newProperties = new Hashtable<String, Object>();
-                final String[] names = job.getPropertyNames();
-                for(int i=0; i<names.length; i++ ) {
-                    newProperties.put(names[i], job.getProperty(names[i]));
-                }
+                final Dictionary<String, Object> newProperties = new EventPropertiesMap(job);
                 newProperties.put(EventUtil.PROPERTY_JOB_RETRY_COUNT, retryCount);
                 newProperties.put(EventUtil.PROPERTY_JOB_RETRIES, retries);
                 job = new Event(job.getTopic(), newProperties);
@@ -1123,7 +1118,7 @@
      */
     private Collection<Event> queryCurrentJobs(final String topic,
                                                final Map<String, Object> filterProps,
-                                               final boolean locked)  {
+                                               final Boolean locked)  {
         // we create a new session
         Session s = null;
         final List<Event> jobs = new ArrayList<Event>();
@@ -1144,10 +1139,12 @@
                 buffer.append(topic);
                 buffer.append("'");
             }
-            if ( locked ) {
-                buffer.append(" and @jcr:lockOwner");
-            } else {
-                buffer.append(" and not(@jcr:lockOwner)");
+            if ( locked != null ) {
+                if ( locked ) {
+                    buffer.append(" and @jcr:lockOwner");
+                } else {
+                    buffer.append(" and not(@jcr:lockOwner)");
+                }
             }
             if ( filterProps != null ) {
                 final Iterator<Map.Entry<String, Object>> i = filterProps.entrySet().iterator();
@@ -1230,6 +1227,15 @@
         return this.queryCurrentJobs(topic, null, false);
     }
 
+
+    /**
+     * @see org.apache.sling.event.JobStatusProvider#getAllJobs(java.lang.String, java.util.Map)
+     */
+    public Collection<Event> getAllJobs(String topic, Map<String, Object> filterProps)
{
+        return this.queryCurrentJobs(topic, null, null);
+    }
+
+
     private static final class JobBlockingQueue extends LinkedBlockingQueue<EventInfo>
{
 
         private EventInfo eventInfo;



Mime
View raw message