public class EventHandler
extends com.streamscape.sef.dispatcher.AbstractEventHandler
Title: Open Service Framework
Description: This class defines an Event Handler
method that will be called when an
appropriate event is processed by the Event Dispatcher
.
An Event Handler
object defines the method that will be triggered as a result of an event raised
by the dispatcher. The method is invoked it's delegate
as part of the Dynamic
Invocation Interface (DII) framework of the Service Event Fabric
. Event handlers are configured
in a given AbstractServiceConfigurationObject
implementation and reside in
the Event Handler Registry
after the configuration is loaded.
Event Handler
methods must have a specific signature and conform to the rules of the DII framework
in the Service Event Fabric
. Event handlers should follow the following guide lines:
StructuredDataObject
interface.java.lang.Object
.ImmutableEventDatagram
allowing direct access to the event.Null
binding in the definition.StructuredDataObject
interface.java.lang.Object
(generics).ImmutableEventDatagram
allowing services to return custom events.Void
binding in the definition.Event Handler
must have an associate request and response eventId
.
When processing exceptions generated by an Event Handler
method the user has the option of overriding the
default error handling mechanism of the Fabric Event Dispatcher
by specifying their own Exception Handler
class. This class may act as an interceptor mechanism allowing developers to perform the following exception handling tasks:
Service Exception
, for example as an XML document or user-defined Structured Data Object
.Service Exception
event by setting the resulting exception to null
.eventId
or logging mechanism using custom handler code.
The Event Handler
definitions are stored in the Service Configuration Object
and may be validated for completeness of
functionality independent of the run-time service hosting environment. The EventHandlerValidator
allows developers and framework users
to check a given Service's registered event handlers utilizing Java Reflection
capabilities. These validations will also
be performed at run-time by the container context when the service is first initialized.
Copyright: Copyright (c) 2009
Company: StreamScape Technologies
DEFAULT_SERIAL_VERSION_ID
Constructor and Description |
---|
EventHandler() |
EventHandler(AbstractServiceConfigurationObject sco,
java.lang.String methodName,
java.lang.String handlerName) |
Modifier and Type | Method and Description |
---|---|
void |
bindRequestEvent(ImmutableEventDatagram event)
Binds the specified event as a request object.
|
void |
bindRequestObject(java.lang.String eventId,
SemanticType type)
Binds the specified event id and semantic type as the request object of the event handler.
|
void |
bindRequestObject(java.lang.String eventId,
java.lang.String type)
Binds the specified event id and semantic type as the request object of the event handler.
|
void |
bindResponseEvent(ImmutableEventDatagram datagram)
Binds the specified event as a response object.
|
void |
bindResponseObject(java.lang.String eventId,
SemanticType type)
Binds the specified event id and semantic type as the response object of the event handler.
|
void |
bindResponseObject(java.lang.String eventId,
java.lang.String type)
Binds the specified event id and semantic type as the response object of the event handler.
|
void |
bindVoidRequestObject(java.lang.String eventId)
Binds a
Void object as a request, indicating a method without parameters. |
void |
bindVoidResponseObject(java.lang.String eventId)
Binds a
void response to the event handler. |
EventHandler |
clone()
Clones the object.
|
java.lang.String |
getHandlerName()
Returns a name of the event handler.
|
InvokeMode |
getInvokeMode()
Returns an invoke mode of the event handler.
|
java.lang.String |
getMethodName()
Returns a name of the event handler's method.
|
java.lang.String |
getRequestEventId()
Returns the request
eventId of the event handler. |
java.lang.String |
getRequestObjectClass()
Returns a name of the request object class of the event handler.
|
java.lang.String |
getRequestSDRPath()
Returns the request
SDR path of the event handler (if set). |
java.lang.String |
getRequestSelector()
Returns the request selector of the event handler.
|
java.lang.String |
getRequestSemanticType()
Returns a name of the request semantic type of the event handler.
|
java.lang.String |
getResponseEventId()
Returns a response
eventId of the event handler. |
java.lang.String |
getResponseObjectClass()
Returns a name of the response object class of the event handler.
|
java.lang.String |
getResponseSemanticType()
Returns a name of the response semantic type of the event handler.
|
long |
getTimeout()
Returns the timeout (in milliseconds) for the event handler.
|
boolean |
isRequestBound()
Returns
true if a request object is bound to the event handler. |
boolean |
isResponseBound()
Returns
true if a response object is bound to the event handler. |
boolean |
isValid()
Checks if the event handler is valid.
|
void |
setHandlerName(java.lang.String name)
Sets a name of the event handler.
|
void |
setInvokeMode(InvokeMode mode)
Sets an invoke mode of the event handler.
|
void |
setMethodName(java.lang.String methodName)
Sets a name of the method for this handler.
|
void |
setRequestSDRPath(java.lang.String path)
Sets the request
SDR path of the event handler (if set). |
void |
setRequestSelector(java.lang.String selector)
Sets the request selector of the event handler.
|
void |
setServiceConfigurationObject(AbstractServiceConfigurationObject sco) |
void |
setTimeout(long timeout)
Sets the timeout (in milliseconds) for the event handler.
|
java.lang.String |
toString() |
void |
unbindRequest()
Unbinds the request object.
|
void |
unbindResponse()
Unbinds the response object.
|
getSerialVersionUID
public EventHandler()
public EventHandler(AbstractServiceConfigurationObject sco, java.lang.String methodName, java.lang.String handlerName)
public long getTimeout()
public void setTimeout(long timeout)
Cancel
if one is registered for the Service Context
.timeout
- the value to be set.public InvokeMode getInvokeMode()
public void setInvokeMode(InvokeMode mode)
mode
- the value to be set.public java.lang.String getMethodName()
public void setMethodName(java.lang.String methodName)
methodName
- the value to be set.public java.lang.String getHandlerName()
public void setHandlerName(java.lang.String name)
name
- the value to be set.public java.lang.String getRequestEventId()
eventId
of the event handler.public java.lang.String getRequestSelector()
public void setRequestSelector(java.lang.String selector)
selector
- the value to be set.public java.lang.String getRequestSDRPath()
SDR path
of the event handler (if set).
public void setRequestSDRPath(java.lang.String path)
SDR path
of the event handler (if set).path
- the value to be set.public java.lang.String getRequestObjectClass()
public java.lang.String getRequestSemanticType()
public boolean isRequestBound()
true
if a request object is bound to the event handler.public java.lang.String getResponseEventId()
eventId
of the event handler.public java.lang.String getResponseObjectClass()
public java.lang.String getResponseSemanticType()
public boolean isResponseBound()
true
if a response object is bound to the event handler.public void bindRequestObject(java.lang.String eventId, SemanticType type) throws EventHandlerException
Data Event
datagram
which has the listed Semantic Type
as it's payload.eventId
- the event id to be bound.type
- the semantic type to be bound.EventHandlerException
- if any parameter has invalid format.public void bindRequestObject(java.lang.String eventId, java.lang.String type) throws EventHandlerException
Data Event
datagram
which has the listed Semantic Type
as it's payload.eventId
- the event id to be bound.type
- the semantic type to be bound.EventHandlerException
- if any parameter has invalid format.public void bindVoidRequestObject(java.lang.String eventId) throws EventHandlerException
Void
object as a request, indicating a method without parameters.eventId
- the event id to be bound.EventHandlerException
- if the parameter has invalid format.public void bindRequestEvent(ImmutableEventDatagram event) throws EventHandlerException
the
- event to be bound.EventHandlerException
- if the parameter has invalid format.public void unbindRequest()
public void bindResponseObject(java.lang.String eventId, SemanticType type) throws EventHandlerException, ServiceConfigurationException
eventId
- the event id to be bound.type
- the semantic type to be bound.EventHandlerException
- if any parameter has invalid format.ServiceConfigurationException
public void bindResponseObject(java.lang.String eventId, java.lang.String type) throws EventHandlerException, ServiceConfigurationException
eventId
- the event id to be bound.type
- the semantic type to be bound.EventHandlerException
- if any parameter has invalid format.ServiceConfigurationException
public void bindResponseEvent(ImmutableEventDatagram datagram) throws EventHandlerException
the
- event to be bound.EventHandlerException
- if the parameter has invalid format.public void bindVoidResponseObject(java.lang.String eventId) throws EventHandlerException, ServiceConfigurationException
void
response to the event handler. Such a method call will
not result in an actionable event being raised.public void unbindResponse() throws ServiceConfigurationException
ServiceConfigurationException
public void setServiceConfigurationObject(AbstractServiceConfigurationObject sco)
public EventHandler clone()
CloneableDataObject
clone
in interface CloneableObject
clone
in class CloneableDataObject
public java.lang.String toString()
toString
in class java.lang.Object
public boolean isValid()
true
if the event handler is valid, false
otherwise.Copyright © 2015-2024 StreamScape Technologies. All rights reserved.