com.tibco.bpm.web.client.model.pagebus.hub
Class ManagedEvent<H extends com.google.gwt.event.shared.EventHandler>

java.lang.Object
  extended by com.google.web.bindery.event.shared.Event<H>
      extended by com.google.gwt.event.shared.GwtEvent<H>
          extended by com.tibco.bpm.web.client.model.pagebus.hub.ManagedEvent<H>
Type Parameters:
H - Handler type.

©2011 Cloud Software Group, Inc.

Direct Known Subclasses:
BusinessServiceDataEvent, BusinessServiceEvent, LocaleChangedEvent, LoginEvent, LogoutEvent, PersistenceEvent, ProcessInstanceEvent, ProcessTemplateEvent, SystemActionsEvent, TemplateManagedEvent, TranslationEvent, TranslationEvent2, WebviewChangedEvent, WorkItemDataEvent, WorkItemEvent

public abstract class ManagedEvent<H extends com.google.gwt.event.shared.EventHandler>
extends com.google.gwt.event.shared.GwtEvent<H>

The ManagedEvent class extends the normal GWT Event/Handler model and results in a PageBusMessage being transparently published on the ManagedHub. Normal GWT event handlers can be added for the event on both the sending (publishing) and receiving (subscribing) side of the ManagedHub. The event is transparently recreated and fired on the receiving side of the ManagedHub.

Class specific data is converted to and from a PageBusMessage using the toPageBusMessage and fromPageBusMessage methods. When the instance is created using the gwt-create generated class the default implementation of the abstract methods: toPageBusMessage, fromPageBusMessage, and dispatchLocal is used. The extending class can optionally provide the implementation for these abstract methods if there is special handling required.

Since:
2.0.0
See Also:
TemplateManagedEvent

Nested Class Summary
static class ManagedEvent.DispatchScope
          Controls how a ManagedEvent is dispatched:

LOCAL - Dispatch is done locally only. MANAGED_HUB - Dispatch is done on the Managed Hub only. BOTH - Dispatch is done both locally and on the Managed Hub.

This value is set on the dispatchScope property.

 
Nested classes/interfaces inherited from class com.google.gwt.event.shared.GwtEvent
com.google.gwt.event.shared.GwtEvent.Type<H>
 
Field Summary
static java.lang.String DEFAULT_VERSION
           
static java.lang.String EXT_SUFFIX
           
 
Constructor Summary
protected ManagedEvent()
           
 
Method Summary
protected  void dispatch(H handler)
           
protected abstract  void dispatchLocal(H handler)
          Called by the ManagedEvent dispatch method to locally dispatch the event to the class specific handler.
 ManagedEvent<?> fromJsonString(java.lang.String json)
           
protected abstract  ManagedEvent<?> fromPageBusMessage(PageBusMessage pageBusMessage)
          Converts the given PageBusMessage to a ManagedEvent.
protected  ManagedEvent<?> fromPageBusMessageDefault(PageBusMessage pageBusMessage)
          The default implementation of the fromPageBusMessageDefault method which is called by the gwt-create generated fromPageBusMessageDefault method.
 ManagedEvent.DispatchScope getDispatchScope()
           
 java.lang.String getEventSourceId()
          Gets the eventSourceId value.
 org.jsonmaker.gwt.client.Jsonizer getJsonizer()
          Returns the Jsonizer for this ManagedEvent type.
 java.lang.String getManagedEventVersion()
          The managedEventVersion can be used to distinguish between different data versions of the ManagedEvent class.
protected  java.lang.String getReceivedSchemaId()
           
protected  java.lang.String getSchemaId()
          The schemaId is used to set the schemaId property of the PageBusMessage that is created if this event is published on the ManagedEventBus.
protected  Subscription getSubscription()
          Gets the subscription value.
 java.lang.String getTopic()
          Returns the topic that will be used to publish and subscribe on the PageBus ManagedHub for this ManagedEvent.
 boolean isCacheEnabled()
          Gets the cacheEnabled value.
protected  boolean isDispatched()
           
 boolean isFireWhenReceivedFromManagedHub()
           
 boolean isReceivedFromManagedHub()
          Gets the receivedFromManagedHub value.
 boolean isRegistered()
          Gets the registered value.
 void setCacheEnabled(boolean cacheEnabled)
          Sets the cacheEnabled value.
protected  void setDispatched(boolean dispatched)
           
 void setDispatchScope(ManagedEvent.DispatchScope dispatchScope)
           
 java.lang.String setEventSourceId(java.lang.String eventSourceId)
          Sets the eventSourceId value and returns the resulting topic.
 void setFireWhenReceivedFromManagedHub(boolean fireWhenReceivedFromManagedHub)
           
 void setManagedEventVersion(java.lang.String managedEventVersion)
           
