flex.messaging.services
Class AbstractService

java.lang.Object
  extended by flex.management.ManageableComponent
      extended by flex.messaging.services.AbstractService
All Implemented Interfaces:
Manageable, FlexComponent, FlexConfigurable, Service
Direct Known Subclasses:
AuthenticationService, HTTPProxyService, MessageService, RemotingService

public abstract class AbstractService
extends ManageableComponent
implements Service

This is the default implementation of Service, which provides a convenient base for behavior and associations common to all Services.


Field Summary
static String LOG_CATEGORY
          Log category for AbstractService.
static String LOG_CATEGORY_STARTUP_DESTINATION
          Log category that captures startup information for service's destinations.
 
Constructor Summary
AbstractService()
          Constructs an unmanaged AbstractService.
AbstractService(boolean enableManagement)
          Constructs an AbstractService with the indicated management.
 
Method Summary
 void addDefaultChannel(String id)
          Adds the channel to the list of channels of the AbstractService.
 void addDestination(Destination destination)
          Adds the Destination instance to the list of destinations known by the AbstractService.
 Destination createDestination(String id)
          Creates a Destination instance, sets its id, sets it manageable if the AbstractService that created it is manageable, and sets its Service to the AbstractService that created it.
 ConfigMap describeService(Endpoint endpoint)
          Returns a ConfigMap service properties that the client needs.
 String getDefaultAdapter()
          Returns the id of the default adapter of the AbstractService.
 List getDefaultChannels()
          Returns the list of channel ids of the AbstractService.
 Destination getDestination(Message message)
          Returns the Destination that the Message targets.
 Destination getDestination(String id)
          Returns the Destination with the specified id or null if no Destination with id exists.
 Map getDestinations()
          Returns the Map of Destination ids and instances.
 MessageBroker getMessageBroker()
          Returns the MessageBroker of the AbstractService.
 Map getRegisteredAdapters()
          Returns the adapters registered with the AbstractService.
 String registerAdapter(String id, String adapterClass)
          Registers the adapter with the AbstractService.
 boolean removeDefaultChannel(String id)
          Removes the channel from the list of channels for the AbstractService.
 Destination removeDestination(String id)
          Removes the Destination from the list of destinations known by the AbstractService.
 Object serviceCommand(CommandMessage message)
          Handles a command routed to the service by the MessageBroker.
abstract  Object serviceMessage(Message message)
          Processes messages by invoking the requested destination's adapter.
 void setDefaultAdapter(String id)
          Sets the default adapter of the AbstractService.
 void setDefaultChannels(List ids)
          Sets the channel list of the AbstractService.
 void setId(String id)
          Sets the id of the AbstractService.
 void setMessageBroker(MessageBroker broker)
          Sets the MessageBroker of the AbstractService.
 void start()
          Starts the service if its associated MessageBroker is started.
 void stop()
          The default implementation of this method stops all of the destinations of the service.
 String unregisterAdapter(String id)
          Unregistered the adapter with the AbstractService and set the default adapter to null if needed.
 
Methods inherited from class flex.management.ManageableComponent
getControl, getId, getParent, initialize, isManaged, isStarted, isValid, setControl, setManaged, setParent
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface flex.messaging.services.Service
getId
 
Methods inherited from interface flex.management.Manageable
getControl, isManaged, setControl, setManaged
 
Methods inherited from interface flex.messaging.FlexComponent
isStarted
 
Methods inherited from interface flex.messaging.FlexConfigurable
initialize
 

Field Detail

LOG_CATEGORY

public static final String LOG_CATEGORY
Log category for AbstractService.

See Also:
Constant Field Values

LOG_CATEGORY_STARTUP_DESTINATION

public static final String LOG_CATEGORY_STARTUP_DESTINATION
Log category that captures startup information for service's destinations.

See Also:
Constant Field Values
Constructor Detail

AbstractService

public AbstractService()
Constructs an unmanaged AbstractService.


AbstractService

public AbstractService(boolean enableManagement)
Constructs an AbstractService with the indicated management.

Parameters:
enableManagement - true if the AbstractService is manageable; otherwise false.
Method Detail

start

public void start()
Starts the service if its associated MessageBroker is started. and if the service is not already running. The default implementation of this method starts all of the destinations of the service. If subclasses override, they must call super.start().

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

stop

public void stop()
The default implementation of this method stops all of the destinations of the service. If subclasses override, they must call super.stop().

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

getRegisteredAdapters

public Map getRegisteredAdapters()
Returns the adapters registered with the AbstractService.

Specified by:
getRegisteredAdapters in interface Service
Returns:
The Map of adapter id and classes.

registerAdapter

public String registerAdapter(String id,
                              String adapterClass)
Registers the adapter with the AbstractService.

Specified by:
registerAdapter in interface Service
Parameters:
id - The id of the adapter.
adapterClass - The class of the adapter.
Returns:
The previous adapter class that the id was associated with.

unregisterAdapter

public String unregisterAdapter(String id)
Unregistered the adapter with the AbstractService and set the default adapter to null if needed.

