Author: dkulp
Date: Mon Feb 22 20:58:11 2010
New Revision: 915057
URL: http://svn.apache.org/viewvc?rev=915057&view=rev
Log:
Remove ws-a stuff from destinations.
Modified:
cxf/trunk/api/src/main/java/org/apache/cxf/transport/Destination.java
cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java
cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractDestination.java
cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
Modified: cxf/trunk/api/src/main/java/org/apache/cxf/transport/Destination.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/transport/Destination.java?rev=915057&r1=915056&r2=915057&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/transport/Destination.java
(original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/transport/Destination.java Mon
Feb 22 20:58:11 2010
@@ -39,18 +39,15 @@
* Retreive a back-channel Conduit, which must be policy-compatible
* with the current Message and associated Destination. For example
* compatible Quality of Protection must be asserted on the back-channel.
- * This would generally only be an issue if the back-channel is decoupled.
*
- * @param inMessage the current message (null to indicate a disassociated
- * back-channel.
- * @param partialResponse in the decoupled case, this is expected to be the
- * outbound Message to be sent over the in-built back-channel.
- * @param address the backchannel address (null to indicate anonymous)
+ * @param inMessage the current message
+ * @param unused1 - will likely always be null
+ * @param unused2 - will likely always be null
* @return a suitable Conduit
*/
Conduit getBackChannel(Message inMessage,
- Message partialResponse,
- EndpointReferenceType address)
+ Message unused1,
+ EndpointReferenceType unused2)
throws IOException;
/**
Modified:
cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java?rev=915057&r1=915056&r2=915057&view=diff
==============================================================================
---
cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java
(original)
+++
cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java
Mon Feb 22 20:58:11 2010
@@ -43,7 +43,6 @@
import org.apache.cxf.service.model.BindingOperationInfo;
import org.apache.cxf.service.model.MessageInfo;
import org.apache.cxf.transport.Conduit;
-import org.apache.cxf.ws.addressing.EndpointReferenceType;
public class OutgoingChainInterceptor extends
AbstractPhaseInterceptor<Message> {
private static final Logger LOG =
LogUtils.getL7dLogger(OutgoingChainInterceptor.class);
@@ -83,9 +82,7 @@
if (ex.getConduit(message) == null
&& ex.getDestination() != null) {
try {
- EndpointReferenceType target =
- ex.get(EndpointReferenceType.class);
- conduit =
ex.getDestination().getBackChannel(ex.getInMessage(), null, target);
+ conduit =
ex.getDestination().getBackChannel(ex.getInMessage(), null, null);
ex.put(ConduitSelector.class,
new PreexistingConduitSelector(conduit,
ex.get(Endpoint.class)));
} catch (IOException e) {
Modified:
cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractDestination.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractDestination.java?rev=915057&r1=915056&r2=915057&view=diff
==============================================================================
---
cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractDestination.java
(original)
+++
cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractDestination.java
Mon Feb 22 20:58:11 2010
@@ -20,11 +20,9 @@
package org.apache.cxf.transport;
import java.io.IOException;
-import java.io.InputStream;
import java.util.logging.Logger;
import org.apache.cxf.Bus;
-import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.Message;
import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.ws.addressing.EndpointReferenceType;
@@ -38,9 +36,6 @@
public abstract class AbstractDestination
extends AbstractObservable implements Destination, DestinationWithEndpoint
{
- public static final String PARTIAL_RESPONSE =
AbstractDestination.class.getName()
- + ".partial.response";
-
protected final EndpointReferenceType reference;
protected final EndpointInfo endpointInfo;
protected final Bus bus;
@@ -82,46 +77,8 @@
Message partialResponse,
EndpointReferenceType address)
throws IOException {
- Conduit backChannel = null;
- Exchange ex = inMessage.getExchange();
- EndpointReferenceType target = address != null
- ? address
- : ex.get(EndpointReferenceType.class);
- if (target == null) {
- backChannel = getInbuiltBackChannel(inMessage);
- } else {
- if (partialResponse != null) {
- if (markPartialResponse(partialResponse, target)) {
- backChannel = getInbuiltBackChannel(inMessage);
- }
- } else {
- //this is a response targeting a decoupled endpoint. Treat
it as a oneway so
- //we don't wait for a response.
- inMessage.getExchange().setOneWay(true);
- ConduitInitiatorManager mgr =
bus.getExtension(ConduitInitiatorManager.class);
- if (mgr != null) {
- ConduitInitiator conduitInitiator
- =
mgr.getConduitInitiatorForUri(target.getAddress().getValue());
- if (conduitInitiator != null) {
- backChannel =
conduitInitiator.getConduit(endpointInfo, target);
- // ensure decoupled back channel input stream is closed
- backChannel.setMessageObserver(new MessageObserver() {
- public void onMessage(Message m) {
- if
(m.getContentFormats().contains(InputStream.class)) {
- InputStream is =
m.getContent(InputStream.class);
- try {
- is.close();
- } catch (Exception e) {
- // ignore
- }
- }
- }
- });
- }
- }
- }
- }
- return backChannel;
+
+ return getInbuiltBackChannel(inMessage);
}
/**
@@ -132,25 +89,6 @@
}
/**
- * Mark message as a partial message. Only required if decoupled
- * mode is supported.
- *
- * @param partialResponse the partial response message
- * @param the decoupled target
- * @return true iff partial responses are supported
- */
- protected boolean markPartialResponse(Message partialResponse,
- EndpointReferenceType
decoupledTarget) {
-
- partialResponse.getExchange().put(EndpointReferenceType.class,
decoupledTarget);
- partialResponse.put(PARTIAL_RESPONSE, Boolean.TRUE);
- return true;
- }
- protected boolean isPartialResponse(Message m) {
- return Boolean.TRUE.equals(m.get(PARTIAL_RESPONSE));
- }
-
- /**
* @param inMessage the incoming message
* @return the inbuilt backchannel
*/
Modified:
cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java?rev=915057&r1=915056&r2=915057&view=diff
==============================================================================
---
cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
(original)
+++
cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
Mon Feb 22 20:58:11 2010
@@ -452,20 +452,19 @@
setUpInMessage();
Message partialResponse = setUpOutMessage();
+ partialResponse.put(Message.PARTIAL_RESPONSE_MESSAGE, Boolean.TRUE);
Conduit partialBackChannel =
destination.getBackChannel(inMessage, partialResponse, replyTo);
+ partialBackChannel.prepare(partialResponse);
assertEquals("unexpected response code",
202,
partialResponse.get(Message.RESPONSE_CODE));
- partialBackChannel.prepare(partialResponse);
verifyBackChannelSend(partialBackChannel, partialResponse, 202);
outMessage = setUpOutMessage();
Conduit fullBackChannel =
destination.getBackChannel(inMessage, null, replyTo);
- assertSame("unexpected back channel",
- decoupledBackChannel,
- fullBackChannel);
+
fullBackChannel.prepare(outMessage);
}
Modified:
cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java?rev=915057&r1=915056&r2=915057&view=diff
==============================================================================
---
cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
(original)
+++
cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
Mon Feb 22 20:58:11 2010
@@ -61,6 +61,7 @@
import org.apache.cxf.message.Attachment;
import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageUtils;
import org.apache.cxf.security.SecurityContext;
import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.transport.AbstractDestination;
@@ -168,6 +169,9 @@
}
protected void updateResponseHeaders(Message message) {
+ if (MessageUtils.isPartialResponse(message)) {
+ message.put(Message.RESPONSE_CODE,
HttpURLConnection.HTTP_ACCEPTED);
+ }
Map<String, List<String>> responseHeaders =
CastUtils.cast((Map)message.get(Message.PROTOCOL_HEADERS));
if (responseHeaders == null) {
@@ -377,22 +381,6 @@
HttpServletResponse response =
(HttpServletResponse)inMessage.get(HTTP_RESPONSE);
return new BackChannelConduit(response);
}
-
- /**
- * Mark message as a partial message.
- *
- * @param partialResponse the partial response message
- * @param the decoupled target
- * @return true iff partial responses are supported
- */
- protected final boolean markPartialResponse(Message partialResponse,
- EndpointReferenceType decoupledTarget) {
- // setup the outbound message to for 202 Accepted
- super.markPartialResponse(partialResponse, decoupledTarget);
- partialResponse.put(Message.RESPONSE_CODE,
HttpURLConnection.HTTP_ACCEPTED);
- return true;
- }
-
private void initConfig() {
PolicyEngine engine = bus.getExtension(PolicyEngine.class);
@@ -515,7 +503,7 @@
copyResponseHeaders(outMessage, response);
- if (oneWay && !isPartialResponse(outMessage)) {
+ if (oneWay && !MessageUtils.isPartialResponse(outMessage)) {
response.setContentLength(0);
response.flushBuffer();
response.getOutputStream().close();
@@ -562,6 +550,9 @@
* @param message the message to be sent.
*/
public void prepare(Message message) throws IOException {
+ if (MessageUtils.isPartialResponse(message)) {
+ message.put(Message.RESPONSE_CODE,
HttpURLConnection.HTTP_ACCEPTED);
+ }
message.put(HTTP_RESPONSE, response);
OutputStream os = message.getContent(OutputStream.class);
if (os == null) {
Modified:
cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java?rev=915057&r1=915056&r2=915057&view=diff
==============================================================================
---
cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
(original)
+++
cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
Mon Feb 22 20:58:11 2010
@@ -20,6 +20,8 @@
package org.apache.cxf.ws.addressing;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.UUID;
import java.util.concurrent.Executor;
import java.util.logging.Level;
@@ -48,11 +50,15 @@
import org.apache.cxf.message.MessageImpl;
import org.apache.cxf.service.model.BindingFaultInfo;
import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.service.model.Extensible;
import org.apache.cxf.service.model.FaultInfo;
import org.apache.cxf.service.model.MessageInfo;
import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.transport.ConduitInitiator;
+import org.apache.cxf.transport.ConduitInitiatorManager;
import org.apache.cxf.transport.Destination;
+import org.apache.cxf.transport.MessageObserver;
import org.apache.cxf.workqueue.OneShotAsyncExecutor;
import org.apache.cxf.workqueue.SynchronousExecutor;
import org.apache.cxf.workqueue.WorkQueueManager;
@@ -342,7 +348,7 @@
* @param inMAPs the inbound MAPs
* @param inMessage the current message
*/
- public static void rebaseResponse(EndpointReferenceType reference,
+ public static void rebaseResponse(final EndpointReferenceType reference,
AddressingProperties inMAPs,
final Message inMessage) {
String namespaceURI = inMAPs.getNamespaceURI();
@@ -391,12 +397,52 @@
chain.reset();
}
exchange.put(ConduitSelector.class, new
NullConduitSelector());
- if (fullResponse != null) {
- exchange.setOutMessage(fullResponse);
- } else {
+
+ if (fullResponse == null) {
fullResponse = createMessage(exchange);
- exchange.setOutMessage(fullResponse);
}
+ exchange.setOutMessage(fullResponse);
+ final EndpointInfo ei =
exchange.get(Endpoint.class).getEndpointInfo();
+ exchange.setDestination(new Destination() {
+ public EndpointReferenceType getAddress() {
+ return reference;
+ }
+ public Conduit getBackChannel(Message inMessage,
Message partialResponse,
+ EndpointReferenceType
address) throws IOException {
+ Bus bus = inMessage.getExchange().get(Bus.class);
+ //this is a response targeting a decoupled
endpoint. Treat it as a oneway so
+ //we don't wait for a response.
+ inMessage.getExchange().setOneWay(true);
+ ConduitInitiator conduitInitiator
+ =
bus.getExtension(ConduitInitiatorManager.class)
+
.getConduitInitiatorForUri(reference.getAddress().getValue());
+ if (conduitInitiator != null) {
+ Conduit c = conduitInitiator.getConduit(ei,
reference);
+ // ensure decoupled back channel input stream
is closed
+ c.setMessageObserver(new MessageObserver() {
+ public void onMessage(Message m) {
+ if
(m.getContentFormats().contains(InputStream.class)) {
+ InputStream is =
m.getContent(InputStream.class);
+ try {
+ is.close();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+ });
+ return c;
+ }
+ return null;
+ }
+ public MessageObserver getMessageObserver() {
+ return null;
+ }
+ public void shutdown() {
+ }
+ public void setMessageObserver(MessageObserver
observer) {
+ }
+ });
if (retrieveAsyncPostResponseDispatch(inMessage)) {
//need to suck in all the data from the input stream as