summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/core
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-10-05 18:38:10 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-10-05 18:38:10 +0000
commitb76e4724a219f78dab6f096591cf363223f7ca95 (patch)
treee6938eab287083ce50f675231f78a915d1ea3bac /java/sca/modules/core
parentcfd54b41d2ffb276de0b33e291934c9d1d380156 (diff)
Further refactor the CompositeContext to be the place to hold information about the Node
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@821953 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/core')
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java2
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java31
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java2
3 files changed, 32 insertions, 3 deletions
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java
index 838ab8a2a0..de9b575926 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java
@@ -496,7 +496,7 @@ public class CompositeActivatorImpl implements CompositeActivator {
return;
}
- compositeContext.configureComponentContext(runtimeComponent);
+ compositeContext.bindComponent(runtimeComponent);
// Reference bindings aren't started until the wire is first used
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java
index 13b0299554..b88c395f31 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java
@@ -20,6 +20,7 @@ package org.apache.tuscany.sca.core.context.impl;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Binding;
@@ -160,8 +161,36 @@ public class ComponentContextImpl implements RuntimeComponentContext {
throw new ServiceRuntimeException("Property not found: " + propertyName);
}
+ /**
+ * @param component
+ */
+ public static ComponentService getSingleService(Component component) {
+ ComponentService targetService;
+ List<ComponentService> services = component.getServices();
+ List<ComponentService> regularServices = new ArrayList<ComponentService>();
+ for (ComponentService service : services) {
+ if (service.isForCallback()) {
+ continue;
+ }
+ String name = service.getName();
+ if (!name.startsWith("$") || name.startsWith("$dynamic$")) {
+ regularServices.add(service);
+ }
+ }
+ if (regularServices.size() == 0) {
+ throw new ServiceRuntimeException("No service is declared on component " + component.getURI());
+ }
+ if (regularServices.size() != 1) {
+ throw new ServiceRuntimeException("More than one service is declared on component " + component.getURI()
+ + ". Service name is required to get the service.");
+ }
+ targetService = regularServices.get(0);
+ return targetService;
+ }
+
+
public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface) {
- ComponentService service = CompositeContext.getSingleService(component);
+ ComponentService service = getSingleService(component);
try {
return createSelfReference(businessInterface, service);
} catch (Exception e) {
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java
index a1fc91e824..2bf4199f92 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java
@@ -380,7 +380,7 @@ public class ServiceReferenceImpl<B> implements ServiceReferenceExt<B> {
fromXMLString();
this.component = (RuntimeComponent)endpointReference.getComponent();
- compositeContext.configureComponentContext(this.component);
+ compositeContext.bindComponent(this.component);
this.reference = (RuntimeComponentReference)endpointReference.getReference();
this.reference.setComponent(this.component);