|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.jms.remoting.JmsInvokerClientInterceptor
public class JmsInvokerClientInterceptor
Interceptor for accessing a JMS-based remote service.
To be configured with a QueueConnectionFactory and a target queue (either as Queue reference or as queue name).
setConnectionFactory(javax.jms.QueueConnectionFactory)
,
setQueue(java.lang.Object)
,
setQueueName(java.lang.String)
,
JmsInvokerServiceExporter
,
JmsInvokerProxyFactoryBean
Constructor Summary | |
---|---|
JmsInvokerClientInterceptor()
|
Method Summary | |
---|---|
void |
afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware). |
protected RemoteInvocation |
createRemoteInvocation(MethodInvocation methodInvocation)
Create a new RemoteInvocation object for the given AOP method invocation. |
protected Message |
createRequestMessage(Session session,
RemoteInvocation invocation)
Create the invoker request message. |
protected RemoteInvocationResult |
executeRequest(RemoteInvocation invocation)
Execute the given remote invocation, sending an invoker request message to this accessor's target queue and waiting for a corresponding response. |
protected RemoteInvocationResult |
extractInvocationResult(Message responseMessage)
Extract the invocation result from the response message. |
protected QueueConnectionFactory |
getConnectionFactory()
Return the QueueConnectionFactory to use for obtaining JMS QueueConnections. |
Object |
invoke(MethodInvocation methodInvocation)
|
protected RemoteInvocationResult |
onInvalidResponse(Message responseMessage)
Callback that is invoked by extractInvocationResult
when it encounters an invalid response message. |
protected Object |
recreateRemoteInvocationResult(RemoteInvocationResult result)
Recreate the invocation result contained in the given RemoteInvocationResult object. |
protected Queue |
resolveQueue(Session session)
Resolve this accessor's target queue. |
protected Queue |
resolveQueueName(Session session,
String queueName)
Resolve the given queue name into a JMS Queue ,
via this accessor's DestinationResolver . |
void |
setConnectionFactory(QueueConnectionFactory connectionFactory)
Set the QueueConnectionFactory to use for obtaining JMS QueueConnections. |
void |
setDestinationResolver(DestinationResolver destinationResolver)
Set the DestinationResolver that is to be used to resolve Queue references for this accessor. |
void |
setQueue(Object queue)
Set the target Queue to send invoker requests to. |
void |
setQueueName(String queueName)
Set the name of target queue to send invoker requests to. |
void |
setRemoteInvocationFactory(RemoteInvocationFactory remoteInvocationFactory)
Set the RemoteInvocationFactory to use for this accessor. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JmsInvokerClientInterceptor()
Method Detail |
---|
public void setConnectionFactory(QueueConnectionFactory connectionFactory)
protected QueueConnectionFactory getConnectionFactory()
public void setQueue(Object queue)
public void setQueueName(String queueName)
public void setDestinationResolver(DestinationResolver destinationResolver)
The default resolver is a DynamicDestinationResolver. Specify a JndiDestinationResolver for resolving destination names as JNDI locations.
destinationResolver
- the DestinationResolver that is to be usedDynamicDestinationResolver
,
JndiDestinationResolver
public void setRemoteInvocationFactory(RemoteInvocationFactory remoteInvocationFactory)
A custom invocation factory can add further context information to the invocation, for example user credentials.
public void afterPropertiesSet()
InitializingBean
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.
afterPropertiesSet
in interface InitializingBean
public Object invoke(MethodInvocation methodInvocation) throws Throwable
invoke
in interface MethodInterceptor
Throwable
protected RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation)
Can be overridden in subclasses to provide custom RemoteInvocation subclasses, containing additional invocation parameters like user credentials. Note that it is preferable to use a custom RemoteInvocationFactory which is a reusable strategy.
methodInvocation
- the current AOP method invocation
RemoteInvocationFactory.createRemoteInvocation(org.aopalliance.intercept.MethodInvocation)
protected RemoteInvocationResult executeRequest(RemoteInvocation invocation) throws JMSException
The default implementation is based on a JMS QueueRequestor, using a freshly obtained JMS Session.
invocation
- the RemoteInvocation to execute
JMSException
- in case of JMS failureprotected Queue resolveQueue(Session session) throws JMSException
session
- the current JMS Session
JMSException
- if resolution failedprotected Queue resolveQueueName(Session session, String queueName) throws JMSException
Queue
,
via this accessor's DestinationResolver
.
session
- the current JMS SessionqueueName
- the name of the queue
JMSException
- if resolution failedsetDestinationResolver(org.springframework.jms.support.destination.DestinationResolver)
protected Message createRequestMessage(Session session, RemoteInvocation invocation) throws JMSException
The default implementation creates a JMS ObjectMessage for the given RemoteInvocation object.
session
- the current JMS Sessioninvocation
- the remote invocation to send
JMSException
- if the message could not be createdprotected RemoteInvocationResult extractInvocationResult(Message responseMessage) throws JMSException
The default implementation expects a JMS ObjectMessage carrying
a RemoteInvocationResult object. If an invalid response message is
encountered, the onInvalidResponse
callback gets invoked.
responseMessage
- the response message
JMSException
- is thrown if a JMS exception occursonInvalidResponse(javax.jms.Message)
protected RemoteInvocationResult onInvalidResponse(Message responseMessage) throws JMSException
extractInvocationResult
when it encounters an invalid response message.
The default implementation throws a MessageFormatException.
responseMessage
- the invalid response message
JMSException
- if the invalid response should lead
to an infrastructure exception propagated to the callerextractInvocationResult(javax.jms.Message)
protected Object recreateRemoteInvocationResult(RemoteInvocationResult result) throws Throwable
Can be overridden in subclass to provide custom recreation, potentially processing the returned result object.
result
- the RemoteInvocationResult to recreate
Throwable
- if the invocation result is an exceptionRemoteInvocationResult.recreate()
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |