org.springframework.flex.core
Class AbstractDestinationFactory

java.lang.Object
  extended by org.springframework.flex.core.AbstractDestinationFactory
All Implemented Interfaces:
org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean
Direct Known Subclasses:
MessageDestinationFactory, RemotingDestinationExporter

public abstract class AbstractDestinationFactory
extends java.lang.Object
implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.BeanFactoryAware

Base class for BlazeDS destination factories.

Author:
Jeremy Grelle, Mark Fisher

Constructor Summary
AbstractDestinationFactory()
           
 
Method Summary
 void afterPropertiesSet()
          
protected  void configureAdapter(flex.messaging.Destination destination)
          Configure the service adapter for the destination.
protected abstract  flex.messaging.Destination createDestination(java.lang.String destinationId, flex.messaging.MessageBroker broker)
          Create a specific destination and add it to the MessageBroker
 void destroy()
          
protected abstract  void destroyDestination(java.lang.String destinationId, flex.messaging.MessageBroker broker)
          Stops and removes the specified destination from the MessageBroker
protected  org.springframework.beans.factory.BeanFactory getBeanFactory()
          Expose the BeanFactory to subclasses
protected  java.lang.String getDestinationId()
          Returns the id for the destination created by this factory
protected abstract  flex.messaging.services.Service getTargetService(flex.messaging.MessageBroker broker)
          Returns the target Service that will manage the destination
protected abstract  void initializeDestination(flex.messaging.Destination destination)
          Perform any necessary initialization logic on the created Destination
 void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
          
 void setBeanName(java.lang.String name)
          
 void setChannels(java.lang.String[] channels)
          Specify the BlazeDS channel ids (in order of preference) for communication with this destination
 void setDestinationId(java.lang.String destinationId)
          Specify the id for the destination
 void setMessageBroker(flex.messaging.MessageBroker broker)
          Set the MessageBroker where this destination will be created.
 void setServiceAdapter(java.lang.String serviceAdapter)
          Specify a custom service adapter id to be used by this destination
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDestinationFactory

public AbstractDestinationFactory()
Method Detail

afterPropertiesSet

public final void afterPropertiesSet()
                              throws java.lang.Exception

Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception

destroy

public final void destroy()
                   throws java.lang.Exception

Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean
Throws:
java.lang.Exception

setBeanFactory

public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
                    throws org.springframework.beans.BeansException

Specified by:
setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
Throws:
org.springframework.beans.BeansException

setBeanName

public void setBeanName(java.lang.String name)

Specified by:
setBeanName in interface org.springframework.beans.factory.BeanNameAware

setChannels

public void setChannels(java.lang.String[] channels)
Specify the BlazeDS channel ids (in order of preference) for communication with this destination

Parameters:
channels - an array of BlazeDS channel ids

setDestinationId

public void setDestinationId(java.lang.String destinationId)
Specify the id for the destination

Parameters:
destinationId - the id to set

setMessageBroker

public void setMessageBroker(flex.messaging.MessageBroker broker)
Set the MessageBroker where this destination will be created.

Parameters:
broker - the message broker for this destination

setServiceAdapter

public void setServiceAdapter(java.lang.String serviceAdapter)
Specify a custom service adapter id to be used by this destination

Parameters:
serviceAdapter - the custom service adapter id

configureAdapter

protected void configureAdapter(flex.messaging.Destination destination)
Configure the service adapter for the destination.

This implementation will first search the BeanFactory for a bean with a matching id and use it if found. Otherwise the normal createAdapter method on the destination will be called.

May be overridden by subclasses that wish to specify custom adapter creation logic.

Parameters:
destination - the destination being created

createDestination

protected abstract flex.messaging.Destination createDestination(java.lang.String destinationId,
                                                                flex.messaging.MessageBroker broker)
                                                         throws java.lang.Exception
Create a specific destination and add it to the MessageBroker

Parameters:
destinationId - the id of the destination to create
broker - the MessageBroker where the destination should be created
Returns:
the created destination
Throws:
java.lang.Exception - if the destination could not be created successfully

destroyDestination

protected abstract void destroyDestination(java.lang.String destinationId,
                                           flex.messaging.MessageBroker broker)
                                    throws java.lang.Exception
Stops and removes the specified destination from the MessageBroker

Parameters:
destinationId - the id of the destination being destroyed
broker - the MessageBroker from which the destination must be removed
Throws:
java.lang.Exception - if the destination could not be destroyed successfully

getBeanFactory

protected org.springframework.beans.factory.BeanFactory getBeanFactory()
Expose the BeanFactory to subclasses

Returns:
the BeanFactory

getDestinationId

protected java.lang.String getDestinationId()
Returns the id for the destination created by this factory

Returns:
the destination id

getTargetService

protected abstract flex.messaging.services.Service getTargetService(flex.messaging.MessageBroker broker)
Returns the target Service that will manage the destination

Parameters:
broker - the MessageBroker that controls the service
Returns:
the service

initializeDestination

protected abstract void initializeDestination(flex.messaging.Destination destination)
                                       throws java.lang.Exception
Perform any necessary initialization logic on the created Destination

Parameters:
destination - the created destination
Throws:
java.lang.Exception - if initialization fails