You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/07/11 06:24:44 UTC
svn commit: r555162 [1/2] - in /incubator/tuscany/java/sca: distribution/
modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/
modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/
modules/assembly/src/main/java/org/apache/...
Author: rfeng
Date: Tue Jul 10 21:24:38 2007
New Revision: 555162
URL: http://svn.apache.org/viewvc?view=rev&rev=555162
Log:
Apply the patch from Simon Nash for TUSCANY-1341. Thank you, Simon.
Added:
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CallbackBinding.java (with props)
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider2.java (with props)
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider2.java (with props)
Modified:
incubator/tuscany/java/sca/distribution/pom.xml
incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseArtifactProcessor.java
incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java
incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2AsyncBindingInvoker.java
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2CallbackInvocationHandler.java
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ReferenceBindingProvider.java
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceBindingProvider.java
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceInMessageReceiver.java
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java
incubator/tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java
incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKCallbackInvocationHandler.java
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivatorImpl.java
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeWireImpl.java
incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java
incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java
incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
incubator/tuscany/java/sca/modules/topology-xml/src/main/java/org/apache/tuscany/sca/topology/xml/BaseArtifactProcessor.java
incubator/tuscany/java/sca/samples/README
incubator/tuscany/java/sca/samples/pom.xml
Modified: incubator/tuscany/java/sca/distribution/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/distribution/pom.xml?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/distribution/pom.xml (original)
+++ incubator/tuscany/java/sca/distribution/pom.xml Tue Jul 10 21:24:38 2007
@@ -127,11 +127,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ant-plugin</artifactId>
+<!--
+ <version>1.1</version>
+-->
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
-
<goals>
<goal>ant</goal>
</goals>
Modified: incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseArtifactProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseArtifactProcessor.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseArtifactProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseArtifactProcessor.java Tue Jul 10 21:24:38 2007
@@ -413,6 +413,14 @@
Binding binding = contract.getBindings().get(i);
extensionProcessor.resolve(binding, resolver);
}
+
+ // Resolve callback bindings
+ if (contract.getCallback() != null) {
+ for (int i = 0, n = contract.getCallback().getBindings().size(); i < n; i++) {
+ Binding binding = contract.getCallback().getBindings().get(i);
+ extensionProcessor.resolve(binding, resolver);
+ }
+ }
}
}
Modified: incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java Tue Jul 10 21:24:38 2007
@@ -149,7 +149,11 @@
} else if (extension instanceof Binding) {
// <service><binding> and <reference><binding>
- contract.getBindings().add((Binding)extension);
+ if (callback != null) {
+ callback.getBindings().add((Binding)extension);
+ } else {
+ contract.getBindings().add((Binding)extension);
+ }
}
}
}
Modified: incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java Tue Jul 10 21:24:38 2007
@@ -33,6 +33,7 @@
import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Callback;
+import org.apache.tuscany.sca.assembly.CallbackBinding;
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentProperty;
import org.apache.tuscany.sca.assembly.ComponentReference;
@@ -252,7 +253,14 @@
} else if (extension instanceof Binding) {
// <service><binding> and <reference><binding>
- contract.getBindings().add((Binding)extension);
+ if (callback != null) {
+ callback.getBindings().add((Binding)extension);
+ } else {
+ contract.getBindings().add((Binding)extension);
+ }
+ if (extension instanceof CallbackBinding) {
+ ((CallbackBinding)extension).setCallback(callback != null);
+ }
} else if (extension instanceof Implementation) {
Added: incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CallbackBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CallbackBinding.java?view=auto&rev=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CallbackBinding.java (added)
+++ incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CallbackBinding.java Tue Jul 10 21:24:38 2007
@@ -0,0 +1,41 @@
+/*
+ * 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.assembly;
+
+/**
+ * Represents a binding that can be used in the <callback> element.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface CallbackBinding extends Binding {
+
+ /**
+ * Returns true if a callback binding, false if not.
+ *
+ * @return true if a callback binding, false if not
+ */
+ boolean isCallback();
+
+ /**
+ * Sets a flag indicating whether this is a callback binding.
+ *
+ * @param true if a callback binding, false if not
+ */
+ void setCallback(boolean isCallback);
+}
Propchange: incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CallbackBinding.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CallbackBinding.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java (original)
+++ incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java Tue Jul 10 21:24:38 2007
@@ -47,6 +47,16 @@
<B> B getBinding(Class<B> bindingClass);
/**
+ * Returns a callback binding of the specified type or null if there is no such
+ * callback binding configured on this contract.
+ *
+ * @param <B> the callback binding type
+ * @param bindingClass the callback binding type class
+ * @return the callback binding or null if there is no callback binding of the specified type
+ */
+ <B> B getCallbackBinding(Class<B> bindingClass);
+
+ /**
* Returns a callback definition of the bindings to use for callbacks.
*
* @return a definition of the bindings to use for callbacks
Modified: incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java (original)
+++ incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java Tue Jul 10 21:24:38 2007
@@ -208,6 +208,14 @@
if (componentService.getBindings().isEmpty()) {
componentService.getBindings().addAll(service.getBindings());
}
+
+ // Reconcile callback bindings
+ if (componentService.getCallback() == null) {
+ componentService.setCallback(service.getCallback());
+ } else if (componentService.getCallback().getBindings().isEmpty() &&
+ service.getCallback() != null) {
+ componentService.getCallback().getBindings().addAll(service.getCallback().getBindings());
+ }
}
}
@@ -282,6 +290,14 @@
componentReference.getBindings().addAll(reference.getBindings());
}
+ // Reconcile callback bindings
+ if (componentReference.getCallback() == null) {
+ componentReference.setCallback(reference.getCallback());
+ } else if (componentReference.getCallback().getBindings().isEmpty() &&
+ reference.getCallback() != null) {
+ componentReference.getCallback().getBindings().addAll(reference.getCallback().getBindings());
+ }
+
// Propagate autowire setting from the component
if (component.isAutowire()) {
componentReference.setAutowire(true);
@@ -465,6 +481,13 @@
binding.setName(componentService.getName());
}
}
+ if (componentService.getCallback() != null) {
+ for (Binding binding : componentService.getCallback().getBindings()) {
+ if (binding.getName() == null) {
+ binding.setName(componentService.getName());
+ }
+ }
+ }
}
for (ComponentReference componentReference : component.getReferences()) {
if (componentReferences.containsKey(componentReference.getName())) {
@@ -481,6 +504,13 @@
binding.setName(componentReference.getName());
}
}
+ if (componentReference.getCallback() != null) {
+ for (Binding binding : componentReference.getCallback().getBindings()) {
+ if (binding.getName() == null) {
+ binding.setName(componentReference.getName());
+ }
+ }
+ }
}
for (ComponentProperty componentProperty : component.getProperties()) {
if (componentProperties.containsKey(componentProperty.getName())) {
@@ -530,6 +560,13 @@
binding.setName(service.getName());
}
}
+ if (service.getCallback() != null) {
+ for (Binding binding : service.getCallback().getBindings()) {
+ if (binding.getName() == null) {
+ binding.setName(service.getName());
+ }
+ }
+ }
}
for (Reference reference : composite.getReferences()) {
for (Binding binding : reference.getBindings()) {
@@ -537,6 +574,13 @@
binding.setName(reference.getName());
}
}
+ if (reference.getCallback() != null) {
+ for (Binding binding : reference.getCallback().getBindings()) {
+ if (binding.getName() == null) {
+ binding.setName(reference.getName());
+ }
+ }
+ }
}
// Initialize all component services and references
@@ -619,6 +663,22 @@
}
scaBinding.setURI(uri);
scaBinding.setComponent(component);
+
+ // if service has a callback, create and configure an SCA binding for the callback
+ if (componentService.getInterfaceContract() != null && // can be null in unit tests
+ componentService.getInterfaceContract().getCallbackInterface() != null) {
+ SCABinding scaCallbackBinding = componentService.getCallbackBinding(SCABinding.class);
+ if (scaCallbackBinding == null) {
+ scaCallbackBinding = scaBindingFactory.createSCABinding();
+ scaCallbackBinding.setName(componentService.getName());
+ if (componentService.getCallback() == null) {
+ componentService.setCallback(assemblyFactory.createCallback());
+ }
+ componentService.getCallback().getBindings().add(scaCallbackBinding);
+ }
+ scaCallbackBinding.setURI(uri);
+ scaCallbackBinding.setComponent(component);
+ }
}
for (ComponentReference componentReference : component.getReferences()) {
String uri = component.getName() + '/' + componentReference.getName();
@@ -633,6 +693,22 @@
}
scaBinding.setURI(uri);
scaBinding.setComponent(component);
+
+ // if reference has a callback, create and configure an SCA binding for the callback
+ if (componentReference.getInterfaceContract() != null && // can be null in unit tests
+ componentReference.getInterfaceContract().getCallbackInterface() != null) {
+ SCABinding scaCallbackBinding = componentReference.getCallbackBinding(SCABinding.class);
+ if (scaCallbackBinding == null) {
+ scaCallbackBinding = scaBindingFactory.createSCABinding();
+ scaCallbackBinding.setName(componentReference.getName());
+ if (componentReference.getCallback() == null) {
+ componentReference.setCallback(assemblyFactory.createCallback());
+ }
+ componentReference.getCallback().getBindings().add(scaCallbackBinding);
+ }
+ scaCallbackBinding.setURI(uri);
+ scaCallbackBinding.setComponent(component);
+ }
}
}
@@ -1013,7 +1089,18 @@
newComponentService.getBindings().add(scaBinding);
newComponentService.getBindings().addAll(compositeService.getBindings());
newComponentService.setInterfaceContract(compositeService.getInterfaceContract());
- newComponentService.setCallback(compositeService.getCallback());
+ if (compositeService.getInterfaceContract() != null && // can be null in unit tests
+ compositeService.getInterfaceContract().getCallbackInterface() != null) {
+ SCABinding scaCallbackBinding = promotedService.getCallbackBinding(SCABinding.class);
+ newComponentService.setCallback(assemblyFactory.createCallback());
+ if (scaCallbackBinding != null) {
+ newComponentService.getCallback().getBindings().add(scaCallbackBinding);
+ }
+ if (compositeService.getCallback() != null) {
+ newComponentService.getCallback().getBindings().addAll(
+ compositeService.getCallback().getBindings());
+ }
+ }
// FIXME: [rfeng] Set the service to promoted
newComponentService.setService(promotedService.getService());
@@ -1056,7 +1143,18 @@
newComponentService.getBindings().add(scaBinding);
newComponentService.getBindings().addAll(compositeService.getBindings());
newComponentService.setInterfaceContract(compositeService.getInterfaceContract());
- newComponentService.setCallback(compositeService.getCallback());
+ if (compositeService.getInterfaceContract() != null && // can be null in unit tests
+ compositeService.getInterfaceContract().getCallbackInterface() != null) {
+ SCABinding scaCallbackBinding = promotedService.getCallbackBinding(SCABinding.class);
+ newComponentService.setCallback(assemblyFactory.createCallback());
+ if (scaCallbackBinding != null) {
+ newComponentService.getCallback().getBindings().add(scaCallbackBinding);
+ }
+ if (compositeService.getCallback() != null) {
+ newComponentService.getCallback().getBindings().addAll(
+ compositeService.getCallback().getBindings());
+ }
+ }
// FIXME: [rfeng] Set the service to promoted
newComponentService.setService(promotedService.getService());
@@ -1094,6 +1192,22 @@
for (ComponentReference promotedReference : promotedReferences) {
consolidateBindings(compositeReference, promotedReference);
+ if (compositeReference.getInterfaceContract() != null && // can be null in unit tests
+ compositeReference.getInterfaceContract().getCallbackInterface() != null) {
+ SCABinding scaCallbackBinding = promotedReference.getCallbackBinding(SCABinding.class);
+ if (promotedReference.getCallback() != null) {
+ promotedReference.getCallback().getBindings().clear();
+ } else {
+ promotedReference.setCallback(assemblyFactory.createCallback());
+ }
+ if (scaCallbackBinding != null) {
+ promotedReference.getCallback().getBindings().add(scaCallbackBinding);
+ }
+ if (compositeReference.getCallback() != null) {
+ promotedReference.getCallback().getBindings().addAll(
+ compositeReference.getCallback().getBindings());
+ }
+ }
}
}
@@ -1110,6 +1224,22 @@
// Override the configuration of the promoted reference
consolidateBindings(componentReference, promotedReference);
+ if (componentReference.getInterfaceContract() != null && // can be null in unit tests
+ componentReference.getInterfaceContract().getCallbackInterface() != null) {
+ SCABinding scaCallbackBinding = promotedReference.getCallbackBinding(SCABinding.class);
+ if (promotedReference.getCallback() != null) {
+ promotedReference.getCallback().getBindings().clear();
+ } else {
+ promotedReference.setCallback(assemblyFactory.createCallback());
+ }
+ if (scaCallbackBinding != null) {
+ promotedReference.getCallback().getBindings().add(scaCallbackBinding);
+ }
+ if (componentReference.getCallback() != null) {
+ promotedReference.getCallback().getBindings().addAll(
+ componentReference.getCallback().getBindings());
+ }
+ }
// Wire the promoted reference to the actual
// non-composite component services
@@ -1315,6 +1445,7 @@
ComponentReference componentReference = assemblyFactory.createComponentReference();
componentReference.setName("$self$." + service.getName());
componentReference.getBindings().addAll(service.getBindings());
+ componentReference.setCallback(service.getCallback());
ComponentService componentService = assemblyFactory.createComponentService();
componentService.setName(component.getName() + "/" + service.getName());
componentService.setUnresolved(true);
Modified: incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java (original)
+++ incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java Tue Jul 10 21:24:38 2007
@@ -69,6 +69,17 @@
return null;
}
+ public <B> B getCallbackBinding(Class<B> bindingClass) {
+ if (callback != null) {
+ for (Binding binding : callback.getBindings()) {
+ if (bindingClass.isInstance(binding)) {
+ return bindingClass.cast(binding);
+ }
+ }
+ }
+ return null;
+ }
+
public boolean isWiredByImpl() {
return wiredByImpl;
}
Modified: incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java (original)
+++ incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java Tue Jul 10 21:24:38 2007
@@ -64,6 +64,17 @@
return null;
}
+ public <B> B getCallbackBinding(Class<B> bindingClass) {
+ if (callback != null) {
+ for (Binding binding : callback.getBindings()) {
+ if (bindingClass.isInstance(binding)) {
+ return bindingClass.cast(binding);
+ }
+ }
+ }
+ return null;
+ }
+
public List<PolicySet> getPolicySets() {
return policySets;
}
Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2AsyncBindingInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2AsyncBindingInvoker.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2AsyncBindingInvoker.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2AsyncBindingInvoker.java Tue Jul 10 21:24:38 2007
@@ -28,6 +28,7 @@
import org.apache.axis2.client.OperationClient;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
+import org.apache.tuscany.sca.interfacedef.ConversationSequence;
public class Axis2AsyncBindingInvoker extends Axis2BindingInvoker {
@@ -40,8 +41,8 @@
super(serviceClient, wsdlOperationName, options, soapFactory);
}
- private Object invokeTarget(final Object payload, String conversationId)
- throws InvocationTargetException {
+ protected Object invokeTarget(final Object payload, final ConversationSequence sequence,
+ String conversationId) throws InvocationTargetException {
try {
Object[] args = (Object[]) payload;
OperationClient operationClient = createOperationClient(args, conversationId);
Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2CallbackInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2CallbackInvocationHandler.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2CallbackInvocationHandler.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2CallbackInvocationHandler.java Tue Jul 10 21:24:38 2007
@@ -18,9 +18,6 @@
*/
package org.apache.tuscany.sca.binding.axis2;
-import java.net.URI;
-import java.util.LinkedList;
-
import org.apache.tuscany.sca.core.invocation.AbstractInvocationHandler;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.MessageFactory;
@@ -35,19 +32,7 @@
this.wire = wire;
}
- public Object invoke(Operation operation, Object[] args, LinkedList<URI> callbackRoutingChain) throws Throwable {
-// Object targetAddress = callbackRoutingChain.removeFirst();
-// if (targetAddress == null) {
-// throw new AssertionError("Popped a null from address from stack");
-// }
-
-// //TODO optimize as this is slow in local invocations
-// Map<Operation, InvocationChain> sourceCallbackInvocationChains =
-// wire.getCallbackInvocationChains();
-// InvocationChain chain = sourceCallbackInvocationChains.get(operation);
-// chain.g
-// TargetInvoker invoker = chain.getTargetInvoker();
-// return invoke(chain, invoker, args, null, callbackRoutingChain, null);
- throw new UnsupportedOperationException("not yet implemented");
+ public Object invoke(Operation operation, Object[] args) throws Throwable {
+ return invoke(wire.getCallbackInvocationMap().get(operation), args, wire);
}
}
Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ReferenceBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ReferenceBindingProvider.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ReferenceBindingProvider.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ReferenceBindingProvider.java Tue Jul 10 21:24:38 2007
@@ -41,14 +41,15 @@
import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
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.invocation.MessageFactory;
-import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider2;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
import org.apache.tuscany.sca.runtime.RuntimeWire;
-public class Axis2ReferenceBindingProvider implements ReferenceBindingProvider {
+public class Axis2ReferenceBindingProvider implements ReferenceBindingProvider2 {
private MessageFactory messageFactory;
private RuntimeComponent component;
@@ -56,6 +57,7 @@
private WebServiceBinding wsBinding;
private ConfigurationContext configContext;
private ServiceClient serviceClient;
+ private WebServiceBinding callbackBinding;
public Axis2ReferenceBindingProvider(RuntimeComponent component,
RuntimeComponentReference reference,
@@ -73,20 +75,57 @@
} catch (AxisFault e) {
throw new RuntimeException(e); // TODO: better exception
}
+
initServiceClient();
+
+ // FIXME: only needed for the current tactical solution
+ // connect forward providers with matching callback providers
+ if (!wsBinding.isCallback()) {
+ // this is a forward binding, so look for a matching callback binding
+ if (reference.getCallback() != null) {
+ for (org.apache.tuscany.sca.assembly.Binding binding :
+ reference.getCallback().getBindings()) {
+ if (binding instanceof WebServiceBinding) {
+ // set the first compatible callback binding
+ setCallbackBinding((WebServiceBinding)binding);
+ continue;
+ }
+ }
+ }
+ } else {
+ // this is a callback binding, so look for all matching forward bindings
+ for (org.apache.tuscany.sca.assembly.Binding binding : reference.getBindings()) {
+ if (reference.getBindingProvider(binding) instanceof Axis2ReferenceBindingProvider) {
+ // set all compatible forward binding providers for this reference
+ ((Axis2ReferenceBindingProvider)reference.getBindingProvider(binding)).
+ setCallbackBinding(wsBinding);
+ }
+ }
+ }
}
- // methods for ReferenceBindingActivator
+ // FIXME: only needed for the current tactical solution
+ public void setCallbackBinding(WebServiceBinding callbackBinding) {
+ if (this.callbackBinding == null) {
+ this.callbackBinding = callbackBinding;
+ }
+ }
public void initServiceClient() {
+
InterfaceContract contract = wsBinding.getBindingInterfaceContract();
if (contract == null) {
- contract = reference.getInterfaceContract();
+ contract = reference.getInterfaceContract().makeUnidirectional(wsBinding.isCallback());
wsBinding.setBindingInterfaceContract(contract);
}
// Set to use the Axiom data binding
- contract.getInterface().setDefaultDataBinding(OMElement.class.getName());
+ if (contract.getInterface() != null) {
+ contract.getInterface().setDefaultDataBinding(OMElement.class.getName());
+ }
+ if (contract.getCallbackInterface() != null) {
+ contract.getCallbackInterface().setDefaultDataBinding(OMElement.class.getName());
+ }
// ??? following line was in Axis2BindingBuilder before the SPI changes
// and code reorg
@@ -104,20 +143,6 @@
serviceClient = createServiceClient();
}
- public void start() {
- }
-
- public void stop() {
-
- // close all connections that we have initiated, so that the jetty
- // server
- // can be restarted without seeing ConnectExceptions
- HttpClient httpClient = (HttpClient)serviceClient.getServiceContext().getConfigurationContext()
- .getProperty(HTTPConstants.CACHED_HTTP_CLIENT);
- if (httpClient != null)
- ((MultiThreadedHttpConnectionManager)httpClient.getHttpConnectionManager()).shutdown();
- }
-
/**
* Create an Axis2 ServiceClient
*/
@@ -137,23 +162,55 @@
}
}
- // methods for ReferenceBindingProvider
+ public void start() {
+ // FIXME: only needed for the current tactical solution
+ for (InvocationChain chain : reference.getRuntimeWire(wsBinding).getInvocationChains()) {
+ Invoker tailInvoker = chain.getTailInvoker();
+ if (tailInvoker instanceof Axis2AsyncBindingInvoker) {
+ RuntimeWire callbackWire = reference.getRuntimeWire(callbackBinding);
+ Operation callbackOperation = findCallbackOperation(callbackBinding.getBindingInterfaceContract());
+ Axis2CallbackInvocationHandler invocationHandler
+ = new Axis2CallbackInvocationHandler(messageFactory, callbackWire);
+ Axis2ReferenceCallbackTargetInvoker callbackInvoker
+ = new Axis2ReferenceCallbackTargetInvoker(callbackOperation, callbackWire, invocationHandler);
+ ((Axis2AsyncBindingInvoker)tailInvoker).setCallbackTargetInvoker(callbackInvoker);
+ }
+ }
+ }
+
+ public void stop() {
+
+ // close all connections that we have initiated, so that the jetty
+ // server
+ // can be restarted without seeing ConnectExceptions
+ HttpClient httpClient = (HttpClient)serviceClient.getServiceContext().getConfigurationContext()
+ .getProperty(HTTPConstants.CACHED_HTTP_CLIENT);
+ if (httpClient != null)
+ ((MultiThreadedHttpConnectionManager)httpClient.getHttpConnectionManager()).shutdown();
+ }
public InterfaceContract getBindingInterfaceContract() {
return wsBinding.getBindingInterfaceContract();
}
+ public boolean supportsAsyncOneWayInvocation() {
+ return true;
+ }
+
+ @Deprecated
public Invoker createInvoker(Operation operation, boolean isCallback) {
+ if (isCallback) {
+ throw new UnsupportedOperationException();
+ } else {
+ return createInvoker(operation);
+ }
+ }
- Axis2BindingInvoker invoker;
+ public Invoker createInvoker(Operation operation) {
- InterfaceContract contract = wsBinding.getBindingInterfaceContract();
- if (contract == null) {
- contract = reference.getInterfaceContract();
- wsBinding.setBindingInterfaceContract(contract);
- }
+ Axis2BindingInvoker invoker;
- if (wsBinding.getBindingInterfaceContract().getCallbackInterface() == null) {
+ if (reference.getInterfaceContract().getCallbackInterface() == null) {
invoker = createOperationInvoker(serviceClient, operation, false, operation.isNonBlocking());
} else {
// FIXME: SDODataBinding needs to pass in TypeHelper and classLoader
@@ -166,29 +223,17 @@
// of what actual callback method was invoked by the service at the
// other end
- RuntimeWire wire = reference.getRuntimeWire(wsBinding);
- Operation callbackOperation = findCallbackOperation(wire);
- Axis2CallbackInvocationHandler invocationHandler = new Axis2CallbackInvocationHandler(messageFactory, wire);
- Axis2ReferenceCallbackTargetInvoker callbackInvoker = new Axis2ReferenceCallbackTargetInvoker(
- callbackOperation,
- wire,
- invocationHandler);
-
- Axis2AsyncBindingInvoker asyncInvoker = (Axis2AsyncBindingInvoker)createOperationInvoker(serviceClient,
- operation,
- true,
- false);
- asyncInvoker.setCallbackTargetInvoker(callbackInvoker);
+ // the code to create the callback invoker has been moved to the start() method
+
+ Axis2AsyncBindingInvoker asyncInvoker
+ = (Axis2AsyncBindingInvoker)createOperationInvoker(serviceClient, operation, true, false);
invoker = asyncInvoker;
}
return invoker;
}
- private Operation findCallbackOperation(RuntimeWire wire) {
- InterfaceContract contract = wire.getTarget().getInterfaceContract(); // TODO:
- // which
- // end?
+ private Operation findCallbackOperation(InterfaceContract contract) {
List callbackOperations = contract.getCallbackInterface().getOperations();
if (callbackOperations.size() != 1) {
throw new RuntimeException("Can only handle one callback operation");
Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java Tue Jul 10 21:24:38 2007
@@ -56,24 +56,11 @@
// FIXME synchronize with forward thread to return value
signal.countDown();
try {
-// return invocationHandler.invoke(operation, args, callbackRoutingChain);
- return null; // TODO ???
+ return invocationHandler.invoke(operation, args);
} catch (Throwable t) {
t.printStackTrace();
throw new InvocationTargetException(t);
}
- }
-
- public Message invoke(Message msg) {
- try {
- Object resp = invokeTarget(msg.getBody(), null);
- msg.setBody(resp);
- } catch (InvocationTargetException e) {
- msg.setFaultBody(e.getCause());
- } catch (Throwable e) {
- msg.setFaultBody(e);
- }
- return msg;
}
public boolean isCacheable() {
Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceBindingProvider.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceBindingProvider.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceBindingProvider.java Tue Jul 10 21:24:38 2007
@@ -43,6 +43,7 @@
import org.apache.axis2.description.WSDLToAxisServiceBuilder;
import org.apache.axis2.engine.MessageReceiver;
import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
import org.apache.tuscany.sca.core.invocation.ThreadMessageContext;
import org.apache.tuscany.sca.http.ServletHost;
@@ -51,11 +52,11 @@
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
import org.apache.tuscany.sca.invocation.MessageFactory;
-import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider2;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
-public class Axis2ServiceBindingProvider implements ServiceBindingProvider {
+public class Axis2ServiceBindingProvider implements ServiceBindingProvider2 {
private RuntimeComponent component;
private RuntimeComponentService service;
@@ -63,6 +64,8 @@
private ServletHost servletHost;
private ConfigurationContext configContext;
private MessageFactory messageFactory;
+ private Axis2ServiceBindingProvider callbackProvider;
+ private InterfaceContract bindingInterfaceContract;
// TODO: what to do about the base URI?
private static final String BASE_URI = "http://localhost:8080/";
@@ -85,51 +88,85 @@
} catch (AxisFault e) {
throw new RuntimeException(e); // TODO: better exception
}
- }
-
- // methods for ServiceBindingActivator
- public void start() {
-
- // TODO: add back in from duplicate code in getBindingInterfaceContract
- // to temporarily bypass NPE
InterfaceContract contract = wsBinding.getBindingInterfaceContract();
if (contract == null) {
- contract = service.getInterfaceContract();
+ contract = service.getInterfaceContract().makeUnidirectional(wsBinding.isCallback());
wsBinding.setBindingInterfaceContract(contract);
}
// Set to use the Axiom data binding
- contract.getInterface().setDefaultDataBinding(OMElement.class.getName());
-
- String uri = computeActualURI(BASE_URI, component, service).normalize().toString();
- if (uri.endsWith("/")) {
- uri = uri.substring(0, uri.length() - 1);
+ if (contract.getInterface() != null) {
+ contract.getInterface().setDefaultDataBinding(OMElement.class.getName());
+ }
+ if (contract.getCallbackInterface() != null) {
+ contract.getCallbackInterface().setDefaultDataBinding(OMElement.class.getName());
}
- wsBinding.setURI(uri.toString());
- // TODO: if <binding.ws> specifies the wsdl service then should create a
- // service for every port
+ // FIXME: only needed for the current tactical solution
+ // connect forward providers with matching callback providers
+ if (!wsBinding.isCallback()) {
+ // this is a forward binding, so look for a matching callback binding
+ if (service.getCallback() != null) {
+ for (Binding binding : service.getCallback().getBindings()) {
+ if (service.getBindingProvider(binding) instanceof Axis2ServiceBindingProvider) {
+ // use the first compatible callback binding provider for this service
+ setCallbackProvider((Axis2ServiceBindingProvider)service.getBindingProvider(binding));
+ continue;
+ }
+ }
+ }
+ } else {
+ // this is a callback binding, so look for all matching forward bindings
+ for (Binding binding : service.getBindings()) {
+ if (service.getBindingProvider(binding) instanceof Axis2ServiceBindingProvider) {
+ // set all compatible forward binding providers for this service
+ ((Axis2ServiceBindingProvider)service.getBindingProvider(binding)).setCallbackProvider(this);
+ }
+ }
+ }
+ }
- try {
- configContext.getAxisConfiguration().addService(createAxisService());
- } catch (AxisFault e) {
- throw new RuntimeException(e);
+ // FIXME: only needed for the current tactical solution
+ public void setCallbackProvider(Axis2ServiceBindingProvider callbackProvider) {
+ if (this.callbackProvider == null) {
+ this.callbackProvider = callbackProvider;
}
+ }
- Axis2ServiceServlet servlet = new Axis2ServiceServlet();
- servlet.init(configContext);
- String servletURI = wsBinding.getURI();
- configContext.setContextRoot(servletURI);
- servletHost.addServletMapping(servletURI, servlet);
+ public void start() {
+ if (!wsBinding.isCallback()) {
+ String uri = computeActualURI(BASE_URI, component, service).normalize().toString();
+ if (uri.endsWith("/")) {
+ uri = uri.substring(0, uri.length() - 1);
+ }
+ wsBinding.setURI(uri.toString());
+
+ // TODO: if <binding.ws> specifies the wsdl service then should create a
+ // service for every port
+
+ try {
+ configContext.getAxisConfiguration().addService(createAxisService());
+ } catch (AxisFault e) {
+ throw new RuntimeException(e);
+ }
+
+ Axis2ServiceServlet servlet = new Axis2ServiceServlet();
+ servlet.init(configContext);
+ String servletURI = wsBinding.getURI();
+ configContext.setContextRoot(servletURI);
+ servletHost.addServletMapping(servletURI, servlet);
+ }
}
public void stop() {
- servletHost.removeServletMapping(wsBinding.getURI());
- try {
- configContext.getAxisConfiguration().removeService(wsBinding.getURI());
- } catch (AxisFault e) {
- throw new RuntimeException(e);
+ if (!wsBinding.isCallback()) {
+ servletHost.removeServletMapping(wsBinding.getURI());
+ try {
+ configContext.getAxisConfiguration().removeService(wsBinding.getURI());
+ } catch (AxisFault e) {
+ throw new RuntimeException(e);
+ }
}
}
@@ -156,9 +193,9 @@
wsdlURI = getEndpoint(wsBinding.getPort());
}
if (wsdlURI != null && wsdlURI.isAbsolute()) {
- if (wsBinding.getURI() != null && (wsBinding.getServiceName() != null && wsBinding.getBindingName() == null)) {
- throw new IllegalArgumentException("binding URI cannot be used with absolute WSDL endpoint URI");
- }
+// if (wsBinding.getURI() != null && (wsBinding.getServiceName() != null && wsBinding.getBindingName() == null)) {
+// throw new IllegalArgumentException("binding URI cannot be used with absolute WSDL endpoint URI");
+// }
return URI.create(wsdlURI.toString());
}
@@ -268,8 +305,8 @@
}
MessageReceiver msgrec = null;
- if (wsBinding.getBindingInterfaceContract().getCallbackInterface() != null) {
- msgrec = new Axis2ServiceInOutAsyncMessageReceiver(this, op);
+ if (service.getInterfaceContract().getCallbackInterface() != null) {
+ msgrec = new Axis2ServiceInOutAsyncMessageReceiver(this, callbackProvider, op);
} else if (op.isNonBlocking()) {
msgrec = new Axis2ServiceInMessageReceiver(this, op);
} else {
@@ -292,44 +329,19 @@
return null;
}
- // methods for ServiceBindingProvider
-
public InterfaceContract getBindingInterfaceContract() {
- InterfaceContract contract = wsBinding.getBindingInterfaceContract();
- if (contract == null) {
- contract = service.getInterfaceContract();
- wsBinding.setBindingInterfaceContract(contract);
- }
-
- // Set to use the Axiom data binding
- contract.getInterface().setDefaultDataBinding(OMElement.class.getName());
- return contract;
+ return wsBinding.getBindingInterfaceContract();
}
- // other methods that were previously in Axis2ServiceBinding
- // TODO: are these still needed?
-
- private Map<Object, InvocationContext> invCtxMap = new HashMap<Object, InvocationContext>();
-
- public Invoker createTargetInvoker(InterfaceContract contract, Operation operation) {
- // if (!operation.isCallback()) { TODO: no isCallback methjod yet?
- // throw new UnsupportedOperationException();
- // } else {
+ public Invoker createCallbackInvoker(Operation operation) {
return new Axis2ServiceCallbackTargetInvoker(this);
- // }
}
- public void addMapping(Object msgId, InvocationContext invCtx) {
- this.invCtxMap.put(msgId, invCtx);
- }
-
- public InvocationContext retrieveMapping(Object msgId) {
- return this.invCtxMap.get(msgId);
+ public boolean supportsAsyncOneWayInvocation() {
+ return true;
}
- public void removeMapping(Object msgId) {
- this.invCtxMap.remove(msgId);
- }
+ // methods for Axis2 message receivers
/**
* @param inMC
@@ -391,6 +403,26 @@
}
}
+ public boolean isConversational() {
+ return wsBinding.getBindingInterfaceContract().getInterface().isConversational();
+ }
+
+ // methods for handling callbacks
+
+ private Map<Object, InvocationContext> invCtxMap = new HashMap<Object, InvocationContext>();
+
+ public void addMapping(Object msgId, InvocationContext invCtx) {
+ this.invCtxMap.put(msgId, invCtx);
+ }
+
+ public InvocationContext retrieveMapping(Object msgId) {
+ return this.invCtxMap.get(msgId);
+ }
+
+ public void removeMapping(Object msgId) {
+ this.invCtxMap.remove(msgId);
+ }
+
protected class InvocationContext {
public MessageContext inMessageContext;
@@ -409,10 +441,6 @@
this.soapFactory = soapFactory;
this.doneSignal = doneSignal;
}
- }
-
- public boolean isConversational() {
- return wsBinding.getBindingInterfaceContract().getInterface().isConversational();
}
}
Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceInMessageReceiver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceInMessageReceiver.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceInMessageReceiver.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceInMessageReceiver.java Tue Jul 10 21:24:38 2007
@@ -18,6 +18,8 @@
*/
package org.apache.tuscany.sca.binding.axis2;
+import java.lang.reflect.InvocationTargetException;
+
import org.apache.axiom.om.OMElement;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
@@ -46,19 +48,16 @@
Object[] args = new Object[] {requestOM};
String conversationID = provider.isConversational() ? Axis2ServiceBindingProvider.getConversationID(inMC) : null;
-// axis2Service.invokeTarget(operation, args, null, conversationID);
+ provider.invokeTarget(operation, args, null, conversationID);
-// } catch (InvocationTargetException e) {
-// Throwable t = e.getCause();
-// if (t instanceof Exception) {
-// throw AxisFault.makeFault((Exception)t);
-// }
-// throw new InvocationRuntimeException(e);
- } catch (Throwable t) {
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getCause();
if (t instanceof Exception) {
throw AxisFault.makeFault((Exception)t);
}
- throw new RuntimeException(t);
+ throw new RuntimeException(e);
+ } catch (Exception e) {
+ throw AxisFault.makeFault(e);
}
}
Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java Tue Jul 10 21:24:38 2007
@@ -18,12 +18,14 @@
*/
package org.apache.tuscany.sca.binding.axis2;
+import java.lang.reflect.InvocationTargetException;
import java.util.concurrent.CountDownLatch;
import org.apache.axiom.om.OMElement;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.receivers.AbstractMessageReceiver;
+import org.apache.tuscany.sca.binding.axis2.Axis2ServiceBindingProvider.InvocationContext;
import org.apache.tuscany.sca.interfacedef.Operation;
public class Axis2ServiceInOutAsyncMessageReceiver extends AbstractMessageReceiver {
@@ -31,39 +33,45 @@
private Operation operation;
private Axis2ServiceBindingProvider provider;
+ private Axis2ServiceBindingProvider callbackProvider;
public Axis2ServiceInOutAsyncMessageReceiver(Axis2ServiceBindingProvider provider,
+ Axis2ServiceBindingProvider callbackProvider,
Operation operation) {
this.provider = provider;
+ this.callbackProvider = callbackProvider;
this.operation = operation;
}
public Axis2ServiceInOutAsyncMessageReceiver() {
}
- public final void receive(final MessageContext messageCtx) {
- try {
- Object messageId = messageCtx.getMessageID();
- if (messageId == null) {
- messageId = new MessageId();
- }
+ public final void receive(final MessageContext messageCtx) throws AxisFault {
+ Object messageId = messageCtx.getMessageID();
+ if (messageId == null) {
+ messageId = new MessageId();
+ }
- // Now use message id as index to context to be used by callback
- // target invoker
- CountDownLatch doneSignal = new CountDownLatch(1);
-// InvocationContext invCtx =
-// service.new InvocationContext(messageCtx, operation, getSOAPFactory(messageCtx), doneSignal);
-// service.addMapping(messageId, invCtx);
+ // Now use message id as index to context to be used by callback
+ // target invoker
+ CountDownLatch doneSignal = new CountDownLatch(1);
+ InvocationContext invCtx =
+ callbackProvider.new InvocationContext(messageCtx, operation, getSOAPFactory(messageCtx), doneSignal);
+ callbackProvider.addMapping(messageId, invCtx);
+ ThreadContextDescriptor tc = setThreadContext(messageCtx);
+ try {
invokeBusinessLogic(messageCtx, messageId);
-
- try {
- doneSignal.await();
- } catch(InterruptedException e) {
- e.printStackTrace();
- }
- } catch (AxisFault e) {
- // log.error(e);
+ } finally {
+ restoreThreadContext(tc);
+ }
+
+ // wait for callback to trigger the latch
+ // if no callback, block forever
+ try {
+ doneSignal.await();
+ } catch(InterruptedException e) {
+ e.printStackTrace();
}
}
@@ -72,17 +80,16 @@
OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
Object[] args = new Object[] {requestOM};
String conversationID = provider.isConversational() ? Axis2ServiceBindingProvider.getConversationID(inMC) : null;
-// service.invokeTarget(operation, args, messageId, conversationID);
-// } catch (InvocationTargetException e) {
-// Throwable t = e.getCause();
-// if (t instanceof Exception) {
-// throw AxisFault.makeFault((Exception)t);
-// }
-// throw new InvocationRuntimeException(e);
+ provider.invokeTarget(operation, args, messageId, conversationID);
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getCause();
+ if (t instanceof Exception) {
+ throw AxisFault.makeFault((Exception)t);
+ }
+ throw new RuntimeException(e);
} catch (Exception e) {
throw AxisFault.makeFault(e);
}
-
}
/**
Modified: incubator/tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java Tue Jul 10 21:24:38 2007
@@ -248,7 +248,11 @@
} catch (InvalidInterfaceException e) {
throw new ContributionResolveException(e);
}
- interfaceContract.setInterface(wsdlInterface);
+ if (!model.isCallback()) {
+ interfaceContract.setInterface(wsdlInterface);
+ } else {
+ interfaceContract.setCallbackInterface(wsdlInterface);
+ }
model.setBindingInterfaceContract(interfaceContract);
}
}
Modified: incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java Tue Jul 10 21:24:38 2007
@@ -22,7 +22,7 @@
import javax.wsdl.Service;
import javax.xml.namespace.QName;
-import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.CallbackBinding;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
@@ -32,7 +32,7 @@
*
* @version $Rev$ $Date$
*/
-public interface WebServiceBinding extends Binding {
+public interface WebServiceBinding extends CallbackBinding {
/**
* Sets the WSDL location.
Modified: incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java Tue Jul 10 21:24:38 2007
@@ -43,6 +43,7 @@
public class WebServiceBindingImpl implements WebServiceBinding {
private String name;
private String uri;
+ private boolean isCallback;
private List<PolicySet> policySets = new ArrayList<PolicySet>();
private List<Intent> requiredIntents = new ArrayList<Intent>();
private boolean unresolved;
@@ -78,6 +79,14 @@
public void setURI(String uri) {
this.uri = uri;
+ }
+
+ public boolean isCallback() {
+ return isCallback;
+ }
+
+ public void setCallback(boolean isCallback) {
+ this.isCallback = isCallback;
}
public List<Intent> getRequiredIntents() {
Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider2.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider2.java?view=auto&rev=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider2.java (added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider2.java Tue Jul 10 21:24:38 2007
@@ -0,0 +1,60 @@
+/*
+ * 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.provider;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+
+/**
+ * A reference binding implementation can optionally implement this
+ * interface to tie into the Tuscany SCA runtime and support
+ * asynchronous invocation.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ReferenceBindingProvider2 extends ReferenceBindingProvider {
+
+ /**
+ * Create an invoker for the reference binding in the invocation chain. The
+ * invoker is responsible for making the outbound invocation over the
+ * binding protocol.
+ *
+ * @param operation The operation that the interceptor will handle
+ * @return An invoker that handles the invocation logic, null should be
+ * returned if no invoker is required
+ */
+ Invoker createInvoker(Operation operation);
+
+ /**
+ * @deprecated This method has been replaced by createInvoker(Operation).
+ */
+ @Deprecated
+ Invoker createInvoker(Operation operation, boolean isCallback);
+
+ /**
+ * For bindings that invoke one-way operations asynchronously, there is no
+ * need to perform a thread switch before calling the invoker. This method
+ * indicates whether the binding has this capability.
+ *
+ * @return true if the binding invoker is able to invoke one-way operations
+ * asynchronously, false if all invocations are synchronous
+ */
+ boolean supportsAsyncOneWayInvocation();
+}
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider2.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider2.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider2.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider2.java?view=auto&rev=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider2.java (added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider2.java Tue Jul 10 21:24:38 2007
@@ -0,0 +1,54 @@
+/*
+ * 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.provider;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+
+/**
+ * A service binding can optionally implement this interface to tie
+ * into the Tuscany SCA runtime with support for callbacks
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ServiceBindingProvider2 extends ServiceBindingProvider {
+
+ /**
+ * Create a callback invoker for the service binding. The invoker is
+ * responsible for making the callback invocation over the binding
+ * protocol.
+ *
+ * @param operation The operation that the interceptor will handle
+ * @return An invoker that handles the invocation logic, null should be
+ * returned if no invoker is required
+ */
+ Invoker createCallbackInvoker(Operation operation);
+
+ /**
+ * For bindings that invoke one-way callback operations asynchronously,
+ * there is no need to perform a thread switch before calling the invoker.
+ * This method indicates whether the binding has this capability.
+ *
+ * @return true if the callback invoker is able to invoke one-way operations
+ * asynchronously, false if all invocations are synchronous
+ */
+ boolean supportsAsyncOneWayInvocation();
+
+}
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider2.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider2.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java (original)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java Tue Jul 10 21:24:38 2007
@@ -19,8 +19,10 @@
package org.apache.tuscany.sca.runtime;
+import java.util.IdentityHashMap;
import java.util.List;
+import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.InvocationChain;
/**
@@ -62,5 +64,21 @@
* with the wire
*/
List<InvocationChain> getCallbackInvocationChains();
+
+ /**
+ * Add an invocation chain for a callback service operation associated
+ * with the wire
+ *
+ * @param chain an invocation chain
+ */
+ void addCallbackInvocationChain(InvocationChain chain);
+
+ /**
+ * Get a map of invocation chains for callback service operations associated
+ * with the wire
+ *
+ * @return a map of invocation chains
+ */
+ IdentityHashMap<Operation, InvocationChain> getCallbackInvocationMap();
}
Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKCallbackInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKCallbackInvocationHandler.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKCallbackInvocationHandler.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKCallbackInvocationHandler.java Tue Jul 10 21:24:38 2007
@@ -72,13 +72,14 @@
// TODO beter hash algorithm
}
EndpointReference from = ThreadMessageContext.getMessageContext().getFrom();
- RuntimeWire wire = wires.get(from.getURI());
- assert wire != null;
- List<InvocationChain> chains = wire.getCallbackInvocationChains();
- IdentityHashMap<Operation, InvocationChain> map = new IdentityHashMap<Operation, InvocationChain>();
- for (InvocationChain chain : chains) {
- map.put(chain.getTargetOperation(), chain);
+ RuntimeWire wire = null;
+ if (from != null) {
+ wire = wires.get(from.getURI());
+ } else { // service with binding
+ wire = wires.get(null);
}
+ assert wire != null;
+ IdentityHashMap<Operation, InvocationChain> map = wire.getCallbackInvocationMap();
Operation operation = JavaInterfaceUtil.findOperation(method, map.keySet());
InvocationChain chain = map.get(operation);
try {
Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java Tue Jul 10 21:24:38 2007
@@ -66,7 +66,7 @@
}
InvocationChain chain = getInvocationChain(method);
if (chain == null) {
- throw new IllegalArgumentException("No matching opeeration is found: " + method);
+ throw new IllegalArgumentException("No matching operation is found: " + method);
}
// send the invocation down the wire
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org