diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-11 18:05:03 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-11 18:05:03 +0000 |
commit | ed95e8719dc29d943884fcfea32b6d9a745a9fd2 (patch) | |
tree | cf251b6303231857d8a8078926c6441abd01f009 /sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java | |
parent | 9ea6686aa690c68a7bdc875351c076b69a6f0fb2 (diff) |
Allows the lookup of services by interface (service name == null) from a node
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1102004 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java')
-rw-r--r-- | sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java index fc219588c6..e46c8b720b 100644 --- a/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java +++ b/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java @@ -28,6 +28,7 @@ import java.util.logging.Logger; import javax.xml.stream.XMLOutputFactory; import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.ComponentService; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.assembly.Service; @@ -41,6 +42,8 @@ import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.core.invocation.ProxyFactory; +import org.apache.tuscany.sca.interfacedef.Interface; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.node.Node; import org.apache.tuscany.sca.node.configuration.NodeConfiguration; @@ -261,22 +264,36 @@ public class NodeImpl implements Node, NodeExtension { public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String name) { // Extract the component name - String componentName; - String serviceName; - int i = name.indexOf('/'); - if (i != -1) { - componentName = name.substring(0, i); - serviceName = name.substring(i + 1); - - } else { - componentName = name; - serviceName = null; + String componentName = null; + String serviceName = null; + if (name != null) { + int i = name.indexOf('/'); + if (i != -1) { + componentName = name.substring(0, i); + serviceName = name.substring(i + 1); + + } else { + componentName = name; + serviceName = null; + } } // Lookup the component Component component = null; for (Component compositeComponent : domainComposite.getComponents()) { + if (componentName == null) { + for (ComponentService service : compositeComponent.getServices()) { + Interface intf = service.getInterfaceContract().getInterface(); + if (intf instanceof JavaInterface) { + JavaInterface ji = (JavaInterface)intf; + if (ji.getJavaClass() == businessInterface) { + return ((RuntimeComponent)compositeComponent).getComponentContext() + .createSelfReference(businessInterface, service); + } + } + } + } if (compositeComponent.getName().equals(componentName)) { component = compositeComponent; break; |