Spring BlazeDS Integration

org.springframework.flex.core
Class AbstractDestinationFactory

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

public abstract class AbstractDestinationFactory
extends Object
implements InitializingBean, DisposableBean, BeanNameAware, BeanFactoryAware, ServletConfigAware

Base class for BlazeDS destination factories.

Author:
Jeremy Grelle, Mark Fisher

Constructor Summary
AbstractDestinationFactory()
           
 
Method Summary
 void afterPropertiesSet()
          
protected  void configureAdapter(Destination destination)
          Configure the service adapter for the destination.
protected abstract  Destination createDestination(String destinationId, MessageBroker broker)
          Create a specific destination and add it to the MessageBroker
 void destroy()
          
protected abstract  void destroyDestination(String destinationId, MessageBroker broker)
          Stops and removes the specified destination from the MessageBroker
protected  BeanFactory getBeanFactory()
          Expose the BeanFactory to subclasses
protected  String getDestinationId()
          Returns the id for the destination created by this factory
protected abstract  Service getTargetService(MessageBroker broker)
          Returns the target Service that will manage the destination
protected abstract  void initializeDestination(Destination destination)
          Perform any necessary initialization logic on the created Destination
 void setBeanFactory(BeanFactory beanFactory)
          
 void setBeanName(String name)
          
 void setChannels(String[] channels)
          Specify the BlazeDS channel ids (in order of preference) for communication with this destination
 void setDestinationId(String destinationId)
          Specify the id for the destination
 void setMessageBroker(MessageBroker broker)
          Set the MessageBroker where this destination will be created.
 void setServiceAdapter(String serviceAdapter)
          Specify a custom service adapter id to be used by this destination
 void setServletConfig(javax.servlet.ServletConfig servletConfig)
          
 
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 Exception

Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

destroy

public final void destroy()
                   throws Exception

Specified by:
destroy in interface DisposableBean
Throws:
Exception

setBeanFactory

public void setBeanFactory(BeanFactory beanFactory)
                    throws BeansException

Specified by:
setBeanFactory in interface BeanFactoryAware
Throws:
BeansException

setBeanName

public void setBeanName(String name)

Specified by:
setBeanName in interface BeanNameAware

setChannels

public void setChannels(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(String destinationId)
Specify the id for the destination

Parameters:
destinationId - the id to set

setMessageBroker

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

Parameters:
broker - the message broker for this destination

setServiceAdapter

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

Parameters:
serviceAdapter - the custom service adapter id

setServletConfig

public void setServletConfig(javax.servlet.ServletConfig servletConfig)

Specified by:
setServletConfig in interface ServletConfigAware

configureAdapter

protected void configureAdapter(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 Destination createDestination(String destinationId,
                                                 MessageBroker broker)
                                          throws 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:
Exception - if the destination could not be created successfully

destroyDestination

protected abstract void destroyDestination(String destinationId,
                                           MessageBroker broker)
                                    throws 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:
Exception - if the destination could not be destroyed successfully

getBeanFactory

protected BeanFactory getBeanFactory()
Expose the BeanFactory to subclasses

Returns:
the BeanFactory

getDestinationId

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

Returns:
the destination id

getTargetService

protected abstract Service getTargetService(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(Destination destination)
                                       throws Exception
Perform any necessary initialization logic on the created Destination

Parameters:
destination - the created destination
Throws:
Exception - if initialization fails

Spring BlazeDS Integration

Copyright © 2011. All Rights Reserved.