|
Spring BlazeDS Integration | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.flex.messaging.MessageTemplate
public class MessageTemplate
Simple helper for sending Flex AsyncMessage
s 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 IntegrationAdapter
, or some other custom adapter implementation.
This class should typically be configured as a Spring bean in the same ApplicationContext as the <flex:message-broker> tag
to allow injection of a Spring-managed MessageBroker
instance. When a single MessageBroker
is detected in the
ApplicationContext, it will be automatically injected into the MessageTemplate bean. If more than one MessageBroker
is
present (not typical), a reference to the correct MessageBroker
must be explicitly set for the setMessageBroker(MessageBroker)
property.
The MessageTemplate
may also be instantiated directly, in which case it will try to look up the ThreadLocal
MessageBroker
instance for the current request, but configuration as a Spring bean is strongly preferred.
Constructor Summary | |
---|---|
MessageTemplate()
|
Method Summary | |
---|---|
void |
afterPropertiesSet()
|
AsyncMessage |
createMessage()
Creates a default AsyncMessage |
AsyncMessage |
createMessageForDestination(String destination)
Creates a default AsyncMessage for a specified destination |
String |
getDefaultDestination()
Returns the id of the default message destination for this template |
MessageBroker |
getMessageBroker()
Returns the MessageBroker for routing messages |
void |
send(AsyncMessageCreator creator)
Sends a message created by the specified AsyncMessageCreator |
void |
send(Object body)
Sends a message with the specified body to the default destination. |
void |
send(String destination,
Object body)
Sends a message with the specified body to the specified destination |
void |
setBeanFactory(BeanFactory beanFactory)
|
void |
setDefaultDestination(String defaultDestination)
Sets the id of the default message destination for this template |
void |
setMessageBroker(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 |
---|
public MessageTemplate()
Method Detail |
---|
public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
Exception
public AsyncMessage createMessage()
AsyncMessage
public AsyncMessage createMessageForDestination(String destination)
AsyncMessage
for a specified destination
destination
- the target destination for the message
public String getDefaultDestination()
public MessageBroker getMessageBroker()
MessageBroker
for routing messages
public void send(AsyncMessageCreator creator)
AsyncMessageCreator
creator
- the message creatorpublic void send(Object body)
body
- the body of the messagepublic void send(String destination, Object body)
destination
- the target destination idbody
- the body of the messagepublic void setBeanFactory(BeanFactory beanFactory) throws BeansException
setBeanFactory
in interface BeanFactoryAware
BeansException
public void setDefaultDestination(String defaultDestination)
defaultDestination
- the default destination idpublic void setMessageBroker(MessageBroker messageBroker)
MessageBroker
for routing messages
messageBroker
- the message broker
|
Spring BlazeDS Integration | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |