com.ibm.websphere.cem
Class ECSEmitter

java.lang.Object
  extended bycom.ibm.websphere.cem.ECSEmitter
All Implemented Interfaces:
com.ibm.events.emitter.Emitter

public class ECSEmitter
extends java.lang.Object
implements com.ibm.events.emitter.Emitter


Constructor Summary
ECSEmitter(java.lang.String jndiName, java.lang.String _ecsID)
          ECSEmitter constructor.
 
Method Summary
 void addUserDataEvent(java.util.Properties properties)
          Creates and sends a user data event.
 void close()
          Instructs the emitter to release all resources that are owned by this object and dependents.
 org.eclipse.hyades.logging.events.cbe.CommonBaseEvent createCommonBaseEvent(java.lang.String eventName)
          Creates an common base event via eventFactory
protected  javax.naming.Context getContext()
          Gets a context for use with JNDI lookups.
 java.lang.String getCurrentEcsID()
          Gets the current ECS ID locally stored on the ECSEmitter instance.
protected  org.eclipse.hyades.logging.events.cbe.EventFactory getEventFactory()
          Gets an eventFactory via jndi lookup
 com.ibm.events.ComponentMetaData getFilterMetaData()
          Used to obtain the filter meta data.
 com.ibm.events.ComponentMetaData getMetaData()
          Used to obtain the emitter component meta data.
 java.lang.String getParentEcsID()
          Gets the parent ECS ID locally stored on the ECSEmitter instance.
 int getSynchronizationMode()
          Allows the caller to determine the current setting for synchronization in this emitter.
 int getTransactionMode()
          Allows the caller to determine the currently active transaction mode.
protected  com.ibm.websphere.cem.WorkAreaHelper getWah()
          Gets an instance of the WorkAreaHelper.
 boolean isSynchronizationModeSupported(int arg0)
          Allows the caller to determine if a synchronization mode is supported by this emitter.
 boolean isWorkAreaEmpty()
          Checks if the current WorkArea is empty or not.
 void releaseAndEndECS(java.lang.String ecsID)
          Releases the current ECSEmitter.
 java.lang.String sendEvent(org.eclipse.hyades.logging.events.cbe.CommonBaseEvent arg0)
          Sends an event to the Event Bus.
 java.lang.String sendEvent(org.eclipse.hyades.logging.events.cbe.CommonBaseEvent arg0, int arg1, int arg2)
          Sends an event to the Event Bus overriding the default emitter behavior with the passed parameters.
 void setCurrentEcsID(java.lang.String newCurEcsID)
          Sets the current ECS ID to be locally stored on the ECSEmitter instance.
 void setParentEcsID(java.lang.String newParEcsID)
          Sets the parent ECS ID to be locally stored on the ECSEmitter instance.
 void setSynchronizationMode(int arg0)
          Sets the default synchronization mode to use when sending events to the Event Bus.
 void setTransactionMode(int arg0)
          Sets the transaction mode to use when sending events to the Event Bus.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ECSEmitter

public ECSEmitter(java.lang.String jndiName,
                  java.lang.String _ecsID)
ECSEmitter constructor. This needs to be called to send common base events to CEI. In case the ECSEmitter is called with a new EcsID a new Event Correlation Spheres is opened and the new EcsID is written to the WorkArea to make it persistent.

Parameters:
jndiName - The jndi Name of the emitter factory
_ecsID - The new EcsID in case a new correlation sphere needs to be opened, otherwise null
Method Detail

sendEvent

public java.lang.String sendEvent(org.eclipse.hyades.logging.events.cbe.CommonBaseEvent arg0)
                           throws com.ibm.events.EventsException
Sends an event to the Event Bus. The event will only be sent to the bus if:

Specified by:
sendEvent in interface com.ibm.events.emitter.Emitter
Parameters:
arg0 - the event to be sent to the Event Bus. This may not be null.
Returns:
the global instance ID of the event that was built.
Throws:
com.ibm.events.EventsException - if an error ocurrs during event processing.
See Also:
Emitter.sendEvent(org.eclipse.hyades.logging.events.cbe.CommonBaseEvent)

