From 73ffdb3c639f918474bc0df9dac57af8b121f3ab Mon Sep 17 00:00:00 2001 From: rfeng Date: Fri, 15 May 2009 18:36:42 +0000 Subject: Push down some of the createNode() methods to NodeFactory and only require the createNode(NodeConfiguration) to be implemented by subclasses git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@775283 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/node/impl/NodeFactoryImpl.java | 62 ---------------------- .../tuscany/sca/node/impl/NodeImplTestCase.java | 4 +- 2 files changed, 2 insertions(+), 64 deletions(-) (limited to 'java/sca/modules/node-impl/src') diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java index 38376a584f..24836c67fb 100644 --- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java +++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java @@ -19,11 +19,7 @@ package org.apache.tuscany.sca.node.impl; -import static org.apache.tuscany.sca.node.impl.NodeUtil.openStream; - -import java.io.IOException; import java.io.InputStream; -import java.net.URL; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLOutputFactory; @@ -31,12 +27,9 @@ import javax.xml.stream.XMLStreamReader; import org.apache.tuscany.sca.extensibility.ServiceDeclaration; import org.apache.tuscany.sca.extensibility.ServiceDiscovery; -import org.apache.tuscany.sca.node.Contribution; -import org.apache.tuscany.sca.node.ContributionLocationHelper; 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.configuration.NodeConfigurationFactory; import org.apache.tuscany.sca.node.configuration.xml.NodeConfigurationProcessor; import org.oasisopen.sca.ServiceRuntimeException; @@ -49,61 +42,6 @@ public class NodeFactoryImpl extends NodeFactory { public NodeFactoryImpl() { } - @Override - public Node createNode(String configurationURI) { - try { - URL url = new URL(configurationURI); - InputStream is = openStream(url); - NodeConfiguration configuration = loadConfiguration(is); - is.close(); - return new NodeImpl(configuration); - } catch (IOException e) { - throw new ServiceRuntimeException(e); - } - } - - @Override - public Node createNode(String compositeURI, Contribution... contributions) { - NodeConfigurationFactory factory = this; - NodeConfiguration configuration = factory.createNodeConfiguration(); - for (Contribution c : contributions) { - configuration.addContribution(c.getURI(), c.getLocation()); - } - if (compositeURI != null && configuration.getContributions().size() > 0) { - configuration.getContributions().get(0).addDeploymentComposite(NodeUtil.createURI(compositeURI)); - } - return new NodeImpl(configuration); - } - - @Override - public Node createNode(String compositeURI, String compositeContent, Contribution... contributions) { - NodeConfigurationFactory factory = this; - NodeConfiguration configuration = factory.createNodeConfiguration(); - for (Contribution c : contributions) { - configuration.addContribution(c.getURI(), c.getLocation()); - } - if (compositeContent != null && configuration.getContributions().size() > 0) { - configuration.getContributions().get(0).addDeploymentComposite(compositeContent); - } - return new NodeImpl(configuration); - } - - @Override - public Node createNode() { - String location = - ContributionLocationHelper - .getContributionLocation(org.apache.tuscany.sca.contribution.Contribution.SCA_CONTRIBUTION_META); - if (location == null) { - location = - ContributionLocationHelper - .getContributionLocation(org.apache.tuscany.sca.contribution.Contribution.SCA_CONTRIBUTION_GENERATED_META); - } - if (location == null) { - throw new ServiceRuntimeException("No SCA contributions are found on the classpath"); - } - return createNode(null, new Contribution("http://contributions/default", location)); - } - @Override public Node createNode(NodeConfiguration configuration) { return new NodeImpl(configuration); diff --git a/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java b/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java index 877e4e3643..da869e78e6 100644 --- a/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java +++ b/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java @@ -22,6 +22,7 @@ package org.apache.tuscany.sca.node.impl; import hello.HelloWorld; import java.io.File; +import java.io.StringReader; import org.apache.tuscany.sca.node.Contribution; import org.apache.tuscany.sca.node.Node; @@ -47,8 +48,7 @@ public class NodeImplTestCase { public void testNodeWithCompositeContent() { NodeFactory factory = new NodeFactoryImpl(); Contribution contribution = new Contribution("c1", new File("target/test-classes").toURI().toString()); - String compositeURI = "HelloWorld.composite"; - Node node = factory.createNode(compositeURI, composite, contribution); + Node node = factory.createNode(new StringReader(composite), contribution); testNode2(node); } -- cgit v1.2.3