org.logicblaze.lingo.jms
Class JmsClientInterceptor

java.lang.Object
  extended by org.springframework.remoting.support.RemotingSupport
      extended by org.springframework.remoting.support.RemoteAccessor
          extended by org.springframework.remoting.support.UrlBasedRemoteAccessor
              extended by org.springframework.remoting.support.RemoteInvocationBasedAccessor
                  extended by org.logicblaze.lingo.jms.JmsClientInterceptor
All Implemented Interfaces:
org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean
Direct Known Subclasses:
JmsProxyFactoryBean

public class JmsClientInterceptor
extends org.springframework.remoting.support.RemoteInvocationBasedAccessor
implements org.aopalliance.intercept.MethodInterceptor, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean

Interceptor for accessing a JMS based service which must be configured with a LingoRemoteInvocationFactory instance.

Author:
James Strachan
See Also:
RemoteAccessor.setServiceInterface(java.lang.Class), UrlBasedRemoteAccessor.setServiceUrl(java.lang.String), JmsServiceExporter, JmsProxyFactoryBean

Field Summary
 
Fields inherited from class org.springframework.remoting.support.RemotingSupport
logger
 
Constructor Summary
JmsClientInterceptor()
           
JmsClientInterceptor(Requestor requestor)
           
JmsClientInterceptor(Requestor requestor, LingoRemoteInvocationFactory factory)
           
 
Method Summary
 void afterPropertiesSet()
           
protected  AsyncReplyHandler createAsyncHandler(Object value)
           
protected  MetadataStrategy createMetadataStrategy()
          Factory method to create a default metadata strategy if none is configured
protected  LingoRemoteInvocationFactory createRemoteInvocationFactory()
          Factory method to create a default lingo based invocation factory if none is configured
protected  Requestor createRequestor()
           
protected  ResultJoinHandler createResultJoinHandler(org.aopalliance.intercept.MethodInvocation methodInvocation, MethodMetadata metadata)
           
 void destroy()
           
 String getClientID()
           
 javax.jms.ConnectionFactory getConnectionFactory()
           
 javax.jms.Destination getDestination()
           
 int getJmsPriority()
           
 String getJmsType()
           
 Marshaller getMarshaller()
           
 Map getMessageProperties()
           
 MetadataStrategy getMetadataStrategy()
           
 long getMultipleResponseTimeout()
           
 JmsProducerConfig getProducerConfig()
           
 long getRemoteReferenceTimeout()
           
 Requestor getRequestor()
           
 javax.jms.Destination getResponseDestination()
           
 long getResponseTimeout()
           
 int getTimeToLive()
           
 Object invoke(org.aopalliance.intercept.MethodInvocation methodInvocation)
           
protected  boolean isMultipleResponse(org.aopalliance.intercept.MethodInvocation methodInvocation, MethodMetadata metadata)
          Returns true if this method expects multiple response messages such as when sending a message over a topic.
 boolean isMultipleResponsesExpected()
           
 boolean isPersistentDelivery()
           
protected  void populateHeaders(javax.jms.Message requestMessage)
           
protected  Object recreateRemoteInvocationResult(org.springframework.remoting.support.RemoteInvocationResult result)
          Recreate the invocation result contained in the given RemoteInvocationResult object.
protected  Object remoteReference(Class type, Object value)
           
