You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ri...@apache.org on 2006/12/06 12:19:05 UTC
svn commit: r483037 - in
/incubator/tuscany/java/sca/services/bindings/binding.axis2/src:
main/java/org/apache/tuscany/binding/axis2/
test/java/org/apache/tuscany/binding/axis2/
Author: rineholt
Date: Wed Dec 6 03:19:02 2006
New Revision: 483037
URL: http://svn.apache.org/viewvc?view=rev&rev=483037
Log:
this seems to run sample...
Sequences not yet added... still runs.
Modified:
incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java
incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java
incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInMessageReceiver.java
incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java
incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java
incubator/tuscany/java/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ServiceTestCase.java
Modified: incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java?view=diff&rev=483037&r1=483036&r2=483037
==============================================================================
--- incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java (original)
+++ incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java Wed Dec 6 03:19:02 2006
@@ -126,7 +126,7 @@
}
Service service = new Axis2Service(serviceDefinition.getName(), outboundContract, parent, wireService, wsBinding,
- servletHost, configContext);
+ servletHost, configContext, workContext);
service.setBindingServiceContract(inboundContract);
return service;
Modified: incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java?view=diff&rev=483037&r1=483036&r2=483037
==============================================================================
--- incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java (original)
+++ incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java Wed Dec 6 03:19:02 2006
@@ -21,6 +21,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
@@ -29,6 +30,7 @@
import javax.wsdl.PortType;
import javax.xml.namespace.QName;
+import org.apache.axiom.om.OMElement;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.ConfigurationContext;
@@ -44,8 +46,11 @@
import org.apache.tuscany.binding.axis2.util.WebServicePortMetaData;
import org.apache.tuscany.spi.builder.BuilderConfigException;
import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.WorkContext;
import org.apache.tuscany.spi.extension.ServiceExtension;
import org.apache.tuscany.spi.host.ServletHost;
+import org.apache.tuscany.spi.model.InteractionScope;
+import org.apache.tuscany.spi.model.Scope;
import org.apache.tuscany.spi.model.ServiceContract;
import org.apache.tuscany.spi.wire.Interceptor;
import org.apache.tuscany.spi.wire.InvocationChain;
@@ -74,13 +79,17 @@
private String serviceName;
+ private WorkContext workContext;
+
+ private Boolean conversational= null;
+
public Axis2Service(String theName,
ServiceContract<?> serviceContract,
CompositeComponent parent,
WireService wireService,
WebServiceBinding binding,
ServletHost servletHost,
- ConfigurationContext configContext) {
+ ConfigurationContext configContext, WorkContext workContext) {
super(theName, serviceContract.getInterfaceClass(), parent, wireService);
@@ -89,6 +98,7 @@
this.servletHost = servletHost;
this.configContext = configContext;
this.serviceName = theName;
+ this.workContext = workContext;
}
public void start() {
@@ -170,45 +180,59 @@
return axisService;
}
- public Object invokeTarget(org.apache.tuscany.spi.model.Operation<?> op, Object[] args, Object messageId)
+ public Object invokeTarget(org.apache.tuscany.spi.model.Operation<?> op, Object[] args, Object messageId, String conversationID)
throws InvocationTargetException {
InvocationChain chain = inboundWire.getInvocationChains().get(op);
Interceptor headInterceptor = chain.getHeadInterceptor();
- if (headInterceptor == null) {
- try {
- // short-circuit the dispatch and invoke the target directly
- if (chain.getTargetInvoker() == null) {
- throw new AssertionError("No target invoker [" + chain.getOperation().getName() + "]");
- }
- return chain.getTargetInvoker().invokeTarget(args, TargetInvoker.NONE);
- } catch (InvocationTargetException e) {
- // the cause was thrown by the target so throw it
- throw e;
- }
+ String oldConversationID= (String) workContext.getIdentifier(Scope.CONVERSATION);
+ if(isConversational() && conversationID != null){
+ workContext.setIdentifier(Scope.CONVERSATION, conversationID);
} else {
+ workContext.clearIdentifier(Scope.CONVERSATION);
+ }
+ try {
+ if (headInterceptor == null) {
+ try {
+ // short-circuit the dispatch and invoke the target directly
+ if (chain.getTargetInvoker() == null) {
+ throw new AssertionError("No target invoker [" + chain.getOperation().getName() + "]");
+ }
+ return chain.getTargetInvoker().invokeTarget(args, TargetInvoker.NONE);
+ } catch (InvocationTargetException e) {
+ // the cause was thrown by the target so throw it
+ throw e;
+ }
+ } else {
- Message msg = new MessageImpl();
- msg.setTargetInvoker(chain.getTargetInvoker());
- msg.pushFromAddress(getFromAddress());
- if (messageId != null) {
- msg.setMessageId(messageId);
- }
- msg.setBody(args);
- Message resp;
- // dispatch the wire down the chain and get the response
- // TODO http://issues.apache.org/jira/browse/TUSCANY-777
- ClassLoader oldtccl = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
- resp = headInterceptor.invoke(msg);
- } finally {
- Thread.currentThread().setContextClassLoader(oldtccl);
- }
- Object body = resp.getBody();
- if (resp.isFault()) {
- throw new InvocationTargetException((Throwable)body);
+ Message msg = new MessageImpl();
+ msg.setTargetInvoker(chain.getTargetInvoker());
+ msg.pushFromAddress(getFromAddress());
+ if (messageId != null) {
+ msg.setMessageId(messageId);
+ }
+ msg.setBody(args);
+ Message resp;
+ // dispatch the wire down the chain and get the response
+ // TODO http://issues.apache.org/jira/browse/TUSCANY-777
+ ClassLoader oldtccl = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ resp = headInterceptor.invoke(msg);
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldtccl);
+ }
+ Object body = resp.getBody();
+ if (resp.isFault()) {
+ throw new InvocationTargetException((Throwable)body);
+ }
+ return body;
}
- return body;
+ } finally {
+ if(null != oldConversationID){
+ workContext.setIdentifier(Scope.CONVERSATION, conversationID);
+ }else{
+ workContext.clearIdentifier(Scope.CONVERSATION);
+ }
}
}
@@ -256,6 +280,31 @@
this.invCtxMap.remove(msgId);
}
+ /**
+ * @param inMC
+ * @return
+ */
+ protected static String getConversationID(MessageContext inMC) {
+ String conversationID= null;
+ Iterator i = inMC.getEnvelope().getHeader().getChildrenWithName(new QName("http://www.w3.org/2005/08/addressing","From"));
+ for(; i.hasNext();){
+ Object a= i.next();
+ if(a instanceof OMElement){
+ OMElement ao= (OMElement) a;
+ for(Iterator rpI= ao.getChildrenWithName(new QName("http://www.w3.org/2005/08/addressing", "ReferenceParameters")); rpI.hasNext();){
+ OMElement rpE= (OMElement)rpI.next();
+ for(Iterator cidI= rpE.getChildrenWithName(WebServiceBinding.CONVERSATION_ID_REFPARM_QN); cidI.hasNext();){
+ OMElement cidE= (OMElement) cidI.next();
+ conversationID= cidE.getText();
+ }
+ }
+
+ }
+
+ }
+ return conversationID;
+ }
+
protected class InvocationContext {
public MessageContext inMessageContext;
@@ -274,5 +323,17 @@
this.soapFactory = soapFactory;
this.doneSignal = doneSignal;
}
+ }
+
+ WorkContext getWorkContext() {
+ return workContext;
+ }
+
+ boolean isConversational() {
+ if(conversational == null){
+ conversational= serviceContract.getInteractionScope()== InteractionScope.CONVERSATIONAL;
+
+ }
+ return conversational;
}
}
Modified: incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInMessageReceiver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInMessageReceiver.java?view=diff&rev=483037&r1=483036&r2=483037
==============================================================================
--- incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInMessageReceiver.java (original)
+++ incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInMessageReceiver.java Wed Dec 6 03:19:02 2006
@@ -47,8 +47,9 @@
try {
OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
Object[] args = new Object[] {requestOM};
+ String conversationID = axis2Service.isConversational() ? Axis2Service.getConversationID(inMC) : null;
- axis2Service.invokeTarget(operation, args, null);
+ axis2Service.invokeTarget(operation, args, null, conversationID);
} catch (InvocationTargetException e) {
Throwable t = e.getCause();
Modified: incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java?view=diff&rev=483037&r1=483036&r2=483037
==============================================================================
--- incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java (original)
+++ incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java Wed Dec 6 03:19:02 2006
@@ -75,7 +75,8 @@
try {
OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
Object[] args = new Object[] {requestOM};
- service.invokeTarget(operation, args, messageId);
+ String conversationID = service.isConversational() ? Axis2Service.getConversationID(inMC) : null;
+ service.invokeTarget(operation, args, messageId, conversationID);
} catch (InvocationTargetException e) {
Throwable t = e.getCause();
if (t instanceof Exception) {
Modified: incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java?view=diff&rev=483037&r1=483036&r2=483037
==============================================================================
--- incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java (original)
+++ incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java Wed Dec 6 03:19:02 2006
@@ -49,11 +49,16 @@
try {
OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
Object[] args = new Object[] {requestOM};
+
+ String conversationID = axis2Service.isConversational() ? Axis2Service.getConversationID(inMC) : null;
- OMElement responseOM = (OMElement)axis2Service.invokeTarget(operation, args, null);
+ OMElement responseOM = (OMElement)axis2Service.invokeTarget(operation, args, null, conversationID);
+
SOAPEnvelope soapEnvelope = getSOAPFactory(inMC).getDefaultEnvelope();
- soapEnvelope.getBody().addChild(responseOM);
+ if(null != responseOM ){
+ soapEnvelope.getBody().addChild(responseOM);
+ }
outMC.setEnvelope(soapEnvelope);
outMC.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN, Constants.VALUE_TRUE);
Modified: incubator/tuscany/java/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ServiceTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ServiceTestCase.java?view=diff&rev=483037&r1=483036&r2=483037
==============================================================================
--- incubator/tuscany/java/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ServiceTestCase.java (original)
+++ incubator/tuscany/java/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ServiceTestCase.java Wed Dec 6 03:19:02 2006
@@ -35,6 +35,7 @@
import org.apache.axis2.context.ConfigurationContext;
import org.apache.tuscany.binding.axis2.util.TuscanyAxisConfigurator;
+import org.apache.tuscany.core.component.WorkContextImpl;
import org.apache.tuscany.spi.host.ServletHost;
import org.apache.tuscany.spi.idl.java.JavaServiceContract;
import org.apache.tuscany.spi.model.Operation;
@@ -120,7 +121,7 @@
wireService,
wsBinding,
tomcatHost,
- configurationContext);
+ configurationContext, new WorkContextImpl());
axis2Service.setInboundWire(inboundWire);
axis2Service.setOutboundWire(outboundWire);
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org