sendEvent

public java.lang.String sendEvent(org.eclipse.hyades.logging.events.cbe.CommonBaseEvent arg0,
                                  int arg1,
                                  int arg2)
                           throws com.ibm.events.EventsException
Sends an event to the Event Bus overriding the default emitter behavior with the passed parameters. The event will only be sent to the bus if:

Specified by:
sendEvent in interface com.ibm.events.emitter.Emitter
Parameters:
arg0 - the event to be sent to the Event Bus. This may not be null.
arg1 - indicates whether the event will be sent synchronously (SynchronizationMode.SYNCHRONOUS) or asynchronously (SynchronizationMode.ASYNCHRONOUS) If synchronous, this call will not return until the event has been processed by the event server. If asynchronous, this call will return as soon as the event emitter has passed the event to the server. To avoid overriding the synchronization mode, pass a value of SynchronizationMode.DEFAULT.
arg2 - indicates whether the event emitter should process the event in the current transaction (TransactionMode.SAME) or not (TransactionMode.NEW). To avoid overriding the transaction mode, pass a value of TransactionMode.DEFAULT.
Returns:
the global instance ID of the event that was built.
Throws:
com.ibm.events.EventsException - if an error ocurrs during event processing.
See Also:
Emitter.sendEvent(org.eclipse.hyades.logging.events.cbe.CommonBaseEvent, int, int)

setTransactionMode

public void setTransactionMode(int arg0)
                        throws com.ibm.events.emitter.TransactionModeNotSupportedException
Sets the transaction mode to use when sending events to the Event Bus.

Specified by:
setTransactionMode in interface com.ibm.events.emitter.Emitter
Parameters:
arg0 - The transaction mode to use. Valid values are:
  • TransactionMode.SAME to use the same transaction as the client.
  • TransactionMode.NEW for a new transaction.
  • TransactionMode.DEFAULT to use the default setting in the emitter.
Throws:
com.ibm.events.emitter.TransactionModeNotSupportedException - if an error occurred in switching the transaction mode.
See Also:
Emitter.setTransactionMode(int)

getTransactionMode

public int getTransactionMode()
Allows the caller to determine the currently active transaction mode.

Specified by:
getTransactionMode in interface com.ibm.events.emitter.Emitter
Returns:
either TransactionMode.SAME or TransactionMode.NEW.
See Also:
Emitter.getTransactionMode()

getSynchronizationMode

public int getSynchronizationMode()
Allows the caller to determine the current setting for synchronization in this emitter.

Specified by:
getSynchronizationMode in interface com.ibm.events.emitter.Emitter
Returns:
a synchronization mode represented by an int value.
See Also:
Emitter.getSynchronizationMode()

setSynchronizationMode

public void setSynchronizationMode(int arg0)
                            throws com.ibm.events.emitter.EmitterException
Sets the default synchronization mode to use when sending events to the Event Bus.

Specified by:
setSynchronizationMode in interface com.ibm.events.emitter.Emitter
Parameters:
arg0 - The synchronization mode to use when sending events to the Event Bus. Valid values are:
  • SynchronizationMode.SYNCHRONOUS to send events to the bus synchronously.
  • SynchronizationMode.ASYNCHRONOUS to send events to the bus asynchronously.
  • SynchronizationMode.DEFAULT to use the default setting in the emitter.
Throws:
com.ibm.events.emitter.EmitterException - if an error occurred in switching the synchronization mode.
See Also:
Emitter.setSynchronizationMode(int)

getMetaData

public com.ibm.events.ComponentMetaData getMetaData()
Used to obtain the emitter component meta data.

Specified by:
getMetaData in interface com.ibm.events.emitter.Emitter
Returns:
the component meta data for the emitter.
See Also:
Emitter.getMetaData()