protected  void setReceivedSchemaId(java.lang.String receivedSchemaId)
           
protected  void setRegistered(boolean registered)
          Sets the registered value.
protected  void setSubscription(Subscription subscription)
          Sets the subscription value.
 java.lang.String toJsonString()
           
protected abstract  PageBusMessage toPageBusMessage()
          Converts this ManagedEvent to a PageBusMessage.
protected  PageBusMessage toPageBusMessageDefault()
          The default implementation of the toPageBusMessage method which is called by the gwt-create generated toPageBusMessage method.
 
Methods inherited from class com.google.gwt.event.shared.GwtEvent
assertLive, getAssociatedType, getSource, isLive, kill, revive
 
Methods inherited from class com.google.web.bindery.event.shared.Event
setSource, toDebugString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EXT_SUFFIX

public static final java.lang.String EXT_SUFFIX
See Also:
Constant Field Values

DEFAULT_VERSION

public static final java.lang.String DEFAULT_VERSION
See Also:
Constant Field Values
Constructor Detail

ManagedEvent

protected ManagedEvent()
Method Detail

getTopic

public final java.lang.String getTopic()
Returns the topic that will be used to publish and subscribe on the PageBus ManagedHub for this ManagedEvent.

If eventSourceId is not null the topic value is:

fullyQualifiedClassName + "." + eventSourceId

Otherwise the topic is:

fullyQualifiedClassName

Returns:
The topic that will be used to publish and subscribe on the PageBus ManagedHub for this ManagedEvent.

dispatch

protected final void dispatch(H handler)
Specified by:
dispatch in class com.google.gwt.event.shared.GwtEvent<H extends com.google.gwt.event.shared.EventHandler>

dispatchLocal

protected abstract void dispatchLocal(H handler)
Called by the ManagedEvent dispatch method to locally dispatch the event to the class specific handler. The GWT.create generator creates this method if the extending class does not provide the implementation. Use of the generator created implementation is recommended unless there is a specific need to implement this beyond a simple dispatch to the handler.

Parameters:
handler -

toPageBusMessage

protected abstract PageBusMessage toPageBusMessage()
Converts this ManagedEvent to a PageBusMessage. Any data held by this event class is set on the JSONValue of the returned PageBusMessage.

The extending class may optionally implement this method if there is a special need to handle the class data. When using GWT.create the generated class uses the default implementation which serializes the class data using gwt-jsonmaker.

When this event is dispatched this method is called. If this method returns a PageBusMessage (a non null value) then the returned PageBusMessage is published on the PageBus ManagedHub. On the subscribing side of the PageBus ManagedHub the PageBusMessage is converted back to a ManagedEvent using the fromPageBusMessage(PageBusMessage) method.

Note: The topic value of the PageBusMessage is always set to the topic value of the ManagedEvent before the event is dispatch so there is no need to set the topic value on the PageBusMessage.

Note: If the schemaId value of the PageBusMessage has not been explicitly set (schemaId == null or PageBusMessage.DEFAULT_SCHEMA_ID) then its value will be set to the fully qualified class name.

Returns:
The PageBusMessage instance or null. If null nothing is published.
See Also:
fromPageBusMessage(PageBusMessage)

toPageBusMessageDefault

protected final PageBusMessage toPageBusMessageDefault()
The default implementation of the toPageBusMessage method which is called by the gwt-create generated toPageBusMessage method.

The gwt-jsonmaker package is used to serialize the class data.

Returns:
The PageBusMessage instance or null. If null nothing is published.
See Also:
fromPageBusMessage(PageBusMessage)

fromPageBusMessage

protected abstract ManagedEvent<?> fromPageBusMessage(PageBusMessage pageBusMessage)
Converts the given PageBusMessage to a ManagedEvent. Any data held by the JSONValue of the PageBusMessage is used to initialize the returned ManagedEvent.

The extending class may optionally implement this method if there is a special need to handle the class data. When using GWT.create the generated class uses the default implementation which serializes the class data using gwt-jsonmaker.

When a PageBusMessage is received on the subscribing side of the PageBus ManagedHub this method is called if the PageBusMessage topic matches the topic of this ManagedEvent class. If this method returns a ManagedEvent (a non null value) then the returned ManagedEvent will be fired on the ManagedEventBus to any registered handlers.

Parameters:
pageBusMessage - The PageBusMessage instance.
Returns:
The ManagedEvent instance or null. If null no event is fired.
See Also:
toPageBusMessage()

fromPageBusMessageDefault

