org.logicblaze.lingo.jms.marshall
Class DefaultMarshaller

java.lang.Object
  extended by org.logicblaze.lingo.jms.marshall.DefaultMarshaller
All Implemented Interfaces:
HeaderMarshaller, Marshaller
Direct Known Subclasses:
XStreamMarshaller

public class DefaultMarshaller
extends Object
implements Marshaller, HeaderMarshaller

Represents the strategy of object marshalling of requests and responses in and out of JMS messages. Collaborates with HeaderMarshaller which captures the strategy for JMS header marshalling.

Version:
$Revision: 84 $

Field Summary
protected  HeaderMarshaller headerMarshaller
           
protected  HeaderMarshaller nativeHeaderMarshaller
           
 
Constructor Summary
DefaultMarshaller()
           
 
Method Summary
 void addResponseMessageHeaders(javax.jms.ObjectMessage answer, org.springframework.remoting.support.RemoteInvocationResult result, javax.jms.Message requestMessage)
          A strategy for derived classes to allow them to plug in custom header processing for responses
 void appendMessageHeaders(javax.jms.Message message, Requestor requestor, LingoInvocation invocation)
          A strategy method for derived classes to allow them a plugin point to perform custom header processing.
 void appendMessageHeaders(javax.jms.Message message, javax.jms.Session session, Object value)
           
 javax.jms.Message createObjectMessage(javax.jms.Session session, Object value)
          Creates a message for a Java Object for when distributing objects in collections
 javax.jms.Message createRequestMessage(Requestor requestor, LingoInvocation invocation)
          Creates the request message
 javax.jms.Message createResponseMessage(javax.jms.Session session, org.springframework.remoting.support.RemoteInvocationResult result, javax.jms.Message requestMessage)
          Creates the response message
 org.springframework.remoting.support.RemoteInvocationResult extractInvocationResult(javax.jms.Message message)
          Extracts the invocation result from the response message
 void handleInvocationHeaders(javax.jms.Message message)
          A strategy method to allow derived classes to process the headers in a special way.
 void handleInvocationResultHeaders(javax.jms.Message message)
          A strategy method to allow derived classes to process the headers in a special way
 void handleMessageHeaders(javax.jms.Message message)
          A strategy method to allow derived classes to process the headers in a special way
 boolean isIgnoreInvalidMessages()
           
protected  org.springframework.remoting.support.RemoteInvocationResult onInvalidClientMessage(javax.jms.Message message)
           
protected  org.springframework.remoting.support.RemoteInvocation onInvalidMessage(javax.jms.Message message)
          Handle invalid messages by just logging, though a different implementation may wish to throw exceptions
 Object readMessage(javax.jms.Message message)
          Extracts the body from the given JMS message
 org.springframework.remoting.support.RemoteInvocation readRemoteInvocation(javax.jms.Message message)
          Read a RemoteInvocation from the given JMS message
 void setHeaderMarshaller(HeaderMarshaller headerMarshaller)
           
 void setIgnoreInvalidMessages(boolean ignoreInvalidMessages)
          Sets whether invalidly formatted messages should be silently ignored or not
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nativeHeaderMarshaller

protected HeaderMarshaller nativeHeaderMarshaller

headerMarshaller

protected HeaderMarshaller headerMarshaller
Constructor Detail

DefaultMarshaller

public DefaultMarshaller()
Method Detail

setHeaderMarshaller

public void setHeaderMarshaller(HeaderMarshaller headerMarshaller)

createRequestMessage

public javax.jms.Message createRequestMessage(Requestor requestor,
                                              LingoInvocation invocation)
                                       throws javax.jms.JMSException
Description copied from interface: Marshaller
Creates the request message

Specified by:
createRequestMessage in interface Marshaller
invocation - the remote invocation to send
Throws:
javax.jms.JMSException - if the message could not be created

createResponseMessage

public javax.jms.Message createResponseMessage(javax.jms.Session session,
                                               org.springframework.remoting.support.RemoteInvocationResult result,
                                               javax.jms.Message requestMessage)
                                        throws javax.jms.JMSException
Description copied from interface: Marshaller
Creates the response message

Specified by:
createResponseMessage in interface Marshaller
Parameters:
session - the JMS session to use
result - the result invocation
requestMessage - the original request message
Returns:
the response message to send
Throws:
javax.jms.JMSException - if the message could not be created