getFilterMetaData

public com.ibm.events.ComponentMetaData getFilterMetaData()
                                                   throws com.ibm.events.filter.FilterException
Used to obtain the filter meta data. Returns null if no filter is configured for this emitter. If a filter is defined then this method returns the result of a Filter.getMetaData() call.

Specified by:
getFilterMetaData in interface com.ibm.events.emitter.Emitter
Returns:
component meta data for the filter, or null if not available.
Throws:
com.ibm.events.filter.FilterException - if an error occurred in the filter while obtaining meta data.
See Also:
Emitter.getFilterMetaData()

close

public void close()
           throws com.ibm.events.EventsException
Instructs the emitter to release all resources that are owned by this object and dependents.

Specified by:
close in interface com.ibm.events.emitter.Emitter
Throws:
com.ibm.events.EventsException - if any other error occurs releasing resources.
See Also:
Emitter.close()

isSynchronizationModeSupported

public boolean isSynchronizationModeSupported(int arg0)
Allows the caller to determine if a synchronization mode is supported by this emitter.

Specified by:
isSynchronizationModeSupported in interface com.ibm.events.emitter.Emitter
Parameters:
arg0 - the SynchronizationMode to be tested for support.
Returns:
true if the passed synchronization mode is supoprted, false otherwise.
See Also:
Emitter.isSynchronizationModeSupported(int)

getContext

protected javax.naming.Context getContext()
Gets a context for use with JNDI lookups. Separated into method to aid unit-testing

Returns:
Context for use with JNDI lookups

getCurrentEcsID

public java.lang.String getCurrentEcsID()
Gets the current ECS ID locally stored on the ECSEmitter instance.

Returns:
The current value of the ECS ID.

setCurrentEcsID

public void setCurrentEcsID(java.lang.String newCurEcsID)
Sets the current ECS ID to be locally stored on the ECSEmitter instance.

Parameters:
newCurEcsID - The new ECS ID to be set as the current ECS ID.

getParentEcsID

public java.lang.String getParentEcsID()
Gets the parent ECS ID locally stored on the ECSEmitter instance.

Returns:
The parent value of the current ECS ID.

isWorkAreaEmpty

public boolean isWorkAreaEmpty()
Checks if the current WorkArea is empty or not.

Returns:
True if the WorkArea is empty, false otherwise.

setParentEcsID

public void setParentEcsID(java.lang.String newParEcsID)
Sets the parent ECS ID to be locally stored on the ECSEmitter instance.

Parameters:
newParEcsID - The new ECS ID to be set as the parent ECS ID.

releaseAndEndECS

public void releaseAndEndECS(java.lang.String ecsID)
Releases the current ECSEmitter. It ends the event correlation sphere represented by the ecsID and deletes this ecsID from the stack on the workarea.


addUserDataEvent

public void addUserDataEvent(java.util.Properties properties)
Creates and sends a user data event. A common base event is created by calling the CEI event factory with event name "WebSphereProcessChoreographerUserDataEventBPEL". The properties are added to the event as extended data elements, the situation is set (ReportSituation) and the event is sent to CEI.

Parameters:
properties - The properties to be added to the event as extended data elements.

getWah

protected com.ibm.websphere.cem.WorkAreaHelper getWah()
Gets an instance of the WorkAreaHelper.

Returns:
An instance of the WorkAreaHelper.

getEventFactory

protected org.eclipse.hyades.logging.events.cbe.EventFactory getEventFactory()
Gets an eventFactory via jndi lookup

Returns:
an EventFactory
See Also:
org.ecplise.hyades.logging.events.cbe.EventFactory

createCommonBaseEvent

public org.eclipse.hyades.logging.events.cbe.CommonBaseEvent createCommonBaseEvent(java.lang.String eventName)
Creates an common base event via eventFactory

Parameters:
eventName - an event name to be set
Returns:
a CommonBaseEvent
See Also:
EventFactory