com.ibm.commerce.event

Class EventService

  • java.lang.Object
    • com.ibm.commerce.event.EventService


  • public class EventService
    extends java.lang.Object
    This class handles creating and publishing CommonBaseEvents objects. This is the central service to be used by the audit context and other components to handle the events. This service will encapsulate how events are created and published so it can be easily customized.
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String CONFIG_VALUE_PRIORITY_HIGH
      The configuration value to specify the event is of high priority.
      static java.lang.String CONFIG_VALUE_PRIORITY_LOW
      The configuration value to specify the event is of low priority.
      static java.lang.String CONSTANT_DEFAULT_PUBLISHER_KEY
      This is the key that represents the default publisher.
      static java.lang.String COPYRIGHT
      IBM copyright notice field.
      static java.lang.String EVENT_CONTEXT_SERIALIZER_PROPERTY_FILE
      This is the name of the properties file that contains the mapping between the context name and the context serializer to create the appropriate CBE context data.
      static java.lang.String EVENT_FACTORY_PROPERTY_FILE
      This is the name of the properties file that contains the mapping between event identifiers and the EventFactory object to create the CommonBaseEvent objects.
      static java.lang.String EVENT_PUBLISHER_PROPERTY_FILE
      This is the name of the properties file that contains the mapping between the event's extension name and the EventPublisher that will raise the event.
      static short PRIORITY_HIGH
      This is the constant value that represents high priority.
      static short PRIORITY_LOW
      This is the constant value that represents low priority.
      static short PRIORITY_MEDIUM
      This is the constant value that represents medium priority.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void changePriority(java.lang.String eventName, java.lang.String eventKey, short priority)
      This method changes the priority of the event that matches the event key that uniquely identifies the event.
      org.eclipse.hyades.logging.events.cbe.CommonBaseEvent createEvent(java.lang.String eventIdentifier, java.lang.Object eventData)
      This method creates a CommonBaseEvent object for the specified event type and populates the object with the specified event data.
      org.eclipse.hyades.logging.events.cbe.CommonBaseEvent createEvent(java.lang.String eventIdentifier, java.lang.Object eventData, java.lang.String eventKey)
      This method creates a CommonBaseEvent object for the specified event type and populates the object with the specified event data.
      void disableAllEvents()
      This method disables all events.
      void disableEvent(java.lang.String eventName)
      This method disables the specified event.
      void enableEvent(java.lang.String eventName)
      This method enables the specified event.
      void enableEvent(java.lang.String eventName, com.ibm.commerce.event.EventContextFilter contextFilter)
      This method enables the specified event.
      void enableEvent(java.lang.String eventName, java.lang.String priority, com.ibm.commerce.event.EventContextFilter contextFilter)
      This method enables the specified event.
      boolean isEventEnabled(java.lang.String eventName)
      This method returns whether the specified event name is enabled.
      void publishEvent(org.eclipse.hyades.logging.events.cbe.CommonBaseEvent commonBaseEvent)
      This method publishes the specified CommonBaseEvent object.
      void raiseEvent(ActivityToken activityToken, java.lang.String eventName, java.lang.Object eventData)
      This method raises the specified event with the given event data to associate with the event.
      void raiseEvent(ActivityToken activityToken, java.lang.String eventName, java.lang.Object eventData, java.lang.String eventKey)
      This method raises the specified event with the given event data to associate with the event.
      void raiseEvent(java.lang.String eventName, java.lang.Object eventData)
      This method raises the specified event with the given event data to associate with the event.
      void raiseEvent(java.lang.String eventName, java.lang.Object eventData, java.lang.String eventKey)
      This method raises the specified event with the given event data to associate with the event.
      void reload()
      This method reloads the configuration of the event service to pick up the new and changed event factories and publishers that will create and publish events.
      static EventService singleton()
      This method gets the singleton object of the event service for the running instance.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        IBM copyright notice field.
        See Also:
        Constant Field Values
      • EVENT_FACTORY_PROPERTY_FILE

        public static final java.lang.String EVENT_FACTORY_PROPERTY_FILE
        This is the name of the properties file that contains the mapping between event identifiers and the EventFactory object to create the CommonBaseEvent objects.
      • EVENT_PUBLISHER_PROPERTY_FILE

        public static final java.lang.String EVENT_PUBLISHER_PROPERTY_FILE
        This is the name of the properties file that contains the mapping between the event's extension name and the EventPublisher that will raise the event.
      • EVENT_CONTEXT_SERIALIZER_PROPERTY_FILE

        public static final java.lang.String EVENT_CONTEXT_SERIALIZER_PROPERTY_FILE
        This is the name of the properties file that contains the mapping between the context name and the context serializer to create the appropriate CBE context data.
      • CONSTANT_DEFAULT_PUBLISHER_KEY

        public static final java.lang.String CONSTANT_DEFAULT_PUBLISHER_KEY
        This is the key that represents the default publisher.
        See Also:
        Constant Field Values
      • PRIORITY_HIGH

        public static final short PRIORITY_HIGH
        This is the constant value that represents high priority. An event with high priority should be processed immediately.
        See Also:
        Constant Field Values
      • PRIORITY_MEDIUM

        public static final short PRIORITY_MEDIUM
        This is the constant value that represents medium priority. An event with medium priority should be processed quickly but not necessary immediately.
        See Also:
        Constant Field Values
      • PRIORITY_LOW

        public static final short PRIORITY_LOW
        This is the constant value that represents low priority. An event with low priority does not require immediate processing and can be processed some time in the future.
        See Also:
        Constant Field Values
      • CONFIG_VALUE_PRIORITY_HIGH

        public static final java.lang.String CONFIG_VALUE_PRIORITY_HIGH
        The configuration value to specify the event is of high priority. A priority of high means that when the event is raised, the current business logic will be suspended and the event will be processed immediately. The business logic will resume depending on whether the event was successfully processed. High priority events can be considered as synchronous events.
        See Also:
        Constant Field Values
      • CONFIG_VALUE_PRIORITY_LOW

        public static final java.lang.String CONFIG_VALUE_PRIORITY_LOW
        The configuration value to specify the event is of low priority. A priority of low means that when the event is raised, it will be process sometime after the business logic completes but there is no guarantee exactly when that will be. Events of low priority will be processed in the same batch as other low priority events. Low priority events can be considered as asynchronous events.
        See Also:
        Constant Field Values
    • Method Detail

      • singleton

        public static EventService singleton()
        This method gets the singleton object of the event service for the running instance.
        Returns:
        This method returns the unique EventService of the instance.
      • reload

        public void reload()
        This method reloads the configuration of the event service to pick up the new and changed event factories and publishers that will create and publish events.
      • isEventEnabled

        public boolean isEventEnabled(java.lang.String eventName)
        This method returns whether the specified event name is enabled.
        Parameters:
        eventName - The event name.
        Returns:
        Whether the specified event name is an enabled event.
      • enableEvent

        public void enableEvent(java.lang.String eventName)
        This method enables the specified event.
        Parameters:
        eventName - This is the name of the event.
      • enableEvent

        public void enableEvent(java.lang.String eventName,
                                com.ibm.commerce.event.EventContextFilter contextFilter)
        This method enables the specified event.
        Parameters:
        eventName - This is the name of the event.
        contextFilter - The context filter to associated with the event.
      • enableEvent

        public void enableEvent(java.lang.String eventName,
                                java.lang.String priority,
                                com.ibm.commerce.event.EventContextFilter contextFilter)
        This method enables the specified event.
        Parameters:
        eventName - This is the name of the event.
        priority - The default priority of the event.
        contextFilter - The context filter to associated with the event.
      • disableEvent

        public void disableEvent(java.lang.String eventName)
        This method disables the specified event.
        Parameters:
        eventName - This is the name of the event.
      • disableAllEvents

        public void disableAllEvents()
        This method disables all events.
      • createEvent

        public org.eclipse.hyades.logging.events.cbe.CommonBaseEvent createEvent(java.lang.String eventIdentifier,
                                                                                 java.lang.Object eventData)
        This method creates a CommonBaseEvent object for the specified event type and populates the object with the specified event data. This operation will determine whether an EventFactory object exists for the given event identifier. If so, it will call it to create the CommonBaseEvent object. If no event factory is found then null will be returned which represents that the event should not be raised.
        Parameters:
        eventIdentifier - This is the identifier of the event.
        eventData - This is the data to associate with the event.
        Returns:
        This method returns a CommonBaseEvent object representing the specified event information.
      • createEvent

        public org.eclipse.hyades.logging.events.cbe.CommonBaseEvent createEvent(java.lang.String eventIdentifier,
                                                                                 java.lang.Object eventData,
                                                                                 java.lang.String eventKey)
        This method creates a CommonBaseEvent object for the specified event type and populates the object with the specified event data. This operation will determine whether an EventFactory object exists for the given event identifier. If so, it will call it to create the CommonBaseEvent object. If no event factory is found then null will be returned which represents that the event should not be raised.
        Parameters:
        eventIdentifier - This is the identifier of the event.
        eventData - This is the data to associate with the event.
        eventKey - This is an identifier of a maximum of 50 characters which can uniquely identify the
        Returns:
        This method returns a CommonBaseEvent object representing the specified event information.
      • publishEvent

        public void publishEvent(org.eclipse.hyades.logging.events.cbe.CommonBaseEvent commonBaseEvent)
                          throws org.eclipse.hyades.logging.events.cbe.CompletionException
        This method publishes the specified CommonBaseEvent object. If null is specified as the event to publish then nothing will be published. If an object is specified, the EventPublisher associated with the extension name of the CommonBaseEvent object will be use to publish the event. If no EventPublisher can be found for the extension name then the default event publisher will be used.
        Parameters:
        commonBaseEvent - This is the CommonBaseEvent object to be published.
        Throws:
        org.eclipse.hyades.logging.events.cbe.CompletionException - This is thrown if there is a problem running the complete operation on the specified common base event.
      • changePriority

        public void changePriority(java.lang.String eventName,
                                   java.lang.String eventKey,
                                   short priority)
                            throws java.lang.Exception
        This method changes the priority of the event that matches the event key that uniquely identifies the event. The appropriate event publisher will be resolved and used to change the priority of the event. This could result in immediate processing of the event depending on the specified priority.
        Parameters:
        eventName - This is the name of the event to raise.
        eventKey - This is an identifier of a maximum of 50 characters which can uniquely identify the event.
        priority - This is the new priority of the event. The priority value should either be EventService.PRIORITY_HIGH, EventService.PRIORITY_MEDIUM or EventService.PRIORITY_LOW.
        Throws:
        java.lang.Exception - This is thrown when any exception occurs while changing the event priority. For those cases where the event immediately executes, the listener may throw and exception and it will be exposed when this change occurs.
      • raiseEvent

        public void raiseEvent(java.lang.String eventName,
                               java.lang.Object eventData)
        This method raises the specified event with the given event data to associate with the event. The specific type of event raised will correspond to the event type specified. The data associated with the event will be extracted from the event data specified.
        Parameters:
        eventName - This is the name of the event to raise.
        eventData - This is the external data to associate with the event.
      • raiseEvent

        public void raiseEvent(java.lang.String eventName,
                               java.lang.Object eventData,
                               java.lang.String eventKey)
        This method raises the specified event with the given event data to associate with the event. The specific type of event raised will correspond to the event type specified. The data associated with the event will be extracted from the event data specified.
        Parameters:
        eventName - This is the name of the event to raise.
        eventData - This is the external data to associate with the event.
        eventKey - This is an identifier of a maximum of 50 characters which can uniquely identify the event.
      • raiseEvent

        public void raiseEvent(ActivityToken activityToken,
                               java.lang.String eventName,
                               java.lang.Object eventData)
        This method raises the specified event with the given event data to associate with the event. The specific type of event raised will correspond to the event type specified. The data associated with the event will be extracted from the event data specified.
        Parameters:
        activityToken - This is the activity to associate with the event.
        eventName - This is the name of the event to raise.
        eventData - This is the external data to associate with the event.
      • raiseEvent

        public void raiseEvent(ActivityToken activityToken,
                               java.lang.String eventName,
                               java.lang.Object eventData,
                               java.lang.String eventKey)
        This method raises the specified event with the given event data to associate with the event. The specific type of event raised will correspond to the event type specified. The data associated with the event will be extracted from the event data specified.
        Parameters:
        activityToken - This is the activity to associate with the event.
        eventName - This is the name of the event to raise.
        eventData - This is the external data to associate with the event.
        eventKey - This is an identifier of a maximum of 50 characters which can uniquely identify the event.