incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r906409 - in /sling/trunk/bundles/extensions/event: ./ src/main/java/org/apache/sling/event/impl/
Date Thu, 04 Feb 2010 09:06:50 GMT
Author: cziegeler
Date: Thu Feb  4 09:06:50 2010
New Revision: 906409

URL: http://svn.apache.org/viewvc?rev=906409&view=rev
Log:
SLING-1348 : Disable DistributingEventHandler by default

Modified:
    sling/trunk/bundles/extensions/event/pom.xml
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/DistributingEventHandler.java
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/EventingThreadPool.java
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/TimedJobHandler.java

Modified: sling/trunk/bundles/extensions/event/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/pom.xml?rev=906409&r1=906408&r2=906409&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/pom.xml (original)
+++ sling/trunk/bundles/extensions/event/pom.xml Thu Feb  4 09:06:50 2010
@@ -89,6 +89,12 @@
     </reporting>
     <dependencies>
         <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+            <version>1.2.0</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
         </dependency>

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java?rev=906409&r1=906408&r2=906409&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java
(original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java
Thu Feb  4 09:06:50 2010
@@ -29,6 +29,10 @@
 import javax.jcr.Session;
 import javax.jcr.observation.EventListener;
 
+import org.apache.felix.scr.annotations.Component;
+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.classloader.DynamicClassLoaderManager;
 import org.apache.sling.commons.osgi.OsgiUtil;
 import org.apache.sling.engine.SlingSettingsService;
@@ -46,25 +50,25 @@
 /**
  * Abstract base class for all event handlers in this package.
  *
- * @scr.component abstract="true" metatype="no"
- * @scr.service interface="org.osgi.service.event.EventHandler"
  */
+@Component(componentAbstract=true)
+@Service(value=EventHandler.class)
 public abstract class AbstractRepositoryEventHandler
     implements EventHandler, EventListener {
 
     /** Default log. */
     protected final Logger logger = LoggerFactory.getLogger(this.getClass());
 
-    /** @scr.property valueRef="DEFAULT_PROPERTY_REPO_PATH" */
-    protected static final String CONFIG_PROPERTY_REPO_PATH = "repository.path";
-
     /** Default path for the {@link #CONFIG_PROPERTY_REPO_PATH} */
     private static final String DEFAULT_PROPERTY_REPO_PATH = "/sling/events";
 
-    /** @scr.reference */
+    @Property(value=DEFAULT_PROPERTY_REPO_PATH)
+    protected static final String CONFIG_PROPERTY_REPO_PATH = "repository.path";
+
+    @Reference
     protected SlingRepository repository;
 
-    /** @scr.reference */
+    @Reference
     protected EventAdmin eventAdmin;
 
     /** Our application id. */
@@ -85,16 +89,17 @@
     /** A local queue for writing received events into the repository. */
     protected final BlockingQueue<Event> writeQueue = new LinkedBlockingQueue<Event>();
 
-    /** @scr.reference */
+    @Reference
     protected DynamicClassLoaderManager classLoaderManager;
 
     /**
      * Our thread pool.
-     * @scr.reference */
+     */
+    @Reference
     protected ThreadPool threadPool;
 
-    /** @scr.reference
-     *  Sling settings service. */
+    /** Sling settings service. */
+    @Reference
     protected SlingSettingsService settingsService;
 
     /** The root node for writing. */

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/DistributingEventHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/DistributingEventHandler.java?rev=906409&r1=906408&r2=906409&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/DistributingEventHandler.java
(original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/DistributingEventHandler.java
Thu Feb  4 09:06:50 2010
@@ -28,6 +28,11 @@
 import javax.jcr.observation.EventIterator;
 import javax.jcr.query.Query;
 
+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.Service;
 import org.apache.jackrabbit.util.ISO8601;
 import org.apache.sling.commons.osgi.OsgiUtil;
 import org.apache.sling.event.EventUtil;
@@ -37,17 +42,23 @@
 
 /**
  * This event handler distributes events across an application cluster.
- * @scr.component label="%dist.events.name" description="%dist.events.description" immediate="true"
- * @scr.property name="event.topics" value="*" private="true"
- * @scr.property name="event.filter" value="(event.distribute=*)" private="true"
- * @scr.property name="repository.path" value="/var/eventing/distribution" private="true"
  *
  * We schedule this event handler to run in the background and clean up
  * obsolete events.
- * @scr.service interface="java.lang.Runnable"
- * @scr.property name="scheduler.period" value="1800" type="Long"
- * @scr.property name="scheduler.concurrent" value="false" type="Boolean" private="true"
  */
+@Component(label="%dist.events.name",
+           description="%dist.events.description",
+           immediate=true,
+           metatype=true,
+           policy=ConfigurationPolicy.REQUIRE)
+@Service(value=Runnable.class)
+@Properties({
+    @Property(name="event.topics",value="*",propertyPrivate=true),
+    @Property(name="event.filter",value="(event.distribute=*)",propertyPrivate=true),
+    @Property(name="repository.path",value="/var/eventing/distribution",propertyPrivate=true),
+    @Property(name="scheduler.period", longValue=1800),
+    @Property(name="scheduler.concurrent", boolValue=false, propertyPrivate=true)
+})
 public class DistributingEventHandler
     extends AbstractRepositoryEventHandler
     implements Runnable {
@@ -55,7 +66,7 @@
     /** Default clean up time is 15 minutes. */
     protected static final int DEFAULT_CLEANUP_PERIOD = 15;
 
-    /** @scr.property valueRef="DEFAULT_CLEANUP_PERIOD" type="Integer" */
+    @Property(intValue=DEFAULT_CLEANUP_PERIOD)
     protected static final String CONFIG_PROPERTY_CLEANUP_PERIOD = "cleanup.period";
 
     /** We remove everything which is older than 15min by default. */

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/EventingThreadPool.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/EventingThreadPool.java?rev=906409&r1=906408&r2=906409&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/EventingThreadPool.java
(original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/EventingThreadPool.java
Thu Feb  4 09:06:50 2010
@@ -18,6 +18,10 @@
  */
 package org.apache.sling.event.impl;
 
+import org.apache.felix.scr.annotations.Component;
+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.OsgiUtil;
 import org.apache.sling.commons.threads.ModifiableThreadPoolConfig;
 import org.apache.sling.commons.threads.ThreadPoolConfig;
@@ -28,29 +32,30 @@
 
 /**
  * The configurable eventing thread pool.
- * @scr.component label="%event.pool.name" description="%event.pool.description"
- * @scr.service interface="org.apache.sling.event.ThreadPool"
- *
- * @scr.property nameRef="PROPERTY_MIN_POOL_SIZE" valueRef="DEFAULT_MIN_POOL_SIZE"
- * @scr.property nameRef="PROPERTY_MAX_POOL_SIZE" valueRef="DEFAULT_MAX_POOL_SIZE"
- * @scr.property nameRef="PROPERTY_QUEUEL_SIZE" valueRef="DEFAULT_QUEUE_SIZE"
  */
+@Component(label="%event.pool.name",
+        description="%event.pool.description",
+        metatype=true)
+@Service(value=ThreadPool.class)
 public class EventingThreadPool implements ThreadPool {
 
-    /** @scr.reference */
+    @Reference
     protected ThreadPoolManager threadPoolManager;
 
     /** The real thread pool used. */
     private org.apache.sling.commons.threads.ThreadPool threadPool;
 
-    private static final String PROPERTY_MIN_POOL_SIZE = "minPoolSize";
-    private static final String PROPERTY_MAX_POOL_SIZE = "maxPoolSize";
-    private static final String PROPERTY_QUEUEL_SIZE = "queueSize";
-
     private static final int DEFAULT_MIN_POOL_SIZE = 35; // this is sufficient for all threads
+ approx 25 job queues
     private static final int DEFAULT_MAX_POOL_SIZE = 50;
     private static final int DEFAULT_QUEUE_SIZE = -1; // infinite
 
+    @Property(intValue=DEFAULT_MIN_POOL_SIZE)
+    private static final String PROPERTY_MIN_POOL_SIZE = "minPoolSize";
+    @Property(intValue=DEFAULT_MAX_POOL_SIZE)
+    private static final String PROPERTY_MAX_POOL_SIZE = "maxPoolSize";
+    @Property(intValue=DEFAULT_QUEUE_SIZE)
+    private static final String PROPERTY_QUEUE_SIZE = "queueSize";
+
     /**
      * Activate this component.
      * @param context
@@ -63,7 +68,7 @@
         final ModifiableThreadPoolConfig config = new ModifiableThreadPoolConfig();
         config.setMinPoolSize(OsgiUtil.toInteger(ctx.getProperties().get(PROPERTY_MIN_POOL_SIZE),
DEFAULT_MIN_POOL_SIZE));
         config.setMaxPoolSize(OsgiUtil.toInteger(ctx.getProperties().get(PROPERTY_MAX_POOL_SIZE),
DEFAULT_MAX_POOL_SIZE));
-        config.setQueueSize(OsgiUtil.toInteger(ctx.getProperties().get(PROPERTY_QUEUEL_SIZE),
DEFAULT_QUEUE_SIZE));
+        config.setQueueSize(OsgiUtil.toInteger(ctx.getProperties().get(PROPERTY_QUEUE_SIZE),
DEFAULT_QUEUE_SIZE));
         config.setShutdownGraceful(true);
         this.threadPool = threadPoolManager.create(config);
     }

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java?rev=906409&r1=906408&r2=906409&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
(original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
Thu Feb  4 09:06:50 2010
@@ -44,6 +44,11 @@
 import javax.jcr.query.Query;
 import javax.jcr.query.QueryManager;
 
+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.Service;
+import org.apache.felix.scr.annotations.Services;
 import org.apache.jackrabbit.util.ISO8601;
 import org.apache.sling.commons.osgi.OsgiUtil;
 import org.apache.sling.commons.scheduler.Scheduler;
@@ -62,19 +67,26 @@
 /**
  * An event handler for special job events.
  *
- * @scr.component label="%job.events.name" description="%job.events.description" immediate="true"
- * @scr.service interface="org.apache.sling.event.JobStatusProvider"
- * @scr.property name="event.topics" valueRefs="EventUtil.TOPIC_JOB"
- *               values.updated="org/osgi/framework/BundleEvent/UPDATED"
- *               values.started="org/osgi/framework/BundleEvent/STARTED"
- *               private="true"
- * @scr.property name="repository.path" value="/var/eventing/jobs" private="true"
  * We schedule this event handler to run in the background and clean up
  * obsolete events.
- * @scr.service interface="java.lang.Runnable"
- * @scr.property name="scheduler.period" value="300" type="Long" label="%jobscheduler.period.name"
description="%jobscheduler.period.description"
- * @scr.property name="scheduler.concurrent" value="false" type="Boolean" private="true"
  */
+@Component(label="%job.events.name",
+        description="%job.events.description",
+        immediate=true,
+        metatype=true)
+@Services({
+    @Service(value=JobStatusProvider.class),
+    @Service(value=Runnable.class)
+})
+@Properties({
+     @Property(name="event.topics",propertyPrivate=true,
+               value={"org/osgi/framework/BundleEvent/UPDATED",
+                      "org/osgi/framework/BundleEvent/STARTED",
+                      EventUtil.TOPIC_JOB}),
+     @Property(name="repository.path",value="/var/eventing/jobs",propertyPrivate=true),
+     @Property(name="scheduler.period", longValue=300,label="%jobscheduler.period.name",description="%jobscheduler.period.description"),
+     @Property(name="scheduler.concurrent", boolValue=false, propertyPrivate=true)
+})
 public class JobEventHandler
     extends AbstractRepositoryEventHandler
     implements EventUtil.JobStatusNotifier, JobStatusProvider, Runnable {
@@ -88,25 +100,25 @@
     /** Default sleep time. */
     private static final long DEFAULT_SLEEP_TIME = 30;
 
-    /** @scr.property valueRef="DEFAULT_SLEEP_TIME" */
-    private static final String CONFIG_PROPERTY_SLEEP_TIME = "sleep.time";
-
     /** Default number of job retries. */
     private static final int DEFAULT_MAX_JOB_RETRIES = 10;
 
-    /** @scr.property valueRef="DEFAULT_MAX_JOB_RETRIES" */
+    @Property(longValue=DEFAULT_SLEEP_TIME)
+    private static final String CONFIG_PROPERTY_SLEEP_TIME = "sleep.time";
+
+    @Property(intValue=DEFAULT_MAX_JOB_RETRIES)
     private static final String CONFIG_PROPERTY_MAX_JOB_RETRIES = "max.job.retries";
 
     /** Default number of seconds to wait for an ack. */
     private static final long DEFAULT_WAIT_FOR_ACK = 90; // by default we wait 90 secs
 
-    /** @scr.property valueRef="DEFAULT_MAXIMUM_PARALLEL_JOBS" */
-    private static final String CONFIG_PROPERTY_MAXIMUM_PARALLEL_JOBS = "max.parallel.jobs";
-
     /** Default nubmer of parallel jobs. */
     private static final long DEFAULT_MAXIMUM_PARALLEL_JOBS = 15;
 
-    /** @scr.property valueRef="DEFAULT_WAIT_FOR_ACK" */
+    @Property(longValue=DEFAULT_MAXIMUM_PARALLEL_JOBS)
+    private static final String CONFIG_PROPERTY_MAXIMUM_PARALLEL_JOBS = "max.parallel.jobs";
+
+    @Property(longValue=DEFAULT_WAIT_FOR_ACK)
     private static final String CONFIG_PROPERTY_WAIT_FOR_ACK = "wait.for.ack";
 
     /** We check every 30 secs by default. */
@@ -133,7 +145,7 @@
     /** Default clean up time is 5 minutes. */
     private static final int DEFAULT_CLEANUP_PERIOD = 5;
 
-    /** @scr.property valueRef="DEFAULT_CLEANUP_PERIOD" type="Integer" label="%jobcleanup.period.name"
description="%jobcleanup.period.description" */
+    @Property(intValue=DEFAULT_CLEANUP_PERIOD,label="%jobcleanup.period.name",description="%jobcleanup.period.description")
     private static final String CONFIG_PROPERTY_CLEANUP_PERIOD = "cleanup.period";
 
     /** We remove everything which is older than 5 min by default. */
@@ -163,39 +175,39 @@
     /** Number of jobs to load from the repository on startup in one go. */
     private long maxLoadJobs;
 
-    /** @scr.property valueRef="DEFAULT_MAXIMUM_LOAD_JOBS" */
-    private static final String CONFIG_PROPERTY_MAX_LOAD_JOBS = "max.load.jobs";
-
     /** Default maximum load jobs. */
     private static final long DEFAULT_MAXIMUM_LOAD_JOBS = 1000;
 
+    @Property(longValue=DEFAULT_MAXIMUM_LOAD_JOBS)
+    private static final String CONFIG_PROPERTY_MAX_LOAD_JOBS = "max.load.jobs";
+
     /** Threshold - if the queue is lower than this threshold the repository is checked for
events. */
     private long loadThreshold;
 
-    /** @scr.property valueRef="DEFAULT_LOAD_THRESHOLD" */
-    private static final String CONFIG_PROPERTY_LOAD_THREASHOLD = "load.threshold";
-
     /** Default load threshold. */
     private static final long DEFAULT_LOAD_THRESHOLD = 400;
 
+    @Property(longValue=DEFAULT_LOAD_THRESHOLD)
+    private static final String CONFIG_PROPERTY_LOAD_THREASHOLD = "load.threshold";
+
     /** The background loader waits this time of seconds after startup before loading events
from the repository. (in secs) */
     private long backgroundLoadDelay;
 
-    /** @scr.property valueRef="DEFAULT_BACKGROUND_LOAD_DELAY" */
-    private static final String CONFIG_PROPERTY_BACKGROUND_LOAD_DELAY = "load.delay";
-
     /** Default background load delay. */
     private static final long DEFAULT_BACKGROUND_LOAD_DELAY = 30;
 
+    @Property(longValue=DEFAULT_BACKGROUND_LOAD_DELAY)
+    private static final String CONFIG_PROPERTY_BACKGROUND_LOAD_DELAY = "load.delay";
+
     /** The background loader waits this time of seconds between loads from the repository.
(in secs) */
     private long backgroundCheckDelay;
 
-    /** @scr.property valueRef="DEFAULT_BACKGROUND_CHECK_DELAY" */
-    private static final String CONFIG_PROPERTY_BACKGROUND_CHECK_DELAY = "load.checkdelay";
-
     /** Default background check delay. */
     private static final long DEFAULT_BACKGROUND_CHECK_DELAY = 240;
 
+    @Property(longValue=DEFAULT_BACKGROUND_CHECK_DELAY)
+    private static final String CONFIG_PROPERTY_BACKGROUND_CHECK_DELAY = "load.checkdelay";
+
     /** Time when this service has been started. */
     private long startTime;
 

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/TimedJobHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/TimedJobHandler.java?rev=906409&r1=906408&r2=906409&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/TimedJobHandler.java
(original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/TimedJobHandler.java
Thu Feb  4 09:06:50 2010
@@ -45,6 +45,11 @@
 import javax.jcr.query.Query;
 import javax.jcr.query.QueryManager;
 
+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.commons.scheduler.Job;
 import org.apache.sling.commons.scheduler.JobContext;
 import org.apache.sling.commons.scheduler.Scheduler;
@@ -57,13 +62,16 @@
 /**
  * An event handler for timed events.
  *
- * @scr.component metatype="no" immediate="true"
- * @scr.service interface="TimedEventStatusProvider"
- * @scr.property name="event.topics" valueRefs="EventUtil.TOPIC_TIMED_EVENT"
- *               values.updated="org/osgi/framework/BundleEvent/UPDATED"
- *               values.started="org/osgi/framework/BundleEvent/STARTED"
- * @scr.property name="repository.path" value="/var/eventing/timed-jobs"
  */
+@Component(immediate=true)
+@Service(value=TimedEventStatusProvider.class)
+@Properties({
+     @Property(name="event.topics",propertyPrivate=true,
+               value={"org/osgi/framework/BundleEvent/UPDATED",
+                      "org/osgi/framework/BundleEvent/STARTED",
+                      EventUtil.TOPIC_TIMED_EVENT}),
+     @Property(name="repository.path",value="/var/eventing/timed-jobs",propertyPrivate=true)
+})
 public class TimedJobHandler
     extends AbstractRepositoryEventHandler
     implements Job, TimedEventStatusProvider {
@@ -74,7 +82,7 @@
 
     protected static final String JOB_SCHEDULE_INFO = "info";
 
-    /** @scr.reference */
+    @Reference
     protected Scheduler scheduler;
 
     /** Unloaded events. */



Mime
View raw message