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
TheAggregatedEventHandlerclass 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
setDefaultHandlermethod. Typically, it is not necessary for custom event handler implementations to explicitly call this method. By default, when the system creates anAggregatedEventHandlerto 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.xmlthat specifies a given bean looks like:<web-bean name="fb" persist-mode="2" sys-bean="FolderBean"/>
We use theevent-handlerattribute 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.CustomFolderHandleris 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
FolderBeaninstance. It will then create a newCustomFolderHandlerinstance that aggregates theFolderBeaninstance's event handler. Finally, it will callWebComponent.setWebEventHandlerto associate theCustomFolderHandlerinstance with theFolderBeaninstance.- 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 WebEventHandlerdefaultHandlerThe 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 protectedAggregatedEventHandler()Constructs anAggregatedEventHandlerwithout a default handler.protectedAggregatedEventHandler(int type)Deprecated.Use theno-arg constructor, along withsetDefaultHandlerif necessary.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected booleandefaultDelegate(RequestKeys keys)booleandelegateRequest(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.WebEventHandlergetDefaultHandler()Returns the default event handler.intgetHandlerType()Returns the event handler type.java.lang.ClassgetSupportedWebComponentType()Returns theClasstype of theWebComponentthis event handler is associated with.WebEventgetWebEvent(int id)Returns the specifiedWebEventinstance which this event handler supports.protected booleanhandleDefaultRequest(RequestKeys keys)Asks the default event handler to handle the request.abstract booleanprocessRequest(RequestKeys keys)This method encapsulates the logic to process an incoming event.voidsetDefaultHandler(WebEventHandler handler)Sets the default event handler.protected voidsetHandlerType(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
@Deprecated protected AggregatedEventHandler(int type)
Deprecated.Use theno-arg constructor, along withsetDefaultHandlerif necessary. For flexibilty reasons, this class should no longer be responsible for creating the default handler based on its type.Constructs anAggregatedEventHandlerwith 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 anAggregatedEventHandlerwithout a default handler. Code that creates anAggregatedEventHandlerinstance programmatically can callsetDefaultHandlerto 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:
getHandlerTypein interfaceWebEventHandler- Overrides:
getHandlerTypein classGenericEventHandler- Returns:
- the event handler type.
-
getWebEvent
public WebEvent getWebEvent(int id)
Returns the specifiedWebEventinstance which this event handler supports.- Specified by:
getWebEventin interfaceWebEventHandler- Overrides:
getWebEventin 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:
processRequestin interfaceWebEventHandler- Overrides:
processRequestin 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:GenericEventHandlerThe default implementation of this method simply delegates the event to the next source component specified in the static fieldGenericWebEvent.URL_SOURCE_NAME.- Specified by:
delegateRequestin interfaceWebEventHandler- Overrides:
delegateRequestin classGenericEventHandler- Parameters:
keys- the RequestKeys object containing event ID, sources, and any other information.- Returns:
- true if handling succeeds in
processRequestor 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:
setHandlerTypein classGenericEventHandler- Parameters:
type- the event handler type.
-
setDefaultHandler
public void setDefaultHandler(WebEventHandler handler)
Sets the default event handler.- Parameters:
handler- AWebEventHandlerinstance 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:
trueif handling succeeds; false if the event is ignored and not handled.- Throws:
WebException
-
getSupportedWebComponentType
public java.lang.Class getSupportedWebComponentType()
Returns theClasstype of theWebComponentthis event handler is associated with.- Specified by:
getSupportedWebComponentTypein interfaceWebEventHandler- Overrides:
getSupportedWebComponentTypein classGenericEventHandler- Returns:
- the
Classof theWebComponentthis event handler is associated with. - Since:
- MicroStrategy Web 8.0.0
-
-