org.apache.sling.event
Class EventUtil

java.lang.Object
  extended by org.apache.sling.event.EventUtil

public abstract class EventUtil
extends Object

The EventUtil class is an utility class for clustered environments.


Nested Class Summary
static class EventUtil.JobPriority
          Deprecated. Use JobUtil.JobPriority
 
Field Summary
static String PROPERTY_APPLICATION
          This event property specifies the application node.
static String PROPERTY_DISTRIBUTE
          This event property indicates, if the event should be distributed in the cluster (default false).
static String PROPERTY_JOB_ID
          Deprecated. Use JobUtil.PROPERTY_JOB_NAME
static String PROPERTY_JOB_PARALLEL
          Deprecated. Use JobUtil.PROPERTY_JOB_PARALLEL
static String PROPERTY_JOB_PRIORITY
          Deprecated. Use JobUtil.PROPERTY_JOB_PRIORITY
static String PROPERTY_JOB_QUEUE_NAME
          Deprecated. Use JobUtil.PROPERTY_JOB_QUEUE_NAME
static String PROPERTY_JOB_QUEUE_ORDERED
          Deprecated. Use JobUtil.PROPERTY_JOB_QUEUE_ORDERED
static String PROPERTY_JOB_RETRIES
          Deprecated. Use JobUtil.PROPERTY_JOB_RETRIES
static String PROPERTY_JOB_RETRY_COUNT
          Deprecated. Use JobUtil.PROPERTY_JOB_RETRY_COUNT
static String PROPERTY_JOB_RETRY_DELAY
          Deprecated. Use JobUtil.PROPERTY_JOB_RETRY_DELAY
static String PROPERTY_JOB_RUN_LOCAL
          Deprecated. Use JobUtil.PROPERTY_JOB_RUN_LOCAL
static String PROPERTY_JOB_TOPIC
          Deprecated. Use JobUtil.PROPERTY_JOB_TOPIC
static String PROPERTY_NOTIFICATION_JOB
          Deprecated. Use JobUtil.PROPERTY_NOTIFICATION_JOB
static String PROPERTY_TIMED_EVENT_DATE
          The date for the timed event.
static String PROPERTY_TIMED_EVENT_ID
          The property for the unique event id.
static String PROPERTY_TIMED_EVENT_PERIOD
          The period for the timed event.
static String PROPERTY_TIMED_EVENT_SCHEDULE
          The scheduler expression for the timed event.
static String PROPERTY_TIMED_EVENT_TOPIC
          The real topic of the event.
static String TOPIC_JOB
          Deprecated. Use JobUtil.TOPIC_JOB
static String TOPIC_JOB_CANCELLED
          Deprecated. Use JobUtil.TOPIC_JOB_CANCELLED
static String TOPIC_JOB_FAILED
          Deprecated. Use JobUtil.TOPIC_JOB_FAILED
static String TOPIC_JOB_FINISHED
          Deprecated. Use JobUtil.TOPIC_JOB_FINISHED
static String TOPIC_JOB_STARTED
          Deprecated. Use JobUtil.TOPIC_JOB_STARTED
static String TOPIC_TIMED_EVENT
          The topic for timed events.
 
Constructor Summary
EventUtil()
           
 
Method Summary
static boolean acknowledgeJob(org.osgi.service.event.Event job)
          Deprecated. Use JobUtil.acknowledgeJob(Event)
static org.osgi.service.event.Event createDistributableEvent(String topic, Dictionary<String,Object> properties)
          Create a distributable event.