Specified by:
unregisterAdapter in interface Service
Parameters:
id - The id of the adapter.
Returns:
The adapter class that the id was associated with.

getDefaultAdapter

public String getDefaultAdapter()
Returns the id of the default adapter of the AbstractService.

Specified by:
getDefaultAdapter in interface Service
Returns:
defaultAdapterId The id of the default adapter of the AbstractService.

setDefaultAdapter

public void setDefaultAdapter(String id)
Sets the default adapter of the AbstractService.

Specified by:
setDefaultAdapter in interface Service
Parameters:
id - The id of the default adapter.

getDefaultChannels

public List getDefaultChannels()
Returns the list of channel ids of the AbstractService.

Specified by:
getDefaultChannels in interface Service
Returns:
The list of channel ids of the Service.

addDefaultChannel

public void addDefaultChannel(String id)
Adds the channel to the list of channels of the AbstractService. MessageBroker has to know the channel. Otherwise, the channel is not added to the list.

Specified by:
addDefaultChannel in interface Service
Parameters:
id - The id of the channel.

setDefaultChannels

public void setDefaultChannels(List ids)
Sets the channel list of the AbstractService. MessageBroker has to know the channels, otherwise they are not added to the list.

Specified by:
setDefaultChannels in interface Service
Parameters:
ids - List of channel ids.

removeDefaultChannel

public boolean removeDefaultChannel(String id)
Removes the channel from the list of channels for the AbstractService.

Specified by:
removeDefaultChannel in interface Service
Parameters:
id - The id of the channel.
Returns:
true if the list contained the channel id.

getDestination

public Destination getDestination(Message message)
Returns the Destination that the Message targets.

Specified by:
getDestination in interface Service
Parameters:
message - The message.
Returns:
The Destination that the Message targets.
Throws:
MessageException - if no such Destination exists.

getDestination

public Destination getDestination(String id)
Returns the Destination with the specified id or null if no Destination with id exists.

Specified by:
getDestination in interface Service
Parameters:
id - The id of the Destination.
Returns:
The Destination with the specified id or null.

getDestinations

public Map getDestinations()
Returns the Map of Destination ids and instances.

Specified by:
getDestinations in interface Service
Returns:
The Map of Destination ids and instances.

createDestination

public Destination createDestination(String id)
Creates a Destination instance, sets its id, sets it manageable if the AbstractService that created it is manageable, and sets its Service to the AbstractService that created it.

Specified by:
createDestination in interface Service
Parameters:
id - The id of the Destination.
Returns:
The Destination instanced created.

addDestination

public void addDestination(Destination destination)
Adds the Destination instance to the list of destinations known by the AbstractService. It also sets destination's service to this AbstractService instance. Note that Destination cannot be null, it cannot have a null id, and it cannot have an id of a Destination already registered with the AbstractService. Destination needs to be started if the AbstractService is already running.

Specified by:
addDestination in interface Service
Parameters:
destination - The Destination instance to be added.

removeDestination

public Destination removeDestination(String id)
Removes the Destination from the list of destinations known by the AbstractService.

Specified by:
removeDestination in interface Service
Parameters:
id - The id of the Destination.
Returns:
Previous Destination associated with the id.

setId

public void setId(String id)
Sets the id of the AbstractService. If the AbstractService has a MessageBroker assigned, it also updates the id in the MessageBroker.

Specified by:
setId in interface Service
Overrides:
setId in class ManageableComponent
Parameters:
id - The id of the ManageableComponent.

getMessageBroker

public MessageBroker getMessageBroker()
Returns the MessageBroker of the AbstractService.

Specified by:
getMessageBroker in interface Service
Returns:
MessageBroker of the AbstractService.

setMessageBroker

public void setMessageBroker(MessageBroker broker)
Sets the MessageBroker of the AbstractService. Removes the AbstractService from the old broker (if there was one) and adds to the list of services in the new broker.

Specified by:
setMessageBroker in interface Service
Parameters:
broker - MessageBroker of the AbstractService.

describeService

public ConfigMap describeService(Endpoint endpoint)
Returns a ConfigMap service properties that the client needs. By default, it returns null. Subclasses can override to return properties relevant to their implementation.

Specified by:
describeService in interface Service
Parameters:
endpoint - Endpoint used to filter the destinations of the service.
Returns:
ConfigMap of service properties.

serviceMessage

public abstract Object serviceMessage(Message message)
Processes messages by invoking the requested destination's adapter. Subclasses should provide their implementation.

Specified by:
serviceMessage in interface Service
Parameters:
message - The message sent by the MessageBroker.
Returns:
The result of the service.

serviceCommand

public Object serviceCommand(CommandMessage message)
Description copied from interface: Service
Handles a command routed to the service by the MessageBroker. Usually these are commands sent by one of the endpoints.

Specified by:
serviceCommand in interface Service
Parameters:
message - The message sent by the MessageBroker.
Returns:
The result of the service.


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/AbstractService.html