org.apache.sling.event.impl
Class DistributingEventHandler

java.lang.Object
  extended by org.apache.sling.event.impl.AbstractRepositoryEventHandler
      extended by org.apache.sling.event.impl.DistributingEventHandler
All Implemented Interfaces:
Runnable, javax.jcr.observation.EventListener, org.osgi.service.event.EventHandler

@Service(value=java.lang.Runnable.class)
@Properties(value={@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=1800L),@Property(name="scheduler.concurrent",boolValue=false,propertyPrivate=true)})
public class DistributingEventHandler
extends AbstractRepositoryEventHandler
implements Runnable

This event handler distributes events across an application cluster. We schedule this event handler to run in the background and clean up obsolete events.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.sling.event.impl.AbstractRepositoryEventHandler
AbstractRepositoryEventHandler.EventInfo
 
Field Summary
 
Fields inherited from class org.apache.sling.event.impl.AbstractRepositoryEventHandler
CONFIG_PROPERTY_REPO_PATH, environment, logger, queue, repositoryPath, running, writeLock, writeQueue, writerSession
 
Constructor Summary
DistributingEventHandler()
           
 
Method Summary
protected  void activate(org.osgi.service.component.ComponentContext context)
          Activate this component.
protected  void addEventProperties(javax.jcr.Node eventNode, Dictionary<String,Object> properties)
          Add properties from the node to the event properties.
protected  javax.jcr.query.Query getCleanUpQuery(javax.jcr.Session s)
          Return the query for the clean up.
 void handleEvent(org.osgi.service.event.Event event)
           
 void onEvent(javax.jcr.observation.EventIterator iterator)
           
protected  void processWriteQueue()
           
 void run()
          This method is invoked periodically.
protected  void runInBackground()
           
protected  void startWriterSession()
          Start the repository session and add this handler as an observer for new events created on other nodes.
 
Methods inherited from class org.apache.sling.event.impl.AbstractRepositoryEventHandler
addNodeProperties, deactivate, getEventNodeType, getWriterRootNode, ignoreException, readEvent, stopWriterSession, writeEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DistributingEventHandler

public DistributingEventHandler()
Method Detail

activate

protected void activate(org.osgi.service.component.ComponentContext context)
Description copied from class: AbstractRepositoryEventHandler
Activate this component.

Overrides:
activate in class AbstractRepositoryEventHandler
See Also:
AbstractRepositoryEventHandler.activate(org.osgi.service.component.ComponentContext)

getCleanUpQuery

protected javax.jcr.query.Query getCleanUpQuery(javax.jcr.Session s)
                                         throws javax.jcr.RepositoryException
Return the query for the clean up.

Throws:
javax.jcr.RepositoryException

run

public void run()
This method is invoked periodically.

Specified by:
run in interface Runnable
See Also:
Runnable.run()

processWriteQueue

protected void processWriteQueue()
Specified by:
processWriteQueue in class AbstractRepositoryEventHandler
See Also:
AbstractRepositoryEventHandler.processWriteQueue()

runInBackground

protected void runInBackground()
Specified by:
runInBackground in class AbstractRepositoryEventHandler
See Also:
AbstractRepositoryEventHandler.runInBackground()

handleEvent

public void handleEvent(org.osgi.service.event.Event event)
Specified by:
handleEvent in interface org.osgi.service.event.EventHandler
See Also:
EventHandler.handleEvent(org.osgi.service.event.Event)

onEvent

public void onEvent(javax.jcr.observation.EventIterator iterator)
Specified by:
onEvent in interface javax.jcr.observation.EventListener
See Also:
EventListener.onEvent(javax.jcr.observation.EventIterator)

addEventProperties

protected void addEventProperties(javax.jcr.Node eventNode,
                                  Dictionary<String,Object> properties)
                           throws javax.jcr.RepositoryException
Description copied from class: AbstractRepositoryEventHandler
Add properties from the node to the event properties.

Overrides:
addEventProperties in class AbstractRepositoryEventHandler
Parameters:
eventNode - The repository node.
properties - The event properties.
Throws:
javax.jcr.RepositoryException
See Also:
AbstractRepositoryEventHandler.addEventProperties(javax.jcr.Node, java.util.Dictionary)

startWriterSession

protected void startWriterSession()
                           throws javax.jcr.RepositoryException
Description copied from class: AbstractRepositoryEventHandler
Start the repository session and add this handler as an observer for new events created on other nodes.

Overrides:
startWriterSession in class AbstractRepositoryEventHandler
Throws:
javax.jcr.RepositoryException
See Also:
AbstractRepositoryEventHandler.startWriterSession()


Copyright © 2007-2013 The Apache Software Foundation. All Rights Reserved.