org.springframework.flex.messaging
Class MessageTemplate

java.lang.Object
  extended by org.springframework.flex.messaging.MessageTemplate
All Implemented Interfaces:
org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.InitializingBean

public class MessageTemplate
extends java.lang.Object
implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.BeanFactoryAware

Simple helper for sending Flex AsyncMessages from a Java client. The message will be routed through the MessageBroker to the specified MessageDestination. This allows for flexible routing of the message using whatever MessagingAdapter is configured for the target destination, be it the basic BlazeDS ActionScriptAdapter, one of the provided Spring adapters such as JmsAdapter or {TODO SpringIntegrationAdapter}, or some other custom adapter implementation.

Author:
Jeremy Grelle

Constructor Summary
MessageTemplate()
           
 
Method Summary
 void afterPropertiesSet()
          
 flex.messaging.messages.AsyncMessage createMessage()
          Creates a default AsyncMessage
 flex.messaging.messages.AsyncMessage createMessageForDestination(java.lang.String destination)
          Creates a default AsyncMessage for a specified destination
 java.lang.String getDefaultDestination()
          Returns the id of the default message destination for this template
 flex.messaging.MessageBroker getMessageBroker()
          Returns the MessageBroker for routing messages
 void send(AsyncMessageCreator creator)
          Sends a message created by the specified AsyncMessageCreator
 void send(java.lang.Object body)
          Sends a message with the specified body to the default destination.
 void send(java.lang.String destination, java.lang.Object body)
          Sends a message with the specified body to the specified destination
 void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
          
 void setDefaultDestination(java.lang.String defaultDestination)
          Sets the id of the default message destination for this template
 void setMessageBroker(flex.messaging.MessageBroker messageBroker)
          Sets the MessageBroker for routing messages
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageTemplate

public MessageTemplate()
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception

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

createMessage

public flex.messaging.messages.AsyncMessage createMessage()
Creates a default AsyncMessage

Returns:
the created message

createMessageForDestination

public flex.messaging.messages.AsyncMessage createMessageForDestination(java.lang.String destination)
Creates a default AsyncMessage for a specified destination

Parameters:
destination - the target destination for the message
Returns:
the created message

getDefaultDestination

public java.lang.String getDefaultDestination()
Returns the id of the default message destination for this template

Returns:
the default destination id

getMessageBroker

public flex.messaging.MessageBroker getMessageBroker()
Returns the MessageBroker for routing messages

Returns:
the message broker

send

public void send(AsyncMessageCreator creator)
Sends a message created by the specified AsyncMessageCreator

Parameters:
creator - the message creator

send

public void send(java.lang.Object body)
Sends a message with the specified body to the default destination.

Parameters:
body - the body of the message

send

public void send(java.lang.String destination,
                 java.lang.Object body)
Sends a message with the specified body to the specified destination

Parameters:
destination - the target destination id
body - the body of the message

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

setDefaultDestination

public void setDefaultDestination(java.lang.String defaultDestination)
Sets the id of the default message destination for this template

Parameters:
defaultDestination - the default destination id

setMessageBroker

public void setMessageBroker(flex.messaging.MessageBroker messageBroker)
Sets the MessageBroker for routing messages

Parameters:
messageBroker - the message broker