summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/trunk/modules')
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java6
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java15
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java15
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java12
-rw-r--r--sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClient.java53
-rw-r--r--sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientFactoryImpl.java6
6 files changed, 31 insertions, 76 deletions
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java
index f6c6dca6ec..135c6a79c7 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java
@@ -35,7 +35,7 @@ import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
import org.apache.tuscany.sca.runtime.EndpointRegistry;
import org.oasisopen.sca.NoSuchDomainException;
import org.oasisopen.sca.NoSuchServiceException;
-import org.oasisopen.sca.client.SCAClient;
+import org.oasisopen.sca.client.SCAClientFactory;
public class DomainNode {
@@ -60,7 +60,7 @@ public class DomainNode {
public DomainNode(String configURI, String[] contributionLocations) {
this.domainRegistryURI = configURI;
initDomainName(configURI);
- nodeFactory = NodeFactory.getInstance(domainName);
+ nodeFactory = NodeFactory.getInstance(domainRegistryURI);
for (String loc : contributionLocations) {
addContribution(loc);
}
@@ -127,7 +127,7 @@ public class DomainNode {
public <T> T getService(Class<T> interfaze, String uri) throws NoSuchServiceException {
try {
- return SCAClient.getService(interfaze, getDomainName() + "/" + uri);
+ return SCAClientFactory.newInstance(URI.create(getDomainConfigURI())).getService(interfaze, uri);
} catch (NoSuchDomainException e) {
throw new IllegalStateException(e);
}
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java
index d901ba4280..8193dbacc6 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java
@@ -21,14 +21,15 @@ package org.apache.tuscany.sca.domain.node;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import itest.nodes.Helloworld;
import static org.junit.Assert.fail;
+import itest.nodes.Helloworld;
+
+import java.net.URI;
-import org.apache.tuscany.sca.domain.node.DomainNode;
import org.junit.After;
import org.junit.Test;
import org.oasisopen.sca.SCARuntimeException;
-import org.oasisopen.sca.client.SCAClient;
+import org.oasisopen.sca.client.SCAClientFactory;
/**
* This shows how to test the Calculator service component.
@@ -43,11 +44,11 @@ public class MultipleNodesPerJVMTestCase{
serviceNode = new DomainNode("target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
clientNode = new DomainNode("target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
- Helloworld service = SCAClient.getService(Helloworld.class, "defaultDomain/HelloworldService");
+ Helloworld service = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldService");
assertNotNull(service);
assertEquals("Hello Petra", service.sayHello("Petra"));
- Helloworld client = SCAClient.getService(Helloworld.class, "defaultDomain/HelloworldClient");
+ Helloworld client = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldClient");
assertNotNull(client);
assertEquals("Hi Hello Petra", client.sayHello("Petra"));
}
@@ -55,12 +56,12 @@ public class MultipleNodesPerJVMTestCase{
@Test
public void testTwoNodesDifferentDomains() throws Exception {
serviceNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"});
- Helloworld service = SCAClient.getService(Helloworld.class, "fooDomain/HelloworldService");
+ Helloworld service = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldService");
assertNotNull(service);
assertEquals("Hello Petra", service.sayHello("Petra"));
clientNode = new DomainNode("vm://barDomain", new String[]{"target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar"});
- Helloworld client = SCAClient.getService(Helloworld.class, "barDomain/HelloworldClient");
+ Helloworld client = SCAClientFactory.newInstance(URI.create("vm://barDomain")).getService(Helloworld.class, "HelloworldClient");
assertNotNull(client);
try {
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java
index 100cbde17a..ab237e6af6 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java
@@ -24,13 +24,14 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import itest.nodes.Helloworld;
-import org.apache.tuscany.sca.domain.node.DomainNode;
+import java.net.URI;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.oasisopen.sca.NoSuchDomainException;
import org.oasisopen.sca.NoSuchServiceException;
-import org.oasisopen.sca.client.SCAClient;
+import org.oasisopen.sca.client.SCAClientFactory;
/**
* This shows how to test the Calculator service component.
@@ -49,14 +50,14 @@ public class OneNodeTestCase{
@Test
public void testService() throws Exception {
- Helloworld service = SCAClient.getService(Helloworld.class, "defaultDomain/HelloworldService");
+ Helloworld service = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldService");
assertNotNull(service);
assertEquals("Hello Petra", service.sayHello("Petra"));
}
@Test
public void testClient() throws Exception {
- Helloworld client = SCAClient.getService(Helloworld.class, "defaultDomain/HelloworldClient");
+ Helloworld client = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldClient");
assertNotNull(client);
assertEquals("Hi Hello Petra", client.sayHello("Petra"));
}
@@ -65,13 +66,13 @@ public class OneNodeTestCase{
public void testRemovingServiceContribution() throws Exception {
domain.removeContribution(serviceContributionUri);
try {
- SCAClient.getService(Helloworld.class, "defaultDomain/HelloworldService");
+ SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldService");
// FIXME: should this be NoSuchServiceException or ServiceNotFoundException?
} catch (NoSuchServiceException e) {
// expected
}
- Helloworld client = SCAClient.getService(Helloworld.class, "defaultDomain/HelloworldClient");
+ Helloworld client = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldClient");
assertNotNull(client);
try {
assertEquals("Hi Hello Petra", client.sayHello("Petra"));
@@ -86,7 +87,7 @@ public class OneNodeTestCase{
public void testStoppingDomainNode() throws Exception {
domain.stop();
try {
- SCAClient.getService(Helloworld.class, "defaultDomain/HelloworldClient");
+ SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldClient");
fail();
} catch (NoSuchDomainException e) {
// expected
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java
index fdfd3fa0cb..9703fc14f8 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java
@@ -24,9 +24,11 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import itest.nodes.Helloworld;
+import java.net.URI;
+
import org.junit.After;
import org.junit.Test;
-import org.oasisopen.sca.client.SCAClient;
+import org.oasisopen.sca.client.SCAClientFactory;
/**
* This shows how to test the Calculator service component.
@@ -41,17 +43,17 @@ public class StopStartNodesTestCase{
serviceNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"});
clientNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar"});
- Helloworld service = SCAClient.getService(Helloworld.class, "fooDomain/HelloworldService");
+ Helloworld service = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldService");
assertNotNull(service);
assertEquals("Hello Petra", service.sayHello("Petra"));
- Helloworld client = SCAClient.getService(Helloworld.class, "fooDomain/HelloworldClient");
+ Helloworld client = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldClient");
assertNotNull(client);
assertEquals("Hi Hello Petra", client.sayHello("Petra"));
serviceNode.stop();
- client = SCAClient.getService(Helloworld.class, "fooDomain/HelloworldClient");
+ client = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldClient");
assertNotNull(client);
try {
assertEquals("Hi Hello Petra", client.sayHello("Petra"));
@@ -61,7 +63,7 @@ public class StopStartNodesTestCase{
}
serviceNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"});
- client = SCAClient.getService(Helloworld.class, "fooDomain/HelloworldClient");
+ client = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldClient");
assertNotNull(client);
assertEquals("Hi Hello Petra", client.sayHello("Petra"));
}
diff --git a/sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClient.java b/sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClient.java
deleted file mode 100644
index 907330e93b..0000000000
--- a/sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClient.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright(C) OASIS(R) 2005,2009. All Rights Reserved. 2299
- * OASIS trademark, IPR and other policies apply. 2300
- */
-package org.oasisopen.sca.client;
-
-import java.net.URI;
-import org.oasisopen.sca.NoSuchDomainException;
-import org.oasisopen.sca.NoSuchServiceException;
-
-/**
- * Client side helper that can be used to lookup SCA Services within a SCA Domain.
- *
- * @see SCAClientFactory
- */
-public class SCAClient {
-
- /**
- * Returns a reference proxy that implements the business interface <T> of a
- * service in a domain
- *
- * @param uri the URI of the target service. Takes the form domainURI/componentName/serviceName.
- * The domainURI can be left off and defaults to the implementation specific default domain
- * The service can also take the extended form
- * domainURI/componentName/serviceName (or /componentName/serviceName).
- * Can also take the extended form domainURI/componentName/serviceName/bindingName
- * (or /componentName/serviceName/bindingName) to use a specific binding of the target service
- * @param interfaze The business interface class of the service in the
- * domain
- * @param <T> The business interface class of the service in the domain
- * @return a proxy to the target service, in the specified SCA Domain that
- * implements the business interface <B>.
- * @throws NoSuchServiceException Service requested was not found
- * @throws NoSuchDomainException Domain requested was not found
- */
- public static <T> T getService(Class<T> interfaze, String uri) throws NoSuchServiceException, NoSuchDomainException {
- URI domainURI = null;
- String serviceURI;
- int i = uri.indexOf('/');
- if (i == -1) {
- domainURI = null;
- serviceURI = uri;
- } else {
- serviceURI = uri.substring(i+1);
- if (i > 0) {
- domainURI = URI.create(uri.substring(0, i));
- } else {
- domainURI = null;
- }
- }
- return SCAClientFactory.newInstance(domainURI).getService(interfaze, serviceURI);
- }
-}
diff --git a/sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientFactoryImpl.java b/sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientFactoryImpl.java
index fd0eadc20a..932f43c4c4 100644
--- a/sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientFactoryImpl.java
+++ b/sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientFactoryImpl.java
@@ -68,7 +68,11 @@ public class SCAClientFactoryImpl extends SCAClientFactory {
if (i > -1 && uri.charAt(i+2) != '/') {
uri = uri.replaceFirst(":/", "://");
}
- return URI.create(uri).getHost();
+ if (i < 0) {
+ return uri;
+ } else {
+ return URI.create(uri).getHost();
+ }
}
public void stop() {