Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.jms.remoting
Class JmsInvokerServiceExporter

    java.lang.Object
      org.springframework.remoting.support.RemotingSupport
          org.springframework.remoting.support.RemoteExporter
              org.springframework.remoting.support.RemoteInvocationBasedExporter
                  org.springframework.jms.remoting.JmsInvokerServiceExporter

All Implemented Interfaces:
  Aware, BeanClassLoaderAware, InitializingBean, SessionAwareMessageListener<javax.jms.Message>

    public class JmsInvokerServiceExporter

extends RemoteInvocationBasedExporter
implements SessionAwareMessageListener<javax.jms.Message>, InitializingBean

JMS message listener that exports the specified service bean as a JMS service endpoint, accessible via a JMS invoker proxy.

Note that this class implements Spring's `SessionAwareMessageListener` interface, since it requires access to the active JMS Session. Hence, this class can only be used with message listener containers which support the SessionAwareMessageListener interface (e.g. Spring's `DefaultMessageListenerContainer`).

Thanks to James Strachan for the original prototype that this JMS invoker mechanism was inspired by!

Since:
  2.0
Author:
  Juergen Hoeller, James Strachan
See Also:
  `JmsInvokerClientInterceptor`, `JmsInvokerProxyFactoryBean`

Field Summary

Fields inherited from class org.springframework.remoting.support.RemotingSupport
`logger`

Constructor Summary
`JmsInvokerServiceExporter()`

Method Summary
`void` | `afterPropertiesSet()` Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
`protected javax.jms.Message` | `createResponseMessage(javax.jms.Message request, javax.jms.Session session, RemoteInvocationResult result)` Create the invocation result response message.
`protected RemoteInvocation` | `onInvalidRequest(javax.jms.Message requestMessage)` Callback that is invoked by `readRemoteInvocation(javax.jms.Message)` when it encounters an invalid request message.
`void` | `onMessage(javax.jms.Message requestMessage, javax.jms.Session session)` Callback for processing a received JMS message.
`protected RemoteInvocation` | `readRemoteInvocation(javax.jms.Message requestMessage)` Read a RemoteInvocation from the given JMS message.
`void` | `setIgnoreInvalidRequests(boolean ignoreInvalidRequests)` Set whether invalidly formatted messages should be discarded.
`void` | `setMessageConverter(MessageConverter messageConverter)` Specify the MessageConverter to use for turning request messages into `RemoteInvocation` objects, as well as `RemoteInvocationResult` objects into response messages.
`protected void` | `writeRemoteInvocationResult(javax.jms.Message requestMessage, javax.jms.Session session, RemoteInvocationResult result)` Send the given RemoteInvocationResult as a JMS message to the originator.

Methods inherited from class org.springframework.remoting.support.RemoteInvocationBasedExporter
`getRemoteInvocationExecutor, invoke, invokeAndCreateResult, setRemoteInvocationExecutor`

Methods inherited from class org.springframework.remoting.support.RemoteExporter
`checkService, checkServiceInterface, getExporterName, getProxyForService, getService, getServiceInterface, setInterceptors, setRegisterTraceInterceptor, setService, setServiceInterface`

Methods inherited from class org.springframework.remoting.support.RemotingSupport
`getBeanClassLoader, overrideThreadContextClassLoader, resetThreadContextClassLoader, setBeanClassLoader`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### JmsInvokerServiceExporter

    public JmsInvokerServiceExporter()

Method Detail

### setMessageConverter

    public void setMessageConverter(MessageConverter messageConverter)

  Specify the MessageConverter to use for turning request messages into `RemoteInvocation` objects, as well as `RemoteInvocationResult` objects into response messages.

  Default is a `SimpleMessageConverter`, using a standard JMS `ObjectMessage` for each invocation / invocation result object.

  Custom implementations may generally adapt Serializables into special kinds of messages, or might be specifically tailored for translating RemoteInvocation(Result)s into specific kinds of messages.

### setIgnoreInvalidRequests

    public void setIgnoreInvalidRequests(boolean ignoreInvalidRequests)

  Set whether invalidly formatted messages should be discarded. Default is "true".

  Switch this flag to "false" to throw an exception back to the listener container. This will typically lead to redelivery of the message, which is usually undesirable - since the message content will be the same (that is, still invalid).

### afterPropertiesSet

    public void afterPropertiesSet()

  Description copied from interface: `InitializingBean`
  Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).

  This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.

  Specified by:
    `afterPropertiesSet` in interface `InitializingBean`

### onMessage

    public void onMessage(javax.jms.Message requestMessage,
                          javax.jms.Session session)
                   throws javax.jms.JMSException

  Description copied from interface: `SessionAwareMessageListener`
  Callback for processing a received JMS message.

  Implementors are supposed to process the given Message, typically sending reply messages through the given Session.

  Specified by:
    `onMessage` in interface `SessionAwareMessageListener<javax.jms.Message>`
  Parameters:
    `requestMessage` - the received JMS message (never `null`)
    `session` - the underlying JMS Session (never `null`)
  Throws:
    `javax.jms.JMSException` - if thrown by JMS methods

### readRemoteInvocation

    protected RemoteInvocation readRemoteInvocation(javax.jms.Message requestMessage)
                                             throws javax.jms.JMSException

  Read a RemoteInvocation from the given JMS message.

  Parameters:
    `requestMessage` - current request message
  Returns:
    the RemoteInvocation object (or `null` in case of an invalid message that will simply be ignored)
  Throws:
    `javax.jms.JMSException` - in case of message access failure

### writeRemoteInvocationResult

    protected void writeRemoteInvocationResult(javax.jms.Message requestMessage,
                                               javax.jms.Session session,
                                               RemoteInvocationResult result)
                                        throws javax.jms.JMSException

  Send the given RemoteInvocationResult as a JMS message to the originator.

  Parameters:
    `requestMessage` - current request message
    `session` - the JMS Session to use
    `result` - the RemoteInvocationResult object
  Throws:
    `javax.jms.JMSException` - if thrown by trying to send the message

### createResponseMessage

    protected javax.jms.Message createResponseMessage(javax.jms.Message request,
                                                      javax.jms.Session session,
                                                      RemoteInvocationResult result)
                                               throws javax.jms.JMSException

  Create the invocation result response message.

  The default implementation creates a JMS ObjectMessage for the given RemoteInvocationResult object. It sets the response's correlation id to the request message's correlation id, if any; otherwise to the request message id.

  Parameters:
    `request` - the original request message
    `session` - the JMS session to use
    `result` - the invocation result
  Returns:
    the message response to send
  Throws:
    `javax.jms.JMSException` - if creating the messsage failed

### onInvalidRequest

    protected RemoteInvocation onInvalidRequest(javax.jms.Message requestMessage)
                                         throws javax.jms.JMSException

  Callback that is invoked by `readRemoteInvocation(javax.jms.Message)` when it encounters an invalid request message.

  The default implementation either discards the invalid message or throws a MessageFormatException - according to the "ignoreInvalidRequests" flag, which is set to "true" (that is, discard invalid messages) by default.

  Parameters:
    `requestMessage` - the invalid request message
  Returns:
    the RemoteInvocation to expose for the invalid request (typically `null` in case of an invalid message that will simply be ignored)
  Throws:
    `javax.jms.JMSException` - in case of the invalid request supposed to lead to an exception (instead of ignoring it)
  See Also:
    `readRemoteInvocation(javax.jms.Message)`, `setIgnoreInvalidRequests(boolean)`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD