Package com.ibm.events.emitter
This package contains the classes and interfaces required for using an event emitter.
See:
Description
Interface Summary |
Emitter |
This is the interface for the event emitter. |
EmitterFactory |
This interface is used by event sources to create
emitter instances. |
SynchronizationMode |
Constants used to specify whether to send an event to the event bus
synchronously or asynchronously. |
TransactionMode |
Constants used to specify whether to send an event to the event bus
in the same transaction as the caller or in a new transaction. |
Package com.ibm.events.emitter Description
This package contains the classes and interfaces required for using an event emitter.
Code sample for submitting an event using default emitter settings in a J2EE environment
try {
javax.naming.Context ctx = new javax.naming.InitialContext();
EmitterFactory emitterFactory = (EmitterFactory) ctx.lookup("com/ibm/events/configuration/emitter/Default");
Emitter emitter = emitterFactory.getEmitter();
EventFactory eventFactory = (EventFactory) ctx.lookup("com/ibm/events/EventFactory");
org.eclipse.hyades.logging.events.cbe.CommonBaseEvent event = eventFactory.createCommonBaseEvent();
// Configure various fields in the event.
emitter.sendEvent(event);
} catch (org.eclipse.hyades.logging.events.cbe.ValidationException validationException) {
// The Emitter.sendEvent method found that the event was invalid.
} catch (com.ibm.events.EventsException eventsException) {
// EmitterFactory.getEmitter or Emitter.sendEvent failed.
} catch (javax.naming.NamingException namingException) {
// A JNDI method threw an exception.
}
Code sample for submitting an event using overridden emitter settings from a J2SE environment
try {
java.util.Hashtable jndiConfig = new java.util.Hashtable();
jndiConfig.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
jndiConfig.put(Context.PROVIDER_URL, "corbaloc:iiop:localhost:2809");
javax.naming.Context ctx = new javax.naming.InitialContext(jndiConfig);
EmitterFactory emitterFactory = (EmitterFactory) ctx.lookup("com/ibm/events/configuration/emitter/Default");
Emitter emitter = emitterFactory.getEmitter();
EventFactory eventFactory = (EventFactory) ctx.lookup("com/ibm/events/configuration/event-groups/Default");
org.eclipse.hyades.logging.events.cbe.CommonBaseEvent event = eventFactory.createEvent();
// Configure various fields in the event.
emitter.sendEvent(event, SychronizationMode.ASYNCHRONOUS, TransactionMode.NEW);
} catch (org.eclipse.hyades.logging.events.cbe.ValidationException validationException) {
// The Emitter.sendEvent method found that the event was invalid.
} catch (com.ibm.events.EventsException eventsException) {
// EmitterFactory.getEmitter or Emitter.sendEvent method failed.
} catch (javax.naming.NamingException namingException) {
// A JNDI method threw an exception.
}