protected final ManagedEvent<?> fromPageBusMessageDefault(PageBusMessage pageBusMessage)
The default implementation of the fromPageBusMessageDefault method which is called by the gwt-create generated fromPageBusMessageDefault method.

The gwt-jsonmaker package is used to serialize the class data.

Parameters:
pageBusMessage - The PageBusMessage instance.
Returns:
The ManagedEvent instance or null. If null no event is fired.
See Also:
toPageBusMessage()

getSchemaId

protected java.lang.String getSchemaId()
The schemaId is used to set the schemaId property of the PageBusMessage that is created if this event is published on the ManagedEventBus. The extending class can override to provide a value other than the default which is the fully qualified class name followed by an underscore and the managedEventVersion value.

Returns:
A schemaId that can be used to differentiate data versions.

isReceivedFromManagedHub

public boolean isReceivedFromManagedHub()
Gets the receivedFromManagedHub value. This is true if this instance was created as a result of receiving a PageBus ManagedHub message.

This can be used to distinguish between an event that was fired locally and one that was fired from an external source via the ManagedHub.

Returns:
The receivedFromManagedHub value

setEventSourceId

public java.lang.String setEventSourceId(java.lang.String eventSourceId)
Sets the eventSourceId value and returns the resulting topic. This can be used to identify the source of an event. The topic used to publish and subscribe on the PageBus ManagedHub for this event is modified if this value is specified.

If eventSourceId is not null the topic is:

fullyQualifiedClassName + "." + eventSourceId

Otherwise the topic is:

fullyQualifiedClassName

This can only be set before the ManagedEvent is registered since this changes the value of the topic. The ManagedEventChangeException is thrown if this is called while the ManagedEvent is registered with the ManagedEventBus.

Parameters:
eventSourceId - The id value to set.
Throws:
ManagedEventChangeException

getEventSourceId

public java.lang.String getEventSourceId()
Gets the eventSourceId value. This can be used to identify the source of an event.

Returns:
The eventSourceId value.
See Also:
setEventSourceId(String)

setCacheEnabled

public void setCacheEnabled(boolean cacheEnabled)
Sets the cacheEnabled value. If this is set true the Hub Subscription created for this event will be CacheEnabled. Default value is false.

Parameters:
cacheEnabled - The cacheEnabled value to set.
Throws:
ManagedEventChangeException

isCacheEnabled

public boolean isCacheEnabled()
Gets the cacheEnabled value. If this is set true the Hub Subscription created for this event will be CacheEnabled.

Returns:
The cacheEnabled value.

setRegistered

protected void setRegistered(boolean registered)
Sets the registered value. Set to true if this ManagedEvent has been registered with the ManagedEventBus.

Parameters:
registered - The registered value to set.

isRegistered

public boolean isRegistered()
Gets the registered value. Set to true if this ManagedEvent has been registered with the ManagedEventBus.

Returns:
The registered value.

setSubscription

protected void setSubscription(Subscription subscription)
Sets the subscription value.

Parameters:
subscription - The subscription value to set.

getSubscription

protected Subscription getSubscription()
Gets the subscription value.

Returns:
The subscription value.

getJsonizer

public org.jsonmaker.gwt.client.Jsonizer getJsonizer()
Returns the Jsonizer for this ManagedEvent type. This is overridden by the extending class which is generated.

Returns:
The Jsonizer for this ManagedEvent type.

toJsonString

public java.lang.String toJsonString()

fromJsonString

public ManagedEvent<?> fromJsonString(java.lang.String json)

getDispatchScope

public ManagedEvent.DispatchScope getDispatchScope()

setDispatchScope

public void setDispatchScope(ManagedEvent.DispatchScope dispatchScope)

getReceivedSchemaId

protected java.lang.String getReceivedSchemaId()

setReceivedSchemaId

protected void setReceivedSchemaId(java.lang.String receivedSchemaId)

getManagedEventVersion

public java.lang.String getManagedEventVersion()
The managedEventVersion can be used to distinguish between different data versions of the ManagedEvent class. The extending class can set this this value as required. If this value is not previously set the ManagedEvent.DEFAULT_VERSION value is set and returned.

Returns:
The managedEventVersion value.

setManagedEventVersion

public void setManagedEventVersion(java.lang.String managedEventVersion)

isDispatched

protected boolean isDispatched()

setDispatched

protected void setDispatched(boolean dispatched)

isFireWhenReceivedFromManagedHub

public boolean isFireWhenReceivedFromManagedHub()

setFireWhenReceivedFromManagedHub

public void setFireWhenReceivedFromManagedHub(boolean fireWhenReceivedFromManagedHub)


Copyright © 2015 Cloud Software Group, Inc. All Rights Reserved.