Author: rfeng
Date: Fri Feb 15 12:26:39 2008
New Revision: 628163
URL: http://svn.apache.org/viewvc?rev=628163&view=rev
Log:
Add the PassByValueAware as an optional SPI for Invoker/Intercetors to support
Pass-by-value
Added:
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/SCABindingInvoker.java
(with props)
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/PassByValueAware.java
(with props)
Modified:
incubator/tuscany/java/sca/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponent.java
incubator/tuscany/java/sca/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponentImpl.java
incubator/tuscany/java/sca/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.java
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingInvoker.java
incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java
incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorImpl.java
incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIReferenceInvoker.java
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAReferenceBindingProvider.java
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2OneWayBindingInvoker.java
incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java
incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataTransformationInterceptor.java
incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/PassByValueInterceptor.java
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InvocationChainImpl.java
incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java
incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionRuntimeWireProcessor.java
Modified:
incubator/tuscany/java/sca/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponent.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponent.java?rev=628163&r1=628162&r2=628163&view=diff
==============================================================================
---
incubator/tuscany/java/sca/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponent.java
(original)
+++
incubator/tuscany/java/sca/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponent.java
Fri Feb 15 12:26:39 2008
@@ -47,6 +47,7 @@
public interface RemoteClientComponent {
String foo1(ParameterObject po);
+ String foo3(ParameterObject po);
String foo2(int i, String str1) throws Exception;
Modified:
incubator/tuscany/java/sca/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponentImpl.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponentImpl.java?rev=628163&r1=628162&r2=628163&view=diff
==============================================================================
---
incubator/tuscany/java/sca/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponentImpl.java
(original)
+++
incubator/tuscany/java/sca/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponentImpl.java
Fri Feb 15 12:26:39 2008
@@ -19,6 +19,7 @@
package org.apache.tuscany.sca.itest.interfaces;
+import org.osoa.sca.annotations.AllowsPassByReference;
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Service;
@@ -35,6 +36,12 @@
return "BComponent";
}
+ @AllowsPassByReference
+ public String foo3(ParameterObject po) {
+ po.field1 = "BComponent";
+ return "BComponent";
+ }
+
public String foo2(int i, String str) throws Exception {
return str + "BComponent" + i;
}
Modified:
incubator/tuscany/java/sca/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.java?rev=628163&r1=628162&r2=628163&view=diff
==============================================================================
---
incubator/tuscany/java/sca/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.java
(original)
+++
incubator/tuscany/java/sca/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.java
Fri Feb 15 12:26:39 2008
@@ -87,11 +87,16 @@
RemoteClientComponent remote =
domain.getService(RemoteClientComponent.class, "RemoteClientComponent");
try {
+ // Test Pass By Value
ParameterObject po = new ParameterObject("NotBComponent");
assertEquals("BComponent", remote.foo1(po));
assertEquals("NotBComponent", po.field1);
assertEquals("BBComponent1", remote.foo2(1, "B"));
+
+ // Test allowsPassByReference
+ assertEquals("BComponent", remote.foo3(po));
+ assertEquals("BComponent", po.field1);
} catch (Exception e) {
e.printStackTrace();
fail();
Modified:
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingInvoker.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingInvoker.java?rev=628163&r1=628162&r2=628163&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingInvoker.java
(original)
+++
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingInvoker.java
Fri Feb 15 12:26:39 2008
@@ -24,11 +24,12 @@
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.PassByValueAware;
/**
* EJBTargetInvoker
*/
-public class EJBBindingInvoker implements Invoker {
+public class EJBBindingInvoker implements Invoker, PassByValueAware {
private Operation operation;
private String location;
@@ -75,6 +76,11 @@
protected NamingEndpoint getNamingEndpoint() {
return new NamingEndpoint(location);
+ }
+
+ public boolean allowsPassByReference() {
+ // EJB RMI/IIOP always pass by value
+ return true;
}
}
Modified:
incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java?rev=628163&r1=628162&r2=628163&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java
(original)
+++
incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java
Fri Feb 15 12:26:39 2008
@@ -34,13 +34,14 @@
import org.apache.tuscany.sca.host.jms.JMSResourceFactory;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.PassByValueAware;
/**
* Interceptor for the JMS binding.
*
* @version $Rev$ $Date$
*/
-public class JMSBindingInvoker implements Invoker {
+public class JMSBindingInvoker implements Invoker, PassByValueAware {
protected Operation operation;
protected String operationName;
@@ -256,6 +257,11 @@
throw new JMSBindingException("No reply message received on " +
replyToDest + " for message id " + requestMsgId);
}
return replyMsg;
+ }
+
+ public boolean allowsPassByReference() {
+ // JMS always pass by value
+ return true;
}
}
Modified:
incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorImpl.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorImpl.java?rev=628163&r1=628162&r2=628163&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorImpl.java
(original)
+++
incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorImpl.java
Fri Feb 15 12:26:39 2008
@@ -137,7 +137,11 @@
if (o instanceof OMElement) {
message.setText(o.toString());
} else {
- message.setText(((Object[])o)[0].toString());
+ if (o instanceof Object[]) {
+ message.setText(((Object[])o)[0].toString());
+ } else {
+ message.setText(String.valueOf(o));
+ }
}
return message;
Modified:
incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIReferenceInvoker.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIReferenceInvoker.java?rev=628163&r1=628162&r2=628163&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIReferenceInvoker.java
(original)
+++
incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIReferenceInvoker.java
Fri Feb 15 12:26:39 2008
@@ -25,8 +25,9 @@
import org.apache.tuscany.sca.host.rmi.RMIHost;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.PassByValueAware;
-public class RMIReferenceInvoker implements Invoker {
+public class RMIReferenceInvoker implements Invoker, PassByValueAware {
private RMIHost rmiHost;
private String host;
@@ -72,6 +73,11 @@
} else {
return remoteMethod.invoke(proxy, (Object[])payload);
}
+ }
+
+ public boolean allowsPassByReference() {
+ // RMI always pass by value
+ return true;
}
}
Modified:
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAReferenceBindingProvider.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAReferenceBindingProvider.java?rev=628163&r1=628162&r2=628163&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAReferenceBindingProvider.java
(original)
+++
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAReferenceBindingProvider.java
Fri Feb 15 12:26:39 2008
@@ -30,6 +30,7 @@
import org.apache.tuscany.sca.domain.SCADomainEventService;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.InvocationChain;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.node.NodeFactory;
import org.apache.tuscany.sca.provider.BindingProviderFactory;
@@ -52,7 +53,7 @@
* @version $Rev$ $Date$
*/
public class RuntimeSCAReferenceBindingProvider implements
ReferenceBindingProvider {
-
+
private final static Logger logger =
Logger.getLogger(RuntimeSCAReferenceBindingProvider.class.getName());
private NodeFactory nodeFactory;
@@ -83,7 +84,6 @@
(BindingProviderFactory<DistributedSCABinding>)factoryExtensionPoint
.getProviderFactory(DistributedSCABinding.class);
-
// determine if the target is remote. If we can tell now then this will
// do some initialization before we get to run time
//isTargetRemote();
@@ -94,7 +94,7 @@
// first look at the target service and see if this has been resolved
OptimizableBinding optimizableBinding = (OptimizableBinding)binding;
-
+
// The descision is based primary on the results of the wiring process
in the assembly model
// however there are two notable situations when this process doesn't
give the right answer
// 1. When a callback is in operation. A callback reference bindings
sometimes has to
@@ -102,7 +102,7 @@
// 2. When a reference is retrieved from the domain. In this case the
reference
// will not have been part of the original wiring process and will
only have
// a target set if the target is local
- if (optimizableBinding.getTargetComponentService() != null){
+ if (optimizableBinding.getTargetComponentService() != null) {
if (optimizableBinding.getTargetComponentService().isUnresolved()
== true) {
targetIsRemote = true;
} else {
@@ -113,54 +113,57 @@
// look at the provided URI to decide whether is a local or remote
case
try {
URI uri = new URI(binding.getURI());
- if (uri.isAbsolute()) {
- targetIsRemote = true;
- } else {
- // look in the domain to see if this referenced service
is available on this node
- // or on some other node
- String serviceNode = null;
-
- SCADomainEventService domainProxy =
(SCADomainEventService)nodeFactory.getNode().getDomain();
-
- try {
- serviceNode =
-
domainProxy.findServiceNode(nodeFactory.getNode().getDomain().getURI(),
- binding.getURI(),
-
binding.getClass().getName());
- } catch (Exception ex) {
- logger.log(Level.WARNING,
- "Unable to contact domain to find service
node. Service: " +
- nodeFactory.getNode().getDomain().getURI()
+ " " +
- nodeFactory.getNode().getURI() + " " +
- binding.getURI() + " " +
- SCABinding.class.getName());
-
- }
-
- if (serviceNode.equals(domainProxy.SERVICE_NOT_KNOWN)){
- throw new IllegalStateException("Can't resolve : " +
component.getName()
- + " and reference: "
- + reference.getName()
- + " as the service "
- + binding.getURI()
- + " has not been
contributed to the domain");
- } else if
((serviceNode.equals(domainProxy.SERVICE_NOT_REGISTERED)) ||
-
(!serviceNode.equals(nodeFactory.getNode().getURI()))){
- targetIsRemote = true;
- } else {
- targetIsRemote = false;
- }
- }
- } catch(Exception ex) {
+ if (uri.isAbsolute()) {
+ targetIsRemote = true;
+ } else {
+ // look in the domain to see if this referenced service is
available on this node
+ // or on some other node
+ String serviceNode = null;
+
+ SCADomainEventService domainProxy =
(SCADomainEventService)nodeFactory.getNode().getDomain();
+
+ try {
+ serviceNode =
+
domainProxy.findServiceNode(nodeFactory.getNode().getDomain().getURI(),
+ binding.getURI(),
+
binding.getClass().getName());
+ } catch (Exception ex) {
+ logger.log(Level.WARNING,
+ "Unable to contact domain to find service
node. Service: " + nodeFactory.getNode()
+ .getDomain().getURI()
+ + " "
+ + nodeFactory.getNode().getURI()
+ + " "
+ + binding.getURI()
+ + " "
+ + SCABinding.class.getName());
+
+ }
+
+ if (serviceNode.equals(domainProxy.SERVICE_NOT_KNOWN)) {
+ throw new IllegalStateException("Can't resolve : " +
component.getName()
+ + " and reference: "
+ + reference.getName()
+ + " as the service "
+ + binding.getURI()
+ + " has not been contributed to the domain");
+ } else if
((serviceNode.equals(domainProxy.SERVICE_NOT_REGISTERED)) || (!serviceNode
+ .equals(nodeFactory.getNode().getURI()))) {
+ targetIsRemote = true;
+ } else {
+ targetIsRemote = false;
+ }
+ }
+ } catch (Exception ex) {
targetIsRemote = false;
}
}
return targetIsRemote;
}
-
- private ReferenceBindingProvider getDistributedProvider(){
-
- if (isTargetRemote()){
+
+ private ReferenceBindingProvider getDistributedProvider() {
+
+ if (isTargetRemote()) {
// initialize the remote provider if it hasn't been done already
if (distributedProvider == null) {
if
(!reference.getInterfaceContract().getInterface().isRemotable()) {
@@ -169,31 +172,31 @@
+ " and reference: "
+ reference.getName());
}
-
+
if (distributedProviderFactory == null) {
throw new IllegalStateException("No distributed SCA
binding available for component: " + component
.getName()
+ " and reference: "
+ reference.getName());
}
-
+
if (nodeFactory.getNode() == null) {
throw new IllegalStateException("No distributed domain
available for component: " + component
.getName()
+ " and reference: "
+ reference.getName());
}
-
+
// create the remote provider
DistributedSCABinding distributedBinding = new
DistributedSCABindingImpl();
distributedBinding.setSCABinging(binding);
-
- distributedProvider = distributedProviderFactory
- .createReferenceBindingProvider(component, reference,
distributedBinding);
+
+ distributedProvider =
+
distributedProviderFactory.createReferenceBindingProvider(component, reference,
distributedBinding);
}
-
+
}
-
+
return distributedProvider;
}
@@ -226,7 +229,9 @@
RuntimeComponentService service =
(RuntimeComponentService)target.getContract();
if (service != null) { // not a callback wire
SCABinding scaBinding = service.getBinding(SCABinding.class);
- return service.getInvoker(scaBinding,
wire.getSource().getInterfaceContract(), operation);
+ InvocationChain chain =
+ service.getInvocationChain(scaBinding,
wire.getSource().getInterfaceContract(), operation);
+ return chain == null ? null : new SCABindingInvoker(chain);
}
}
return null;
@@ -239,9 +244,8 @@
RuntimeWire wire = reference.getRuntimeWire(binding);
Invoker invoker = getInvoker(wire, operation);
if (invoker == null) {
- throw new ServiceUnavailableException("Service not found for
component "
- + component.getName()
- + " reference "
+ throw new ServiceUnavailableException("Service not found for
component " + component.getName()
+ + " reference "
+ reference.getName()
+ " (bindingURI="
+ binding.getURI()
@@ -273,7 +277,7 @@
} else {
started = false;
}
-
+
if (getDistributedProvider() != null) {
distributedProvider.stop();
}
Added:
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/SCABindingInvoker.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/SCABindingInvoker.java?rev=628163&view=auto
==============================================================================
---
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/SCABindingInvoker.java
(added)
+++
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/SCABindingInvoker.java
Fri Feb 15 12:26:39 2008
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.sca.impl;
+
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.PassByValueAware;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SCABindingInvoker implements Interceptor, PassByValueAware {
+ private InvocationChain chain;
+
+ /**
+ * Construct a SCABindingInvoker that delegates to the service invocaiton
chain
+ * @param chain
+ */
+ public SCABindingInvoker(InvocationChain chain) {
+ super();
+ this.chain = chain;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.invocation.Interceptor#getNext()
+ */
+ public Invoker getNext() {
+ return chain.getHeadInvoker();
+ }
+
+ /**
+ * @see
org.apache.tuscany.sca.invocation.Interceptor#setNext(org.apache.tuscany.sca.invocation.Invoker)
+ */
+ public void setNext(Invoker next) {
+ // NOOP
+ }
+
+ /**
+ * @see
org.apache.tuscany.sca.invocation.Invoker#invoke(org.apache.tuscany.sca.invocation.Message)
+ */
+ public Message invoke(Message msg) {
+ return getNext().invoke(msg);
+ }
+
+ /**
+ * @see
org.apache.tuscany.sca.invocation.PassByValueAware#allowsPassByReference()
+ */
+ public boolean allowsPassByReference() {
+ return chain.allowsPassByReference();
+ }
+
+}
Propchange:
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/SCABindingInvoker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/SCABindingInvoker.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java?rev=628163&r1=628162&r2=628163&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java
(original)
+++
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java
Fri Feb 15 12:26:39 2008
@@ -38,12 +38,13 @@
import org.apache.tuscany.sca.interfacedef.util.FaultException;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.PassByValueAware;
import org.apache.tuscany.sca.runtime.ReferenceParameters;
/**
* Axis2BindingInvoker uses an Axis2 OperationClient to invoke a remote web
service
*/
-public class Axis2BindingInvoker implements Invoker {
+public class Axis2BindingInvoker implements Invoker, PassByValueAware {
private Axis2ServiceClient serviceClient;
private QName wsdlOperationName;
@@ -194,5 +195,9 @@
operationClient.addMessageContext(requestMC);
return operationClient;
+ }
+
+ public boolean allowsPassByReference() {
+ return true;
}
}
Modified:
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2OneWayBindingInvoker.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2OneWayBindingInvoker.java?rev=628163&r1=628162&r2=628163&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2OneWayBindingInvoker.java
(original)
+++
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2OneWayBindingInvoker.java
Fri Feb 15 12:26:39 2008
@@ -24,7 +24,6 @@
import org.apache.axis2.AxisFault;
import org.apache.axis2.client.OperationClient;
import org.apache.axis2.client.Options;
-import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.wsdl.WSDLConstants;
Modified:
incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java?rev=628163&r1=628162&r2=628163&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java
(original)
+++
incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java
Fri Feb 15 12:26:39 2008
@@ -19,10 +19,8 @@
package org.apache.tuscany.sca.core.databinding.wire;
-import java.lang.reflect.Method;
import java.util.List;
-import org.apache.tuscany.sca.assembly.Implementation;
import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
import org.apache.tuscany.sca.databinding.Mediator;
import org.apache.tuscany.sca.interfacedef.DataType;
@@ -30,7 +28,6 @@
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Interceptor;
import org.apache.tuscany.sca.invocation.InvocationChain;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeWire;
import org.apache.tuscany.sca.runtime.RuntimeWireProcessor;
@@ -57,7 +54,7 @@
if (source == target) {
return false;
}
-
+
// Output type can be null
if (source == null && target == null) {
return false;
@@ -80,7 +77,7 @@
if (source == target) {
return false;
}
-
+
if (source.isWrapperStyle() != target.isWrapperStyle()) {
return true;
}
@@ -148,8 +145,8 @@
} else {
// assume pass-by-values copies are required if interfaces are
remotable and there is no data binding
// transformation, i.e. a transformation will result in a copy
so another pass-by-value copy is unnecessary
- if (requiresCopy(wire, sourceOperation, targetOperation)) {
- interceptor = new PassByValueInterceptor(dataBindings,
targetOperation);
+ if (isRemotable(chain, sourceOperation, targetOperation)) {
+ interceptor = new PassByValueInterceptor(dataBindings,
chain, targetOperation);
}
}
if (interceptor != null) {
@@ -163,58 +160,14 @@
* Pass-by-value copies are required if the interfaces are remotable
unless the
* implementation uses the @AllowsPassByReference annotation.
*/
- protected boolean requiresCopy(RuntimeWire wire, Operation
sourceOperation, Operation targetOperation) {
+ protected boolean isRemotable(InvocationChain chain, Operation
sourceOperation, Operation targetOperation) {
if (!sourceOperation.getInterface().isRemotable()) {
return false;
}
if (!targetOperation.getInterface().isRemotable()) {
return false;
}
-
- if (allowsPassByReference(wire.getSource().getComponent(),
sourceOperation)) {
- return false;
- }
-
- if (allowsPassByReference(wire.getTarget().getComponent(),
sourceOperation)) {
- return false;
- }
-
return true;
- }
-
- /**
- * Does the implementation use the @AllowsPassByReference annotation for
the operation.
- * Uses reflection to avoid a dependency on JavaImplementation because the
isAllowsPassByReference
- * and getAllowsPassByReference methods are not on the Implementation
interface.
- * TODO: move isAllowsPassByReference/getAllowsPassByReference to
Implementation interface
- */
- protected boolean allowsPassByReference(RuntimeComponent component,
Operation operation) {
- if (component == null || component.getImplementation() == null) {
- return true; // err on the side of no copies
- }
- Implementation impl = component.getImplementation();
- try {
-
- Method m = impl.getClass().getMethod("isAllowsPassByReference",
new Class[] {});
- if ((Boolean)m.invoke(impl, new Object[]{})) {
- return true;
- }
-
- m = impl.getClass().getMethod("getAllowsPassByReferenceMethods",
new Class[] {});
- List<Method> ms = (List<Method>)m.invoke(impl, new Object[]{});
- if (ms != null) {
- for (Method m2 : ms) {
- // simple name matching is ok as its a remote operation so
no overloading
- if (operation.getName().equals(m2.getName()))
- return true;
- }
- }
-
- } catch (Exception e) {
- // ignore, assume the impl has no isAllowsPassByReference method
- }
-
- return false;
}
}
Modified:
incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataTransformationInterceptor.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataTransformationInterceptor.java?rev=628163&r1=628162&r2=628163&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataTransformationInterceptor.java
(original)
+++
incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataTransformationInterceptor.java
Fri Feb 15 12:26:39 2008
@@ -37,6 +37,7 @@
import org.apache.tuscany.sca.invocation.Interceptor;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.PassByValueAware;
import org.apache.tuscany.sca.runtime.RuntimeWire;
/**
@@ -44,7 +45,7 @@
*
* @version $Rev$ $Date$
*/
-public class DataTransformationInterceptor implements Interceptor {
+public class DataTransformationInterceptor implements Interceptor,
PassByValueAware {
private Invoker next;
private Operation sourceOperation;
@@ -252,6 +253,10 @@
public void setNext(Invoker next) {
this.next = next;
+ }
+
+ public boolean allowsPassByReference() {
+ return true;
}
}
Modified:
incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/PassByValueInterceptor.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/PassByValueInterceptor.java?rev=628163&r1=628162&r2=628163&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/PassByValueInterceptor.java
(original)
+++
incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/PassByValueInterceptor.java
Fri Feb 15 12:26:39 2008
@@ -32,6 +32,7 @@
import org.apache.tuscany.sca.interfacedef.DataType;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.InvocationChain;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
@@ -50,31 +51,33 @@
private DataBinding jaxbDataBinding;
private Operation operation;
private Invoker nextInvoker;
+ private InvocationChain chain;
/**
* Constructs a new PassByValueInterceptor.
* @param dataBindings databinding extension point
* @param operation the intercepted operation
*/
- public PassByValueInterceptor(DataBindingExtensionPoint dataBindings,
Operation operation) {
+ public PassByValueInterceptor(DataBindingExtensionPoint dataBindings,
InvocationChain chain, Operation operation) {
+ this.chain = chain;
this.operation = operation;
-
+
// Cache data bindings to use
this.dataBindings = dataBindings;
jaxbDataBinding = dataBindings.getDataBinding(JAXBDataBinding.NAME);
javaBeanDataBinding =
dataBindings.getDataBinding(JavaBeansDataBinding.NAME);
-
+
// Determine the input databindings
if (operation.getInputType() != null) {
List<DataType> inputTypes = operation.getInputType().getLogical();
inputDataBindings = new DataBinding[inputTypes.size()];
int i = 0;
- for (DataType inputType: inputTypes) {
- String id = inputType.getDataBinding();
+ for (DataType inputType : inputTypes) {
+ String id = inputType.getDataBinding();
inputDataBindings[i++] = dataBindings.getDataBinding(id);
}
}
-
+
// Determine the output databinding
if (operation.getOutputType() != null) {
String id = operation.getOutputType().getDataBinding();
@@ -83,6 +86,10 @@
}
public Message invoke(Message msg) {
+ if (chain.allowsPassByReference()) {
+ return nextInvoker.invoke(msg);
+ }
+
msg.setBody(copy((Object[])msg.getBody(), inputDataBindings));
Message resultMsg = nextInvoker.invoke(msg);
@@ -145,15 +152,15 @@
}
}
if (dataBinding == null) {
-
+
// Default to the JavaBean databinding
- dataBinding = javaBeanDataBinding;
+ dataBinding = javaBeanDataBinding;
}
}
-
+
// Use the JAXB databinding to copy non-Serializable data
if (dataBinding == javaBeanDataBinding) {
-
+
// If the input data is an array containing non serializable
elements
// use JAXB
Class<?> clazz = data.getClass();
@@ -172,7 +179,7 @@
}
}
}
-
+
Object copy = dataBinding.copy(data);
return copy;
}
Modified:
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java?rev=628163&r1=628162&r2=628163&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java
(original)
+++
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java
Fri Feb 15 12:26:39 2008
@@ -29,7 +29,7 @@
*
* @version $Rev$ $Date$
*/
-public interface InvocationChain {
+public interface InvocationChain extends PassByValueAware {
/**
* Returns the target operation for this invocation chain.
*
Added:
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/PassByValueAware.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/PassByValueAware.java?rev=628163&view=auto
==============================================================================
---
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/PassByValueAware.java
(added)
+++
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/PassByValueAware.java
Fri Feb 15 12:26:39 2008
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.invocation;
+
+/**
+ * An invoker or interceptor can optionally implement this interface to
indicate if they can
+ * enforce the pass-by-value semantics for an operation on remotable
interfaces.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface PassByValueAware {
+ /**
+ * Indicate if the data can be passed in by reference as they won't be
mutated.
+ * @return true if pass-by-reference is allowed
+ */
+ boolean allowsPassByReference();
+}
Propchange:
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/PassByValueAware.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/PassByValueAware.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java?rev=628163&r1=628162&r2=628163&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java
(original)
+++
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java
Fri Feb 15 12:26:39 2008
@@ -97,6 +97,7 @@
/**
* Get the invoker for the given binding and operation
* @param binding The assembly model binding
+ * @param interfaceContract the client interface contract
* @param operation The assembly model operation
* @return The runtime invoker
*/
@@ -108,5 +109,14 @@
* @param operation The assembly model operation
* @return The runtime invocation chain
*/
- InvocationChain getInvocationChain(Binding binding, Operation operation);
+ InvocationChain getInvocationChain(Binding binding, Operation operation);
+
+ /**
+ * Get the invocation chain for the given binding and operation
+ * @param binding The assembly model binding
+ * @param operation The assembly model operation
+ * @param interfaceContract the client interface contract
+ * @return The runtime invocation chain
+ */
+ InvocationChain getInvocationChain(Binding binding, InterfaceContract
interfaceContract, Operation operation);
}
Modified:
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InvocationChainImpl.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InvocationChainImpl.java?rev=628163&r1=628162&r2=628163&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InvocationChainImpl.java
(original)
+++
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InvocationChainImpl.java
Fri Feb 15 12:26:39 2008
@@ -25,6 +25,7 @@
import org.apache.tuscany.sca.invocation.Interceptor;
import org.apache.tuscany.sca.invocation.InvocationChain;
import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.PassByValueAware;
/**
* Default implementation of an invocation chain
@@ -113,6 +114,20 @@
Invoker after = invokers.get(index + 1);
interceptor.setNext(after);
}
+ }
+
+ public boolean allowsPassByReference() {
+ // Check if any of the invokers allows pass-by-reference
+ boolean allowsPBR = false;
+ for (Invoker i : invokers) {
+ if (i instanceof PassByValueAware) {
+ if (((PassByValueAware)i).allowsPassByReference()) {
+ allowsPBR = true;
+ break;
+ }
+ }
+ }
+ return allowsPBR;
}
}
Modified:
incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java?rev=628163&r1=628162&r2=628163&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java
(original)
+++
incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java
Fri Feb 15 12:26:39 2008
@@ -25,10 +25,12 @@
import org.apache.tuscany.sca.core.scope.Scope;
import org.apache.tuscany.sca.core.scope.ScopeContainer;
import org.apache.tuscany.sca.core.scope.ScopedRuntimeComponent;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
import org.apache.tuscany.sca.interfacedef.ConversationSequence;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.PassByValueAware;
import org.apache.tuscany.sca.runtime.EndpointReference;
import org.apache.tuscany.sca.runtime.ReferenceParameters;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
@@ -39,9 +41,10 @@
*
* @version $Rev$ $Date$
*/
-public class JavaImplementationInvoker implements Invoker {
+public class JavaImplementationInvoker implements Invoker, PassByValueAware {
protected Operation operation;
- protected Method method;
+ protected Method method;
+ protected boolean allowsPBR;
@SuppressWarnings("unchecked")
protected final ScopeContainer scopeContainer;
@@ -51,6 +54,7 @@
this.method = method;
this.operation = operation;
this.scopeContainer =
((ScopedRuntimeComponent)component).getScopeContainer();
+ this.allowsPBR =
((JavaImplementation)component.getImplementation()).isAllowsPassByReference(method);
}
@SuppressWarnings("unchecked")
@@ -120,6 +124,10 @@
msg.setFaultBody(e);
}
return msg;
+ }
+
+ public boolean allowsPassByReference() {
+ return allowsPBR;
}
}
Modified:
incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionRuntimeWireProcessor.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionRuntimeWireProcessor.java?rev=628163&r1=628162&r2=628163&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionRuntimeWireProcessor.java
(original)
+++
incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionRuntimeWireProcessor.java
Fri Feb 15 12:26:39 2008
@@ -70,7 +70,7 @@
TransactionInterceptor interceptor =
new TransactionInterceptor(helper, outbound,
interactionPolicy, implementationPolicy);
- chain.addInterceptor(interceptor);
+ chain.addInterceptor(0, interceptor);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]