Return-Path: Delivered-To: apmail-incubator-sling-commits-archive@locus.apache.org Received: (qmail 19994 invoked from network); 28 Aug 2008 07:55:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Aug 2008 07:55:47 -0000 Received: (qmail 85539 invoked by uid 500); 28 Aug 2008 07:55:45 -0000 Delivered-To: apmail-incubator-sling-commits-archive@incubator.apache.org Received: (qmail 85489 invoked by uid 500); 28 Aug 2008 07:55:45 -0000 Mailing-List: contact sling-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sling-dev@incubator.apache.org Delivered-To: mailing list sling-commits@incubator.apache.org Received: (qmail 85480 invoked by uid 99); 28 Aug 2008 07:55:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Aug 2008 00:55:45 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Aug 2008 07:54:56 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 81AFF23889C0; Thu, 28 Aug 2008 00:55:26 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: sling-commits@incubator.apache.org From: cziegeler@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080828075526.81AFF23889C0@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 getCurrentJobs(String topic, Map 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 getAllJobs(String topic, Map 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 newProperties; - // create a new dictionary - newProperties = new Hashtable(); - final String[] names = job.getPropertyNames(); - for(int i=0; i 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 queryCurrentJobs(final String topic, final Map filterProps, - final boolean locked) { + final Boolean locked) { // we create a new session Session s = null; final List jobs = new ArrayList(); @@ -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> 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 getAllJobs(String topic, Map filterProps) { + return this.queryCurrentJobs(topic, null, null); + } + + private static final class JobBlockingQueue extends LinkedBlockingQueue { private EventInfo eventInfo;