Author: cziegeler Date: Thu May 4 08:03:38 2017 New Revision: 1793745 URL: http://svn.apache.org/viewvc?rev=1793745&view=rev Log: SLING-6824 : Migrate to R6 annotations, clean up dependencies
Modified: sling/trunk/bundles/extensions/event/resource/pom.xml sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/EnvironmentComponent.java sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/EventingThreadPool.java sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/JobConsumerManager.java sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/Utility.java sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/ConfigurationConstants.java sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/InternalQueueConfiguration.java sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/JobManagerConfiguration.java sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/MainQueueConfiguration.java sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/QueueConfigurationManager.java sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/TopologyHandler.java sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/console/InventoryPlugin.java sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/console/WebConsolePlugin.java sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/jmx/AllJobStatisticsMBean.java sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/jmx/QueuesMBeanImpl.java sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/notifications/NewJobSender.java sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/queues/QueueManager.java sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/stats/StatisticsManager.java sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/tasks/HistoryCleanUpTask.java sling/trunk/bundles/extensions/event/resource/src/test/java/org/apache/sling/event/impl/jobs/JobConsumerManagerTest.java sling/trunk/bundles/extensions/event/resource/src/test/java/org/apache/sling/event/impl/jobs/config/InternalQueueConfigurationTest.java sling/trunk/bundles/extensions/event/resource/src/test/java/org/apache/sling/event/it/AbstractJobHandlingTest.java Modified: sling/trunk/bundles/extensions/event/resource/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/resource/pom.xml?rev=1793745&r1=1793744&r2=1793745&view=diff ============================================================================== --- sling/trunk/bundles/extensions/event/resource/pom.xml (original) +++ sling/trunk/bundles/extensions/event/resource/pom.xml Thu May 4 08:03:38 2017 @@ -205,6 +205,10 @@ </profiles> <dependencies> <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.service.component.annotations</artifactId> + </dependency> + <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.discovery.api</artifactId> <version>1.0.0</version> @@ -223,8 +227,6 @@ <dependency> <groupId>org.osgi</groupId> <artifactId>osgi.core</artifactId> - <version>6.0.0</version> - <scope>provided</scope> </dependency> <dependency> <groupId>org.osgi</groupId> @@ -233,11 +235,6 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>org.apache.felix</groupId> - <artifactId>org.apache.felix.scr.annotations</artifactId> - <scope>provided</scope> - </dependency> - <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.settings</artifactId> <version>1.0.0</version> @@ -316,13 +313,13 @@ <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.testing.tools</artifactId> - <version>1.0.6</version> + <version>1.0.14</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.testing.sling-mock</artifactId> - <version>1.6.0</version> + <version>2.2.6</version> <scope>test</scope> </dependency> @@ -364,7 +361,7 @@ <dependency> <groupId>org.apache.felix</groupId> <artifactId>org.apache.felix.framework</artifactId> - <version>5.4.0</version> + <version>5.6.2</version> <scope>test</scope> </dependency> <dependency> Modified: sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/EnvironmentComponent.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/EnvironmentComponent.java?rev=1793745&r1=1793744&r2=1793745&view=diff ============================================================================== --- sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/EnvironmentComponent.java (original) +++ sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/EnvironmentComponent.java Thu May 4 08:03:38 2017 @@ -18,14 +18,14 @@ */ package org.apache.sling.event.impl; -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Deactivate; -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.Service; import org.apache.sling.commons.threads.ThreadPool; import org.apache.sling.event.impl.support.Environment; import org.apache.sling.settings.SlingSettingsService; +import org.osgi.framework.Constants; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Reference; /** * Environment component. This component provides "global settings" @@ -35,14 +35,17 @@ import org.apache.sling.settings.SlingSe * This component needs to be immediate to set the global variables * (application id and thread pool). */ -@Component(immediate=true) -@Service(value=EnvironmentComponent.class) +@Component(immediate=true, + property = { + Constants.SERVICE_VENDOR + "=The Apache Software Foundation" + }, + service={EnvironmentComponent.class}) public class EnvironmentComponent { /** * Our thread pool. */ - @Reference(referenceInterface=EventingThreadPool.class) + @Reference(service=EventingThreadPool.class) private ThreadPool threadPool; /** Sling settings service. */ Modified: sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/EventingThreadPool.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/EventingThreadPool.java?rev=1793745&r1=1793744&r2=1793745&view=diff ============================================================================== --- sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/EventingThreadPool.java (original) +++ sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/EventingThreadPool.java Thu May 4 08:03:38 2017 @@ -18,34 +18,44 @@ */ package org.apache.sling.event.impl; -import java.util.Map; - -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Deactivate; -import org.apache.felix.scr.annotations.Modified; -import org.apache.felix.scr.annotations.Property; -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.Service; -import org.apache.sling.commons.osgi.PropertiesUtil; import org.apache.sling.commons.threads.ModifiableThreadPoolConfig; import org.apache.sling.commons.threads.ThreadPool; import org.apache.sling.commons.threads.ThreadPoolConfig; import org.apache.sling.commons.threads.ThreadPoolConfig.ThreadPriority; import org.apache.sling.commons.threads.ThreadPoolManager; +import org.osgi.framework.Constants; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Modified; +import org.osgi.service.component.annotations.Reference; +import org.osgi.service.metatype.annotations.AttributeDefinition; +import org.osgi.service.metatype.annotations.Designate; +import org.osgi.service.metatype.annotations.ObjectClassDefinition; /** * The configurable eventing thread pool. */ -@Component(label="Apache Sling Job Thread Pool", +@Component(service = EventingThreadPool.class, + property = { + Constants.SERVICE_VENDOR + "=The Apache Software Foundation" +}) +@Designate(ocd = EventingThreadPool.Config.class) +public class EventingThreadPool implements ThreadPool { + + @ObjectClassDefinition(name = "Apache Sling Job Thread Pool", description="This is the thread pool used by the Apache Sling job handling. The " + "threads from this pool are merely used for executing jobs. By limiting this pool, it is " + "possible to limit the maximum number of parallel processed jobs - regardless of the queue " - + "configuration.", - metatype=true) -@Service(value=EventingThreadPool.class) -public class EventingThreadPool implements ThreadPool { + + "configuration.") + public @interface Config { + + @AttributeDefinition(name = "Pool Size", + description="The size of the thread pool. This pool is used to execute jobs and therefore " + + "limits the maximum number of jobs executed in parallel.") + int minPoolSize() default 35; + } @Reference private ThreadPoolManager threadPoolManager; @@ -53,14 +63,6 @@ public class EventingThreadPool implemen /** The real thread pool used. */ private org.apache.sling.commons.threads.ThreadPool threadPool; - private static final int DEFAULT_POOL_SIZE = 35; - - @Property(intValue=DEFAULT_POOL_SIZE, - label="Pool Size", - description="The size of the thread pool. This pool is used to execute jobs and therefore " - + "limits the maximum number of jobs executed in parallel.") - private static final String PROPERTY_POOL_SIZE = "minPoolSize"; - public EventingThreadPool() { // default constructor } @@ -79,9 +81,8 @@ public class EventingThreadPool implemen */ @Activate @Modified - protected void activate(final Map<String, Object> props) { - final int maxPoolSize = PropertiesUtil.toInteger(props.get(PROPERTY_POOL_SIZE), DEFAULT_POOL_SIZE); - this.configure(maxPoolSize); + protected void activate(final Config config) { + this.configure(config.minPoolSize()); } private void configure(final int maxPoolSize) { Modified: sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/JobConsumerManager.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/JobConsumerManager.java?rev=1793745&r1=1793744&r2=1793745&view=diff ============================================================================== --- sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/JobConsumerManager.java (original) +++ sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/JobConsumerManager.java Thu May 4 08:03:38 2017 @@ -27,17 +27,6 @@ import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Deactivate; -import org.apache.felix.scr.annotations.Modified; -import org.apache.felix.scr.annotations.Property; -import org.apache.felix.scr.annotations.PropertyUnbounded; -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.References; -import org.apache.felix.scr.annotations.Service; import org.apache.sling.commons.osgi.PropertiesUtil; import org.apache.sling.discovery.PropertyProvider; import org.apache.sling.event.impl.jobs.config.TopologyCapabilities; @@ -53,55 +42,62 @@ import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; import org.osgi.framework.ServiceReference; import org.osgi.framework.ServiceRegistration; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Modified; +import org.osgi.service.component.annotations.Reference; +import org.osgi.service.component.annotations.ReferenceCardinality; +import org.osgi.service.component.annotations.ReferencePolicy; +import org.osgi.service.metatype.annotations.AttributeDefinition; +import org.osgi.service.metatype.annotations.Designate; +import org.osgi.service.metatype.annotations.ObjectClassDefinition; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * This component manages/keeps track of all job consumer services. */ -@Component(label="Apache Sling Job Consumer Manager", +@Component(service = JobConsumerManager.class, + property = { + Constants.SERVICE_VENDOR + "=The Apache Software Foundation" + }) +@Designate(ocd = JobConsumerManager.Config.class) +public class JobConsumerManager { + + @ObjectClassDefinition(name = "Apache Sling Job Consumer Manager", description="The consumer manager controls the job consumer (= processors). " + "It can be used to temporarily disable job processing on the current instance. Other instances " - + "in a cluster are not affected.", - metatype=true) -@Service(value=JobConsumerManager.class) -@References({ - @Reference(referenceInterface=JobConsumer.class, - cardinality=ReferenceCardinality.OPTIONAL_MULTIPLE, - policy=ReferencePolicy.DYNAMIC), - @Reference(referenceInterface=JobExecutor.class, - cardinality=ReferenceCardinality.OPTIONAL_MULTIPLE, - policy=ReferencePolicy.DYNAMIC) -}) -@Property(name="org.apache.sling.installer.configuration.persist", boolValue=false, - label="Distribute config", + + "in a cluster are not affected.") + public @interface Config { + + @AttributeDefinition(name = "Distribute config", description="If this is disabled, the configuration is not persisted on save in the cluster and is " + "only used on the current instance. This option should always be disabled!") -public class JobConsumerManager { - - private final Logger logger = LoggerFactory.getLogger(this.getClass()); + boolean org_apache_sling_installer_configuration_persist() default false; - @Property(unbounded=PropertyUnbounded.ARRAY, value = "*", - label="Topic Whitelist", + @AttributeDefinition(name = "Topic Whitelist", description="This is a list of topics which currently should be " + "processed by this instance. Leaving it empty, all job consumers are disabled. Putting a '*' as " + "one entry, enables all job consumers. Adding separate topics enables job consumers for exactly " + "this topic.") - private static final String PROPERTY_WHITELIST = "job.consumermanager.whitelist"; + String[] job_consumermanager_whitelist() default "*"; - @Property(unbounded=PropertyUnbounded.ARRAY, - label="Topic Blacklist", + @AttributeDefinition(name = "Topic Blacklist", description="This is a list of topics which currently shouldn't be " + "processed by this instance. Leaving it empty, all job consumers are enabled. Putting a '*' as " + "one entry, disables all job consumers. Adding separate topics disables job consumers for exactly " + "this topic.") - private static final String PROPERTY_BLACKLIST = "job.consumermanager.blacklist"; + String[] job_consumermanager_blacklist(); + } + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); /** The map with the consumers, keyed by topic, sorted by service ranking. */ - private final Map<String, List<ConsumerInfo>> topicToConsumerMap = new HashMap<String, List<ConsumerInfo>>(); + private final Map<String, List<ConsumerInfo>> topicToConsumerMap = new HashMap<>(); /** ServiceRegistration for propagation. */ - private ServiceRegistration propagationService; + private ServiceRegistration<PropertyProvider> propagationService; private String topics; @@ -113,10 +109,10 @@ public class JobConsumerManager { private BundleContext bundleContext; - private final Map<String, Object[]> listenerMap = new HashMap<String, Object[]>(); + private final Map<String, Object[]> listenerMap = new HashMap<>(); private Dictionary<String, Object> getRegistrationProperties() { - final Dictionary<String, Object> serviceProps = new Hashtable<String, Object>(); + final Dictionary<String, Object> serviceProps = new Hashtable<>(); serviceProps.put(PropertyProvider.PROPERTY_PROPERTIES, TopologyCapabilities.PROPERTY_TOPICS); // we add a changing property to the service registration // to make sure a modification event is really sent @@ -127,16 +123,16 @@ public class JobConsumerManager { } @Activate - protected void activate(final BundleContext bc, final Map<String, Object> props) { + protected void activate(final BundleContext bc, final Config config) { this.bundleContext = bc; - this.modified(bc, props); + this.modified(bc, config); } @Modified - protected void modified(final BundleContext bc, final Map<String, Object> props) { + protected void modified(final BundleContext bc, final Config config) { final boolean wasEnabled = this.propagationService != null; - this.whitelistMatchers = TopicMatcherHelper.buildMatchers(PropertiesUtil.toStringArray(props.get(PROPERTY_WHITELIST))); - this.blacklistMatchers = TopicMatcherHelper.buildMatchers(PropertiesUtil.toStringArray(props.get(PROPERTY_BLACKLIST))); + this.whitelistMatchers = TopicMatcherHelper.buildMatchers(config.job_consumermanager_whitelist()); + this.blacklistMatchers = TopicMatcherHelper.buildMatchers(config.job_consumermanager_blacklist()); final boolean enable = this.whitelistMatchers != null && this.blacklistMatchers != TopicMatcherHelper.MATCH_ALL; if ( wasEnabled != enable ) { @@ -145,7 +141,7 @@ public class JobConsumerManager { } if ( enable ) { logger.debug("Registering property provider with: {}", this.topics); - this.propagationService = bc.registerService(PropertyProvider.class.getName(), + this.propagationService = bc.registerService(PropertyProvider.class, new PropertyProvider() { @Override @@ -240,7 +236,10 @@ public class JobConsumerManager { * Bind a new consumer * @param serviceReference The service reference to the consumer. */ - protected void bindJobConsumer(final ServiceReference serviceReference) { + @Reference(service=JobConsumer.class, + cardinality=ReferenceCardinality.MULTIPLE, + policy=ReferencePolicy.DYNAMIC) + protected void bindJobConsumer(final ServiceReference<JobConsumer> serviceReference) { this.bindService(serviceReference, true); } @@ -248,7 +247,7 @@ public class JobConsumerManager { * Unbind a consumer * @param serviceReference The service reference to the consumer. */ - protected void unbindJobConsumer(final ServiceReference serviceReference) { + protected void unbindJobConsumer(final ServiceReference<JobConsumer> serviceReference) { this.unbindService(serviceReference, true); } @@ -256,7 +255,10 @@ public class JobConsumerManager { * Bind a new executor * @param serviceReference The service reference to the executor. */ - protected void bindJobExecutor(final ServiceReference serviceReference) { + @Reference(service=JobExecutor.class, + cardinality=ReferenceCardinality.MULTIPLE, + policy=ReferencePolicy.DYNAMIC) + protected void bindJobExecutor(final ServiceReference<JobExecutor> serviceReference) { this.bindService(serviceReference, false); } @@ -264,7 +266,7 @@ public class JobConsumerManager { * Unbind a executor * @param serviceReference The service reference to the executor. */ - protected void unbindJobExecutor(final ServiceReference serviceReference) { + protected void unbindJobExecutor(final ServiceReference<JobExecutor> serviceReference) { this.unbindService(serviceReference, false); } @@ -273,7 +275,7 @@ public class JobConsumerManager { * @param serviceReference The service reference to the consumer or executor. * @param isConsumer Indicating whether this is a JobConsumer or JobExecutor */ - private void bindService(final ServiceReference serviceReference, final boolean isConsumer) { + private void bindService(final ServiceReference<?> serviceReference, final boolean isConsumer) { final String[] topics = PropertiesUtil.toStringArray(serviceReference.getProperty(JobConsumer.PROPERTY_TOPICS)); if ( topics != null && topics.length > 0 ) { final ConsumerInfo info = new ConsumerInfo(serviceReference, isConsumer); @@ -285,7 +287,7 @@ public class JobConsumerManager { if ( topic.length() > 0 ) { List<ConsumerInfo> consumers = this.topicToConsumerMap.get(topic); if ( consumers == null ) { - consumers = new ArrayList<JobConsumerManager.ConsumerInfo>(); + consumers = new ArrayList<>(); this.topicToConsumerMap.put(topic, consumers); changed = true; } @@ -310,7 +312,7 @@ public class JobConsumerManager { * @param serviceReference The service reference to the consumer or executor. * @param isConsumer Indicating whether this is a JobConsumer or JobExecutor */ - private void unbindService(final ServiceReference serviceReference, final boolean isConsumer) { + private void unbindService(final ServiceReference<?> serviceReference, final boolean isConsumer) { final String[] topics = PropertiesUtil.toStringArray(serviceReference.getProperty(JobConsumer.PROPERTY_TOPICS)); if ( topics != null && topics.length > 0 ) { final ConsumerInfo info = new ConsumerInfo(serviceReference, isConsumer); @@ -367,7 +369,7 @@ public class JobConsumerManager { if ( enabled ) { // create a sorted list - this ensures that the property value // is always the same for the same topics. - final List<String> topicList = new ArrayList<String>(); + final List<String> topicList = new ArrayList<>(); for(final String topic : this.topicToConsumerMap.keySet() ) { // check whitelist if ( this.match(topic, this.whitelistMatchers) ) { @@ -400,13 +402,13 @@ public class JobConsumerManager { */ private final static class ConsumerInfo implements Comparable<ConsumerInfo> { - public final ServiceReference serviceReference; + public final ServiceReference<?> serviceReference; private final boolean isConsumer; public JobExecutor executor; public final int ranking; public final long serviceId; - public ConsumerInfo(final ServiceReference serviceReference, final boolean isConsumer) { + public ConsumerInfo(final ServiceReference<?> serviceReference, final boolean isConsumer) { this.serviceReference = serviceReference; this.isConsumer = isConsumer; final Object sr = serviceReference.getProperty(Constants.SERVICE_RANKING); Modified: sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java?rev=1793745&r1=1793744&r2=1793745&view=diff ============================================================================== --- sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java (original) +++ sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java Thu May 4 08:03:38 2017 @@ -28,13 +28,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Deactivate; -import org.apache.felix.scr.annotations.Properties; -import org.apache.felix.scr.annotations.Property; -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.Service; import org.apache.jackrabbit.util.ISO9075; import org.apache.sling.api.resource.LoginException; import org.apache.sling.api.resource.PersistenceException; @@ -69,6 +62,10 @@ import org.apache.sling.event.jobs.jmx.Q import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; import org.osgi.framework.ServiceRegistration; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Reference; import org.osgi.service.event.Event; import org.osgi.service.event.EventAdmin; import org.osgi.service.event.EventConstants; @@ -80,15 +77,15 @@ import org.slf4j.LoggerFactory; /** * Implementation of the job manager. */ -@Component(immediate=true) -@Service(value={JobManager.class, EventHandler.class, Runnable.class}) -@Properties({ - @Property(name="scheduler.period", longValue=60), - @Property(name="scheduler.concurrent", boolValue=false), - @Property(name=EventConstants.EVENT_TOPIC, - value={ResourceHelper.BUNDLE_EVENT_STARTED, - ResourceHelper.BUNDLE_EVENT_UPDATED}) -}) +@Component(immediate=true, + service={JobManager.class, EventHandler.class, Runnable.class}, + property = { + Constants.SERVICE_VENDOR + "=The Apache Software Foundation", + "scheduler.period:Long=60", + "scheduler.concurrent:Boolean=false", + EventConstants.EVENT_TOPIC + "=" + ResourceHelper.BUNDLE_EVENT_STARTED, + EventConstants.EVENT_TOPIC + "=" + ResourceHelper.BUNDLE_EVENT_UPDATED + }) public class JobManagerImpl implements JobManager, EventHandler, Runnable { @@ -383,7 +380,7 @@ public class JobManagerImpl || type == QueryType.ERROR || type == QueryType.GIVEN_UP || type == QueryType.STOPPED; - final List<Job> result = new ArrayList<Job>(); + final List<Job> result = new ArrayList<>(); final ResourceResolver resolver = this.configuration.createResourceResolver(); final StringBuilder buf = new StringBuilder(64); try { @@ -609,7 +606,7 @@ public class JobManagerImpl final String path = this.configuration.getUniquePath(info.targetId, jobTopic, jobId, jobProperties); // create properties - final Map<String, Object> properties = new HashMap<String, Object>(); + final Map<String, Object> properties = new HashMap<>(); if ( jobProperties != null ) { for(final Map.Entry<String, Object> entry : jobProperties.entrySet() ) { @@ -720,7 +717,7 @@ public class JobManagerImpl errorMessage}); return null; } - final List<String> errorList = new ArrayList<String>(); + final List<String> errorList = new ArrayList<>(); Job result = this.addJobInternal(topic, properties, errorList); if ( errors != null ) { errors.addAll(errorList); Modified: sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/Utility.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/Utility.java?rev=1793745&r1=1793744&r2=1793745&view=diff ============================================================================== --- sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/Utility.java (original) +++ sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/Utility.java Thu May 4 08:03:38 2017 @@ -40,8 +40,6 @@ import org.slf4j.Logger; public abstract class Utility { - public static volatile boolean LOG_DEPRECATION_WARNINGS = true; - /** * Check if the job topic is a valid OSGI event name (see 113.3.1 of the OSGI spec) * @return <code>null</code> if the topic is syntactically correct otherwise an error description is returned @@ -55,7 +53,7 @@ public abstract class Utility { } catch (final IllegalArgumentException iae) { message = String.format("Discarding job - job has an illegal job topic '%s'",jobTopic); } - + } else { message = "Discarding job - job topic is not of type string"; } @@ -90,7 +88,7 @@ public abstract class Utility { * @return New event object. */ public static Event toEvent(final Job job) { - final Map<String, Object> eventProps = new HashMap<String, Object>(); + final Map<String, Object> eventProps = new HashMap<>(); eventProps.putAll(((JobImpl)job).getProperties()); eventProps.put(ResourceHelper.PROPERTY_JOB_ID, job.getId()); eventProps.remove(JobConsumer.PROPERTY_JOB_ASYNC_HANDLER); @@ -257,7 +255,7 @@ public abstract class Utility { * @return Sorted list of children. */ public static List<Resource> getSortedChildren(final Logger logger, final String type, final Resource rsrc) { - final List<Resource> children = new ArrayList<Resource>(); + final List<Resource> children = new ArrayList<>(); final Iterator<Resource> monthIter = rsrc.listChildren(); while ( monthIter.hasNext() ) { final Resource monthResource = monthIter.next(); @@ -267,15 +265,4 @@ public abstract class Utility { Collections.sort(children, RESOURCE_COMPARATOR); return children; } - - /** - * Log a deprecation warning on level info into the log - * @param logger The logger to use - * @param message The message. - */ - public static void logDeprecated(final Logger logger, final String message) { - if ( LOG_DEPRECATION_WARNINGS && logger.isInfoEnabled() ) { - logger.info("DEPRECATION-WARNING: " + message, new Exception(message)); - } - } } Modified: sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/ConfigurationConstants.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/ConfigurationConstants.java?rev=1793745&r1=1793744&r2=1793745&view=diff ============================================================================== --- sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/ConfigurationConstants.java (original) +++ sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/ConfigurationConstants.java Thu May 4 08:03:38 2017 @@ -25,14 +25,10 @@ public abstract class ConfigurationConst public static final int NUMBER_OF_PROCESSORS = Runtime.getRuntime().availableProcessors(); - public static final String DEFAULT_TYPE = "UNORDERED"; public static final String DEFAULT_PRIORITY = "NORM"; public static final int DEFAULT_RETRIES = 10; public static final long DEFAULT_RETRY_DELAY = 2000; public static final int DEFAULT_MAX_PARALLEL = 15; - public static final boolean DEFAULT_KEEP_JOBS = false; - public static final int DEFAULT_THREAD_POOL_SIZE = 0; - public static final boolean DEFAULT_PREFER_RUN_ON_CREATION_INSTANCE = false; public static final String PROP_NAME = "queue.name"; public static final String PROP_TYPE = "queue.type"; Modified: sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/InternalQueueConfiguration.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/InternalQueueConfiguration.java?rev=1793745&r1=1793744&r2=1793745&view=diff ============================================================================== --- sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/InternalQueueConfiguration.java (original) +++ sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/InternalQueueConfiguration.java Thu May 4 08:03:38 2017 @@ -21,103 +21,108 @@ package org.apache.sling.event.impl.jobs import java.util.Arrays; import java.util.Map; -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.ConfigurationPolicy; -import org.apache.felix.scr.annotations.Properties; -import org.apache.felix.scr.annotations.Property; -import org.apache.felix.scr.annotations.PropertyOption; -import org.apache.felix.scr.annotations.PropertyUnbounded; -import org.apache.felix.scr.annotations.Service; -import org.apache.sling.commons.osgi.PropertiesUtil; import org.apache.sling.event.impl.support.TopicMatcher; import org.apache.sling.event.impl.support.TopicMatcherHelper; import org.apache.sling.event.jobs.QueueConfiguration; import org.osgi.framework.Constants; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.ConfigurationPolicy; +import org.osgi.service.metatype.annotations.AttributeDefinition; +import org.osgi.service.metatype.annotations.Designate; +import org.osgi.service.metatype.annotations.ObjectClassDefinition; +import org.osgi.service.metatype.annotations.Option; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -@Component(metatype=true, +@Component(service=InternalQueueConfiguration.class, name="org.apache.sling.event.jobs.QueueConfiguration", - label="Apache Sling Job Queue Configuration", - description="The configuration of a job processing queue.", - configurationFactory=true, policy=ConfigurationPolicy.REQUIRE) -@Service(value={InternalQueueConfiguration.class}) -@Properties({ - @Property(name=ConfigurationConstants.PROP_NAME, - label="Name", - description="The name of the queue. If matching is used the token {0} can be used to substitute the real value."), - @Property(name=ConfigurationConstants.PROP_TOPICS, - unbounded=PropertyUnbounded.ARRAY, - label="Topics", + configurationPolicy=ConfigurationPolicy.REQUIRE, + property={ + "webconsole.configurationFactory.nameHint=Queue: {" + ConfigurationConstants.PROP_NAME + "}", + Constants.SERVICE_VENDOR + "=The Apache Software Foundation" + }) +@Designate(ocd = InternalQueueConfiguration.Config.class, factory = true) +public class InternalQueueConfiguration + implements QueueConfiguration, Comparable<InternalQueueConfiguration> { + + @ObjectClassDefinition(name = "Apache Sling Job Queue Configuration", + description="The configuration of a job processing queue.") + public @interface Config { + + @AttributeDefinition(name="Name", + description="The name of the queue. If matching is used the token {0} can be used to substitute the real value.") + String queue_name(); + + @AttributeDefinition(name="Topics", description="This value is required and lists the topics processed by " + "this queue. The value is a list of strings. If a string ends with a dot, " + "all topics in exactly this package match. If the string ends with a star, " + "all topics in this package and all subpackages match. If the string neither " - + "ends with a dot nor with a star, this is assumed to define an exact topic."), - @Property(name=ConfigurationConstants.PROP_TYPE, - value=ConfigurationConstants.DEFAULT_TYPE, - options={@PropertyOption(name="UNORDERED",value="Parallel"), - @PropertyOption(name="ORDERED",value="Ordered"), - @PropertyOption(name="TOPIC_ROUND_ROBIN",value="Topic Round Robin")}, - label="Type", - description="The queue type."), - @Property(name=ConfigurationConstants.PROP_MAX_PARALLEL, - doubleValue=ConfigurationConstants.DEFAULT_MAX_PARALLEL, - label="Maximum Parallel Jobs", - description="The maximum number of parallel jobs started for this queue. " - + "A value of -1 is substituted with the number of available processors. " - + "Positive integer values specify number of processors to use. Can be greater than number of processors. " - + "A decimal number between 0.0 and 1.0 is treated as a fraction of available processors. " - + "For example 0.5 means half of the available processors. For ordered queue types this value is ignored (always enforced to be 1)."), - @Property(name=ConfigurationConstants.PROP_RETRIES, - intValue=ConfigurationConstants.DEFAULT_RETRIES, - label="Maximum Retries", - description="The maximum number of times a failed job slated " - + "for retries is actually retried. If a job has been retried this number of " - + "times and still fails, it is not rescheduled and assumed to have failed. The " - + "default value is 10."), - @Property(name=ConfigurationConstants.PROP_RETRY_DELAY, - longValue=ConfigurationConstants.DEFAULT_RETRY_DELAY, - label="Retry Delay", - description="The number of milliseconds to sleep between two " - + "consecutive retries of a job which failed and was set to be retried. The " - + "default value is 2 seconds. This value is only relevant if there is a single " - + "failed job in the queue. If there are multiple failed jobs, each job is " - + "retried in turn without an intervening delay."), - @Property(name=ConfigurationConstants.PROP_PRIORITY, - value=ConfigurationConstants.DEFAULT_PRIORITY, - options={@PropertyOption(name="NORM",value="Norm"), - @PropertyOption(name="MIN",value="Min"), - @PropertyOption(name="MAX",value="Max")}, - label="Priority", - description="The priority for the threads used by this queue. Default is norm."), - @Property(name=ConfigurationConstants.PROP_KEEP_JOBS, - boolValue=ConfigurationConstants.DEFAULT_KEEP_JOBS, - label="Keep History", + + "ends with a dot nor with a star, this is assumed to define an exact topic.") + String[] queue_topics(); + + @AttributeDefinition(name = "Type", + description="The queue type.", + options = {@Option(label="UNORDERED",value="Parallel"), + @Option(label="ORDERED",value="Ordered"), + @Option(label="TOPIC_ROUND_ROBIN",value="Topic Round Robin")}) + String queue_type() default "UNORDERED"; + + @AttributeDefinition( + name="Priority", + description="The priority for the threads used by this queue. Default is norm.", + options = { + @Option(label="NORM",value="Norm"), + @Option(label="MIN",value="Min"), + @Option(label="MAX",value="Max") + }) + String queue_priority() default ConfigurationConstants.DEFAULT_PRIORITY; + + @AttributeDefinition(name="Maximum Retries", + description="The maximum number of times a failed job slated " + + "for retries is actually retried. If a job has been retried this number of " + + "times and still fails, it is not rescheduled and assumed to have failed. The " + + "default value is 10.") + int queue_retries() default ConfigurationConstants.DEFAULT_RETRIES; + + @AttributeDefinition(name="Retry Delay", + description="The number of milliseconds to sleep between two " + + "consecutive retries of a job which failed and was set to be retried. The " + + "default value is 2 seconds. This value is only relevant if there is a single " + + "failed job in the queue. If there are multiple failed jobs, each job is " + + "retried in turn without an intervening delay.") + long queue_retrydelay() default ConfigurationConstants.DEFAULT_RETRY_DELAY; + + @AttributeDefinition(name="Maximum Parallel Jobs", + description="The maximum number of parallel jobs started for this queue. " + + "A value of -1 is substituted with the number of available processors. " + + "Positive integer values specify number of processors to use. Can be greater than number of processors. " + + "A decimal number between 0.0 and 1.0 is treated as a fraction of available processors. " + + "For example 0.5 means half of the available processors. For ordered queue types this value is ignored (always enforced to be 1).") + double queue_maxparallel() default ConfigurationConstants.DEFAULT_MAX_PARALLEL; + + @AttributeDefinition(name="Keep History", description="If this option is enabled, successful finished jobs are kept " - + "to provide a complete history."), - @Property(name=ConfigurationConstants.PROP_PREFER_RUN_ON_CREATION_INSTANCE, - boolValue=ConfigurationConstants.DEFAULT_PREFER_RUN_ON_CREATION_INSTANCE, - label="Prefer Creation Instance", + + "to provide a complete history.") + boolean queue_keepJobs() default false; + + @AttributeDefinition(name="Prefer Creation Instance", description="If this option is enabled, the jobs are tried to " - + "be run on the instance where the job was created."), - @Property(name=ConfigurationConstants.PROP_THREAD_POOL_SIZE, - intValue=ConfigurationConstants.DEFAULT_THREAD_POOL_SIZE, - label="Thread Pool Size", - description="Optional configuration value for a thread pool to be used by " - + "this queue. If this is value has a positive number of threads configuration, this queue uses " - + "an own thread pool with the configured number of threads."), - @Property(name=Constants.SERVICE_RANKING, - intValue=0, - propertyPrivate=false, - label="Ranking", + + "be run on the instance where the job was created.") + boolean queue_preferRunOnCreationInstance() default false; + + @AttributeDefinition(name="Thread Pool Size", + description="Optional configuration value for a thread pool to be used by " + + "this queue. If this is value has a positive number of threads configuration, this queue uses " + + "an own thread pool with the configured number of threads.") + int queue_threadPoolSize() default 0; + + @AttributeDefinition(name="Ranking", description="Integer value defining the ranking of this queue configuration. " - + "If more than one queue matches a job topic, the one with the highest ranking is used."), - @Property(name="webconsole.configurationFactory.nameHint", value="Queue: {" + ConfigurationConstants.PROP_NAME + "}") -}) -public class InternalQueueConfiguration - implements QueueConfiguration, Comparable<InternalQueueConfiguration> { + + "If more than one queue matches a job topic, the one with the highest ranking is used.") + int service_ranking() default 0; + } /** Logger. */ private final Logger logger = LoggerFactory.getLogger(this.getClass()); @@ -166,9 +171,9 @@ public class InternalQueueConfiguration /** * Create a new configuration from a config */ - public static InternalQueueConfiguration fromConfiguration(final Map<String, Object> params) { + public static InternalQueueConfiguration fromConfiguration(final Map<String, Object> props, final Config config) { final InternalQueueConfiguration c = new InternalQueueConfiguration(); - c.activate(params); + c.activate(props, config); return c; } @@ -180,28 +185,27 @@ public class InternalQueueConfiguration * Create a new queue configuration */ @Activate - protected void activate(final Map<String, Object> params) { - this.name = PropertiesUtil.toString(params.get(ConfigurationConstants.PROP_NAME), null); + protected void activate(final Map<String, Object> props, final Config config) { + this.name = config.queue_name(); try { - this.priority = ThreadPriority.valueOf(PropertiesUtil.toString(params.get(ConfigurationConstants.PROP_PRIORITY), ConfigurationConstants.DEFAULT_PRIORITY)); + this.priority = ThreadPriority.valueOf(config.queue_priority()); } catch ( final IllegalArgumentException iae) { - logger.warn("Invalid value for queue priority. Using default instead of : {}", params.get(ConfigurationConstants.PROP_PRIORITY)); + logger.warn("Invalid value for queue priority. Using default instead of : {}", config.queue_priority()); this.priority = ThreadPriority.valueOf(ConfigurationConstants.DEFAULT_PRIORITY); } try { - this.type = Type.valueOf(PropertiesUtil.toString(params.get(ConfigurationConstants.PROP_TYPE), ConfigurationConstants.DEFAULT_TYPE)); + this.type = Type.valueOf(config.queue_type()); } catch ( final IllegalArgumentException iae) { - logger.error("Invalid value for queue type configuration: {}", params.get(ConfigurationConstants.PROP_TYPE)); + logger.error("Invalid value for queue type configuration: {}", config.queue_type()); this.type = null; } - this.retries = PropertiesUtil.toInteger(params.get(ConfigurationConstants.PROP_RETRIES), ConfigurationConstants.DEFAULT_RETRIES); - this.retryDelay = PropertiesUtil.toLong(params.get(ConfigurationConstants.PROP_RETRY_DELAY), ConfigurationConstants.DEFAULT_RETRY_DELAY); + this.retries = config.queue_retries(); + this.retryDelay = config.queue_retrydelay(); // Float values are treated as percentage. int values are treated as number of cores, -1 == all available // Note: the value is based on the core count at startup. It will not change dynamically if core count changes. int cores = ConfigurationConstants.NUMBER_OF_PROCESSORS; - final double inMaxParallel = PropertiesUtil.toDouble(params.get(ConfigurationConstants.PROP_MAX_PARALLEL), - ConfigurationConstants.DEFAULT_MAX_PARALLEL); + final double inMaxParallel = config.queue_maxparallel(); logger.debug("Max parallel for queue {} is {}", this.name, inMaxParallel); if ((inMaxParallel == Math.floor(inMaxParallel)) && !Double.isInfinite(inMaxParallel)) { // integral type @@ -224,18 +228,18 @@ public class InternalQueueConfiguration if ( this.type == Type.ORDERED ) { this.maxParallelProcesses = 1; } - final String[] topicsParam = PropertiesUtil.toStringArray(params.get(ConfigurationConstants.PROP_TOPICS)); + final String[] topicsParam = config.queue_topics(); this.matchers = TopicMatcherHelper.buildMatchers(topicsParam); if ( this.matchers == null ) { this.topics = null; } else { this.topics = topicsParam; } - this.keepJobs = PropertiesUtil.toBoolean(params.get(ConfigurationConstants.PROP_KEEP_JOBS), ConfigurationConstants.DEFAULT_KEEP_JOBS); - this.serviceRanking = PropertiesUtil.toInteger(params.get(Constants.SERVICE_RANKING), 0); - this.ownThreadPoolSize = PropertiesUtil.toInteger(params.get(ConfigurationConstants.PROP_THREAD_POOL_SIZE), ConfigurationConstants.DEFAULT_THREAD_POOL_SIZE); - this.preferCreationInstance = PropertiesUtil.toBoolean(params.get(ConfigurationConstants.PROP_PREFER_RUN_ON_CREATION_INSTANCE), ConfigurationConstants.DEFAULT_PREFER_RUN_ON_CREATION_INSTANCE); - this.pid = (String)params.get(Constants.SERVICE_PID); + this.keepJobs = config.queue_keepJobs(); + this.serviceRanking = config.service_ranking(); + this.ownThreadPoolSize = config.queue_threadPoolSize(); + this.preferCreationInstance = config.queue_preferRunOnCreationInstance(); + this.pid = (String)props.get(Constants.SERVICE_PID); this.valid = this.checkIsValid(); } Modified: sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/JobManagerConfiguration.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/JobManagerConfiguration.java?rev=1793745&r1=1793744&r2=1793745&view=diff ============================================================================== --- sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/JobManagerConfiguration.java (original) +++ sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/JobManagerConfiguration.java Thu May 4 08:03:38 2017 @@ -27,14 +27,6 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Deactivate; -import org.apache.felix.scr.annotations.Modified; -import org.apache.felix.scr.annotations.Properties; -import org.apache.felix.scr.annotations.Property; -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.Service; import org.apache.sling.api.resource.LoginException; import org.apache.sling.api.resource.PersistenceException; import org.apache.sling.api.resource.ResourceResolver; @@ -46,7 +38,6 @@ import org.apache.sling.discovery.Topolo import org.apache.sling.discovery.TopologyEventListener; import org.apache.sling.discovery.commons.InitDelayingTopologyEventListener; import org.apache.sling.event.impl.EnvironmentComponent; -import org.apache.sling.event.impl.jobs.Utility; import org.apache.sling.event.impl.jobs.tasks.CheckTopologyTask; import org.apache.sling.event.impl.jobs.tasks.FindUnfinishedJobsTask; import org.apache.sling.event.impl.jobs.tasks.UpgradeTask; @@ -54,6 +45,15 @@ import org.apache.sling.event.impl.suppo import org.apache.sling.event.impl.support.ResourceHelper; import org.apache.sling.event.jobs.Job; import org.apache.sling.serviceusermapping.ServiceUserMapped; +import org.osgi.framework.Constants; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Modified; +import org.osgi.service.component.annotations.Reference; +import org.osgi.service.metatype.annotations.AttributeDefinition; +import org.osgi.service.metatype.annotations.Designate; +import org.osgi.service.metatype.annotations.ObjectClassDefinition; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -61,35 +61,32 @@ import org.slf4j.LoggerFactory; * Configuration of the job handling * */ -@Component(immediate=true, metatype=true, - label="Apache Sling Job Manager", - description="This is the central service of the job handling.", - name="org.apache.sling.event.impl.jobs.jcr.PersistenceHandler") -@Service(value={JobManagerConfiguration.class}) -@Properties({ - @Property(name=JobManagerConfiguration.PROPERTY_DISABLE_DISTRIBUTION, - boolValue=JobManagerConfiguration.DEFAULT_DISABLE_DISTRIBUTION, - label="Disable Distribution", - description="If the distribution is disabled, all jobs will be processed on the leader only! " - + "Please use this switch with care."), - @Property(name=JobManagerConfiguration.PROPERTY_LOG_DEPRECATION_WARNINGS, - boolValue=JobManagerConfiguration.DEFAULT_LOG_DEPRECATION_WARNINGS, - label="Deprecation Warnings", - description="If this switch is enabled, deprecation warnings will be logged with the INFO level."), - @Property(name=JobManagerConfiguration.PROPERTY_STARTUP_DELAY, - longValue=JobManagerConfiguration.DEFAULT_STARTUP_DELAY, - label="Startup Delay", - description="Specify amount in seconds that job manager waits on startup before starting with job handling. " - + "This can be used to allow enough time to restart a cluster before jobs are eventually reassigned."), - @Property(name=JobManagerConfiguration.PROPERTY_REPOSITORY_PATH, - value=JobManagerConfiguration.DEFAULT_REPOSITORY_PATH, propertyPrivate=true), - @Property(name=JobManagerConfiguration.PROPERTY_SCHEDULED_JOBS_PATH, - value=JobManagerConfiguration.DEFAULT_SCHEDULED_JOBS_PATH, propertyPrivate=true), - @Property(name=JobManagerConfiguration.PROPERTY_BACKGROUND_LOAD_DELAY, - longValue=JobManagerConfiguration.DEFAULT_BACKGROUND_LOAD_DELAY, propertyPrivate=true), +@Component(immediate=true, + service=JobManagerConfiguration.class, + name="org.apache.sling.event.impl.jobs.jcr.PersistenceHandler", + property = { + Constants.SERVICE_VENDOR + "=The Apache Software Foundation", + JobManagerConfiguration.PROPERTY_REPOSITORY_PATH + "=" + JobManagerConfiguration.DEFAULT_REPOSITORY_PATH, + JobManagerConfiguration.PROPERTY_SCHEDULED_JOBS_PATH + "=" + JobManagerConfiguration.DEFAULT_SCHEDULED_JOBS_PATH, + JobManagerConfiguration.PROPERTY_BACKGROUND_LOAD_DELAY + ":Long=" + JobManagerConfiguration.DEFAULT_BACKGROUND_LOAD_DELAY }) +@Designate(ocd = JobManagerConfiguration.Config.class) public class JobManagerConfiguration { + @ObjectClassDefinition(name = "Apache Sling Job Manager", + description="This is the central service of the job handling.") + public @interface Config { + + @AttributeDefinition(name = "Disable Distribution", + description="If the distribution is disabled, all jobs will be processed on the leader only! " + + "Please use this switch with care.") + boolean job_consumermanager_disableDistribution() default false; + + @AttributeDefinition(name = "Startup Delay", + description="Specify amount in seconds that job manager waits on startup before starting with job handling. " + + "This can be used to allow enough time to restart a cluster before jobs are eventually reassigned.") + long startup_delay() default 30; + } /** Logger. */ private final Logger logger = LoggerFactory.getLogger("org.apache.sling.event.impl.jobs"); @@ -102,12 +99,6 @@ public class JobManagerConfiguration { /** Default background load delay. */ public static final long DEFAULT_BACKGROUND_LOAD_DELAY = 10; - /** Default startup delay. */ - public static final long DEFAULT_STARTUP_DELAY = 30; - - /** Default for disabling the distribution. */ - public static final boolean DEFAULT_DISABLE_DISTRIBUTION = false; - /** Default resource path for scheduled jobs. */ public static final String DEFAULT_SCHEDULED_JOBS_PATH = "/var/eventing/scheduled-jobs"; @@ -117,24 +108,9 @@ public class JobManagerConfiguration { /** The background loader waits this time of seconds after startup before loading events from the repository. (in secs) */ public static final String PROPERTY_BACKGROUND_LOAD_DELAY = "load.delay"; - /** The entire job handling waits time amount of seconds until it starts - to allow avoiding reassign on restart of a cluster */ - public static final String PROPERTY_STARTUP_DELAY = "startup.delay"; - - /** Configuration switch for distributing the jobs. */ - public static final String PROPERTY_DISABLE_DISTRIBUTION = "job.consumermanager.disableDistribution"; - /** Configuration property for the scheduled jobs path. */ public static final String PROPERTY_SCHEDULED_JOBS_PATH = "job.scheduled.jobs.path"; - /** Default value for background loading. */ - public static final boolean DEFAULT_BACKGROUND_LOAD_SEARCH = true; - - /** Configuration property for deprecation warnings. */ - public static final String PROPERTY_LOG_DEPRECATION_WARNINGS = "job.log.deprecation"; - - /** Default value for deprecation warnings. */ - public static final boolean DEFAULT_LOG_DEPRECATION_WARNINGS = true; - /** The jobs base path with a slash. */ private String jobsBasePathWithSlash; @@ -173,7 +149,7 @@ public class JobManagerConfiguration { private String scheduledJobsPathWithSlash; /** List of topology awares. */ - private final List<ConfigurationChangeListener> listeners = new ArrayList<ConfigurationChangeListener>(); + private final List<ConfigurationChangeListener> listeners = new ArrayList<>(); /** The environment component. */ @Reference @@ -200,11 +176,12 @@ public class JobManagerConfiguration { /** * Activate this component. * @param props Configuration properties + * @param config Configuration properties * @throws RuntimeException If the default paths can't be created */ @Activate - protected void activate(final Map<String, Object> props) { - this.update(props); + protected void activate(final Map<String, Object> props, final Config config) { + this.update(props, config); this.jobsBasePathWithSlash = PropertiesUtil.toString(props.get(PROPERTY_REPOSITORY_PATH), DEFAULT_REPOSITORY_PATH) + '/'; @@ -240,7 +217,7 @@ public class JobManagerConfiguration { // SLING-5560 : use an InitDelayingTopologyEventListener if (this.startupDelay > 0) { - logger.debug("activate: job manager will start in {} sec. ({})", this.startupDelay, PROPERTY_STARTUP_DELAY); + logger.debug("activate: job manager will start in {} sec. ({})", this.startupDelay, config.startup_delay()); this.startupDelayListener = new InitDelayingTopologyEventListener(startupDelay, new TopologyEventListener() { @Override @@ -249,7 +226,7 @@ public class JobManagerConfiguration { } }, this.scheduler, logger); } else { - logger.debug("activate: job manager will start without delay. ({}:{})", PROPERTY_STARTUP_DELAY, this.startupDelay); + logger.debug("activate: job manager will start without delay. ({}:{})", config.startup_delay(), this.startupDelay); } } @@ -257,14 +234,13 @@ public class JobManagerConfiguration { * Update with a new configuration */ @Modified - protected void update(final Map<String, Object> props) { - this.disabledDistribution = PropertiesUtil.toBoolean(props.get(PROPERTY_DISABLE_DISTRIBUTION), DEFAULT_DISABLE_DISTRIBUTION); + protected void update(final Map<String, Object> props, final Config config) { + this.disabledDistribution = config.job_consumermanager_disableDistribution(); this.backgroundLoadDelay = PropertiesUtil.toLong(props.get(PROPERTY_BACKGROUND_LOAD_DELAY), DEFAULT_BACKGROUND_LOAD_DELAY); // SLING-5560: note that currently you can't change the startupDelay to have // an immediate effect - it will only have an effect on next activation. // (as 'startup delay runnable' is already scheduled in activate) - this.startupDelay = PropertiesUtil.toLong(props.get(PROPERTY_STARTUP_DELAY), DEFAULT_STARTUP_DELAY); - Utility.LOG_DEPRECATION_WARNINGS = PropertiesUtil.toBoolean(props.get(PROPERTY_LOG_DEPRECATION_WARNINGS), DEFAULT_LOG_DEPRECATION_WARNINGS); + this.startupDelay = config.startup_delay(); } /** @@ -622,7 +598,7 @@ public class JobManagerConfiguration { } } - private final Map<String, Job> retryList = new HashMap<String, Job>(); + private final Map<String, Job> retryList = new HashMap<>(); public void addJobToRetryList(final Job job) { synchronized ( retryList ) { @@ -631,7 +607,7 @@ public class JobManagerConfiguration { } public List<Job> clearJobRetryList() { - final List<Job> result = new ArrayList<Job>(); + final List<Job> result = new ArrayList<>(); synchronized ( this.retryList ) { result.addAll(retryList.values()); retryList.clear(); Modified: sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/MainQueueConfiguration.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/MainQueueConfiguration.java?rev=1793745&r1=1793744&r2=1793745&view=diff ============================================================================== --- sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/MainQueueConfiguration.java (original) +++ sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/MainQueueConfiguration.java Thu May 4 08:03:38 2017 @@ -18,17 +18,17 @@ */ package org.apache.sling.event.impl.jobs.config; -import java.util.HashMap; -import java.util.Map; +import java.lang.annotation.Annotation; +import java.util.Collections; -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Modified; -import org.apache.felix.scr.annotations.Properties; -import org.apache.felix.scr.annotations.Property; -import org.apache.felix.scr.annotations.PropertyOption; -import org.apache.felix.scr.annotations.Service; import org.osgi.framework.Constants; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Modified; +import org.osgi.service.metatype.annotations.AttributeDefinition; +import org.osgi.service.metatype.annotations.Designate; +import org.osgi.service.metatype.annotations.ObjectClassDefinition; +import org.osgi.service.metatype.annotations.Option; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,42 +37,49 @@ import org.slf4j.LoggerFactory; * This is the configuration for the main queue. * */ -@Component(label="Apache Sling Job Default Queue", - description="The configuration of the default job queue.", - name="org.apache.sling.event.impl.jobs.DefaultJobManager", - metatype=true) -@Service(value=MainQueueConfiguration.class) -@Properties({ - @Property(name=ConfigurationConstants.PROP_PRIORITY, - value=ConfigurationConstants.DEFAULT_PRIORITY, - options={@PropertyOption(name="NORM",value="Norm"), - @PropertyOption(name="MIN",value="Min"), - @PropertyOption(name="MAX",value="Max")}, - label="Priority", - description="The priority for the threads used by this queue. Default is norm."), - @Property(name=ConfigurationConstants.PROP_RETRIES, - intValue=ConfigurationConstants.DEFAULT_RETRIES, - label="Maximum Retries", - description="The maximum number of times a failed job slated " - + "for retries is actually retried. If a job has been retried this number of " - + "times and still fails, it is not rescheduled and assumed to have failed. The " - + "default value is 10."), - @Property(name=ConfigurationConstants.PROP_RETRY_DELAY, - longValue=ConfigurationConstants.DEFAULT_RETRY_DELAY, - label="Retry Delay", - description="The number of milliseconds to sleep between two " - + "consecutive retries of a job which failed and was set to be retried. The " - + "default value is 2 seconds. This value is only relevant if there is a single " - + "failed job in the queue. If there are multiple failed jobs, each job is " - + "retried in turn without an intervening delay."), - @Property(name=ConfigurationConstants.PROP_MAX_PARALLEL, - intValue=ConfigurationConstants.DEFAULT_MAX_PARALLEL, - label="Maximum Parallel Jobs", - description="The maximum number of parallel jobs started for this queue. " - + "A value of -1 is substituted with the number of available processors."), -}) +@Component(name="org.apache.sling.event.impl.jobs.DefaultJobManager", + service=MainQueueConfiguration.class, + property={ + Constants.SERVICE_VENDOR + "=The Apache Software Foundation" + }) +@Designate(ocd=MainQueueConfiguration.Config.class) public class MainQueueConfiguration { + @ObjectClassDefinition(name = "Apache Sling Job Default Queue", + description="The configuration of the default job queue.") + public @interface Config { + + @AttributeDefinition( + name="Priority", + description="The priority for the threads used by this queue. Default is norm.", + options = { + @Option(label="NORM",value="Norm"), + @Option(label="MIN",value="Min"), + @Option(label="MAX",value="Max") + }) + String queue_priority() default ConfigurationConstants.DEFAULT_PRIORITY; + + @AttributeDefinition(name="Maximum Retries", + description="The maximum number of times a failed job slated " + + "for retries is actually retried. If a job has been retried this number of " + + "times and still fails, it is not rescheduled and assumed to have failed. The " + + "default value is 10.") + int queue_retries() default ConfigurationConstants.DEFAULT_RETRIES; + + @AttributeDefinition(name="Retry Delay", + description="The number of milliseconds to sleep between two " + + "consecutive retries of a job which failed and was set to be retried. The " + + "default value is 2 seconds. This value is only relevant if there is a single " + + "failed job in the queue. If there are multiple failed jobs, each job is " + + "retried in turn without an intervening delay.") + long queue_retrydelay() default ConfigurationConstants.DEFAULT_RETRY_DELAY; + + @AttributeDefinition(name="Maximum Parallel Jobs", + description="The maximum number of parallel jobs started for this queue. " + + "A value of -1 is substituted with the number of available processors.") + int queue_maxparallel() default ConfigurationConstants.DEFAULT_MAX_PARALLEL; + } + public static final String MAIN_QUEUE_NAME = "<main queue>"; /** Default logger. */ @@ -82,27 +89,84 @@ public class MainQueueConfiguration { /** * Activate this component. - * @param props Configuration properties + * @param config Configuration properties */ @Activate - protected void activate(final Map<String, Object> props) { - this.update(props); + protected void activate(final Config config) { + this.update(config); } /** * Configure this component. - * @param props Configuration properties + * @param config Configuration properties */ @Modified - protected void update(final Map<String, Object> props) { - // create a new dictionary with the missing info and do some sanity puts - final Map<String, Object> queueProps = new HashMap<String, Object>(props); - queueProps.put(ConfigurationConstants.PROP_TOPICS, "*"); - queueProps.put(ConfigurationConstants.PROP_NAME, MAIN_QUEUE_NAME); - queueProps.put(ConfigurationConstants.PROP_TYPE, InternalQueueConfiguration.Type.UNORDERED); - queueProps.put(Constants.SERVICE_PID, "org.apache.sling.event.impl.jobs.DefaultJobManager"); - logger.debug("properties for queue {}: {}", MAIN_QUEUE_NAME, queueProps); - this.mainConfiguration = InternalQueueConfiguration.fromConfiguration(queueProps); + protected void update(final Config config) { + logger.debug("properties for queue {}: {}", MAIN_QUEUE_NAME, config); + this.mainConfiguration = InternalQueueConfiguration.fromConfiguration( + Collections.singletonMap(Constants.SERVICE_PID, (Object)"org.apache.sling.event.impl.jobs.DefaultJobManager"), + new InternalQueueConfiguration.Config() { + + @Override + public Class<? extends Annotation> annotationType() { + return InternalQueueConfiguration.Config.class; + } + + @Override + public int service_ranking() { + return 0; + } + + @Override + public String queue_type() { + return InternalQueueConfiguration.Type.UNORDERED.name(); + } + + @Override + public String[] queue_topics() { + return new String[] {"*"}; + } + + @Override + public int queue_threadPoolSize() { + return 0; + } + + @Override + public long queue_retrydelay() { + return config.queue_retrydelay(); + } + + @Override + public int queue_retries() { + return config.queue_retries(); + } + + @Override + public String queue_priority() { + return config.queue_priority(); + } + + @Override + public boolean queue_preferRunOnCreationInstance() { + return false; + } + + @Override + public String queue_name() { + return MAIN_QUEUE_NAME; + } + + @Override + public double queue_maxparallel() { + return config.queue_maxparallel(); + } + + @Override + public boolean queue_keepJobs() { + return false; + } + }); } /** Modified: sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/QueueConfigurationManager.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/QueueConfigurationManager.java?rev=1793745&r1=1793744&r2=1793745&view=diff ============================================================================== --- sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/QueueConfigurationManager.java (original) +++ sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/QueueConfigurationManager.java Thu May 4 08:03:38 2017 @@ -22,22 +22,21 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.apache.felix.scr.annotations.Component; -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.event.impl.support.ResourceHelper; +import org.osgi.framework.Constants; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; +import org.osgi.service.component.annotations.ReferenceCardinality; +import org.osgi.service.component.annotations.ReferencePolicy; /** * The queue manager manages queue configurations. */ -@Component -@Service(value=QueueConfigurationManager.class) -@Reference(referenceInterface=InternalQueueConfiguration.class, policy=ReferencePolicy.DYNAMIC, - cardinality=ReferenceCardinality.OPTIONAL_MULTIPLE, - bind="bindConfig", unbind="unbindConfig", updated="updateConfig") +@Component(service = QueueConfigurationManager.class, +property = { + Constants.SERVICE_VENDOR + "=The Apache Software Foundation" +}) public class QueueConfigurationManager { /** Empty configuration array. */ @@ -47,7 +46,7 @@ public class QueueConfigurationManager { private volatile InternalQueueConfiguration[] orderedConfigs = EMPTY_CONFIGS; /** All configurations. */ - private final List<InternalQueueConfiguration> configurations = new ArrayList<InternalQueueConfiguration>(); + private final List<InternalQueueConfiguration> configurations = new ArrayList<>(); /** The main queue configuration. */ @Reference @@ -57,6 +56,9 @@ public class QueueConfigurationManager { * Add a new queue configuration. * @param config A new queue configuration. */ + @Reference(service=InternalQueueConfiguration.class, policy=ReferencePolicy.DYNAMIC, + cardinality=ReferenceCardinality.MULTIPLE, + updated="updateConfig") protected void bindConfig(final InternalQueueConfiguration config) { synchronized ( configurations ) { configurations.add(config); Modified: sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/TopologyHandler.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/TopologyHandler.java?rev=1793745&r1=1793744&r2=1793745&view=diff ============================================================================== --- sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/TopologyHandler.java (original) +++ sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/config/TopologyHandler.java Thu May 4 08:03:38 2017 @@ -22,13 +22,13 @@ import java.util.concurrent.BlockingQueu import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Deactivate; -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.Service; import org.apache.sling.discovery.TopologyEvent; import org.apache.sling.discovery.TopologyEventListener; +import org.osgi.framework.Constants; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Reference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,8 +36,10 @@ import org.slf4j.LoggerFactory; * This topology handler is handling the topology change events asynchronously * and processes them by queuing them. */ -@Component -@Service(value = TopologyEventListener.class) +@Component(service = TopologyEventListener.class, + property = { + Constants.SERVICE_VENDOR + "=The Apache Software Foundation" + }) public class TopologyHandler implements TopologyEventListener, Runnable { /** The logger. */ @@ -47,7 +49,7 @@ public class TopologyHandler implements private JobManagerConfiguration configuration; /** A local queue for async handling of the events */ - private final BlockingQueue<QueueItem> queue = new LinkedBlockingQueue<QueueItem>(); + private final BlockingQueue<QueueItem> queue = new LinkedBlockingQueue<>(); /** Active flag. */ private final AtomicBoolean isActive = new AtomicBoolean(false); Modified: sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/console/InventoryPlugin.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/console/InventoryPlugin.java?rev=1793745&r1=1793744&r2=1793745&view=diff ============================================================================== --- sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/console/InventoryPlugin.java (original) +++ sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/console/InventoryPlugin.java Thu May 4 08:03:38 2017 @@ -31,11 +31,6 @@ import java.util.Map; import org.apache.felix.inventory.Format; import org.apache.felix.inventory.InventoryPrinter; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Properties; -import org.apache.felix.scr.annotations.Property; -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.Service; import org.apache.sling.discovery.InstanceDescription; import org.apache.sling.event.impl.jobs.JobConsumerManager; import org.apache.sling.event.impl.jobs.config.InternalQueueConfiguration; @@ -48,19 +43,23 @@ import org.apache.sling.event.jobs.Sched import org.apache.sling.event.jobs.ScheduledJobInfo; import org.apache.sling.event.jobs.Statistics; import org.apache.sling.event.jobs.TopicStatistics; +import org.osgi.framework.Constants; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; /** * This is a inventory plugin displaying the active queues, some statistics * and the configurations. * @since 3.2 */ -@Component -@Service(value={InventoryPrinter.class}) -@Properties({ - @Property(name=InventoryPrinter.NAME, value="slingjobs"), - @Property(name=InventoryPrinter.TITLE, value="Sling Jobs"), - @Property(name=InventoryPrinter.FORMAT, value={"TEXT", "JSON"}), - @Property(name=InventoryPrinter.WEBCONSOLE, boolValue=false) +@Component(service={InventoryPrinter.class}, + property = { + Constants.SERVICE_VENDOR + "=The Apache Software Foundation", + InventoryPrinter.NAME + "=slingjobs", + InventoryPrinter.TITLE + "=Sling Jobs", + InventoryPrinter.FORMAT + "=TEXT", + InventoryPrinter.FORMAT + "=JSON", + InventoryPrinter.WEBCONSOLE + ":Boolean=false" }) public class InventoryPlugin implements InventoryPrinter { @@ -325,7 +324,7 @@ public class InventoryPlugin implements final Iterator<Map.Entry<String, List<InstanceDescription>>> iter = instanceCaps.entrySet().iterator(); while ( iter.hasNext() ) { final Map.Entry<String, List<InstanceDescription>> entry = iter.next(); - final List<String> instances = new ArrayList<String>(); + final List<String> instances = new ArrayList<>(); for(final InstanceDescription id : entry.getValue()) { if ( id.isLocal() ) { instances.add("local"); Modified: sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/console/WebConsolePlugin.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/console/WebConsolePlugin.java?rev=1793745&r1=1793744&r2=1793745&view=diff ============================================================================== --- sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/console/WebConsolePlugin.java (original) +++ sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/console/WebConsolePlugin.java Thu May 4 08:03:38 2017 @@ -33,11 +33,6 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Properties; -import org.apache.felix.scr.annotations.Property; -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.Service; import org.apache.sling.api.request.ResponseUtil; import org.apache.sling.discovery.InstanceDescription; import org.apache.sling.event.impl.jobs.JobConsumerManager; @@ -53,6 +48,9 @@ import org.apache.sling.event.jobs.Sched import org.apache.sling.event.jobs.Statistics; import org.apache.sling.event.jobs.TopicStatistics; import org.apache.sling.event.jobs.consumer.JobConsumer; +import org.osgi.framework.Constants; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -61,13 +59,13 @@ import org.slf4j.LoggerFactory; * and the configurations. * @since 3.0 */ -@Component -@Service(value={javax.servlet.Servlet.class, JobConsumer.class}) -@Properties({ - @Property(name="felix.webconsole.label", value="slingevent"), - @Property(name="felix.webconsole.title", value="Jobs"), - @Property(name="felix.webconsole.category", value="Sling"), - @Property(name=JobConsumer.PROPERTY_TOPICS, value={"sling/webconsole/test"}) +@Component(service={javax.servlet.Servlet.class, JobConsumer.class}, +property = { + Constants.SERVICE_VENDOR + "=The Apache Software Foundation", + "felix.webconsole.label=slingevent", + "felix.webconsole.title=Jobs", + "felix.webconsole.category=SLING", + JobConsumer.PROPERTY_TOPICS + "=sling/webconsole/test" }) public class WebConsolePlugin extends HttpServlet implements JobConsumer { Modified: sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/jmx/AllJobStatisticsMBean.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/jmx/AllJobStatisticsMBean.java?rev=1793745&r1=1793744&r2=1793745&view=diff ============================================================================== --- sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/jmx/AllJobStatisticsMBean.java (original) +++ sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/jmx/AllJobStatisticsMBean.java Thu May 4 08:03:38 2017 @@ -17,23 +17,24 @@ */ package org.apache.sling.event.impl.jobs.jmx; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Properties; -import org.apache.felix.scr.annotations.Property; -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.Service; import org.apache.sling.event.jobs.JobManager; import org.apache.sling.event.jobs.Statistics; import org.apache.sling.event.jobs.jmx.StatisticsMBean; +import org.osgi.framework.Constants; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; -@Component -@Service(value = StatisticsMBean.class) -@Properties(@Property(name = "jmx.objectname", value = "org.apache.sling:type=queues,name=AllQueues")) +@Component(service = StatisticsMBean.class, + property = { + "jmx.objectname=org.apache.sling:type=queues,name=AllQueues", + Constants.SERVICE_VENDOR + "=The Apache Software Foundation" +}) public class AllJobStatisticsMBean extends AbstractJobStatistics { private static final long TTL = 1000L; private long agregateStatisticsTTL = 0L; private Statistics aggregateStatistics; + @Reference private JobManager jobManager;