From c148dc21980189096868c5d8edd05040b90dd68d Mon Sep 17 00:00:00 2001 From: antelder Date: Sat, 16 May 2009 08:03:50 +0000 Subject: Decouple node-impl from sca-client-impl git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@775426 13f79535-47bb-0310-9956-ffa450edef68 --- java/sca/itest/scaclient-api/pom.xml | 2 +- .../org/apache/tuscany/sca/node/NodeFinder.java | 42 ++++++++++++++++++++++ .../configuration/impl/NodeConfigurationImpl.java | 2 +- java/sca/modules/node-impl/META-INF/MANIFEST.MF | 1 - java/sca/modules/node-impl/pom.xml | 7 ---- .../org/apache/tuscany/sca/node/impl/NodeImpl.java | 21 +++++------ java/sca/modules/sca-client-impl/pom.xml | 2 +- .../tuscany/sca/client/impl/SCAClientImpl.java | 15 ++------ 8 files changed, 55 insertions(+), 37 deletions(-) create mode 100644 java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFinder.java (limited to 'java/sca') diff --git a/java/sca/itest/scaclient-api/pom.xml b/java/sca/itest/scaclient-api/pom.xml index 54151c5ce7..795221292c 100644 --- a/java/sca/itest/scaclient-api/pom.xml +++ b/java/sca/itest/scaclient-api/pom.xml @@ -31,7 +31,7 @@ org.apache.tuscany.sca - tuscany-node-impl + tuscany-sca-client-impl 2.0-SNAPSHOT diff --git a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFinder.java b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFinder.java new file mode 100644 index 0000000000..f81906af89 --- /dev/null +++ b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFinder.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.node; + +import java.net.URI; +import java.util.HashMap; +import java.util.Map; + +public class NodeFinder { + + private static Map nodes = new HashMap(); + + public static void addNode(URI domainName, Node node) { + nodes.put(domainName, node); + } + + public static Node removeNode(URI domainName) { + return nodes.remove(domainName); + } + + public static Node getNode(URI domainURI) { + return nodes.get(domainURI); + } + +} diff --git a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java index e9bd791f96..867e46ee75 100644 --- a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java +++ b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java @@ -37,7 +37,7 @@ import org.apache.tuscany.sca.node.configuration.NodeConfiguration; */ public class NodeConfigurationImpl implements NodeConfiguration { private String uri; - private String domainURI; + private String domainURI = "default"; private List contributions = new ArrayList(); private List bindings = new ArrayList(); diff --git a/java/sca/modules/node-impl/META-INF/MANIFEST.MF b/java/sca/modules/node-impl/META-INF/MANIFEST.MF index 5feccbf81d..fcf9d25ad0 100644 --- a/java/sca/modules/node-impl/META-INF/MANIFEST.MF +++ b/java/sca/modules/node-impl/META-INF/MANIFEST.MF @@ -22,7 +22,6 @@ Import-Package: javax.xml.namespace, org.apache.tuscany.sca.assembly;version="2.0.0", org.apache.tuscany.sca.assembly.builder;version="2.0.0", org.apache.tuscany.sca.assembly.xml;version="2.0.0", - org.apache.tuscany.sca.client.impl;version="2.0.0", org.apache.tuscany.sca.contribution;version="2.0.0", org.apache.tuscany.sca.contribution.processor;version="2.0.0", org.apache.tuscany.sca.contribution.resolver;version="2.0.0", diff --git a/java/sca/modules/node-impl/pom.xml b/java/sca/modules/node-impl/pom.xml index 5231d40b65..7918805412 100644 --- a/java/sca/modules/node-impl/pom.xml +++ b/java/sca/modules/node-impl/pom.xml @@ -69,13 +69,6 @@ compile - - org.apache.tuscany.sca - tuscany-sca-client-impl - 2.0-SNAPSHOT - compile - - org.apache.tuscany.sca tuscany-binding-sca diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java index 15794d9581..c6f1df2086 100644 --- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java +++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java @@ -52,7 +52,6 @@ import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.CompositeService; import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint; -import org.apache.tuscany.sca.client.impl.SCAClientImpl; import org.apache.tuscany.sca.contribution.Artifact; import org.apache.tuscany.sca.contribution.Contribution; import org.apache.tuscany.sca.contribution.ContributionFactory; @@ -92,6 +91,7 @@ import org.apache.tuscany.sca.monitor.Problem; import org.apache.tuscany.sca.monitor.Problem.Severity; import org.apache.tuscany.sca.node.Client; import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFinder; import org.apache.tuscany.sca.node.configuration.ContributionConfiguration; import org.apache.tuscany.sca.node.configuration.DeploymentComposite; import org.apache.tuscany.sca.node.configuration.NodeConfiguration; @@ -140,6 +140,8 @@ public class NodeImpl implements Node, Client, SCAClient { private WorkScheduler workScheduler; private Contribution systemContribution; private Definitions systemDefinitions; + + private URI domainURI; NodeImpl(NodeConfiguration configuration) { logger.log(Level.INFO, "Creating node: " + configuration.getURI()); @@ -284,6 +286,9 @@ public class NodeImpl implements Node, Client, SCAClient { } private void configureNode(NodeConfiguration configuration) throws Exception { + + domainURI = URI.create(configuration.getDomainURI()); + List contributions = new ArrayList(); // Load the specified contributions @@ -548,7 +553,7 @@ public class NodeImpl implements Node, Client, SCAClient { compositeActivator.start(composite); } - SCAClientImpl.addDomain(getDomainName(), this); + NodeFinder.addNode(domainURI, this); return this; @@ -563,7 +568,7 @@ public class NodeImpl implements Node, Client, SCAClient { try { - SCAClientImpl.removeDomain(getDomainName()); + NodeFinder.removeNode(domainURI); List composites = compositeActivator.getDomainComposite().getIncludes(); for (Composite composite : composites) { @@ -582,16 +587,6 @@ public class NodeImpl implements Node, Client, SCAClient { } - private URI getDomainName() { - URI domainName; - if (configurationName != null) { - domainName = URI.create(configurationName); - } else { - domainName = URI.create("default"); - } - return domainName; - } - public void destroy() { // Stop the runtime modules for (ModuleActivator moduleActivator : moduleActivators) { diff --git a/java/sca/modules/sca-client-impl/pom.xml b/java/sca/modules/sca-client-impl/pom.xml index 07475d8553..9a0fe91a7c 100644 --- a/java/sca/modules/sca-client-impl/pom.xml +++ b/java/sca/modules/sca-client-impl/pom.xml @@ -38,7 +38,7 @@ org.apache.tuscany.sca - tuscany-node-api + tuscany-node-impl 2.0-SNAPSHOT diff --git a/java/sca/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientImpl.java b/java/sca/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientImpl.java index e49f5faf2f..0f4c661f35 100644 --- a/java/sca/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientImpl.java +++ b/java/sca/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientImpl.java @@ -20,28 +20,17 @@ package org.apache.tuscany.sca.client.impl; import java.net.URI; -import java.util.HashMap; -import java.util.Map; import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFinder; import org.oasisopen.sca.NoSuchDomainException; import org.oasisopen.sca.NoSuchServiceException; import org.oasisopen.sca.client.SCAClient; public class SCAClientImpl implements SCAClient { - private static Map nodes = new HashMap(); - - public static void addDomain(URI domainName, Node node) { - nodes.put(domainName, node); - } - - public static Node removeDomain(URI domainName) { - return nodes.remove(domainName); - } - public T getService(Class serviceInterface, String serviceName, URI domainURI) throws NoSuchServiceException, NoSuchDomainException { - Node node = nodes.get(domainURI); + Node node = NodeFinder.getNode(domainURI); if (node == null) { throw new NoSuchDomainException(domainURI.toString()); } -- cgit v1.2.3