diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-01-19 09:39:38 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-01-19 09:39:38 +0000 |
commit | 1844575eba4024ab299ebf179af0bed8ec1c0f52 (patch) | |
tree | 95c3c6f89287b74d8c2a0e37c52fa85bd9464e90 /sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache | |
parent | 98a6c203285b86758f333b8dcff69f78e53e7f74 (diff) |
Rename main class to TuscanyRuntime
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1060728 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r-- | sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/TuscanyRuntime.java (renamed from sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/NodeFactory.java) | 45 | ||||
-rw-r--r-- | sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/impl/NodeImpl.java | 12 |
2 files changed, 39 insertions, 18 deletions
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/NodeFactory.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/TuscanyRuntime.java index 2e8e29a05b..b2181ef1f4 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/NodeFactory.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/TuscanyRuntime.java @@ -49,7 +49,7 @@ import org.apache.tuscany.sca.runtime.impl.NodeImpl; import org.apache.tuscany.sca.work.WorkScheduler; import org.oasisopen.sca.ServiceRuntimeException; -public class NodeFactory { +public class TuscanyRuntime { private Deployer deployer; private ExtensionPointRegistry extensionPointRegistry; @@ -57,26 +57,39 @@ public class NodeFactory { private ExtensibleDomainRegistryFactory domainRegistryFactory; private RuntimeAssemblyFactory assemblyFactory; - public static NodeFactory newInstance() { - return new NodeFactory(null); + public static TuscanyRuntime newInstance() { + return new TuscanyRuntime(null); } - public static NodeFactory newInstance(Properties config) { - return new NodeFactory(config); + public static TuscanyRuntime newInstance(Properties config) { + return new TuscanyRuntime(config); } /** - * A helper method to simplify creating a standalone Node + * A helper method to run a standalone SCA composite * @param compositeURI URI within the contribution of a composite to run * if compositeURI is null then all deployable composites in the contribution will be run * @param contributionURL URL of the contribution * @param dependentContributionURLs optional URLs of dependent contributions * @return a Node with installed contributions */ - public static Node createStandaloneNode(String compositeURI, String contributionURL, String... dependentContributionURLs) { + public static Node runComposite(String compositeURI, String contributionURL, String... dependentContributionURLs) { + return runComposite(newInstance(), compositeURI, contributionURL, dependentContributionURLs); + } + + /** + * A helper method to run a standalone SCA composite + * @param runtime a TuscanyRuntime instance which will be used to run the composite + * this allows sharing a runtime instance to run multiple composites + * @param compositeURI URI within the contribution of a composite to run + * if compositeURI is null then all deployable composites in the contribution will be run + * @param contributionURL URL of the contribution + * @param dependentContributionURLs optional URLs of dependent contributions + * @return a Node with installed contributions + */ + public static Node runComposite(TuscanyRuntime runtime, String compositeURI, String contributionURL, String... dependentContributionURLs) { try { - NodeFactory nodeFactory = newInstance(); - EndpointRegistry endpointRegistry = new EndpointRegistryImpl(nodeFactory.extensionPointRegistry, null, null); - NodeImpl node = new NodeImpl("default", nodeFactory.deployer, nodeFactory.compositeActivator, endpointRegistry, nodeFactory.extensionPointRegistry, nodeFactory); + EndpointRegistry endpointRegistry = new EndpointRegistryImpl(runtime.extensionPointRegistry, null, null); + NodeImpl node = new NodeImpl("default", runtime.deployer, runtime.compositeActivator, endpointRegistry, runtime.extensionPointRegistry, runtime); if (dependentContributionURLs != null) { for (int i=dependentContributionURLs.length-1; i>-1; i--) { @@ -95,7 +108,7 @@ public class NodeFactory { } } - protected NodeFactory(Properties config) { + protected TuscanyRuntime(Properties config) { init(config); } @@ -122,7 +135,6 @@ public class NodeFactory { } public void stop() { - deployer.stop(); extensionPointRegistry.stop(); } @@ -152,6 +164,15 @@ public class NodeFactory { this.domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionPointRegistry); } + + /** + * Get the ExtensionPointRegistry used by this runtime + * @return extensionPointRegistry + */ + public ExtensionPointRegistry getExtensionPointRegistry() { + return extensionPointRegistry; + } + /** * Get the Deployer. The Deployer can be used to create contribution artifacts * when configuring a Node programatically. diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/impl/NodeImpl.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/impl/NodeImpl.java index 32f01698bf..347d63f625 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/impl/NodeImpl.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/impl/NodeImpl.java @@ -63,7 +63,7 @@ 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.Node; -import org.apache.tuscany.sca.runtime.NodeFactory; +import org.apache.tuscany.sca.runtime.TuscanyRuntime; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; @@ -78,17 +78,17 @@ public class NodeImpl implements Node { private CompositeActivator compositeActivator; private EndpointRegistry endpointRegistry; private ExtensionPointRegistry extensionPointRegistry; - private NodeFactory nodeFactory; + private TuscanyRuntime tuscanyRuntime; private static Map<String, Node> allNodes = new HashMap<String, Node>(); - public NodeImpl(String domainName, Deployer deployer, CompositeActivator compositeActivator, EndpointRegistry endpointRegistry, ExtensionPointRegistry extensionPointRegistry, NodeFactory nodeFactory) { + public NodeImpl(String domainName, Deployer deployer, CompositeActivator compositeActivator, EndpointRegistry endpointRegistry, ExtensionPointRegistry extensionPointRegistry, TuscanyRuntime tuscanyRuntime) { this.domainName = domainName; this.deployer = deployer; this.compositeActivator = compositeActivator; this.endpointRegistry = endpointRegistry; this.extensionPointRegistry = extensionPointRegistry; - this.nodeFactory = nodeFactory; + this.tuscanyRuntime = tuscanyRuntime; allNodes.put(domainName, this); } @@ -273,8 +273,8 @@ public class NodeImpl implements Node { e.printStackTrace(); } } - if (nodeFactory != null) { - nodeFactory.stop(); + if (tuscanyRuntime != null) { + tuscanyRuntime.stop(); } allNodes.remove(this.domainName); } |