public class EventDatagramFactory
extends com.streamscape.sdo.IAbstractDatagramFactory
Title: Structured Data Objects
Description: A datagram factory for EventDatagram
objects.
This factory provides facilities for creating event datagram objects based on specific system models.
All factory classes are descendants of the DatagramFactory
object and allow users to register,
load and instantiate events from prototypes.
The following evengram types are supported:
AcknowledgementEvent
- An event used for acknowledging process state changes.AuditEvent
- An event used for auditing and Audit Queue interactions.BytesEvent
- An event used for optimized binary data streaming such as file content.DataEvent
- A generic event whose payload is an arbitrary, user-define data object (SDO).DeltaEvent
- An event that presents a before and after image of some data and allows comparison.ExceptionEvent
- A generic event representing an exception, not a Throwable
object.FileEvent
- An event used to convey file state change.MailEvent
- An event representing an SMTP mail object with support for attachments and mime types.MapEvent
- An event representing a HashMap
of objects.ObjectEvent
- A Data Event whose payload can be any object.RowArrayEvent
- An event that contains an array of Row
objects as RowArray
.RowChangeEvent
- An event that conveys the change of a row in a tabular data collection.RowEvent
- An event that contains a Row
object.RowSetEvent
- An event that contains a RowSet
object.StreamStateEvent
- An event that conveys a stream state changeTextEvent
- An event with a text payload.XMLEvent
- An event that contains a validated, DOM
capable XML document.XMPPEvent
- An event that transmits XMPP (Jabber) events.
A factory allows users to create events as new entities (unregistered) or as instances based on user-defined
prototypes. However, prototypes should always be defined and created using the DatagramPrototypeFactory
. This
factory interface is returned to the user from the application fabric context in both ClientContext
and RuntimeContext
environments.
The event fabric provides several event datagram factories:
Copyright: Copyright (c) 2010
Company: StreamScape Technologies
DEFAULT_SERIAL_VERSION_ID
Modifier and Type | Method and Description |
---|---|
AcknowledgementEvent |
createAcknowledgement(EventDatagram event)
Executes the method
createAcknowledgement(EventDatagram, boolean) with false second parameter. |
AcknowledgementEvent |
createAcknowledgement(EventDatagram event,
boolean withSourceData)
Creates and returns an instance of an acknowledgement event datagram based on the
supplied Source Event Datagram.
|
AcknowledgementEvent |
createAcknowledgement(ExceptionEventDatagram event)
Creates and returns an instance of an acknowledgment event datagram based on the
supplied Exception Event Datagram.
|
AcknowledgementEvent |
createAcknowledgement(java.lang.String eventId)
Creates and returns an instance of an acknowledgement event datagram using the specified Event Id.
|
EventDatagram |
createEvent(Prototype prototype)
Create and returns an event datagram object of a specific type based on the
Prototype . |
EventDatagram |
createEvent(java.lang.String eventId)
Creates an event datagram object using the specified Event Id.
|
static EventDatagramFactory |
getInstance() |
void |
initSerializer(SerializerFactory factory,
java.lang.String serializerName)
Allows for initialization of a user-defined serializer (and factory) with this datagram's
semantic types and aliases.
|
EventDatagram |
newEventInstance(SemanticType type)
Creates and returns an instance of an event datagram of this factory's type
based on the semantic type.
|
EventDatagram |
newEventInstance(java.lang.String semanticType)
Creates an event instance based on the specified semantic type.
|
EventDatagram |
newEventInstanceFrom(ImmutableEventDatagram event)
Creates an event instance using the specified event.
|
EventDatagram |
newEventInstanceFrom(java.lang.String eventId)
Creates an event instance using the specified Event Id.
|
existsPrototype, getAncestorType, getCipherSuite, getName, getPrototypeNamespace, getSemanticType, getSerialVersionUID, getSupportedTypes, listEventIds, listPrototypeModels, setCipherSuiteName, supportsModel
getContext, getContextType, hasContext
clone
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clone
public void initSerializer(SerializerFactory factory, java.lang.String serializerName) throws com.streamscape.omf.SerializerSupportException
factory
- SerializerFactoryserializerName
- Stringcom.streamscape.omf.SerializerSupportException
public static EventDatagramFactory getInstance()
public AcknowledgementEvent createAcknowledgement(EventDatagram event) throws DatagramFactoryException
createAcknowledgement(EventDatagram, boolean)
with false
second parameter.
(i.e. createAcknowledgement(event, false);
)event
- the event to be acknowledged.DatagramFactoryException
- if some error occurs.public AcknowledgementEvent createAcknowledgement(EventDatagram event, boolean withSourceData) throws DatagramFactoryException
Event Identity
Management
elements from the header are copied into the acknowledgement to
allow correlation between an event and it's acknowledgement.event
- the event to be acknowledged.withSourceData
- the flag indicating if the event data will be set to the acknowledgement event.DatagramFactoryException
- if some error occurs.public AcknowledgementEvent createAcknowledgement(java.lang.String eventId) throws DatagramFactoryException
eventId
- the unique identifier of the event.DatagramFactoryException
- if some error occurs.public AcknowledgementEvent createAcknowledgement(ExceptionEventDatagram event) throws DatagramFactoryException
Event Identity
Management
elements from the header are copied into the acknowledgment to
allow correlation between an event and it's acknowledgment.event
- the exception to be acknowledged.DatagramFactoryException
- if some error occurs.public EventDatagram createEvent(Prototype prototype) throws DatagramFactoryException
DatagramFactory
Prototype
.
Exact behavior of this method is implementation specific. This method throws an exception
if the prototype does not exist in the prototype cache.
Prototypes allow users to create pre-populated datagrams that may hold default values. This
is particularly useful in situations where a data event may have a specific, user
defined payload as it's data element. Such data elements may be pre-populated and
annotations on such elements may be pre-defined in the prototype. The resulting prototype,
while considered an instance of a data event would act as a discrete type and have
a discrete Event Id
.
In general it is expected that creating an event from a prototype results in partial
or full cloning of the prototype object. It should be noted that general cloning of simple
prototypes (shell objects) may be comparable in performance to normal instantiation.
The framework will attempt a general optimization which may not be sufficient for complex
types. For this reason, given the possible performance impact of cloning, developers may
optimize this method by implementing partial cloning or other optimizations.
See the DatagramFactory.newEventInstance(com.streamscape.repository.types.SemanticType)
documentation for a comparison of these methods.
createEvent
in interface DatagramFactory
createEvent
in class com.streamscape.sdo.IAbstractDatagramFactory
prototype
- the Prototype
object associated with the event.DatagramFactoryException
- if some error occurs.public EventDatagram createEvent(java.lang.String eventId) throws DatagramFactoryException
DatagramFactory
DatagramFactory.createEvent(com.streamscape.repository.types.Prototype)
for further information.createEvent
in interface DatagramFactory
createEvent
in class com.streamscape.sdo.IAbstractDatagramFactory
eventId
- the unique identifier of the event.DatagramFactoryException
- if some error occurs.public EventDatagram newEventInstance(SemanticType type) throws DatagramFactoryException
DatagramFactory
null
Event Id, intending for users to
assign the identifier by registering the datagram as a prototype.
EventDatagram
types are the following:
AcknowledgementEvent
AuditEvent
BytesEvent
DataEvent
DeltaEvent
ExceptionEvent
FileEvent
MailEvent
MapEvent
RowArrayEvent
RowChangeEvent
RowEvent
RowSetEvent
StreamEvent
StreamStateEvent
TextEvent
XMLEvent
MapEvent
OpaqueDatagram
types are the following:
OpaqueEvent
AdvisoryEventDatagram
types are the following:
AdvisoryEvent
IAbstractDataEvent
which is the core datagram implementation. This allows for creation of other model (level 1)
event types. Each model type is registered as a unique Semantic Type and the
method will directly instantiate such a type, which is typically faster than using the
DatagramFactory.createEvent(com.streamscape.repository.types.Prototype)
method. That method uses prototype cloning to create a new datagram
instance, however it generates pre-populated instances.
Optimization: In general it is expected that directly creating an instance and populating
it's values will be faster then creating an instance from a prototype. However, in case of
the DataEvent
some optimization is possible. Data events mandate that all encapsulated
objects (data elements) are known Semantic Types. The data event therefore uses
optimized object creation. Datagram header properties, annotations and user-defined fields
are copied from the prototype, however the payload (data elements) may be instantiated directly
resulting in faster object creation. This technique may be used by developers designing their
own datagram factories in order to employ a mixed mode instantiation. By creating a discrete
payload with specific defaults registered as a Semantic Type event object
instantiation may be optimized.
As with any advanced performance tuning careful profiling should be performed so that a developer not engage in so called 'premature optimization'. Prototype cloning is an extremely fast way to instantiate objects and in most cases, direct instance creation may not be necessary.
newEventInstance
in interface DatagramFactory
newEventInstance
in class com.streamscape.sdo.IAbstractDatagramFactory
type
- the semantic type that the created event is based on.DatagramFactoryException
- if some error occurs.public EventDatagram newEventInstance(java.lang.String semanticType) throws DatagramFactoryException
DatagramFactory
DatagramFactory.newEventInstance(com.streamscape.repository.types.SemanticType)
for further information.newEventInstance
in interface DatagramFactory
newEventInstance
in class com.streamscape.sdo.IAbstractDatagramFactory
semanticType
- the semantic type that the created event is based on.DatagramFactoryException
- if some error occurs.public EventDatagram newEventInstanceFrom(java.lang.String eventId) throws DatagramFactoryException
DatagramFactory
DatagramFactory.createEvent(String)
method,
but the created event will have a null
event id.
Then this event instance can be used for a creation of new event prototypes, but cannot be raised.newEventInstanceFrom
in interface DatagramFactory
newEventInstanceFrom
in class com.streamscape.sdo.IAbstractDatagramFactory
DatagramFactoryException
- if some error occurs.public EventDatagram newEventInstanceFrom(ImmutableEventDatagram event) throws DatagramFactoryException
DatagramFactory
null
event id.
Then this event instance can be used for a creation of new event prototypes, but cannot be raised.newEventInstanceFrom
in interface DatagramFactory
newEventInstanceFrom
in class com.streamscape.sdo.IAbstractDatagramFactory
DatagramFactoryException
- if some error occurs.Copyright © 2015-2024 StreamScape Technologies. All rights reserved.