Author: richard.opalka(a)jboss.com
Date: 2008-05-15 10:24:04 -0400 (Thu, 15 May 2008)
New Revision: 7045
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/DispatchImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java
Log:
ensure message context is always released
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientImpl.java 2008-05-15
13:59:34 UTC (rev 7044)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientImpl.java 2008-05-15
14:24:04 UTC (rev 7045)
@@ -263,106 +263,105 @@
CommonMessageContext msgContext = new SOAPMessageContextJAXWS();
MessageContextAssociation.pushMessageContext(msgContext);
- // The contents of the request context are used to initialize the message context
(see section 9.4.1)
- // prior to invoking any handlers (see chapter 9) for the outbound message. Each
property within the
- // request context is copied to the message context with a scope of HANDLER.
- Map<String, Object> reqContext = getBindingProvider().getRequestContext();
-
- if (this.wsrmSequence != null)
+ try
{
- if (RMConstant.PROTOCOL_OPERATION_QNAMES.contains(opName) == false)
+ // The contents of the request context are used to initialize the message
context (see section 9.4.1)
+ // prior to invoking any handlers (see chapter 9) for the outbound message. Each
property within the
+ // request context is copied to the message context with a scope of HANDLER.
+ Map<String, Object> reqContext =
getBindingProvider().getRequestContext();
+
+ if (this.wsrmSequence != null)
{
- if (this.wsrmSequence.getBackPort() != null)
+ if (RMConstant.PROTOCOL_OPERATION_QNAMES.contains(opName) == false)
{
- // rewrite ReplyTo to use client addressable back port
- Map<String, Object> requestContext =
getBindingProvider().getRequestContext();
- AddressingProperties addressingProps =
(AddressingProperties)requestContext.get(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND);
-
addressingProps.setReplyTo(AddressingBuilder.getAddressingBuilder().newEndpointReference(this.wsrmSequence.getBackPort()));
+ if (this.wsrmSequence.getBackPort() != null)
+ {
+ // rewrite ReplyTo to use client addressable back port
+ Map<String, Object> requestContext =
getBindingProvider().getRequestContext();
+ AddressingProperties addressingProps =
(AddressingProperties)requestContext.get(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND);
+
addressingProps.setReplyTo(AddressingBuilder.getAddressingBuilder().newEndpointReference(this.wsrmSequence.getBackPort()));
+ }
+ Map<String, Object> rmRequestContext = new HashMap<String,
Object>();
+ List<QName> outMsgs = new LinkedList<QName>();
+ wsrmSequence.newMessageNumber();
+ outMsgs.add(RMProvider.get().getConstants().getSequenceQName());
+ outMsgs.add(RMProvider.get().getConstants().getAckRequestedQName());
+ if (wsrmSequence.isAckRequested())
+ {
+ // piggy backing
+
outMsgs.add(RMProvider.get().getConstants().getSequenceAcknowledgementQName());
+ }
+ rmRequestContext.put(RMConstant.PROTOCOL_MESSAGES, outMsgs);
+ rmRequestContext.put(RMConstant.SEQUENCE_REFERENCE, wsrmSequence);
+ reqContext.put(RMConstant.REQUEST_CONTEXT, rmRequestContext);
}
- Map<String, Object> rmRequestContext = new HashMap<String,
Object>();
- List<QName> outMsgs = new LinkedList<QName>();
- wsrmSequence.newMessageNumber();
- outMsgs.add(RMProvider.get().getConstants().getSequenceQName());
- outMsgs.add(RMProvider.get().getConstants().getAckRequestedQName());
- if (wsrmSequence.isAckRequested())
- {
- // piggy backing
-
outMsgs.add(RMProvider.get().getConstants().getSequenceAcknowledgementQName());
- }
- rmRequestContext.put(RMConstant.PROTOCOL_MESSAGES, outMsgs);
- rmRequestContext.put(RMConstant.SEQUENCE_REFERENCE, wsrmSequence);
- reqContext.put(RMConstant.REQUEST_CONTEXT, rmRequestContext);
}
- }
- msgContext.putAll(reqContext);
+ msgContext.putAll(reqContext);
- try
- {
- Object retObj = invoke(opName, args, false);
- return retObj;
- }
- catch (Exception ex)
- {
- OperationMetaData opMetaData = getOperationMetaData();
- if (opMetaData.isOneWay())
+ try
{
- handleOneWayException(opMetaData, ex);
+ Object retObj = invoke(opName, args, false);
+ return retObj;
}
- else
+ catch (Exception ex)
{
- handleRemoteException(opMetaData, ex);
+ OperationMetaData opMetaData = getOperationMetaData();
+ if (opMetaData.isOneWay())
+ {
+ handleOneWayException(opMetaData, ex);
+ }
+ else
+ {
+ handleRemoteException(opMetaData, ex);
+ }
+ return null;
}
- return null;
- }
- finally
- {
- msgContext = MessageContextAssociation.peekMessageContext();
-
- try
+ finally
{
- if (this.wsrmSequence != null)
- {
- if (RMConstant.PROTOCOL_OPERATION_QNAMES.contains(opName) == false)
- {
- Map<String, Object> wsrmResCtx = (Map<String, Object>)
msgContext.get(RMConstant.RESPONSE_CONTEXT);
- if (wsrmResCtx != null)
- {
- RMConstants wsrmConstants = RMProvider.get().getConstants();
- Map<QName, RMSerializable> mapping = (Map<QName,
RMSerializable>)wsrmResCtx.get(RMConstant.PROTOCOL_MESSAGES_MAPPING);
- QName seq = wsrmConstants.getSequenceQName();
- if (mapping.keySet().contains(seq))
- {
- RMHelper.handleSequenceHeader((RMSequence)mapping.get(seq),
this.wsrmSequence);
- }
- QName seqAck = wsrmConstants.getSequenceAcknowledgementQName();
- if (mapping.keySet().contains(seqAck))
- {
-
RMHelper.handleSequenceAcknowledgementHeader((RMSequenceAcknowledgement)mapping.get(seqAck),
this.wsrmSequence);
- }
- QName ackReq = wsrmConstants.getAckRequestedQName();
- if (mapping.keySet().contains(ackReq))
- {
- RMHelper.handleAckRequestedHeader((RMAckRequested)mapping.get(ackReq),
this.wsrmSequence);
- }
- }
- }
- }
+ msgContext = MessageContextAssociation.peekMessageContext();
- // Copy the inbound msg properties to the binding's response context
- for (String key : msgContext.keySet())
- {
- Object value = msgContext.get(key);
- resContext.put(key, value);
- }
+ if (this.wsrmSequence != null)
+ {
+ if (RMConstant.PROTOCOL_OPERATION_QNAMES.contains(opName) == false)
+ {
+ Map<String, Object> wsrmResCtx = (Map<String, Object>)
msgContext.get(RMConstant.RESPONSE_CONTEXT);
+ if (wsrmResCtx != null)
+ {
+ RMConstants wsrmConstants = RMProvider.get().getConstants();
+ Map<QName, RMSerializable> mapping = (Map<QName,
RMSerializable>)wsrmResCtx.get(RMConstant.PROTOCOL_MESSAGES_MAPPING);
+ QName seq = wsrmConstants.getSequenceQName();
+ if (mapping.keySet().contains(seq))
+ {
+ RMHelper.handleSequenceHeader((RMSequence)mapping.get(seq),
this.wsrmSequence);
+ }
+ QName seqAck = wsrmConstants.getSequenceAcknowledgementQName();
+ if (mapping.keySet().contains(seqAck))
+ {
+
RMHelper.handleSequenceAcknowledgementHeader((RMSequenceAcknowledgement)mapping.get(seqAck),
this.wsrmSequence);
+ }
+ QName ackReq = wsrmConstants.getAckRequestedQName();
+ if (mapping.keySet().contains(ackReq))
+ {
+
RMHelper.handleAckRequestedHeader((RMAckRequested)mapping.get(ackReq),
this.wsrmSequence);
+ }
+ }
+ }
+ }
+ // Copy the inbound msg properties to the binding's response context
+ for (String key : msgContext.keySet())
+ {
+ Object value = msgContext.get(key);
+ resContext.put(key, value);
+ }
}
- finally
- {
- // Reset the message context association
- MessageContextAssociation.popMessageContext();
- }
}
+ finally
+ {
+ // Reset the message context association
+ MessageContextAssociation.popMessageContext();
+ }
}
protected CommonMessageContext processPivot(CommonMessageContext reqMessageContext)
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/DispatchImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/DispatchImpl.java 2008-05-15
13:59:34 UTC (rev 7044)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/DispatchImpl.java 2008-05-15
14:24:04 UTC (rev 7045)
@@ -211,78 +211,82 @@
// Associate a message context with the current thread
CommonMessageContext msgContext = new SOAPMessageContextJAXWS();
MessageContextAssociation.pushMessageContext(msgContext);
- msgContext.setEndpointMetaData(epMetaData);
- msgContext.setSOAPMessage(reqMsg);
- msgContext.putAll(reqContext);
- // Try to find out the operation metadata corresponding to the message we're
sending
- msgContext.setOperationMetaData(getOperationMetaData(epMetaData,reqMsg));
-
-
- // The contents of the request context are used to initialize the message context
(see section 9.4.1)
- // prior to invoking any handlers (see chapter 9) for the outbound message. Each
property within the
- // request context is copied to the message context with a scope of HANDLER.
- msgContext.put(MessageContextJAXWS.MESSAGE_OUTBOUND_PROPERTY, Boolean.TRUE);
-
- QName portName = epMetaData.getPortName();
try
{
- // Call the request handlers
- boolean handlerPass = callRequestHandlerChain(portName, handlerType[0]);
- handlerPass = handlerPass && callRequestHandlerChain(portName,
handlerType[1]);
- handlerPass = handlerPass && callRequestHandlerChain(portName,
handlerType[2]);
+ msgContext.setEndpointMetaData(epMetaData);
+ msgContext.setSOAPMessage(reqMsg);
+ msgContext.putAll(reqContext);
+ // Try to find out the operation metadata corresponding to the message we're
sending
+ msgContext.setOperationMetaData(getOperationMetaData(epMetaData,reqMsg));
- XOPContext.visitAndRestoreXOPData();
-
- // Handlers might have replaced the message
- reqMsg = (SOAPMessageImpl)msgContext.getSOAPMessage();
+ // The contents of the request context are used to initialize the message
context (see section 9.4.1)
+ // prior to invoking any handlers (see chapter 9) for the outbound message. Each
property within the
+ // request context is copied to the message context with a scope of HANDLER.
+ msgContext.put(MessageContextJAXWS.MESSAGE_OUTBOUND_PROPERTY, Boolean.TRUE);
- MessageAbstraction resMsg = null;
- if (handlerPass)
+ QName portName = epMetaData.getPortName();
+ try
{
- Map<String, Object> callProps = new HashMap<String,
Object>(getRequestContext());
- if (callProps.containsKey(BindingProvider.ENDPOINT_ADDRESS_PROPERTY)) {
- targetAddress = (String)
callProps.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
+ // Call the request handlers
+ boolean handlerPass = callRequestHandlerChain(portName, handlerType[0]);
+ handlerPass = handlerPass && callRequestHandlerChain(portName,
handlerType[1]);
+ handlerPass = handlerPass && callRequestHandlerChain(portName,
handlerType[2]);
+
+ XOPContext.visitAndRestoreXOPData();
+
+ // Handlers might have replaced the message
+ reqMsg = (SOAPMessageImpl)msgContext.getSOAPMessage();
+
+ MessageAbstraction resMsg = null;
+ if (handlerPass)
+ {
+ Map<String, Object> callProps = new HashMap<String,
Object>(getRequestContext());
+ if (callProps.containsKey(BindingProvider.ENDPOINT_ADDRESS_PROPERTY)) {
+ targetAddress = (String)
callProps.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
+ }
+ EndpointInfo epInfo = new EndpointInfo(epMetaData, targetAddress,
callProps);
+ resMsg = getRemotingConnection().invoke(reqMsg, epInfo, false);
+
+ //Pivot, switch to response ctx and save the response message there
+ msgContext = MessageContextJAXWS.processPivot(msgContext);
+ msgContext.setMessageAbstraction(resMsg);
+
+ // Call the response handler chain, removing the fault type entry will
not call handleFault for that chain
+ handlerPass = callResponseHandlerChain(portName, handlerType[2]);
+ faultType[2] = null;
+ handlerPass = handlerPass && callResponseHandlerChain(portName,
handlerType[1]);
+ faultType[1] = null;
+ handlerPass = handlerPass && callResponseHandlerChain(portName,
handlerType[0]);
+ faultType[0] = null;
}
- EndpointInfo epInfo = new EndpointInfo(epMetaData, targetAddress,
callProps);
- resMsg = getRemotingConnection().invoke(reqMsg, epInfo, false);
- //Pivot, switch to response ctx and save the response message there
+ if (handlerPass)
+ {
+ retObj = getReturnObject(resMsg);
+ }
+ }
+ catch (Exception ex)
+ {
msgContext = MessageContextJAXWS.processPivot(msgContext);
- msgContext.setMessageAbstraction(resMsg);
-
- // Call the response handler chain, removing the fault type entry will not
call handleFault for that chain
- handlerPass = callResponseHandlerChain(portName, handlerType[2]);
- faultType[2] = null;
- handlerPass = handlerPass && callResponseHandlerChain(portName,
handlerType[1]);
- faultType[1] = null;
- handlerPass = handlerPass && callResponseHandlerChain(portName,
handlerType[0]);
- faultType[0] = null;
+ if (faultType[2] != null)
+ callFaultHandlerChain(portName, faultType[2], ex);
+ if (faultType[1] != null)
+ callFaultHandlerChain(portName, faultType[1], ex);
+ if (faultType[0] != null)
+ callFaultHandlerChain(portName, faultType[0], ex);
+
+ throw ex;
}
-
- if (handlerPass)
+ finally
{
- retObj = getReturnObject(resMsg);
+ closeHandlerChain(portName, handlerType[2]);
+ closeHandlerChain(portName, handlerType[1]);
+ closeHandlerChain(portName, handlerType[0]);
}
}
- catch (Exception ex)
- {
- msgContext = MessageContextJAXWS.processPivot(msgContext);
- if (faultType[2] != null)
- callFaultHandlerChain(portName, faultType[2], ex);
- if (faultType[1] != null)
- callFaultHandlerChain(portName, faultType[1], ex);
- if (faultType[0] != null)
- callFaultHandlerChain(portName, faultType[0], ex);
-
- throw ex;
- }
finally
{
- closeHandlerChain(portName, handlerType[2]);
- closeHandlerChain(portName, handlerType[1]);
- closeHandlerChain(portName, handlerType[0]);
-
- MessageContextAssociation.popMessageContext();
+ MessageContextAssociation.popMessageContext();
}
return retObj;
}
@@ -340,9 +344,9 @@
{
CommonMessageContext msgContext = new SOAPMessageContextJAXWS();
MessageContextAssociation.pushMessageContext(msgContext);
- msgContext.setEndpointMetaData(epMetaData);
try
{
+ msgContext.setEndpointMetaData(epMetaData);
MessageAbstraction reqMsg = getRequestMessage(msg);
String targetAddress = epMetaData.getEndpointAddress();
getRemotingConnection().invoke(reqMsg, targetAddress, true);
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java 2008-05-15
13:59:34 UTC (rev 7044)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java 2008-05-15
14:24:04 UTC (rev 7045)
@@ -277,10 +277,10 @@
// Associate a message context with the current thread
MessageContextAssociation.pushMessageContext(msgContext);
- msgContext.setEndpointMetaData(sepMetaData);
try
{
+ msgContext.setEndpointMetaData(sepMetaData);
MessageAbstraction resMessage = processRequest(endpoint, headerSource,
invContext, inStream);
// Replace the message context with the response context