extractInvocationResult

public org.springframework.remoting.support.RemoteInvocationResult extractInvocationResult(javax.jms.Message message)
                                                                                    throws javax.jms.JMSException
Description copied from interface: Marshaller
Extracts the invocation result from the response message

Specified by:
extractInvocationResult in interface Marshaller
Parameters:
message - the response message
Returns:
the invocation result
Throws:
javax.jms.JMSException - is thrown if a JMS exception occurs

readRemoteInvocation

public org.springframework.remoting.support.RemoteInvocation readRemoteInvocation(javax.jms.Message message)
                                                                           throws javax.jms.JMSException
Description copied from interface: Marshaller
Read a RemoteInvocation from the given JMS message

Specified by:
readRemoteInvocation in interface Marshaller
Parameters:
message - current JMS message
Returns:
the RemoteInvocation object
Throws:
javax.jms.JMSException

createObjectMessage

public javax.jms.Message createObjectMessage(javax.jms.Session session,
                                             Object value)
                                      throws javax.jms.JMSException
Description copied from interface: Marshaller
Creates a message for a Java Object for when distributing objects in collections

Specified by:
createObjectMessage in interface Marshaller
Throws:
javax.jms.JMSException

readMessage

public Object readMessage(javax.jms.Message message)
                   throws javax.jms.JMSException
Description copied from interface: Marshaller
Extracts the body from the given JMS message

Specified by:
readMessage in interface Marshaller
Throws:
javax.jms.JMSException

isIgnoreInvalidMessages

public boolean isIgnoreInvalidMessages()

setIgnoreInvalidMessages

public void setIgnoreInvalidMessages(boolean ignoreInvalidMessages)
Sets whether invalidly formatted messages should be silently ignored or not


onInvalidClientMessage

protected org.springframework.remoting.support.RemoteInvocationResult onInvalidClientMessage(javax.jms.Message message)
                                                                                      throws javax.jms.JMSException
Throws:
javax.jms.JMSException

onInvalidMessage

protected org.springframework.remoting.support.RemoteInvocation onInvalidMessage(javax.jms.Message message)
Handle invalid messages by just logging, though a different implementation may wish to throw exceptions


appendMessageHeaders

public void appendMessageHeaders(javax.jms.Message message,
                                 Requestor requestor,
                                 LingoInvocation invocation)
                          throws javax.jms.JMSException
Description copied from interface: HeaderMarshaller
A strategy method for derived classes to allow them a plugin point to perform custom header processing. This method is called when a message is being sent

Specified by:
appendMessageHeaders in interface HeaderMarshaller
Throws:
javax.jms.JMSException

appendMessageHeaders

public void appendMessageHeaders(javax.jms.Message message,
                                 javax.jms.Session session,
                                 Object value)
Specified by:
appendMessageHeaders in interface HeaderMarshaller

addResponseMessageHeaders

public void addResponseMessageHeaders(javax.jms.ObjectMessage answer,
                                      org.springframework.remoting.support.RemoteInvocationResult result,
                                      javax.jms.Message requestMessage)
                               throws javax.jms.JMSException
Description copied from interface: HeaderMarshaller
A strategy for derived classes to allow them to plug in custom header processing for responses

Specified by:
addResponseMessageHeaders in interface HeaderMarshaller
Throws:
javax.jms.JMSException

handleInvocationHeaders

public void handleInvocationHeaders(javax.jms.Message message)
Description copied from interface: HeaderMarshaller
A strategy method to allow derived classes to process the headers in a special way. This method is called when a message is received

Specified by:
handleInvocationHeaders in interface HeaderMarshaller

handleInvocationResultHeaders

public final void handleInvocationResultHeaders(javax.jms.Message message)
Description copied from interface: HeaderMarshaller
A strategy method to allow derived classes to process the headers in a special way

Specified by:
handleInvocationResultHeaders in interface HeaderMarshaller

handleMessageHeaders

public final void handleMessageHeaders(javax.jms.Message message)
Description copied from interface: HeaderMarshaller
A strategy method to allow derived classes to process the headers in a special way

Specified by:
handleMessageHeaders in interface HeaderMarshaller


Copyright © 2012 LogicBlaze, Inc.. All Rights Reserved.