summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/node-api
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-02-08 21:36:46 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-02-08 21:36:46 +0000
commitfd207779a42554d576f6b4a587249446fc992bae (patch)
treedce7855e635b5c7fca7381f12c5b233199e1e1a7 /sca-java-2.x/trunk/modules/node-api
parentf740fbe6c1b14f5accb0d32482f078f0db6142f3 (diff)
Generate unique Node URI if it's not set in the NodeConfiguration
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@907810 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/node-api')
-rw-r--r--sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java b/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java
index 8f7859367a..69f09e55da 100644
--- a/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java
+++ b/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java
@@ -415,12 +415,11 @@ public abstract class NodeFactory extends DefaultNodeConfigurationFactory {
return createNode(contributions);
}
- private volatile static int count =0;
private NodeConfiguration createConfiguration(Contribution... contributions) {
NodeConfigurationFactory factory = this;
NodeConfiguration configuration = factory.createNodeConfiguration();
// Make sure a unique node URI is created for the same node factory
- configuration.setURI(Node.DEFAULT_NODE_URI+(count++));
+ configuration.setURI(generateNodeURI());
if (contributions != null) {
for (Contribution c : contributions) {
configuration.addContribution(c.getURI(), c.getLocation());
@@ -429,6 +428,12 @@ public abstract class NodeFactory extends DefaultNodeConfigurationFactory {
return configuration;
}
+ private static int count = 0;
+
+ protected synchronized String generateNodeURI() {
+ return Node.DEFAULT_NODE_URI + (count++);
+ }
+
private Contribution[] getContributions(List<String> locations) {
Contribution[] contributions = new Contribution[locations.size()];
int index = 0;