flex.messaging.services
Class ServiceAdapter

java.lang.Object
  extended byflex.management.ManageableComponent
      extended byflex.messaging.services.ServiceAdapter
All Implemented Interfaces:
Manageable

public abstract class ServiceAdapter
extends ManageableComponent

The ServiceAdapter class is the base definition of a service adapter.


Constructor Summary
ServiceAdapter()
          Constructs an unmanaged ServiceAdapter instance.
ServiceAdapter(boolean enableManagement)
          Constructs a ServiceAdapter instance.
 
Method Summary
 Object getAdapterState()
          Return an object, usually a Collection, representing any shared state for the adapter.
 String getId()
          Retrieve the id for this adapter, used in configuration and as an identifier in various data structures in the system.
 boolean handlesSubscriptions()
          Returns true if the adapter performs custom subscription management.
 void initialize()
          The default implementation of this method is a no-op.
abstract  Object invoke(Message message)
          Handle a data message intended for this adapter.
 Object manage(CommandMessage commandMessage)
          Accept a command from the adapter's service and perform some internal action based upon it.
 void setAdapterState(Object adapterState)
          Set an object, usually a Collection, to represent shared state for the adapter.
 void setService(Service service)
          Make the adapter aware of the service that ultimately controls it.
 void setSettings(Destination destination, AdapterSettings adapterSettings, DestinationSettings destinationSettings)
          Establish the configuration settings for this adapter.
 void setupAdapterControl(Destination destination)
          Managed subclasses should override this method to setup and register their corresponding MBean control.
 void stop()
          The default implementation of this method is a no-op.
 
Methods inherited from class flex.management.ManageableComponent
getControl, isManaged, setControl, setManaged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceAdapter

public ServiceAdapter()
Constructs an unmanaged ServiceAdapter instance.


ServiceAdapter

public ServiceAdapter(boolean enableManagement)
Constructs a ServiceAdapter instance.

Parameters:
enableManagement - true if the ServiceAdapter has a corresponding MBean control for management; otherwise false.
Method Detail

invoke

public abstract Object invoke(Message message)
Handle a data message intended for this adapter. This method is responsible for handling the message and returning a result (if any). The return value of this message is used as the body of the acknowledge message returned to the client. It may be null if there is no data being returned for this message.

Typically the data content for the message is stored in the body property of the message. The headers of the message are used to store fields which relate to the transport of the message. The type of operation is stored as the operation property of the message.

Parameters:
message - the message as sent by the client intended for this adapter
Returns:
the body of the acknowledge message (or null if there is no body)
See Also:
Message, AsyncMessage

manage

public Object manage(CommandMessage commandMessage)
Accept a command from the adapter's service and perform some internal action based upon it. CommandMessages are used for messages which control the state of the connection between the client and the server. For example, this handles subscribe, unsubscribe, and ping operations. The messageRefType property of the CommandMessage is used to associate a command message with a particular service. Services are configured to handle messages of a particular concrete type. For example, the MessageService is typically invoked to handle messages of type flex.messaging.messages.AsyncMessage. To ensure a given CommandMessage is routed to the right service, its MessageRefType is set to the string name of the message type for messages handled by that service.

See Also:
CommandMessage, AsyncMessage

getAdapterState

public Object getAdapterState()
Return an object, usually a Collection, representing any shared state for the adapter. If adapters have shared state, they should override this method, as the default implementation throws an UnsupportedOperationException.


setAdapterState

public void setAdapterState(Object adapterState)
Set an object, usually a Collection, to represent shared state for the adapter. If adapters have shared state, they should override this method, as the default implementation throws an UnsupportedOperationException.


handlesSubscriptions

public boolean handlesSubscriptions()
Returns true if the adapter performs custom subscription management. The default return value is false, and subclasses should override this method as necessary.


getId

public String getId()
Retrieve the id for this adapter, used in configuration and as an identifier in various data structures in the system.


setService

public void setService(Service service)
Make the adapter aware of the service that ultimately controls it. This must be called before setSettings to allow adapters to read default settings from the service but then apply local settings from the adapter itself or the individual destination, as is neccessary.


setSettings

public void setSettings(Destination destination,
                        AdapterSettings adapterSettings,
                        DestinationSettings destinationSettings)
Establish the configuration settings for this adapter. This must be called after setService.


initialize

public void initialize()
The default implementation of this method is a no-op. Subclasses should override it if they require functionality to occur after their services have been setup under management of the MessageBroker.


stop

public void stop()
The default implementation of this method is a no-op. Subclasses should override it if they require functionality to occur when their services are about to be stopped.


setupAdapterControl

public void setupAdapterControl(Destination destination)
Managed subclasses should override this method to setup and register their corresponding MBean control. If this method is not overridden the adapter will be unmanaged by default.

Parameters:
destination - The associated Destination for the adapter.


Copyright © 2006 Adobe Systems Inc. All Rights Reserved. (Updated August 2, 2006)

Take a survey