Author: slaws
Date: Tue Aug 14 03:17:32 2007
New Revision: 565693
URL: http://svn.apache.org/viewvc?view=rev&rev=565693
Log:
TUSCANY-1512
Fix up all the other parts of the sca runtime to make the distributed sca
binding work
Added:
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/DistributedSCABinding.java
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/BindingNotDistributedException.java
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/DistributedSCABindingImpl.java
Modified:
incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireableBinding.java
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeWireBuilderImpl.java
incubator/tuscany/java/sca/modules/binding-sca/pom.xml
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCABindingProviderFactory.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-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAServiceBindingProvider.java
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/SCABindingImpl.java
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceProvider.java
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivatorImpl.java
incubator/tuscany/java/sca/modules/pom.xml
Modified:
incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java?view=diff&rev=565693&r1=565692&r2=565693
==============================================================================
---
incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java
(original)
+++
incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java
Tue Aug 14 03:17:32 2007
@@ -47,7 +47,8 @@
private ComponentService targetComponentService;
private Binding targetBinding;
private List<Intent> computedIntents = new ArrayList<Intent>();;
- private List<PolicySet> computedPolicySets = new ArrayList<PolicySet>();;
+ private List<PolicySet> computedPolicySets = new ArrayList<PolicySet>();
+ private boolean isRemote = false;
public List<Intent> getComputedIntents() {
return computedIntents;
@@ -156,4 +157,21 @@
public void setTargetBinding(Binding targetBinding) {
this.targetBinding = targetBinding;
}
+
+ /**
+ * If a reference targets in a component running in a separate
+ * node then its binding will be set remote until runtime
+ *
+ * @param isRemote
+ */
+ public void setIsRemote(Boolean isRemote){
+ this.isRemote = isRemote;
+ }
+
+ /**
+ * @return the flag indicating whether the binding targets a remote
component
+ */
+ public boolean getIsRemote(){
+ return isRemote;
+ }
}
Modified:
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireableBinding.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireableBinding.java?view=diff&rev=565693&r1=565692&r2=565693
==============================================================================
---
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireableBinding.java
(original)
+++
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireableBinding.java
Tue Aug 14 03:17:32 2007
@@ -41,6 +41,19 @@
void setTargetBinding(Binding binding);
/**
+ * If a reference targets in a component running in a separate
+ * node then its binding will be set remote until runtime
+ *
+ * @param isRemote
+ */
+ void setIsRemote(Boolean isRemote);
+
+ /**
+ * @return the flag indicating whether the binding targets a remote
component
+ */
+ boolean getIsRemote();
+
+ /**
* @return
*/
Binding getTargetBinding();
Modified:
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeWireBuilderImpl.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeWireBuilderImpl.java?view=diff&rev=565693&r1=565692&r2=565693
==============================================================================
---
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeWireBuilderImpl.java
(original)
+++
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeWireBuilderImpl.java
Tue Aug 14 03:17:32 2007
@@ -353,7 +353,11 @@
composite);
}
} else {
- warning("Component reference target not found: " +
target.getName(), composite);
+ // put all the reference bindings into the target
so that they
+ // can be used for comparison when the target is
resolved at runtime
+
target.getBindings().addAll(componentReference.getBindings());
+
+ warning("Component reference target not found, it
might be a remote service: " + target.getName(), composite);
}
}
}
@@ -400,23 +404,31 @@
for (ComponentService service : targets) {
ComponentService target = service;
- if (service.getService() instanceof CompositeService) {
- // Normalize the service to be the final target
- target =
((CompositeService)service.getService()).getPromotedService();
- }
- Binding selected =
BindingUtil.resolveBindings(componentReference, target);
- if (selected == null) {
- warning("Component reference doesn't have a matching
binding", componentReference);
- } else {
- selectedBindings.add(selected);
- }
- if (bidirectional) {
- Binding selectedCallback =
BindingUtil.resolveCallbackBindings(componentReference, target);
- if (selectedCallback != null) {
- selectedCallbackBindings.add(selectedCallback);
+
+ // if the target is unresolved it will now have a list of the
reference
+ // bindings so ignore it
+ if (!target.isUnresolved()){
+
+ if (service.getService() instanceof CompositeService) {
+ // Normalize the service to be the final target
+ target =
((CompositeService)service.getService()).getPromotedService();
+ }
+ Binding selected =
BindingUtil.resolveBindings(componentReference, target);
+ if (selected == null) {
+ warning("Component reference doesn't have a matching
binding", componentReference);
+ } else {
+ selectedBindings.add(selected);
+ }
+ if (bidirectional) {
+ Binding selectedCallback =
BindingUtil.resolveCallbackBindings(componentReference, target);
+ if (selectedCallback != null) {
+ selectedCallbackBindings.add(selectedCallback);
+ }
}
}
+
}
+
if (!targets.isEmpty()) {
// Add all the effective bindings
componentReference.getBindings().clear();
@@ -426,7 +438,9 @@
componentReference.getCallback().getBindings().addAll(selectedCallbackBindings);
}
// Remove the targets since they have been normalized as
bindings
- targets.clear();
+ // TODO - leave then in for the case where there are still
unresolved
+ // targets that will be resolved at runtime
+ //targets.clear();
}
}
}
Modified: incubator/tuscany/java/sca/modules/binding-sca/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-sca/pom.xml?view=diff&rev=565693&r1=565692&r2=565693
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-sca/pom.xml (original)
+++ incubator/tuscany/java/sca/modules/binding-sca/pom.xml Tue Aug 14 03:17:32
2007
@@ -60,7 +60,13 @@
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-contribution-impl</artifactId>
<version>1.0-incubating-SNAPSHOT</version>
- </dependency>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-distributed</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.easymock</groupId>
Added:
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/DistributedSCABinding.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/DistributedSCABinding.java?view=auto&rev=565693
==============================================================================
---
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/DistributedSCABinding.java
(added)
+++
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/DistributedSCABinding.java
Tue Aug 14 03:17:32 2007
@@ -0,0 +1,39 @@
+/*
+ * 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;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.SCABinding;
+
+
+/**
+ * Represents an SCA binding used in the distributed runtime.
+ * At the moment just provides us with a sensibly named type
+ * against which the distributed sca binding providers can be registered
+ *
+ * @version $Rev: 556322 $ $Date: 2007-07-14 19:53:15 +0100 (Sat, 14 Jul 2007)
$
+ */
+public interface DistributedSCABinding extends Binding {
+
+ public SCABinding getSCABinding();
+ public void setSCABinging(SCABinding scaBinding);
+
+}
Added:
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/BindingNotDistributedException.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/BindingNotDistributedException.java?view=auto&rev=565693
==============================================================================
---
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/BindingNotDistributedException.java
(added)
+++
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/BindingNotDistributedException.java
Tue Aug 14 03:17:32 2007
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+
+/**
+ * Denotes that the sca binding does not have distributed providers
+ *
+ * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007)
$
+ */
+public class BindingNotDistributedException extends Exception {
+ private static final long serialVersionUID = 8612661660934426128L;
+
+}
Added:
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/DistributedSCABindingImpl.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/DistributedSCABindingImpl.java?view=auto&rev=565693
==============================================================================
---
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/DistributedSCABindingImpl.java
(added)
+++
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/DistributedSCABindingImpl.java
Tue Aug 14 03:17:32 2007
@@ -0,0 +1,145 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.WireableBinding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.binding.sca.DistributedSCABinding;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * The Distributed SCA binding wrapper for the SCA binding model object
+ *
+ * @version $Rev: 564307 $ $Date: 2007-08-09 18:48:29 +0100 (Thu, 09 Aug 2007)
$
+ */
+public class DistributedSCABindingImpl implements DistributedSCABinding {
+
+ private SCABinding scaBinding;
+
+ public List<Intent> getComputedIntents() {
+ return null;
+ }
+
+ public List<PolicySet> getComputedPolicySets() {
+ return null;
+ }
+
+ public Component getComponent() {
+ return null;
+ }
+
+ public void setComponent(Component component) {
+ }
+
+ public String getName() {
+ return null;
+ }
+
+ public String getURI() {
+ return null;
+ }
+
+ public void setName(String name) {
+ }
+
+ public void setURI(String uri) {
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return null;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return null;
+ }
+
+ public List<Object> getExtensions() {
+ return null;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ /**
+ * @return the targetComponent
+ */
+ public Component getTargetComponent() {
+ return null;
+ }
+
+ /**
+ * @param targetComponent the targetComponent to set
+ */
+ public void setTargetComponent(Component targetComponent) {
+ }
+
+ /**
+ * @return the targetComponentService
+ */
+ public ComponentService getTargetComponentService() {
+ return null;
+ }
+
+ /**
+ * @param targetComponentService the targetComponentService to set
+ */
+ public void setTargetComponentService(ComponentService
targetComponentService) {
+
+ }
+
+ /**
+ * @return the targetBinding
+ */
+ public Binding getTargetBinding() {
+ return null;
+ }
+
+ /**
+ * @param targetBinding the targetBinding to set
+ */
+ public void setTargetBinding(Binding targetBinding) {
+ }
+
+ public SCABinding getSCABinding(){
+ return scaBinding;
+ }
+
+ public void setSCABinging(SCABinding scaBinding){
+ this.scaBinding = scaBinding;
+ }
+}
Modified:
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCABindingProviderFactory.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCABindingProviderFactory.java?view=diff&rev=565693&r1=565692&r2=565693
==============================================================================
---
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCABindingProviderFactory.java
(original)
+++
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCABindingProviderFactory.java
Tue Aug 14 03:17:32 2007
@@ -20,10 +20,19 @@
package org.apache.tuscany.sca.binding.sca.impl;
import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.WireableBinding;
+import org.apache.tuscany.sca.binding.sca.DistributedSCABinding;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.distributed.domain.DistributedSCADomain;
+import org.apache.tuscany.sca.distributed.management.ServiceDiscovery;
+import org.apache.tuscany.sca.invocation.MessageFactory;
import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider2;
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.RuntimeComponentReference;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
@@ -33,19 +42,36 @@
*/
public class RuntimeSCABindingProviderFactory implements
BindingProviderFactory<SCABinding> {
+ private ExtensionPointRegistry extensionPoints;
+
public RuntimeSCABindingProviderFactory(ExtensionPointRegistry
extensionPoints) {
- }
-
+ this.extensionPoints = extensionPoints;
+
+ }
+
public ReferenceBindingProvider
createReferenceBindingProvider(RuntimeComponent component,
RuntimeComponentReference reference,
SCABinding
binding) {
- return new RuntimeSCAReferenceBindingProvider(component, reference,
binding);
+ RuntimeSCAReferenceBindingProvider provider = null;
+
+ try {
+ provider = new RuntimeSCAReferenceBindingProvider(extensionPoints,
component, reference, binding);
+ } catch (Exception ex) {
+ // The binding could not create a reference provider because either
+ // the sca binding does not have remote support or the interface
+ // in question is not remoteable
+ // null will be returned
+ System.err.println(ex.toString());
+ ex.printStackTrace();
+ }
+
+ return provider;
}
public ServiceBindingProvider
createServiceBindingProvider(RuntimeComponent component,
RuntimeComponentService service,
SCABinding
binding) {
- return new RuntimeSCAServiceBindingProvider(component, service,
binding);
+ return new RuntimeSCAServiceBindingProvider(extensionPoints,
component, service, binding);
}
public Class<SCABinding> getModelType() {
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?view=diff&rev=565693&r1=565692&r2=565693
==============================================================================
---
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
Tue Aug 14 03:17:32 2007
@@ -20,11 +20,19 @@
package org.apache.tuscany.sca.binding.sca.impl;
import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.WireableBinding;
+import org.apache.tuscany.sca.binding.sca.DistributedSCABinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.distributed.domain.DistributedSCADomain;
+import org.apache.tuscany.sca.distributed.management.ServiceDiscovery;
+import org.apache.tuscany.sca.distributed.management.ServiceNotFoundException;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
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.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
import org.apache.tuscany.sca.provider.ReferenceBindingProvider2;
import org.apache.tuscany.sca.runtime.EndpointReference;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
@@ -37,19 +45,53 @@
*/
public class RuntimeSCAReferenceBindingProvider implements
ReferenceBindingProvider2 {
+ private ExtensionPointRegistry extensionPoints;
private RuntimeComponentReference reference;
private SCABinding binding;
private boolean started = false;
+
+ private ReferenceBindingProvider2 distributedProvider = null;
- public RuntimeSCAReferenceBindingProvider(RuntimeComponent component,
+ public RuntimeSCAReferenceBindingProvider(ExtensionPointRegistry
extensionPoints,
+ RuntimeComponent component,
RuntimeComponentReference
reference,
- SCABinding binding) {
+ SCABinding binding)
+ throws BindingNotDistributedException, ServiceNotFoundException{
this.reference = reference;
this.binding = binding;
+
+ // look to see if a distributed SCA binding implementation has
+ // been included on the classpath. This will be needed by the
+ // provider itself to do it's thing
+ ProviderFactoryExtensionPoint factoryExtensionPoint =
extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+ BindingProviderFactory<DistributedSCABinding>
distributedProviderFactory = (BindingProviderFactory<DistributedSCABinding>)
+
factoryExtensionPoint.getProviderFactory(DistributedSCABinding.class);
+
+ // if there is a wire to this service that crosses the node boundary
+ if (((WireableBinding)binding).getIsRemote() == true) {
+ // Make sure that we have a distributed sca binding and
+ // that the interface is remoteable
+
+ if ((distributedProviderFactory != null) &&
+
(reference.getInterfaceContract().getInterface().isRemotable())){
+ DistributedSCABinding distributedBinding = new
DistributedSCABindingImpl();
+ distributedBinding.setSCABinging(binding);
+
+ distributedProvider = (ReferenceBindingProvider2)
+
distributedProviderFactory.createReferenceBindingProvider(component, reference,
distributedBinding);
+
+ } else {
+ throw new BindingNotDistributedException();
+ }
+ }
}
public InterfaceContract getBindingInterfaceContract() {
- return reference.getInterfaceContract();
+ if (distributedProvider != null){
+ return distributedProvider.getBindingInterfaceContract();
+ } else {
+ return reference.getInterfaceContract();
+ }
}
public boolean supportsAsyncOneWayInvocation() {
@@ -57,7 +99,11 @@
}
public Invoker createInvoker(Operation operation) {
- return new RuntimeSCABindingInvoker();
+ if (distributedProvider != null){
+ return distributedProvider.createInvoker(operation);
+ } else {
+ return new RuntimeSCABindingInvoker();
+ }
}
@Deprecated
@@ -107,9 +153,16 @@
}
}
}
+
+ if (distributedProvider != null){
+ distributedProvider.start();
+ }
}
public void stop() {
+ if (distributedProvider != null){
+ distributedProvider.stop();
+ }
}
}
Modified:
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAServiceBindingProvider.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAServiceBindingProvider.java?view=diff&rev=565693&r1=565692&r2=565693
==============================================================================
---
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAServiceBindingProvider.java
(original)
+++
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAServiceBindingProvider.java
Tue Aug 14 03:17:32 2007
@@ -21,11 +21,18 @@
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.binding.sca.DistributedSCABinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.distributed.domain.DistributedSCADomain;
+import org.apache.tuscany.sca.distributed.management.ServiceDiscovery;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
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.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ProviderFactory;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
import org.apache.tuscany.sca.provider.ServiceBindingProvider2;
import org.apache.tuscany.sca.runtime.EndpointReference;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
@@ -38,16 +45,78 @@
*/
public class RuntimeSCAServiceBindingProvider implements
ServiceBindingProvider2 {
+ private ExtensionPointRegistry extensionPoints;
+ private RuntimeComponent component;
private RuntimeComponentService service;
+ private SCABinding binding;
+
+ private BindingProviderFactory<DistributedSCABinding>
distributedProviderFactory;
+ private ServiceBindingProvider2 distributedProvider;
+ private DistributedSCABinding distributedBinding;
+
+ private boolean started = false;
+
+
- public RuntimeSCAServiceBindingProvider(RuntimeComponent component,
+ public RuntimeSCAServiceBindingProvider(ExtensionPointRegistry
extensionPoints,
+ RuntimeComponent component,
RuntimeComponentService service,
SCABinding binding) {
+ this.extensionPoints = extensionPoints;
+ this.component = component;
this.service = service;
+ this.binding = binding;
+
+ // look to see if a distributed SCA binding implementation has
+ // been included on the classpath and store it if it has
+ ProviderFactoryExtensionPoint factoryExtensionPoint =
extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+ distributedProviderFactory =
(BindingProviderFactory<DistributedSCABinding>)
+
factoryExtensionPoint.getProviderFactory(DistributedSCABinding.class);
+
+ // if a distributed sca binding is available and
+ // the target interface is remoteable and
+ // there is a wire to this service that crosses the node boundary
+ //then
+ // create a nested provider to handle the remote case
+ if ( (distributedProviderFactory != null) &&
+ (service.getInterfaceContract().getInterface().isRemotable()) ){
+ distributedBinding = new DistributedSCABindingImpl();
+ distributedBinding.setSCABinging(binding);
+ distributedProvider = (ServiceBindingProvider2)
+
distributedProviderFactory.createServiceBindingProvider(component, service,
distributedBinding);
+
+ // get the url out of the binding and send it to the registry if
+ // a distributed domain is configured
+ DistributedSCADomain distributedDomain =
((SCABindingImpl)binding).getDistributedDomain();
+
+ if (distributedDomain != null){
+ ServiceDiscovery serviceDiscovery =
distributedDomain.getServiceDiscovery();
+
+ // register endpoint twice to take account the formats
+ // ComponentName
+ // ComponentName/ServiceName
+
serviceDiscovery.registerServiceEndpoint(distributedDomain.getDomainName(),
+
distributedDomain.getNodeName(),
+ component.getName(),
+
SCABinding.class.getName(),
+ binding.getURI());
+
serviceDiscovery.registerServiceEndpoint(distributedDomain.getDomainName(),
+
distributedDomain.getNodeName(),
+ component.getName() +
"/" + service.getName(),
+
SCABinding.class.getName(),
+ binding.getURI());
+ }
+
+ }
+
}
public InterfaceContract getBindingInterfaceContract() {
- return service.getInterfaceContract();
+ if (distributedProvider != null){
+ return distributedProvider.getBindingInterfaceContract();
+ } else {
+ return service.getInterfaceContract();
+ }
}
public boolean supportsAsyncOneWayInvocation() {
@@ -59,9 +128,16 @@
}
public void start() {
+
+ if (distributedProvider != null) {
+ distributedProvider.start();
+ }
}
public void stop() {
+ if (distributedProvider != null) {
+ distributedProvider.stop();
+ }
}
}
Modified:
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/SCABindingImpl.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/SCABindingImpl.java?view=diff&rev=565693&r1=565692&r2=565693
==============================================================================
---
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/SCABindingImpl.java
(original)
+++
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/SCABindingImpl.java
Tue Aug 14 03:17:32 2007
@@ -28,6 +28,7 @@
import org.apache.tuscany.sca.assembly.SCABinding;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.distributed.domain.DistributedSCADomain;
/**
* Represents an SCA binding.
@@ -47,7 +48,19 @@
private ComponentService targetComponentService;
private Binding targetBinding;
private List<Intent> computedIntents = new ArrayList<Intent>();;
- private List<PolicySet> computedPolicySets = new ArrayList<PolicySet>();;
+ private List<PolicySet> computedPolicySets = new ArrayList<PolicySet>();
+ private boolean isRemote = false;
+
+ private DistributedSCADomain distributedDomain;
+
+
+ public void setDistributedDomain(DistributedSCADomain distributedDomain){
+ this.distributedDomain = distributedDomain;
+ }
+
+ public DistributedSCADomain getDistributedDomain(){
+ return distributedDomain;
+ }
public List<Intent> getComputedIntents() {
return computedIntents;
@@ -155,5 +168,22 @@
*/
public void setTargetBinding(Binding targetBinding) {
this.targetBinding = targetBinding;
+ }
+
+ /**
+ * If a reference targets in a component running in a separate
+ * node then its binding will be set remote until runtime
+ *
+ * @param isRemote
+ */
+ public void setIsRemote(Boolean isRemote){
+ this.isRemote = isRemote;
+ }
+
+ /**
+ * @return the flag indicating whether the binding targets a remote
component
+ */
+ public boolean getIsRemote(){
+ return isRemote;
}
}
Modified:
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceProvider.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceProvider.java?view=diff&rev=565693&r1=565692&r2=565693
==============================================================================
---
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceProvider.java
(original)
+++
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceProvider.java
Tue Aug 14 03:17:32 2007
@@ -45,6 +45,7 @@
import org.apache.axis2.engine.MessageReceiver;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.tuscany.sca.assembly.AbstractContract;
+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.core.runtime.EndpointReferenceImpl;
@@ -96,7 +97,7 @@
wsBinding.setURI(uri);
}
- protected void start() {
+ public void start() {
// TODO: if <binding.ws> specifies the wsdl service then should create
a
// service for every port
@@ -114,7 +115,7 @@
servletHost.addServletMapping(servletURI, servlet);
}
- protected void stop() {
+ public void stop() {
servletHost.removeServletMapping(wsBinding.getURI());
try {
configContext.getAxisConfiguration().removeService(wsBinding.getURI());
@@ -389,9 +390,9 @@
requestMsg.setBody(args);
if (contract instanceof RuntimeComponentService)
-
requestMsg.setTo(((RuntimeComponentService)contract).getRuntimeWire(wsBinding).getTarget());
+
requestMsg.setTo(((RuntimeComponentService)contract).getRuntimeWire(getBinding()).getTarget());
else
-
requestMsg.setTo(((RuntimeComponentReference)contract).getRuntimeWire(wsBinding).getTarget());
+
requestMsg.setTo(((RuntimeComponentReference)contract).getRuntimeWire(getBinding()).getTarget());
if (callbackAddress != null) {
requestMsg.setFrom(new EndpointReferenceImpl(callbackAddress));
}
@@ -406,7 +407,7 @@
requestMsg.setConversationID(null);
}
- Message responseMsg =
((RuntimeComponentService)contract).getInvoker(wsBinding,
op).invoke(requestMsg);
+ Message responseMsg =
((RuntimeComponentService)contract).getInvoker(getBinding(),
op).invoke(requestMsg);
if (responseMsg.isFault()) {
throw new
InvocationTargetException((Throwable)responseMsg.getBody());
}
@@ -419,6 +420,16 @@
public boolean isConversational() {
return
wsBinding.getBindingInterfaceContract().getInterface().isConversational();
+ }
+
+ /**
+ * Return the binding for this provider as a primitive binding type
+ * For use when looking up wires registered against the binding.
+ *
+ * @return the binding
+ */
+ protected Binding getBinding(){
+ return wsBinding;
}
}
Modified:
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivatorImpl.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivatorImpl.java?view=diff&rev=565693&r1=565692&r2=565693
==============================================================================
---
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivatorImpl.java
(original)
+++
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivatorImpl.java
Tue Aug 14 03:17:32 2007
@@ -19,6 +19,7 @@
package org.apache.tuscany.sca.core.runtime;
+import java.util.ArrayList;
import java.util.List;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
@@ -29,6 +30,7 @@
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.Implementation;
import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.SCABinding;
import org.apache.tuscany.sca.assembly.SCABindingFactory;
import org.apache.tuscany.sca.assembly.Service;
import org.apache.tuscany.sca.assembly.WireableBinding;
@@ -203,6 +205,11 @@
private void addReferenceBindingProviders(RuntimeComponent component,
RuntimeComponentReference
reference,
List<Binding> bindings) {
+
+ List<Binding> unresolvedTargetBindings = new ArrayList<Binding>();
+
+ // create binding providers for all of the bindings for resolved
targets
+ // or for all of the bindings where no targets are specified
for (Binding binding : bindings) {
BindingProviderFactory providerFactory =
(BindingProviderFactory)providerFactories.getProviderFactory(binding.getClass());
@@ -219,6 +226,59 @@
throw new IllegalStateException("Provider factory not found
for class: " + binding.getClass().getName());
}
}
+
+ // go over any targets that have not been resolved yet (as they are
running on other nodes)
+ // and try an resolve them remotely
+ // TODO - this should work for any kind of wired binding but the only
wireable binding
+ // is currently the SCA binding so we assume that
+ for ( ComponentService service : reference.getTargets()){
+ if ( service.isUnresolved()){
+ for (Binding binding : service.getBindings()) {
+ // TODO - we should look at all the bindings now
associated with the
+ // unresolved target but we assume the SCA binding
here as
+ // its currently the only wireable one
+ if (binding instanceof SCABinding) {
+ SCABinding scaBinding = (SCABinding)binding;
+
+ BindingProviderFactory providerFactory =
+
(BindingProviderFactory)providerFactories.getProviderFactory(SCABinding.class);
+
+ if (providerFactory == null) {
+ throw new IllegalStateException("Provider factory
not found for class: " + scaBinding.getClass().getName());
+ }
+
+ // clone the SCA binding and fill in service details
+ SCABinding clonedSCABinding = null;
+ try {
+ clonedSCABinding =
(SCABinding)((WireableBinding)scaBinding).clone();
+ clonedSCABinding.setURI(service.getName());
+
((WireableBinding)clonedSCABinding).setIsRemote(true);
+ } catch (Exception e) {
+ // warning("The binding doesn't support clone: " +
binding.getClass().getSimpleName(), binding);
+ }
+
+ @SuppressWarnings("unchecked")
+ ReferenceBindingProvider bindingProvider =
+
providerFactory.createReferenceBindingProvider((RuntimeComponent)component,
+
(RuntimeComponentReference)reference,
+
clonedSCABinding);
+ if (bindingProvider != null) {
+
((RuntimeComponentReference)reference).setBindingProvider(clonedSCABinding,
bindingProvider);
+
+ // add the cloned SCA binding to the reference as
it will be used to look up the
+ // provider later
+ reference.getBindings().add(clonedSCABinding);
+ } else {
+ throw new IllegalStateException("No distributed
SCA Binding implementation found for reference: " +
+
reference.getName() +
+ " and target: " +
+ service.getName()
+
+ " or the
referenced interface is not remoteable");
+ }
+ }
+ }
+ }
+ }
}
private void removeReferenceBindingProviders(RuntimeComponent component,
Modified: incubator/tuscany/java/sca/modules/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/pom.xml?view=diff&rev=565693&r1=565692&r2=565693
==============================================================================
--- incubator/tuscany/java/sca/modules/pom.xml (original)
+++ incubator/tuscany/java/sca/modules/pom.xml Tue Aug 14 03:17:32 2007
@@ -47,8 +47,8 @@
<module>binding-notification</module>
<module>binding-rmi</module>
<module>binding-sca</module>
- <!--
<module>binding-sca-axis2</module>
+ <!--
<module>binding-sca-jms</module>
-->
<module>binding-sca-xml</module>
@@ -74,6 +74,7 @@
<module>discovery-jms</module>
-->
<module>distributed</module>
+ <module>distributed-impl</module>
<module>extension-helper</module>
<module>host-embedded</module>
<module>host-http</module>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]