diff options
Diffstat (limited to 'java/sca/modules/core/src')
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); |