flex.messaging.services
Class ServiceAdapter

java.lang.Object
  extended by flex.management.ManageableComponent
      extended by flex.messaging.services.ServiceAdapter
All Implemented Interfaces:
Manageable, FlexComponent, FlexConfigurable
Direct Known Subclasses:
HTTPProxyAdapter, JavaAdapter, MessagingAdapter

public abstract class ServiceAdapter
extends ManageableComponent

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


Field Summary
static String LOG_CATEGORY
          Log category for ServiceAdapter.
 
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.
 Destination getDestination()
          Returns the Destination of the ServiceAdapter.
 boolean handlesSubscriptions()
          Returns true if the adapter performs custom subscription management.
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 setDestination(Destination destination)
          Sets the Destination of the ServiceAdapter.
 void start()
          Starts the adapter if its associated Destination is started and if the adapter is not already running.
 void stop()
          Stops the ServiceAdapter.
 
Methods inherited from class flex.management.ManageableComponent
getControl, getId, getParent, initialize, isManaged, isStarted, isValid, setControl, setId, setManaged, setParent
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_CATEGORY

public static final String LOG_CATEGORY
Log category for ServiceAdapter.

See Also:
Constant Field Values
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

start

public void start()
Starts the adapter if its associated Destination is started and if the adapter is not already running. If subclasses override, they must call super.start().

Specified by:
start in interface FlexComponent
Overrides:
start in class ManageableComponent

stop

public void stop()
Stops the ServiceAdapter. If subclasses override, they must call super.start().

Specified by:
stop in interface FlexComponent
Overrides:
stop in class ManageableComponent

getDestination

public Destination getDestination()
Returns the Destination of the ServiceAdapter.

Returns:
The Destination of the ServiceAdapter.

setDestination

public void setDestination(Destination destination)
Sets the Destination of the ServiceAdapter. Also sets the ServiceAdapter of the Destination if needed.

Parameters:
destination - The Destination of the ServiceAdapter.

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 lets the adapter perform processing with subscribe, unsubscribe, and poll operations. For subscribe and unsubscribe, this method is only called if handlesSubscriptions returns true.

The service will perform some processing on the message before and after it calls this method. For subscribe messages the MessageService will register a subscription after this method returns successfully. For unsubscribe messages, the MessageService will unsubscribe after this method returns successfully. For both of these messages, this method can return null or it can return the AcknowledgeMessage to send to the client for the reply to this operation. If a MultiTopicConsumer is used on the client, this method will receive a MULTI_SUBSCRIBE message.

For POLL operations, this method can return a list of messages to be added to the set returned to the client for this poll. If it returns null, it means no messages are to be added to the set already queued up for this client.

Parameters:
commandMessage - The command message to manage.
Returns:
The result of manage. The default implementation returns null.
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.

Returns:
The state of the adapter. The default implementations throws 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.

Parameters:
adapterState - The object representing the adapter state.

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.

Returns:
true if the adapter performs custom subscription management. The default return value is false.


Copyright © 2008 Adobe Systems Inc. All Rights Reserved.

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/blazeds/1/javadoc/flex/messaging/services/ServiceAdapter.html