summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/node-impl
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/trunk/modules/node-impl')
-rw-r--r--sca-java-2.x/trunk/modules/node-impl/META-INF/MANIFEST.MF2
-rw-r--r--sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java37
-rw-r--r--sca-java-2.x/trunk/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java4
3 files changed, 32 insertions, 11 deletions
diff --git a/sca-java-2.x/trunk/modules/node-impl/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/node-impl/META-INF/MANIFEST.MF
index 8d0141e369..0f8eebd936 100644
--- a/sca-java-2.x/trunk/modules/node-impl/META-INF/MANIFEST.MF
+++ b/sca-java-2.x/trunk/modules/node-impl/META-INF/MANIFEST.MF
@@ -26,6 +26,8 @@ Import-Package: javax.management;resolution:=optional,
org.apache.tuscany.sca.definitions.xml;version="2.0.0",
org.apache.tuscany.sca.deployment;version="2.0.0",
org.apache.tuscany.sca.extensibility;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
org.apache.tuscany.sca.management;version="2.0.0",
org.apache.tuscany.sca.monitor;version="2.0.0",
org.apache.tuscany.sca.node;version="2.0.0",
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;
diff --git a/sca-java-2.x/trunk/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java b/sca-java-2.x/trunk/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java
index f869744b90..fc7547f830 100644
--- a/sca-java-2.x/trunk/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java
+++ b/sca-java-2.x/trunk/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java
@@ -116,6 +116,8 @@ public class NodeImplTestCase {
node.start();
HelloWorld hw = node.getService(HelloWorld.class, "HelloWorld");
Assert.assertEquals("Hello, Node", hw.hello("Node"));
+ hw = node.getService(HelloWorld.class, null);
+ Assert.assertEquals("Hello, Node", hw.hello("Node"));
String address = node.getEndpointAddress("HelloWorld");
Assert.assertNotNull(address);
address = node.getEndpointAddress("HelloWorld/HelloWorld");
@@ -123,7 +125,7 @@ public class NodeImplTestCase {
address = node.getEndpointAddress("HelloWorld/HelloWorld/HelloWorld");
Assert.assertNotNull(address);
address = node.getEndpointAddress("HelloWorld/HelloWorld1");
- Assert.assertNull(address);
+ Assert.assertNull(address);
node.stop();
}