Author: antelder
Date: Tue Nov 24 11:30:21 2009
New Revision: 883659
URL: http://svn.apache.org/viewvc?rev=883659&view=rev
Log:
Remove ConfigAttributesImpl as its not used now and simplify constructors
Removed:
tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/ConfigAttributesImpl.java
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/ConfigTestCase.java
Modified:
tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java
Modified:
tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java?rev=883659&r1=883658&r2=883659&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java
Tue Nov 24 11:30:21 2009
@@ -28,10 +28,8 @@
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
-import org.apache.tuscany.sca.management.ConfigAttributes;
import org.apache.tuscany.sca.node.Node;
import org.apache.tuscany.sca.node.NodeFactory;
-import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
import org.apache.tuscany.sca.node.impl.NodeImpl;
import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
import org.apache.tuscany.sca.runtime.EndpointRegistry;
@@ -41,57 +39,37 @@
public class DomainNode {
- public static final String DOMAIN_NAME_ATTR = "domainName";
- public static final String DOMAIN_SCHEME_ATTR = "domainScheme";
- public static final String DEFAULT_DOMAIN_SCHEME = "vm";
- public static final String DEFAULT_DOMAIN_NAME = "defaultDomain";
+ private static final String DEFAULT_DOMAIN_SCHEME = "vm";
+ private static final String DEFAULT_DOMAIN_NAME = "defaultDomain";
+ private static final String DEFAULT_CONFIG_URI = DEFAULT_DOMAIN_SCHEME +
"://" + DEFAULT_DOMAIN_NAME;
- private ConfigAttributes configAttributes = new ConfigAttributesImpl();
+ private String domainName;
private String domainRegistryURI;
private NodeFactory nodeFactory;
private Map<String, Node> nodes = new HashMap<String, Node>();
public DomainNode() {
- this(DEFAULT_DOMAIN_SCHEME + "://" + DEFAULT_DOMAIN_NAME);
+ this(DEFAULT_CONFIG_URI, new String[]{});
}
- public DomainNode(String configURI) {
- this.domainRegistryURI = configURI;
- parseConfigURI(configURI);
- start();
+ public DomainNode(String... contributionLocations) {
+ this(DEFAULT_CONFIG_URI, contributionLocations);
}
- public DomainNode(String configURI, String... contributionLocations) {
+ public DomainNode(String configURI, String[] contributionLocations) {
this.domainRegistryURI = configURI;
- parseConfigURI(configURI);
- start();
+ initDomainName(configURI);
+ nodeFactory = NodeFactory.getInstance(domainName);
for (String loc : contributionLocations) {
addContribution(loc);
}
}
-
- public void start() {
- if (nodeFactory != null) {
- throw new IllegalStateException("The node is already started");
- }
-
- nodeFactory =
NodeFactory.getInstance(configAttributes.getAttributes().get(DOMAIN_NAME_ATTR));
- }
-
- public boolean isStarted() {
- return nodeFactory != null;
- }
public void stop() {
- if (nodeFactory == null) {
- throw new IllegalStateException("The node is not started");
- }
-
for (Node node : nodes.values()) {
node.stop();
}
-
}
public String addContribution(String location) {
@@ -104,12 +82,7 @@
if (nodes.containsKey(uri)) {
throw new IllegalArgumentException("contribution already added: "
+ uri);
}
- NodeConfiguration configuration =
nodeFactory.createNodeConfiguration();
- configuration.addContribution(uri, location);
- configuration.setDomainRegistryURI(domainRegistryURI);
-
configuration.setDomainURI(configAttributes.getAttributes().get(DOMAIN_NAME_ATTR));
- configuration.setURI(uri);
- Node node = nodeFactory.createNode(configuration).start();
+ Node node = nodeFactory.createNode((String)null, new String[] {uri},
new String[] {location}).start();
nodes.put(uri, node);
}
@@ -121,50 +94,8 @@
node.stop();
}
- public ConfigAttributes getConfigAttributes() {
- return configAttributes;
- }
-
public String getDomainName() {
- return configAttributes.getAttributes().get(DOMAIN_NAME_ATTR);
- }
-
- protected void parseConfigURI(String configURI) {
- URI uri = URI.create(fixScheme(configURI));
- String dn = uri.getHost();
- if (dn == null || dn.length() < 1) {
- dn = DEFAULT_DOMAIN_NAME;
- }
- configAttributes.getAttributes().put(DOMAIN_NAME_ATTR, dn);
- String scheme = uri.getScheme();
- if (scheme != null && scheme.length() > 0) {
- configAttributes.getAttributes().put(DOMAIN_SCHEME_ATTR, scheme);
- }
-
- String query = uri.getQuery();
- if (query != null && query.length() > 0) {
- String[] params = query.split("&");
- for (String param : params){
- String name = param.split("=")[0];
- String value = param.split("=")[1];
- configAttributes.getAttributes().put(name, value);
- }
- }
- }
-
- /**
- * I keep typing the scheme part with just a colon instead of colon slash
slash
- * which URI doesn't parse properly which irritates me so fix it up here
- */
- private String fixScheme(String uri) {
- int i = uri.indexOf(":");
- if (i > -1 && uri.charAt(i+1) != '/') {
- uri = uri.replaceFirst(":", ":/");
- }
- if (i > -1 && uri.charAt(i+2) != '/') {
- uri = uri.replaceFirst(":/", "://");
- }
- return uri;
+ return domainName;
}
public String getDomainConfigURI() {
@@ -201,4 +132,28 @@
throw new IllegalStateException(e);
}
}
+
+ protected void initDomainName(String configURI) {
+ URI uri = URI.create(fixScheme(configURI));
+ String dn = uri.getHost();
+ if (dn == null || dn.length() < 1) {
+ dn = DEFAULT_DOMAIN_NAME;
+ }
+ domainName = dn;
+ }
+
+ /**
+ * I keep typing the scheme part with just a colon instead of colon slash
slash
+ * which URI doesn't parse properly which irritates me so fix it up here
+ */
+ protected String fixScheme(String uri) {
+ int i = uri.indexOf(":");
+ if (i > -1 && uri.charAt(i+1) != '/') {
+ uri = uri.replaceFirst(":", ":/");
+ }
+ if (i > -1 && uri.charAt(i+2) != '/') {
+ uri = uri.replaceFirst(":/", "://");
+ }
+ return uri;
+ }
}
Modified:
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java?rev=883659&r1=883658&r2=883659&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java
Tue Nov 24 11:30:21 2009
@@ -21,14 +21,12 @@
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 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;
/**
* This shows how to test the Calculator service component.
@@ -40,8 +38,8 @@
@Test
public void testTwoNodesSameDomain() throws Exception {
- serviceNode = new DomainNode("vm://fooDomain",
"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
- clientNode = new DomainNode("vm://fooDomain",
"target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
+ 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 = serviceNode.getService(Helloworld.class,
"HelloworldService");
assertNotNull(service);
@@ -50,23 +48,16 @@
Helloworld client = clientNode.getService(Helloworld.class,
"HelloworldClient");
assertNotNull(client);
assertEquals("Hi Hello Petra", client.sayHello("Petra"));
-
- if (clientNode != null && clientNode.isStarted()) {
- clientNode.stop();
- }
- if (serviceNode != null && serviceNode.isStarted()) {
- serviceNode.stop();
- }
}
@Test
public void testTwoNodesDifferentDomains() throws Exception {
- serviceNode = new DomainNode("vm://fooDomain",
"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
+ serviceNode = new DomainNode("vm://fooDomain", new
String[]{"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"});
Helloworld service = serviceNode.getService(Helloworld.class,
"HelloworldService");
assertNotNull(service);
assertEquals("Hello Petra", service.sayHello("Petra"));
- clientNode = new DomainNode("vm://barDomain",
"target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
+ clientNode = new DomainNode("vm://barDomain", new String[]
{"target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar"});
Helloworld client = clientNode.getService(Helloworld.class,
"HelloworldClient");
assertNotNull(client);
@@ -81,10 +72,10 @@
@After
public void tearDownAfterClass() throws Exception {
- if (clientNode != null && clientNode.isStarted()) {
+ if (clientNode != null) {
clientNode.stop();
}
- if (serviceNode != null && serviceNode.isStarted()) {
+ if (serviceNode != null) {
serviceNode.stop();
}
}
Modified:
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java?rev=883659&r1=883658&r2=883659&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java
Tue Nov 24 11:30:21 2009
@@ -40,33 +40,26 @@
@Test
public void testTwoNodesSameDomain() throws Exception {
- serviceNode = new DomainNode("vm://fooDomain",
"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
- clientNode = new DomainNode("vm://fooDomain",
"target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
+ 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,
"fooDomain/HelloworldService");
+ Helloworld service = SCAClient.getService(Helloworld.class,
"defaultDomain/HelloworldService");
assertNotNull(service);
assertEquals("Hello Petra", service.sayHello("Petra"));
- Helloworld client = SCAClient.getService(Helloworld.class,
"fooDomain/HelloworldClient");
+ Helloworld client = SCAClient.getService(Helloworld.class,
"defaultDomain/HelloworldClient");
assertNotNull(client);
assertEquals("Hi Hello Petra", client.sayHello("Petra"));
-
- if (clientNode != null && clientNode.isStarted()) {
- clientNode.stop();
- }
- if (serviceNode != null && serviceNode.isStarted()) {
- serviceNode.stop();
- }
}
@Test
public void testTwoNodesDifferentDomains() throws Exception {
- serviceNode = new DomainNode("vm://fooDomain",
"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
+ 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");
assertNotNull(service);
assertEquals("Hello Petra", service.sayHello("Petra"));
- clientNode = new DomainNode("vm://barDomain",
"target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
+ 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");
assertNotNull(client);
@@ -81,10 +74,10 @@
@After
public void tearDownAfterClass() throws Exception {
- if (clientNode != null && clientNode.isStarted()) {
+ if (clientNode != null) {
clientNode.stop();
}
- if (serviceNode != null && serviceNode.isStarted()) {
+ if (serviceNode != null) {
serviceNode.stop();
}
}
Modified:
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java?rev=883659&r1=883658&r2=883659&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java
Tue Nov 24 11:30:21 2009
@@ -95,7 +95,7 @@
@After
public void tearDownAfterClass() throws Exception {
- if (domain != null && domain.isStarted()) {
+ if (domain != null) {
domain.stop();
}
}
Modified:
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java?rev=883659&r1=883658&r2=883659&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java
Tue Nov 24 11:30:21 2009
@@ -38,8 +38,8 @@
@Test
public void testTwoNodesSameDomain() throws Exception {
- serviceNode = new DomainNode("vm://fooDomain",
"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
- clientNode = new DomainNode("vm://fooDomain",
"target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
+ 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");
assertNotNull(service);
@@ -60,7 +60,7 @@
// expected
}
- serviceNode = new DomainNode("vm://fooDomain",
"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
+ 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");
assertNotNull(client);
assertEquals("Hi Hello Petra", client.sayHello("Petra"));
@@ -68,10 +68,10 @@
@After
public void tearDownAfterClass() throws Exception {
- if (clientNode != null && clientNode.isStarted()) {
+ if (clientNode != null) {
clientNode.stop();
}
- if (serviceNode != null && serviceNode.isStarted()) {
+ if (serviceNode != null) {
serviceNode.stop();
}
}