protected  void replaceRemoteReferences(LingoInvocation invocation, MethodMetadata metadata)
           
 void setClientID(String clientID)
          Sets the JMS connections unique clientID.
 void setConnectionFactory(javax.jms.ConnectionFactory connectionFactory)
          Used to create a default Requestor if no requestor is explicitly configured.
 void setCorrelationID(String correlationID)
           
 void setDestination(javax.jms.Destination destination)
          Sets the destination used to make requests
 void setJmsPriority(int jmsPriority)
          Sets the JMS priority of the request message
 void setJmsType(String jmsType)
          Sets the JMS message type string which is appended to messages if set
 void setMarshaller(Marshaller marshaller)
           
 void setMessageProperties(Map messageProperties)
          Sets the message properties to be added to each message.
 void setMetadataStrategy(MetadataStrategy metadataStrategy)
           
 void setMultipleResponsesExpected(boolean multipleResponsesExpected)
          Sets whether or not multiple response messages are expected.
 void setMultipleResponseTimeout(long multipleResponseTimeout)
          Sets the maximum amount of time to wait for multiple results to come back if communicating with multiple servers and aggregating together the results.
 void setPersistentDelivery(boolean persistent)
          Sets the delivery mode to be persistent or non-persistent.
 void setProducerConfig(JmsProducerConfig producerConfig)
          Sets the configuration of the producer used to send back responses
 void setRemoteReferenceTimeout(long remoteReferenceTimeout)
          Sets the maximum amount of time an inactive remote object reference will keep around until it is garbage collected.
 void setRequestor(Requestor requestor)
           
 void setResponseDestination(javax.jms.Destination responseDestination)
          Sets the destination used to consume responses on - or null and a temporary queue will be created.
 void setResponseTimeout(long responseTimeout)
          Sets the maximum amount of time (in milliseconds) to wait for responses to come back before timing out the request.
 void setTimeToLive(int timeToLive)
          Sets the JMS expiration timeout (in milliseconds) of the request message
 
Methods inherited from class org.springframework.remoting.support.RemoteInvocationBasedAccessor
createRemoteInvocation, getRemoteInvocationFactory, setRemoteInvocationFactory
 
Methods inherited from class org.springframework.remoting.support.UrlBasedRemoteAccessor
getServiceUrl, setServiceUrl
 
Methods inherited from class org.springframework.remoting.support.RemoteAccessor
getServiceInterface, 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

JmsClientInterceptor

public JmsClientInterceptor()

JmsClientInterceptor

public JmsClientInterceptor(Requestor requestor)

JmsClientInterceptor

public JmsClientInterceptor(Requestor requestor,
                            LingoRemoteInvocationFactory factory)
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Overrides:
afterPropertiesSet in class org.springframework.remoting.support.UrlBasedRemoteAccessor

invoke

public Object invoke(org.aopalliance.intercept.MethodInvocation methodInvocation)
              throws Throwable
Specified by:
invoke in interface org.aopalliance.intercept.MethodInterceptor
Throws:
Throwable

destroy

public void destroy()
             throws Exception
Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean
Throws:
Exception

getRequestor

public Requestor getRequestor()

setRequestor

public void setRequestor(Requestor requestor)

getDestination

public javax.jms.Destination getDestination()

setDestination

public void setDestination(javax.jms.Destination destination)
Sets the destination used to make requests

Parameters:
destination -

getResponseDestination

public javax.jms.Destination getResponseDestination()

setResponseDestination

public void setResponseDestination(javax.jms.Destination responseDestination)
Sets the destination used to consume responses on - or null and a temporary queue will be created.

Parameters:
responseDestination -

setCorrelationID

public void setCorrelationID(String correlationID)

getJmsType

public String getJmsType()

setJmsType

public void setJmsType(String jmsType)
Sets the JMS message type string which is appended to messages if set


getMessageProperties

public Map getMessageProperties()

getJmsPriority

public int getJmsPriority()

setJmsPriority

public void setJmsPriority(int jmsPriority)
Sets the JMS priority of the request message


getTimeToLive

public int getTimeToLive()

setTimeToLive

public void setTimeToLive(int timeToLive)
Sets the JMS expiration timeout (in milliseconds) of the request message


setMessageProperties

public void setMessageProperties(Map messageProperties)
Sets the message properties to be added to each message. Note that the keys should be Strings and the values should be primitive types.


getMarshaller

public Marshaller getMarshaller()

setMarshaller

public void setMarshaller(Marshaller marshaller)

getConnectionFactory

public javax.jms.ConnectionFactory getConnectionFactory()

setConnectionFactory

public void setConnectionFactory(javax.jms.ConnectionFactory connectionFactory)
Used to create a default Requestor if no requestor is explicitly configured.


