## org.red5.server.messaging
Class ServiceAdapter

    java.lang.Object
      org.red5.server.messaging.ServiceAdapter

    public abstract class ServiceAdapter

extends Object

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

Author:
  Paul Gregoire

Constructor Summary
`ServiceAdapter()`

Method Summary
`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` `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 java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ServiceAdapter

    public ServiceAdapter()

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().

### stop

    public void stop()

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

### 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)

### 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.

  Parameters:
    `commandMessage` -
  Returns:
    Exception if not implemented

### 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 subscriptions are handled

Copyright © 2006-2010 The Red5 Project