This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.jobs-1.0.0 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jobs.git
commit 09609b06c5995ac52a88fc30e626593ce138b516 Author: Ian Boston <i...@apache.org> AuthorDate: Tue Oct 4 09:23:13 2016 +0000 SLING-5645 Improved IT tests, improved config checking and reduced dependency footprint git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/commons/mom/jobs/core@1763255 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 5 --- .../org/apache/sling/jobs/impl/JobSubsystem.java | 39 +++++++++++++++++++--- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 08a38ad..43b2911 100644 --- a/pom.xml +++ b/pom.xml @@ -116,11 +116,6 @@ <!-- Use the version being used in Sling --> <version>15.0</version> </dependency> - <dependency> - <groupId>org.apache.sling</groupId> - <artifactId>org.apache.sling.commons.osgi</artifactId> - <version>2.4.0</version> - </dependency> <!-- Testing --> <dependency> <groupId>junit</groupId> diff --git a/src/main/java/org/apache/sling/jobs/impl/JobSubsystem.java b/src/main/java/org/apache/sling/jobs/impl/JobSubsystem.java index ef3123b..1be6a00 100644 --- a/src/main/java/org/apache/sling/jobs/impl/JobSubsystem.java +++ b/src/main/java/org/apache/sling/jobs/impl/JobSubsystem.java @@ -28,8 +28,14 @@ import org.apache.felix.scr.annotations.Reference; import org.apache.felix.scr.annotations.ReferenceCardinality; import org.apache.felix.scr.annotations.ReferencePolicy; import org.apache.felix.scr.annotations.Service; -import org.apache.sling.commons.osgi.PropertiesUtil; -import org.apache.sling.jobs.*; +import org.apache.sling.jobs.Job; +import org.apache.sling.jobs.JobBuilder; +import org.apache.sling.jobs.JobCallback; +import org.apache.sling.jobs.JobConsumer; +import org.apache.sling.jobs.JobManager; +import org.apache.sling.jobs.JobTypeValve; +import org.apache.sling.jobs.JobUpdateListener; +import org.apache.sling.jobs.Types; import org.apache.sling.jobs.impl.spi.JobStorage; import org.apache.sling.jobs.impl.storage.InMemoryJobStorage; import org.apache.sling.mom.QueueManager; @@ -41,7 +47,8 @@ import org.slf4j.LoggerFactory; import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.io.Closeable; -import java.util.Collection; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -180,10 +187,34 @@ public class JobSubsystem implements JobManager, JobConsumer { if ( consumer instanceof JobTypeValve) { jobTypes = ImmutableSet.of(); } else { - jobTypes = Types.jobType(PropertiesUtil.toStringArray(properties.get(JobConsumer.JOB_TYPES))); + jobTypes = getJobTypes(properties); } } + public Set<Types.JobType> getJobTypes(Map<Object, Object> properties) { + Object types = properties.get(JobConsumer.JOB_TYPES); + if (types instanceof String) { + return Types.jobType(new String[]{(String) types}); + + } else if (types instanceof String[]) { + return Types.jobType((String[]) types); + + } else if (types instanceof Iterable) { + List<String> l = new ArrayList<String>(); + for (Object o : (Iterable<?>) types) { + l.add(String.valueOf(o)); + } + return Types.jobType((String[]) l.toArray(new String[l.size()])); + } + throw new IllegalArgumentException("For the JobConsumer to work, the job consumer must either " + + "implement a JobTypeValve or define a list of JobTypes, neither were specified. " + + "Please check the implementation or OSGi configuration, was expecting " + + JobConsumer.JOB_TYPES + " property to be set to a String[]"); + } + + + + @Override public boolean accept(@Nonnull Types.JobType jobType) { if ( consumer instanceof JobTypeValve) { -- To stop receiving notification emails like this one, please contact "commits@sling.apache.org" <commits@sling.apache.org>.