com.neeve.event
Class EventFactory

java.lang.Object
  extended by com.neeve.root.RootObject
      extended by com.neeve.event.EventFactory

public final class EventFactory
extends RootObject

Factory class used to instantiate event objects.

This class is a singleton class used to instantiate events. Events are classified by type. Type information is loaded at class load time from a deployment's default configuration repository and also can be registered by the user programattically.

Threading:
This event factory is not safe for concurrent access by multiple threads.

Nested Class Summary
static class EventFactory.EventType
          Stores event type information.
 
Method Summary
 Event createEvent(short id)
          Create a event using an event type id.
 Event createEvent(String name)
          Create a event using a event type name.
 EventFactory.EventType getEventType(short id)
          Get an event type by id.
 EventFactory.EventType getEventType(String name)
          Get an event type by name.
 String getEventTypeNameFromId(short id)
          Get the event type name by id.
static EventFactory getInstance()
          Return the singleton event factory instance.
 cern.colt.bitvector.BitVector getRegisteredEventTypes()
          Get a bitmask representing the registered set of event types
 void registerEventType(EventFactory.EventType evType)
          Register an event type with the factory.
 
Methods inherited from class com.neeve.root.RootObject
getChecked, getThreaded, getTracer, setChecked, setTracer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static EventFactory getInstance()
Return the singleton event factory instance.

Returns:
Returns the event factory
Threading:
This method is safe for concurrent access by multiple threads

registerEventType

public final void registerEventType(EventFactory.EventType evType)
Register an event type with the factory.

Throws:
IllegalArgumentException - Thrown in case the supplied event type is null.
Threading:
This method is not safe for concurrent acces by multiple threads with itself or any other method in this class.

This method is supplied for programmatic registration of event types with the event factory. This method should be used with caution since the underlying event type table is not managed in a thread safe manner and invoking this method while eventing is in progress can corrupt the table. The recommended practice is to register all event types in the local configuration repository. The factory loads up all event types in the local repository in its class constructor thus ensuring thread safe management of the type table. If this method is used to register event types, the user must ensure it is done so before any eventing is started.

It is a fatal error to register a event type with a duplicate name or id. Doing so will result in an {link hava.lang.Error} being thrown.


getEventType

public final EventFactory.EventType getEventType(short id)
Get an event type by id.

Parameters:
id - The event type's id.
Threading:
This method is safe for concurrent access by multiple threads with itself and all other methods except for registerEventType(com.neeve.event.EventFactory.EventType, boolean).

getEventType

public final EventFactory.EventType getEventType(String name)
Get an event type by name.

Parameters:
name - The event type's name.
Threading:
This method is safe for concurrent access by multiple threads with itself and all other methods except for registerEventType(com.neeve.event.EventFactory.EventType, boolean).

getRegisteredEventTypes

public final cern.colt.bitvector.BitVector getRegisteredEventTypes()
Get a bitmask representing the registered set of event types


getEventTypeNameFromId

public final String getEventTypeNameFromId(short id)
Get the event type name by id.

Parameters:
id - The id for which to return the event type's name.
Threading:
This method is safe for concurrent access by multiple threads with itself and all other methods except for registerEventType(com.neeve.event.EventFactory.EventType, boolean).

createEvent

public final Event createEvent(short id)
                        throws EEventTypeInvalidException,
                               EEventClassLoadException,
                               EEventClassInstantiateException,
                               EEventException
Create a event using an event type id.

Parameters:
id - The event type id.
Returns:
Returns the created event
Throws:
EEventTypeInvalidException - Thrown if the specified id is not a valid event type id.
EEventClassLoadException - Thrown if a failure was encountered while loading the event class.
EEventClassInstantiateException - Thrown if a failure was encountered while instantiating the event object.
EEventException - Thrown if any other exception was encountered while creating the new event.
Threading:
This method is safe for concurrent access by multiple threads with itself and all other methods except for registerEventType(com.neeve.event.EventFactory.EventType, boolean).

createEvent

public final Event createEvent(String name)
                        throws EEventTypeInvalidException,
                               EEventClassLoadException,
                               EEventClassInstantiateException,
                               EEventException
Create a event using a event type name.

Parameters:
name - The event type name.
Returns:
Returns the created event
Throws:
EEventTypeInvalidException - Thrown if the specified name is not a valid event type name.
EEventClassLoadException - Thrown if a failure was encountered while loading the event class.
EEventClassInstantiateException - Thrown if a failure was encountered while instantiating the event object.
EEventException - Thrown if any other exception was encountered while creating the new event.
Threading:
This method is safe for concurrent access by multiple threads with itself and all other methods except for registerEventType(com.neeve.event.EventFactory.EventType, boolean).


Copyright © 2016 Neeve Research, LLC. All Rights Reserved.