getProducerConfig

public JmsProducerConfig getProducerConfig()

setProducerConfig

public void setProducerConfig(JmsProducerConfig producerConfig)
Sets the configuration of the producer used to send back responses


isPersistentDelivery

public boolean isPersistentDelivery()

setPersistentDelivery

public void setPersistentDelivery(boolean persistent)
Sets the delivery mode to be persistent or non-persistent.


getClientID

public String getClientID()

setClientID

public void setClientID(String clientID)
Sets the JMS connections unique clientID. This is optional unless you wish to use durable topic subscriptions. Only one connection can have a given clientID at any time.


getMetadataStrategy

public MetadataStrategy getMetadataStrategy()

setMetadataStrategy

public void setMetadataStrategy(MetadataStrategy metadataStrategy)

isMultipleResponsesExpected

public boolean isMultipleResponsesExpected()

setMultipleResponsesExpected

public void setMultipleResponsesExpected(boolean multipleResponsesExpected)
Sets whether or not multiple response messages are expected. Typically multiple responses are only expected when the getDestination() method returns a Topic but there could be circumstances when sending a request to a queue results in messages being fanned out to many servers which could all respond.


getRemoteReferenceTimeout

public long getRemoteReferenceTimeout()

setRemoteReferenceTimeout

public void setRemoteReferenceTimeout(long remoteReferenceTimeout)
Sets the maximum amount of time an inactive remote object reference will keep around until it is garbage collected.


getMultipleResponseTimeout

public long getMultipleResponseTimeout()

setMultipleResponseTimeout

public void setMultipleResponseTimeout(long multipleResponseTimeout)
Sets the maximum amount of time to wait for multiple results to come back if communicating with multiple servers and aggregating together the results.


getResponseTimeout

public long getResponseTimeout()

setResponseTimeout

public void setResponseTimeout(long responseTimeout)
Sets the maximum amount of time (in milliseconds) to wait for responses to come back before timing out the request. You should typically set this value greater than the getTimeToLive() property which is used to set the expiration time on the request message.


isMultipleResponse

protected boolean isMultipleResponse(org.aopalliance.intercept.MethodInvocation methodInvocation,
                                     MethodMetadata metadata)
Returns true if this method expects multiple response messages such as when sending a message over a topic.


populateHeaders

protected void populateHeaders(javax.jms.Message requestMessage)
                        throws javax.jms.JMSException
Throws:
javax.jms.JMSException

recreateRemoteInvocationResult

protected Object recreateRemoteInvocationResult(org.springframework.remoting.support.RemoteInvocationResult result)
                                         throws Throwable
Recreate the invocation result contained in the given RemoteInvocationResult object. The default implementation calls the default recreate method.

Can be overridden in subclass to provide custom recreation, potentially processing the returned result object.

Overrides:
recreateRemoteInvocationResult in class org.springframework.remoting.support.RemoteInvocationBasedAccessor
Parameters:
result - the RemoteInvocationResult to recreate
Returns:
a return value if the invocation result is a successful return
Throws:
Throwable - if the invocation result is an exception
See Also:
RemoteInvocationResult.recreate()

replaceRemoteReferences

protected void replaceRemoteReferences(LingoInvocation invocation,
                                       MethodMetadata metadata)

remoteReference

protected Object remoteReference(Class type,
                                 Object value)

createResultJoinHandler

protected ResultJoinHandler createResultJoinHandler(org.aopalliance.intercept.MethodInvocation methodInvocation,
                                                    MethodMetadata metadata)

createAsyncHandler

protected AsyncReplyHandler createAsyncHandler(Object value)

createRequestor

protected Requestor createRequestor()
                             throws javax.jms.JMSException
Throws:
javax.jms.JMSException

createRemoteInvocationFactory

protected LingoRemoteInvocationFactory createRemoteInvocationFactory()
Factory method to create a default lingo based invocation factory if none is configured


createMetadataStrategy

protected MetadataStrategy createMetadataStrategy()
Factory method to create a default metadata strategy if none is configured

Returns:


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