static void finishedJob(org.osgi.service.event.Event job)
          Deprecated. Use {link JobUtil.finishedJob(Event)
static String getApplicationId(org.osgi.service.event.Event event)
          Return the application id the event was created at.
static boolean isJobEvent(org.osgi.service.event.Event event)
          Deprecated. Use JobUtil.isJobEvent(Event)
static boolean isLocal(org.osgi.service.event.Event event)
          Is this a local event?
static void processJob(org.osgi.service.event.Event job, JobProcessor processor)
          Deprecated. Use JobUtil.processJob(Event, org.apache.sling.event.jobs.JobProcessor)
static boolean rescheduleJob(org.osgi.service.event.Event job)
          Deprecated. Use JobUtil.rescheduleJob(Event)
static boolean shouldDistribute(org.osgi.service.event.Event event)
          Should this event be distributed in the cluster?
static String toString(org.osgi.service.event.Event e)
          Improved toString method for an Event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_DISTRIBUTE

public static final String PROPERTY_DISTRIBUTE
This event property indicates, if the event should be distributed in the cluster (default false).

See Also:
Constant Field Values

PROPERTY_APPLICATION

public static final String PROPERTY_APPLICATION
This event property specifies the application node.

See Also:
Constant Field Values

PROPERTY_JOB_TOPIC

@Deprecated
public static final String PROPERTY_JOB_TOPIC
Deprecated. Use JobUtil.PROPERTY_JOB_TOPIC
The job topic property.

See Also:
Constant Field Values

PROPERTY_JOB_ID

@Deprecated
public static final String PROPERTY_JOB_ID
Deprecated. Use JobUtil.PROPERTY_JOB_NAME
The property for the unique event id. Value is of type String (This is optional).

See Also:
Constant Field Values

PROPERTY_JOB_PARALLEL

@Deprecated
public static final String PROPERTY_JOB_PARALLEL
Deprecated. Use JobUtil.PROPERTY_JOB_PARALLEL
The property to set if a job can be run parallel to any other job. The following values are supported: - boolean value true and false - string value true and false - integer value higher than 1 - if this is specified jobs are run in parallel but never more than the specified number. We might want to use different values in the future for enhanced parallel job handling. This value is only used, if JobUtil.PROPERTY_JOB_QUEUE_NAME is specified and the referenced queue is not started yet.

See Also:
Constant Field Values

PROPERTY_JOB_RUN_LOCAL

@Deprecated
public static final String PROPERTY_JOB_RUN_LOCAL
Deprecated. Use JobUtil.PROPERTY_JOB_RUN_LOCAL
The property to set if a job should only be run on the same app it has been created.

See Also:
Constant Field Values

PROPERTY_JOB_RETRY_COUNT

@Deprecated
public static final String PROPERTY_JOB_RETRY_COUNT
Deprecated. Use JobUtil.PROPERTY_JOB_RETRY_COUNT
The property to track the retry count for jobs. Value is of type Integer.

See Also:
Constant Field Values

PROPERTY_JOB_RETRIES

@Deprecated
public static final String PROPERTY_JOB_RETRIES
Deprecated. Use JobUtil.PROPERTY_JOB_RETRIES
The property for setting the maximum number of retries. Value is of type Integer.

See Also:
Constant Field Values

PROPERTY_JOB_RETRY_DELAY

@Deprecated
public static final String PROPERTY_JOB_RETRY_DELAY
Deprecated. Use JobUtil.PROPERTY_JOB_RETRY_DELAY
The property to set a retry delay. Value is of type Long and specifies milliseconds.

See Also:
Constant Field Values

PROPERTY_JOB_QUEUE_NAME

@Deprecated
public static final String PROPERTY_JOB_QUEUE_NAME
Deprecated. Use JobUtil.PROPERTY_JOB_QUEUE_NAME
The property to set to put the jobs into a separate job queue. This property specifies the name of the job queue. If the job queue does not exists yet a new queue is created. If a ordered job queue is used, the jobs are never executed in parallel from this queue! For non ordered queues the JobUtil.PROPERTY_JOB_PARALLEL with an integer value higher than 1 can be used to specify the maximum number of parallel jobs for this queue.

See Also:
Constant Field Values

PROPERTY_JOB_QUEUE_ORDERED

@Deprecated
public static final String PROPERTY_JOB_QUEUE_ORDERED
Deprecated. Use JobUtil.PROPERTY_JOB_QUEUE_ORDERED
If this property is set with any value, the queue processes the jobs in the same order as they have arrived. This property has only an effect if PROPERTY_JOB_QUEUE_NAME is specified and the job queue has not been started yet.

See Also:
Constant Field Values

PROPERTY_JOB_PRIORITY

@Deprecated
public static final String PROPERTY_JOB_PRIORITY
Deprecated. Use JobUtil.PROPERTY_JOB_PRIORITY
This property allows to override the priority for the thread used to start this job. The property is evaluated by the JobUtil.processJob(Event, org.apache.sling.event.jobs.JobProcessor) method. If another way of executing the job is used, it is up to the client to ensure the job priority. For possible values see EventUtil.JobPriority.

Since:
2.4
See Also:
Constant Field Values

TOPIC_JOB

@Deprecated
public static final String TOPIC_JOB
Deprecated. Use JobUtil.TOPIC_JOB
The topic for jobs.

See Also:
Constant Field Values

TOPIC_TIMED_EVENT

public static final String TOPIC_TIMED_EVENT
The topic for timed events.

See Also:
Constant Field Values

PROPERTY_TIMED_EVENT_TOPIC

public static final String PROPERTY_TIMED_EVENT_TOPIC
The real topic of the event.

See Also:
Constant Field Values

PROPERTY_TIMED_EVENT_ID

public static final String PROPERTY_TIMED_EVENT_ID
The property for the unique event id.

See Also:
Constant Field Values

PROPERTY_TIMED_EVENT_SCHEDULE

public static final String PROPERTY_TIMED_EVENT_SCHEDULE
The scheduler expression for the timed event.

See Also:
Constant Field Values

PROPERTY_TIMED_EVENT_PERIOD

public static final String PROPERTY_TIMED_EVENT_PERIOD
The period for the timed event.

See Also:
Constant Field Values

PROPERTY_TIMED_EVENT_DATE

public static final String PROPERTY_TIMED_EVENT_DATE
The date for the timed event.

See Also:
Constant Field Values

TOPIC_JOB_STARTED

@Deprecated
public static final String TOPIC_JOB_STARTED
Deprecated. Use JobUtil.TOPIC_JOB_STARTED
Asynchronous notification event when a job is started. The property PROPERTY_NOTIFICATION_JOB contains the job event and the property EventConstants.TIMESTAMP contains the timestamp of the event (as a Long).

Since:
2.2
See Also:
Constant Field Values

TOPIC_JOB_FINISHED

@Deprecated
public static final String TOPIC_JOB_FINISHED
Deprecated. Use JobUtil.TOPIC_JOB_FINISHED
Asynchronous notification event when a job is finished. The property PROPERTY_NOTIFICATION_JOB contains the job event and the property EventConstants.TIMESTAMP contains the timestamp of the event (as a Long).

Since:
2.2
See Also:
Constant Field Values

TOPIC_JOB_FAILED

@Deprecated
public static final String TOPIC_JOB_FAILED
Deprecated. Use JobUtil.TOPIC_JOB_FAILED
Asynchronous notification event when a job failed. If a job execution fails, it is rescheduled for another try. The property PROPERTY_NOTIFICATION_JOB contains the job event and the property EventConstants.TIMESTAMP contains the timestamp of the event (as a Long).

Since:
2.2
See Also:
Constant Field Values

TOPIC_JOB_CANCELLED

@Deprecated
public static final String TOPIC_JOB_CANCELLED
Deprecated. Use JobUtil.TOPIC_JOB_CANCELLED
Asynchronous notification event when a job is cancelled. If a job execution is cancelled it is not rescheduled. The property PROPERTY_NOTIFICATION_JOB contains the job event and the property EventConstants.TIMESTAMP contains the timestamp of the event (as a Long).

Since:
2.2
See Also:
Constant Field Values

PROPERTY_NOTIFICATION_JOB

@Deprecated
public static final String PROPERTY_NOTIFICATION_JOB
Deprecated. Use JobUtil.PROPERTY_NOTIFICATION_JOB
Property containing the job event.

Since:
2.2
See Also:
Constant Field Values
Constructor Detail

EventUtil

public EventUtil()
Method Detail

createDistributableEvent

public static org.osgi.service.event.Event createDistributableEvent(String topic,
                                                                    Dictionary<String,Object> properties)
Create a distributable event. A distributable event is distributed across the cluster.

Parameters:
topic -
properties -
Returns:
An OSGi event.

shouldDistribute

public static boolean shouldDistribute(org.osgi.service.event.Event event)
Should this event be distributed in the cluster?

Parameters:
event -
Returns:
true if the event should be distributed.

isLocal

public static boolean isLocal(org.osgi.service.event.Event event)
Is this a local event?

Parameters:
event -
Returns:
true if this is a local event

getApplicationId

public static String getApplicationId(org.osgi.service.event.Event event)
Return the application id the event was created at.

Parameters:
event -
Returns:
The application id or null if the event has been created locally.

toString

public static String toString(org.osgi.service.event.Event e)
Improved toString method for an Event. This method prints out the event topic and all of the properties.


isJobEvent

@Deprecated
public static boolean isJobEvent(org.osgi.service.event.Event event)
Deprecated. Use JobUtil.isJobEvent(Event)

Is this a job event? This method checks if the event contains the PROPERTY_JOB_TOPIC property.

Parameters:
event - The event to check.
Returns:
true> if this is a job event.

acknowledgeJob

@Deprecated
public static boolean acknowledgeJob(org.osgi.service.event.Event job)
Deprecated. Use JobUtil.acknowledgeJob(Event)

Send an acknowledge. This signals the job handler that someone is starting to process the job. This method should be invoked as a first command during job processing. If this method returns false this means someone else is already processing this job, and the caller should not process the event anymore.

Returns:
Returns true if the acknowledge could be sent
Throws:
IllegalArgumentException - If the event is a job event but does not have a notifier context.
Since:
2.3

finishedJob

@Deprecated
public static void finishedJob(org.osgi.service.event.Event job)
Deprecated. Use {link JobUtil.finishedJob(Event)

Notify a finished job.

Throws:
IllegalArgumentException - If the event is a job event but does not have a notifier context.

rescheduleJob

@Deprecated
public static boolean rescheduleJob(org.osgi.service.event.Event job)
Deprecated. Use JobUtil.rescheduleJob(Event)

Notify a failed job.

Returns:
true if the job has been rescheduled, false otherwise.
Throws:
IllegalArgumentException - If the event is a job event but does not have a notifier context.

processJob

@Deprecated
public static void processJob(org.osgi.service.event.Event job,
                                         JobProcessor processor)
Deprecated. Use JobUtil.processJob(Event, org.apache.sling.event.jobs.JobProcessor)

Process a job in the background and notify its success. This method also sends an acknowledge message to the job event handler.

Throws:
IllegalArgumentException - If the event is a job event but does not have a notifier context.


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