summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/binding-sca-runtime/src/main/java/org
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-05-18 16:46:33 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-05-18 16:46:33 +0000
commit1f8bafbfc5aa7b5ca4d64e220498b83141243dfd (patch)
tree2c103f44b5ed9f9d332dda5c129653f99f265e7e /java/sca/modules/binding-sca-runtime/src/main/java/org
parent4b61a4eee852de02043729e3ee4bdf7014ef29ae (diff)
Change the creation of DistributedSCABinding to the factory to avoid OSGi violations
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@776005 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/binding-sca-runtime/src/main/java/org')
-rw-r--r--java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java8
-rw-r--r--java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java77
2 files changed, 46 insertions, 39 deletions
diff --git a/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java b/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java
index 4ba67620e1..23b3e60fea 100644
--- a/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java
+++ b/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java
@@ -25,8 +25,9 @@ import java.util.logging.Logger;
import org.apache.tuscany.sca.assembly.DistributedSCABinding;
import org.apache.tuscany.sca.assembly.OptimizableBinding;
import org.apache.tuscany.sca.assembly.SCABinding;
-import org.apache.tuscany.sca.assembly.impl.DistributedSCABindingImpl;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.InvocationChain;
@@ -61,6 +62,7 @@ public class RuntimeSCAReferenceBindingProvider implements ReferenceBindingProvi
private BindingProviderFactory<DistributedSCABinding> distributedProviderFactory = null;
private ReferenceBindingProvider distributedProvider = null;
+ private SCABindingFactory scaBindingFactory;
public RuntimeSCAReferenceBindingProvider(ExtensionPointRegistry extensionPoints,
RuntimeComponent component,
@@ -69,6 +71,8 @@ public class RuntimeSCAReferenceBindingProvider implements ReferenceBindingProvi
this.component = component;
this.reference = reference;
this.binding = binding;
+ this.scaBindingFactory =
+ extensionPoints.getExtensionPoint(FactoryExtensionPoint.class).getFactory(SCABindingFactory.class);
// look to see if a distributed SCA binding implementation has
// been included on the classpath. This will be needed by the
@@ -149,7 +153,7 @@ public class RuntimeSCAReferenceBindingProvider implements ReferenceBindingProvi
}
// create the remote provider
- DistributedSCABinding distributedBinding = new DistributedSCABindingImpl();
+ DistributedSCABinding distributedBinding = scaBindingFactory.createDistributedSCABinding();
distributedBinding.setSCABinding(binding);
distributedProvider =
diff --git a/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java b/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java
index 35b4de4d83..6852bcaab0 100644
--- a/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java
+++ b/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java
@@ -6,15 +6,15 @@
* 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.
+ * under the License.
*/
package org.apache.tuscany.sca.binding.sca.provider;
@@ -23,8 +23,9 @@ import java.net.URI;
import org.apache.tuscany.sca.assembly.DistributedSCABinding;
import org.apache.tuscany.sca.assembly.SCABinding;
-import org.apache.tuscany.sca.assembly.impl.DistributedSCABindingImpl;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.provider.BindingProviderFactory;
import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
@@ -33,67 +34,69 @@ import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
/**
- * The sca service binding provider mediates between the twin requirements of
- * local sca bindings and remote sca bindings. In the local case is does
- * very little. When the sca binding model is set as being remote this binding will
- * try and create a remote service endpoint for remote references to connect to
- *
+ * The sca service binding provider mediates between the twin requirements of
+ * local sca bindings and remote sca bindings. In the local case is does
+ * very little. When the sca binding model is set as being remote this binding will
+ * try and create a remote service endpoint for remote references to connect to
+ *
* @version $Rev$ $Date$
*/
public class RuntimeSCAServiceBindingProvider implements ServiceBindingProvider {
-
+
private RuntimeComponentService service;
private BindingProviderFactory<DistributedSCABinding> distributedProviderFactory;
private ServiceBindingProvider distributedProvider;
private DistributedSCABinding distributedBinding;
-
+
public RuntimeSCAServiceBindingProvider(ExtensionPointRegistry extensionPoints,
RuntimeComponent component,
RuntimeComponentService service,
SCABinding binding) {
this.service = service;
- // if there is potentially a wire to this service that crosses the node boundary
- if (service.getInterfaceContract().getInterface().isRemotable()) {
-
+ // if there is potentially a wire to this service that crosses the node boundary
+ if (service.getInterfaceContract().getInterface().isRemotable()) {
+
// look to see if a distributed SCA binding implementation has
- // been included on the classpath. This will be needed by the
+ // been included on the classpath. This will be needed by the
// provider itself to do it's thing
ProviderFactoryExtensionPoint factoryExtensionPoint =
extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class);
distributedProviderFactory =
(BindingProviderFactory<DistributedSCABinding>)factoryExtensionPoint
- .getProviderFactory(DistributedSCABinding.class);
-
- // Check the things that will generally be required to set up a
+ .getProviderFactory(DistributedSCABinding.class);
+
+ // Check the things that will generally be required to set up a
// distributed sca domain reference provider. I.e. make sure that we have a
// - distributed implementation of the sca binding available
// - remotable interface on the service
if (distributedProviderFactory != null) {
-
+
URI serviceURI = null;
try {
serviceURI = new URI(binding.getURI());
} catch(Exception ex) {
-
+
}
-
- if (RemoteBindingHelper.isTargetRemote() || ((serviceURI != null) && (serviceURI.isAbsolute()))) {
-
+
+ if (RemoteBindingHelper.isTargetRemote() || ((serviceURI != null) && (serviceURI.isAbsolute()))) {
+ SCABindingFactory scaBindingFactory =
+ extensionPoints.getExtensionPoint(FactoryExtensionPoint.class).getFactory(SCABindingFactory.class);
+
// create a nested provider to handle the remote case
- distributedBinding = new DistributedSCABindingImpl();
+ distributedBinding = scaBindingFactory.createDistributedSCABinding();
distributedBinding.setSCABinding(binding);
-
- distributedProvider =
+
+ distributedProvider =
distributedProviderFactory.createServiceBindingProvider(component, service, distributedBinding);
-
-
+
+
} else {
/* do nothing at the moment as only apps using the node implementation
- * will currently have the distributed domain set.
- *
+ * will currently have the distributed domain set.
+ *
throw new IllegalStateException("No distributed domain available for component: "+
component.getName() +
- " and service: " +
+ " and service: " +
service.getName());
*/
}
@@ -102,11 +105,11 @@ public class RuntimeSCAServiceBindingProvider implements ServiceBindingProvider
* are marked as remote
throw new IllegalStateException("No distributed SCA binding available for component: "+
component.getName() +
- " and service: " +
+ " and service: " +
service.getName());
*/
}
- }
+ }
}
public InterfaceContract getBindingInterfaceContract() {
@@ -124,7 +127,7 @@ public class RuntimeSCAServiceBindingProvider implements ServiceBindingProvider
public boolean supportsOneWayInvocation() {
return false;
}
-
+
public void start() {
if (distributedProvider != null) {
distributedProvider.start();
@@ -135,7 +138,7 @@ public class RuntimeSCAServiceBindingProvider implements ServiceBindingProvider
if (distributedProvider != null) {
distributedProvider.stop();
}
-
+
if (distributedBinding != null) {
// reset the binding URI to null so that if the composite containing the component
// with the service/binding is restarted the binding will have the correct URI set
@@ -147,9 +150,9 @@ public class RuntimeSCAServiceBindingProvider implements ServiceBindingProvider
}
} catch (Exception ex){
scaBinding.setURI(null);
- }
+ }
}
-
+
}
}