org.apache.sling.event.impl.jobs.jcr
Class PersistenceHandler

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

@Services(value={@Service(value=PersistenceHandler.class),@Service(value=org.osgi.service.event.EventHandler.class),@Service(value=java.lang.Runnable.class)})
@Properties(value={@Property(name="event.topics",propertyPrivate=true,value={"org/osgi/framework/BundleEvent/UPDATED","org/osgi/framework/BundleEvent/STARTED","org/apache/sling/event/job"}),@Property(name="scheduler.period",longValue=300L,label="%persscheduler.period.name",description="%persscheduler.period.description"),@Property(name="scheduler.concurrent",boolValue=false,propertyPrivate=true)})
public class PersistenceHandler
extends Object
implements javax.jcr.observation.EventListener, Runnable, org.osgi.service.event.EventHandler

Persistence handler for the jobs


Constructor Summary
PersistenceHandler()
           
 
Method Summary
protected  void activate(org.osgi.service.component.ComponentContext context)
          Activate this component.
 void cleanup()
          This method is invoked periodically.
protected  void deactivate(org.osgi.service.component.ComponentContext context)
          Deactivate this component.
 void finished(JobEvent info)
          Finish the job
 org.osgi.service.event.Event forceReadEvent(javax.jcr.Node eventNode)
          Read an event from the repository.
 String getRepositoryPath()
          Return the repository path.
 void handleEvent(org.osgi.service.event.Event event)
           
 boolean lock(JobEvent info)
          Try to lock the node in the repository.
 void onEvent(javax.jcr.observation.EventIterator iter)
           
 boolean remove(String jobId)
          Remove the job - if not currently in processing.
 boolean reschedule(JobEvent info)
          Reschedule the job
 void restart(JobEvent info)
          Try to restart the job
 void run()
          This method is invoked periodically by the scheduler.
 void unlock(JobEvent info)
          Unlock the node for the event
protected  void update(org.osgi.service.component.ComponentContext context)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistenceHandler

public PersistenceHandler()
Method Detail

activate

@Activate
protected void activate(org.osgi.service.component.ComponentContext context)
                 throws javax.jcr.RepositoryException
Activate this component.

Parameters:
context - The component context.
Throws:
javax.jcr.RepositoryException

deactivate

@Deactivate
protected void deactivate(org.osgi.service.component.ComponentContext context)
Deactivate this component.

Parameters:
context - The component context.

update

@Modified
protected void update(org.osgi.service.component.ComponentContext context)

onEvent

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

cleanup

public void cleanup()
This method is invoked periodically.

See Also:
Runnable.run()

getRepositoryPath

public String getRepositoryPath()
Return the repository path.


forceReadEvent

public org.osgi.service.event.Event forceReadEvent(javax.jcr.Node eventNode)
                                            throws javax.jcr.RepositoryException
Read an event from the repository. This method is similar as readEvent(Node, boolean) with the exception that it even loads the event if classes are missing

Throws:
javax.jcr.RepositoryException

lock

public boolean lock(JobEvent info)
Try to lock the node in the repository. Locking might fail if: - the node has been removed - the job has alreay been processed - someone else locked it already

Parameters:
info - The job event
Returns:
true if the node could be locked

restart

public void restart(JobEvent info)
Try to restart the job


unlock

public void unlock(JobEvent info)
Unlock the node for the event


finished

public void finished(JobEvent info)
Finish the job


remove

public boolean remove(String jobId)
Remove the job - if not currently in processing.


reschedule

public boolean reschedule(JobEvent info)
Reschedule the job


run

public void run()
This method is invoked periodically by the scheduler.

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

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)


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