You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ga...@apache.org on 2008/04/10 07:03:15 UTC
svn commit: r646647 - in /webservices/axis2/trunk/java/modules/jaxws:
src/org/apache/axis2/jaxws/context/utils/
src/org/apache/axis2/jaxws/handler/ src/org/apache/axis2/jaxws/server/
test/org/apache/axis2/jaxws/handler/ test/org/apache/axis2/jaxws/hand...
Author: gawor
Date: Wed Apr 9 22:03:13 2008
New Revision: 646647
URL: http://svn.apache.org/viewvc?rev=646647&view=rev
Log:
set SERVLET_CONTEXT property only when set (part of AXIS2-3720)
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/utils/ContextUtils.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/SoapMessageContext.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerChainProcessorTests.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/context/SOAPMessageContextTests.java
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/utils/ContextUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/utils/ContextUtils.java?rev=646647&r1=646646&r2=646647&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/utils/ContextUtils.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/utils/ContextUtils.java Wed Apr 9 22:03:13 2008
@@ -34,6 +34,7 @@
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Element;
+import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.namespace.QName;
@@ -115,17 +116,16 @@
// If we are running within a servlet container, then JAX-WS requires that the
// servlet related properties be set on the MessageContext
- soapMessageContext.put(javax.xml.ws.handler.MessageContext.SERVLET_CONTEXT,
- jaxwsMessageContext.getProperty(HTTPConstants.MC_HTTP_SERVLETCONTEXT));
- soapMessageContext
+ ServletContext servletContext =
+ (ServletContext)jaxwsMessageContext.getProperty(HTTPConstants.MC_HTTP_SERVLETCONTEXT);
+ if (servletContext != null) {
+ log.debug("Servlet Context Set");
+ soapMessageContext.put(javax.xml.ws.handler.MessageContext.SERVLET_CONTEXT,
+ servletContext);
+ soapMessageContext
.setScope(javax.xml.ws.handler.MessageContext.SERVLET_CONTEXT, Scope.APPLICATION);
-
- if (log.isDebugEnabled()) {
- if (jaxwsMessageContext.getProperty(HTTPConstants.MC_HTTP_SERVLETCONTEXT) != null) {
- log.debug("Servlet Context Set");
- } else {
- log.debug("Servlet Context not found");
- }
+ } else {
+ log.debug("Servlet Context not found");
}
HttpServletRequest req = (HttpServletRequest)jaxwsMessageContext
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java?rev=646647&r1=646646&r2=646647&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java Wed Apr 9 22:03:13 2008
@@ -265,6 +265,14 @@
// a request that requires no response is a one-way message
// and we should only close whomever got invoked
callCloseHandlers(newStart_inclusive, newEnd, newDirection);
+
+ // As according to the Sun "experts", exceptions raised by
+ // handlers in one way invocation are discarded. They
+ // are NOT propagated to the user code.
+ if (savedException != null) {
+ log.warn("Exception thrown by a handler in one way invocation",
+ savedException);
+ }
}
else {
// it's a response, so we can safely assume that
@@ -275,12 +283,12 @@
} else {
callCloseHandlers(0, handlers.size() - 1, direction);
}
- }
- if (savedException != null) {
- // we have a saved exception, throw it (JAX-WS 9.3.2.1 "Throw
- // ProtocolException or any other runtime exception --> No
- // response" case.
- throw savedException;
+ if (savedException != null) {
+ // we have a saved exception, throw it (JAX-WS 9.3.2.1 "Throw
+ // ProtocolException or any other runtime exception --> No
+ // response" case.
+ throw savedException;
+ }
}
}
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/SoapMessageContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/SoapMessageContext.java?rev=646647&r1=646646&r2=646647&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/SoapMessageContext.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/SoapMessageContext.java Wed Apr 9 22:03:13 2008
@@ -54,6 +54,7 @@
private static final Log log = LogFactory.getLog(SoapMessageContext.class);
// cache the message object after transformation --- see getMessage and setMessage methods
+ Message cachedMessage = null;
SOAPMessage cachedSoapMessage = null;
public SoapMessageContext(MessageContext messageCtx) {
@@ -127,10 +128,11 @@
}
public SOAPMessage getMessage() {
- if (cachedSoapMessage == null) {
- Message msg = messageCtx.getMEPContext().getMessageObject();
- cachedSoapMessage = msg.getAsSOAPMessage();
- }
+ Message msg = messageCtx.getMEPContext().getMessageObject();
+ if (msg != cachedMessage) {
+ cachedMessage = msg;
+ cachedSoapMessage = msg.getAsSOAPMessage();
+ }
return cachedSoapMessage;
}
@@ -166,6 +168,7 @@
Message msg =
((MessageFactory) FactoryRegistry.getFactory(MessageFactory.class)).createFrom(soapmessage);
messageCtx.getMEPContext().setMessage(msg);
+ cachedMessage = msg;
cachedSoapMessage = soapmessage;
} catch (XMLStreamException e) {
// TODO log it, and throw something?
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java?rev=646647&r1=646646&r2=646647&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java Wed Apr 9 22:03:13 2008
@@ -93,8 +93,9 @@
}
MessageContext request = eic.getRequestMessageContext();
+ boolean good = false;
try {
- boolean good = handleRequest(eic);
+ good = handleRequest(eic);
if (!good) {
return eic;
@@ -119,7 +120,9 @@
} finally {
// Passed pivot point
request.getMessage().setPostPivot();
- handleResponse(eic);
+ if (good) {
+ handleResponse(eic);
+ }
}
return eic;
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerChainProcessorTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerChainProcessorTests.java?rev=646647&r1=646646&r2=646647&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerChainProcessorTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerChainProcessorTests.java Wed Apr 9 22:03:13 2008
@@ -584,7 +584,7 @@
} catch (ProtocolException pe) {
e = pe;
}
- assertNotNull(e);
+ assertNull(e);
// no handleFault calls
assertEquals("S2m:S1m:L1m:L1c:S1c:S2c:", result);
}
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/context/SOAPMessageContextTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/context/SOAPMessageContextTests.java?rev=646647&r1=646646&r2=646647&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/context/SOAPMessageContextTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/context/SOAPMessageContextTests.java Wed Apr 9 22:03:13 2008
@@ -39,16 +39,17 @@
public class SOAPMessageContextTests extends TestCase {
- private final String INPUT = "sample input";
+ private final String INPUT_1 = "sample input";
+ private final String INPUT_2 = "sample input two";
- private SoapMessageContext createSampleContext() throws Exception {
+ private Message createMessage(String input) throws Exception {
MessageFactory factory = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
Message msg = factory.create(Protocol.soap11);
// Create a jaxb object
ObjectFactory objFactory = new ObjectFactory();
EchoString echo = objFactory.createEchoString();
- echo.setInput(INPUT);
+ echo.setInput(input);
// Create the necessary JAXBContext
JAXBContext jbc = JAXBContext.newInstance("test");
@@ -60,12 +61,16 @@
msg.setBodyBlock(block);
+ return msg;
+ }
+
+ private SoapMessageContext createSampleContext() throws Exception {
+ Message msg = createMessage(INPUT_1);
MessageContext mc = new MessageContext();
mc.setMEPContext(new MEPContext(mc));
mc.setMessage(msg);
return MessageContextFactory.createSoapMessageContext(mc);
-
}
public void testGetAsSoapMessageObjectID() {
@@ -78,5 +83,31 @@
} catch (Exception e) {
assertNull("should not get an exception in this test", e);
}
+ }
+
+ public void testSoapMessageCaching() throws Exception {
+ Message msg1 = createMessage(INPUT_1);
+ Message msg2 = createMessage(INPUT_2);
+
+ MessageContext mc = new MessageContext();
+ mc.setMessage(msg1);
+ SoapMessageContext soapCtx = MessageContextFactory.createSoapMessageContext(mc);
+
+ SOAPMessage m1 = soapCtx.getMessage();
+ SOAPMessage m2 = soapCtx.getMessage();
+
+ assertTrue("retrieval of message from SoapMessageContext twice in a row should result in same object", m1 == m2);
+
+ // let's change underlying message as
+ // HandlerChainProcessor.convertToFaultMessage() does
+ mc.setMessage(msg2);
+
+ SOAPMessage m3 = soapCtx.getMessage();
+ SOAPMessage m4 = soapCtx.getMessage();
+
+ assertTrue("retrieval of message from SoapMessageContext twice in a row should result in same object", m3 == m4);
+
+ // Soap messages from before and after must be different!
+ assertTrue("retrieval of message from SoapMessageContext after message has changed in the underlying context", m1 != m3);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org