diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-01-12 08:56:52 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-01-12 08:56:52 +0000 |
commit | 9a4d83faf250efb00160c20c05fb727ad92c555c (patch) | |
tree | a249e7ad5933517b6f1f6c0c239547289a62e2b9 /sca-java-2.x/trunk/modules/domain-node/src/main/java/org | |
parent | e30d27ecbcbfa0c5f08299af755a38f2c2365db0 (diff) |
Update to create a service proxy directly instead of using the sca client factory api and update testcases for that, and rename package
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1058025 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/domain-node/src/main/java/org')
-rw-r--r-- | sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/Node.java (renamed from sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/Node.java) | 2 | ||||
-rw-r--r-- | sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/NodeFactory.java (renamed from sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/NodeFactory.java) | 6 | ||||
-rw-r--r-- | sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/impl/DeployedComposite.java (renamed from sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/DeployedComposite.java) | 2 | ||||
-rw-r--r-- | sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/impl/InstalledContribution.java (renamed from sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/InstalledContribution.java) | 2 | ||||
-rw-r--r-- | sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/impl/NodeImpl.java (renamed from sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/NodeImpl.java) | 38 |
5 files changed, 33 insertions, 17 deletions
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/Node.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/Node.java index 9a82997a33..5e9d9973c3 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/Node.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/Node.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.tuscany.sca.node2; +package org.apache.tuscany.sca.runtime; import java.io.Reader; import java.util.List; diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/NodeFactory.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/NodeFactory.java index 999311b05d..2e8e29a05b 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/NodeFactory.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/NodeFactory.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.tuscany.sca.node2; +package org.apache.tuscany.sca.runtime; import java.io.IOException; import java.io.InputStream; @@ -40,12 +40,12 @@ import org.apache.tuscany.sca.deployment.Deployer; import org.apache.tuscany.sca.monitor.ValidationException; import org.apache.tuscany.sca.node.configuration.ContributionConfiguration; import org.apache.tuscany.sca.node.configuration.NodeConfiguration; -import org.apache.tuscany.sca.node2.impl.NodeImpl; import org.apache.tuscany.sca.runtime.ActivationException; import org.apache.tuscany.sca.runtime.CompositeActivator; import org.apache.tuscany.sca.runtime.EndpointRegistry; import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory; import org.apache.tuscany.sca.runtime.RuntimeProperties; +import org.apache.tuscany.sca.runtime.impl.NodeImpl; import org.apache.tuscany.sca.work.WorkScheduler; import org.oasisopen.sca.ServiceRuntimeException; @@ -72,7 +72,7 @@ public class NodeFactory { * @param dependentContributionURLs optional URLs of dependent contributions * @return a Node with installed contributions */ - public static Node newStandaloneNode(String compositeURI, String contributionURL, String... dependentContributionURLs) { + public static Node createStandaloneNode(String compositeURI, String contributionURL, String... dependentContributionURLs) { try { NodeFactory nodeFactory = newInstance(); EndpointRegistry endpointRegistry = new EndpointRegistryImpl(nodeFactory.extensionPointRegistry, null, null); diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/DeployedComposite.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/impl/DeployedComposite.java index 6e31f283ee..dab3309bfd 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/DeployedComposite.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/impl/DeployedComposite.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.tuscany.sca.node2.impl; +package org.apache.tuscany.sca.runtime.impl; import java.util.ArrayList; import java.util.HashMap; diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/InstalledContribution.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/impl/InstalledContribution.java index d847c8d199..4a8e600c76 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/InstalledContribution.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/impl/InstalledContribution.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.tuscany.sca.node2.impl; +package org.apache.tuscany.sca.runtime.impl; import java.util.ArrayList; import java.util.List; diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/NodeImpl.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/impl/NodeImpl.java index 15f5e2b18e..2721bf4496 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/NodeImpl.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/impl/NodeImpl.java @@ -17,11 +17,10 @@ * under the License. */ -package org.apache.tuscany.sca.node2.impl; +package org.apache.tuscany.sca.runtime.impl; import java.io.File; import java.io.Reader; -import java.net.URI; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -33,6 +32,7 @@ import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamException; import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.common.java.io.IOHelper; import org.apache.tuscany.sca.contribution.Artifact; import org.apache.tuscany.sca.contribution.Contribution; @@ -42,14 +42,13 @@ import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.deployment.Deployer; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.ValidationException; -import org.apache.tuscany.sca.node2.Node; -import org.apache.tuscany.sca.node2.NodeFactory; import org.apache.tuscany.sca.runtime.ActivationException; import org.apache.tuscany.sca.runtime.CompositeActivator; import org.apache.tuscany.sca.runtime.EndpointRegistry; -import org.oasisopen.sca.NoSuchDomainException; +import org.apache.tuscany.sca.runtime.Node; +import org.apache.tuscany.sca.runtime.NodeFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.oasisopen.sca.NoSuchServiceException; -import org.oasisopen.sca.client.SCAClientFactory; public class NodeImpl implements Node { @@ -61,6 +60,8 @@ public class NodeImpl implements Node { private ExtensionPointRegistry extensionPointRegistry; private NodeFactory nodeFactory; + private static Map<String, Node> allNodes = new HashMap<String, Node>(); + public NodeImpl(String domainName, Deployer deployer, CompositeActivator compositeActivator, EndpointRegistry endpointRegistry, ExtensionPointRegistry extensionPointRegistry, NodeFactory nodeFactory) { this.domainName = domainName; this.deployer = deployer; @@ -68,6 +69,7 @@ public class NodeImpl implements Node { this.endpointRegistry = endpointRegistry; this.extensionPointRegistry = extensionPointRegistry; this.nodeFactory = nodeFactory; + allNodes.put(domainName, this); } public String installContribution(String contributionURL) throws ContributionReadException, ActivationException, ValidationException { @@ -254,15 +256,25 @@ public class NodeImpl implements Node { if (nodeFactory != null) { nodeFactory.stop(); } + allNodes.remove(this.domainName); } public <T> T getService(Class<T> interfaze, String serviceURI) throws NoSuchServiceException { - try { - return SCAClientFactory.newInstance(URI.create(getDomainName())).getService(interfaze, serviceURI); - } catch (NoSuchDomainException e) { - // shouldn't ever happen as we know this is the domain so it must exist - throw new IllegalStateException(e); + + List<Endpoint> endpoints = endpointRegistry.findEndpoint(serviceURI); + if (endpoints.size() < 1) { + throw new NoSuchServiceException(serviceURI); + } + + String serviceName = null; + if (serviceURI.contains("/")) { + int i = serviceURI.indexOf("/"); + if (i < serviceURI.length()-1) { + serviceName = serviceURI.substring(i+1); + } } + + return ((RuntimeComponent)endpoints.get(0).getComponent()).getServiceReference(interfaze, serviceName).getService(); } public String getDomainName() { @@ -357,5 +369,9 @@ public class NodeImpl implements Node { public EndpointRegistry getEndpointRegistry() { return endpointRegistry; } + + public static Node nodeExists(String domainName) { + return allNodes.get(domainName); + } } |