Class AggregatedEventHandler
- java.lang.Object
-
- com.microstrategy.web.beans.GenericEventHandler
-
- com.microstrategy.web.beans.AggregatedEventHandler
-
- All Implemented Interfaces:
WebEventHandler
,WebEventTags
,java.lang.Cloneable
- Direct Known Subclasses:
AggregatedAppEventHandler
,AggregatedFolderEventHandler
,AggregatedReportSavePropertiesEventHandler
,ReportPageEventHandler
,RWBeanHTML5VIEventHandler
public abstract class AggregatedEventHandler extends GenericEventHandler
TheAggregatedEventHandler
class is intended for customization of existing event handlers. By extending this abstract class, a customized event handler can change the way events are processed, extend the definition of existing events, and create new events.An instance of this class aggregates a "default" event handler. A custom event handler subclass can either handle a given event itself or delegate it to the aggregated default handler.
Custom event handler subclasses must implement the abstract method
processRequest
, which serves as the entrypoint for event processing. From there, the custom handler can choose to handle a given event itself, or delegate it by callinghandleDefaultRequest
.The default event handler is set via the
setDefaultHandler
method. Typically, it is not necessary for custom event handler implementations to explicitly call this method. By default, when the system creates anAggregatedEventHandler
to be associated with a given bean, it will use the bean's event handler as the default handler (see the example below).The following code shows a custom event handler that can be associated with a
FolderBean
:public class CustomFolderHandler extends AggregatedEventHandler { public boolean processRequest(RequestKeys keys) throws WebException { int eventID = getEventID(keys); switch (eventID) { // handle desired events here } // or delegate to the default handler return handleDefaultRequest(keys); } }
To associate this event handler with a bean, update the bean's<web-bean>
node inpageConfig.xml
.
Typically, the line inpageConfig.xml
that specifies a given bean looks like:<web-bean name="fb" persist-mode="2" sys-bean="FolderBean"/>
We use theevent-handler
attribute to associate a custom event handler with that bean:<web-bean name="fb" persist-mode="2" sys-bean="FolderBean" event-handler="com.xyz.CustomFolderHandler"/>
where
com.xyz.CustomFolderHandler
is the fully qualified class name of the custom event handler class.At runtime, when the bean shown above needs to be created, the system will first instantiate a new
FolderBean
instance. It will then create a newCustomFolderHandler
instance that aggregates theFolderBean
instance's event handler. Finally, it will callWebComponent.setWebEventHandler
to associate theCustomFolderHandler
instance with theFolderBean
instance.- Since:
- MicroStrategy Web 7.3.1 or earlier
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.microstrategy.web.beans.GenericEventHandler
GenericEventHandler.GenericEventKeys
-
-
Field Summary
Fields Modifier and Type Field Description protected WebEventHandler
defaultHandler
The default event handler.-
Fields inherited from class com.microstrategy.web.beans.GenericEventHandler
_extraEvents, layerOfHandleRequest, MULTIPLE_EVENT_SOURCE_SUFFIX, NO_EVENT_ID
-
Fields inherited from interface com.microstrategy.web.beans.WebEventTags
ATT_ARGUMENT_ENUMERATOR, ATT_ARGUMENT_ID, ATT_ARGUMENT_INDEX, ATT_ARGUMENT_NAME, ATT_ARGUMENT_REQUIRED, ATT_ARGUMENT_TYPE, ATT_ARGUMENT_VALIDATOR, ATT_ARGUMENT_VALUE, ATT_EVENT_DEPRECATED, ATT_EVENT_ENUMERATOR, ATT_EVENT_HANDLER_ENUMERATOR, ATT_EVENT_HANDLER_NAME, ATT_EVENT_HANDLER_TYPE, ATT_EVENT_ID, ATT_EVENT_NAME, ATT_EVENT_TARGET, TAG_ARGUMENT, TAG_ARGUMENTS, TAG_EVENT, TAG_EVENT_HANDLER, TAG_EVENT_HANDLERS, TAG_EVENTS
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AggregatedEventHandler()
Constructs anAggregatedEventHandler
without a default handler.protected
AggregatedEventHandler(int type)
Deprecated.Use theno-arg constructor
, along withsetDefaultHandler
if necessary.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected boolean
defaultDelegate(RequestKeys keys)
boolean
delegateRequest(RequestKeys keys)
The default implementation of this method simply delegates the event to the next source component specified in the static fieldGenericWebEvent.URL_SOURCE_NAME
.WebEventHandler
getDefaultHandler()
Returns the default event handler.int
getHandlerType()
Returns the event handler type.java.lang.Class
getSupportedWebComponentType()
Returns theClass
type of theWebComponent
this event handler is associated with.WebEvent
getWebEvent(int id)
Returns the specifiedWebEvent
instance which this event handler supports.protected boolean
handleDefaultRequest(RequestKeys keys)
Asks the default event handler to handle the request.abstract boolean
processRequest(RequestKeys keys)
This method encapsulates the logic to process an incoming event.void
setDefaultHandler(WebEventHandler handler)
Sets the default event handler.protected void
setHandlerType(int type)
Sets the event handlertype
.-
Methods inherited from class com.microstrategy.web.beans.GenericEventHandler
addEvent, addEvent, addEvents, addEventsFromRequestKeys, addEventsFromXML, appendRemainingEvent, clone, getEventID, getEventTarget, getName, getNextSourceName, getNextSourceName, getOrderedEvents, getPendingEvents, getWebComponent, getWebEvent, getWebEvent, getWebEvents, getWebEventsFromRequest, handleRequest, isInitialized, isMyEvent, markInitailized, processExtraEvents, processMultipleEvents, processMultipleEvents, setName, setWebComponent, validateRequiredArgument
-
-
-
-
Field Detail
-
defaultHandler
protected WebEventHandler defaultHandler
The default event handler.
-
-
Constructor Detail
-
AggregatedEventHandler
protected AggregatedEventHandler(int type)
Deprecated.Use theno-arg constructor
, along withsetDefaultHandler
if necessary. For flexibilty reasons, this class should no longer be responsible for creating the default handler based on its type.Constructs anAggregatedEventHandler
with the specified event handlertype
. Internally callssetHandlerType
, which creates an instance of the event handler with the specified type and sets it to be the default handler.- Parameters:
type
- the event handler type.
-
AggregatedEventHandler
protected AggregatedEventHandler()
Constructs anAggregatedEventHandler
without a default handler. Code that creates anAggregatedEventHandler
instance programmatically can callsetDefaultHandler
to set the default handler.- Since:
- MicroStrategy Web 9.0.0
-
-
Method Detail
-
getHandlerType
public int getHandlerType()
Returns the event handler type. This implementation simply returns the default handler's type.- Specified by:
getHandlerType
in interfaceWebEventHandler
- Overrides:
getHandlerType
in classGenericEventHandler
- Returns:
- the event handler type.
-
getWebEvent
public WebEvent getWebEvent(int id)
Returns the specifiedWebEvent
instance which this event handler supports.- Specified by:
getWebEvent
in interfaceWebEventHandler
- Overrides:
getWebEvent
in classGenericEventHandler
- Parameters:
id
- the event id of the WebEvent.- Returns:
- the specified WebEvent; null if the event is not supported by this event handler.
-
processRequest
public abstract boolean processRequest(RequestKeys keys) throws WebException
This method encapsulates the logic to process an incoming event. Normally, this is invoked byGenericEventHandler.handleRequest(RequestKeys)
.- Specified by:
processRequest
in interfaceWebEventHandler
- Overrides:
processRequest
in classGenericEventHandler
- Parameters:
keys
- the RequestKeys object containing event ID, sources, and any other information.- Returns:
- true if handling succeeds; false if the event is ignored and not handled.
- Throws:
WebException
- thrown if handling of the request fails.
-
delegateRequest
public boolean delegateRequest(RequestKeys keys) throws WebException
Description copied from class:GenericEventHandler
The default implementation of this method simply delegates the event to the next source component specified in the static fieldGenericWebEvent.URL_SOURCE_NAME
.- Specified by:
delegateRequest
in interfaceWebEventHandler
- Overrides:
delegateRequest
in classGenericEventHandler
- Parameters:
keys
- the RequestKeys object containing event ID, sources, and any other information.- Returns:
- true if handling succeeds in
processRequest
or one of its children. - Throws:
WebException
- thrown if handling of the request fails.- Since:
- MicroStrategy Web 7.5.4
-
setHandlerType
protected void setHandlerType(int type)
Sets the event handlertype
. This implementation creates a new instance of the event handler with the specified type and sets it to be the default handler. Can be overridden in subclasses to change the way default handlers are created.NOTE: This implementation is provided for backward compatibility only. New code should set the default handler using
setDefaultHandler
.- Overrides:
setHandlerType
in classGenericEventHandler
- Parameters:
type
- the event handler type.
-
setDefaultHandler
public void setDefaultHandler(WebEventHandler handler)
Sets the default event handler.- Parameters:
handler
- AWebEventHandler
instance to use as the default event handler.- Since:
- MicroStrategy Web 9.0.0
-
getDefaultHandler
public WebEventHandler getDefaultHandler()
Returns the default event handler.- Returns:
- WebEventHandler The default event handler, or null if no default event handler has been set.
- Since:
- MicroStrategy Web 9.0.0
-
defaultDelegate
protected boolean defaultDelegate(RequestKeys keys) throws WebException
- Throws:
WebException
- Since:
- MicroStrategy Web 7.5.4
-
handleDefaultRequest
protected boolean handleDefaultRequest(RequestKeys keys) throws WebException
Asks the default event handler to handle the request.- Parameters:
keys
- the RequestKeys object containing event ID, sources, and any other information.- Returns:
true
if handling succeeds; false if the event is ignored and not handled.- Throws:
WebException
-
getSupportedWebComponentType
public java.lang.Class getSupportedWebComponentType()
Returns theClass
type of theWebComponent
this event handler is associated with.- Specified by:
getSupportedWebComponentType
in interfaceWebEventHandler
- Overrides:
getSupportedWebComponentType
in classGenericEventHandler
- Returns:
- the
Class
of theWebComponent
this event handler is associated with. - Since:
- MicroStrategy Web 8.0.0
-
-