You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2010/07/01 12:01:33 UTC

svn commit: r959582 - in /tuscany/sca-java-2.x/trunk/modules/domain-node/src: main/java/org/apache/tuscany/sca/node2/ main/java/org/apache/tuscany/sca/node2/impl/ test/java/org/apache/tuscany/sca/node2/

Author: antelder
Date: Thu Jul  1 10:01:33 2010
New Revision: 959582

URL: http://svn.apache.org/viewvc?rev=959582&view=rev
Log:
Start cleaning up JavaDoc and changes coming to light while doing that: move getDeployer and getAssemblyFactory from Node to NodeFactory, change getInstalledContribution to return an assembly Contribution instead of an InstalledContribution, rename deployDeployables to runDeployables

Modified:
    tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/Node.java
    tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/NodeFactory.java
    tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/NodeImpl.java
    tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/DeployerTestCase.java

Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/Node.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/Node.java?rev=959582&r1=959581&r2=959582&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/Node.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/Node.java Thu Jul  1 10:01:33 2010
@@ -31,51 +31,59 @@ import org.apache.tuscany.sca.contributi
 import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
 import org.apache.tuscany.sca.deployment.Deployer;
 import org.apache.tuscany.sca.monitor.ValidationException;
-import org.apache.tuscany.sca.node2.impl.InstalledContribution;
 import org.apache.tuscany.sca.runtime.ActivationException;
 import org.oasisopen.sca.NoSuchServiceException;
 
 public interface Node {
 
     /**
-     * 4577 10.5.1 install Contribution & update Contribution
-     * 4578 Creates or updates an installed contribution with a supplied root contribution, and installed at a supplied
-     * 4579 base URI. A supplied dependent contribution list (<export/> elements) specifies the contributions that are
-     * 4580 used to resolve the dependencies of the root contribution and other dependent contributions. These
-     * 4581 override any dependent contributions explicitly listed via the @location attribute in the import statements
-     * 4582 of the contribution.
-     * 4583 SCA follows the simplifying assumption that the use of a contribution for resolving anything also means
-     * 4584 that all other exported artifacts can be used from that contribution. Because of this, the dependent
-     * 4585 contribution list is just a list of installed contribution URIs. There is no need to specify what is being used
-     * 4586 from each one.
-     * 4587 Each dependent contribution is also an installed contribution, with its own dependent contributions. By
-     * 4588 default these dependent contributions of the dependent contributions (which we will call indirect
-     * 4589 dependent contributions) are included as dependent contributions of the installed contribution. However,
-     * 4590 if a contribution in the dependent contribution list exports any conflicting definitions with an indirect
-     * 4591 dependent contribution, then the indirect dependent contribution is not included (i.e. the explicit list
-     * 4592 overrides the default inclusion of indirect dependent contributions). Also, if there is ever a conflict
-     * 4593 between two indirect dependent contributions, then the conflict MUST be resolved by an explicit entry in
-     * 4594 the dependent contribution list.
-     * 4595 [ASM12009]
-     * 4596 Note that in many cases, the dependent contribution list can be generated. In particular, if the creator of
-     * 4597 a Domain is careful to avoid creating duplicate definitions for the same qualified name, then it is easy for
-     * 4598 this list to be generated by tooling.     * 
-     * @param uri
-     * @param contributionURL
+     * Creates an installed contribution from a supplied root contribution and installed at a supplied base URI.
+     * See section 10.5.1 of the Assembly Specification.
+     * 
+     * @param uri  the base uri of where to install the contribution
+     * @param contributionURL  the URL where the contribution is located
+     * @param metaDataURL  the location of an optional generated Contribution Metadata Document. See section 10.2.2
+     *               of the Assembly Specification. May be null.
+     * @param dependentContributionURIs  specifies the contributions that are used to resolve the dependencies of the 
+     *               root contribution and other dependent contributions. May be null.
+     * @param runDeployables  true if the composites defined as deployable in the contributions sca-contribution.xml
+     *               file or supplied metaData file should be run, false if they should not be. 
+     * 
      * @throws ContributionReadException 
      * @throws ActivationException 
      * @throws ValidationException 
      */
-    void installContribution(String uri, String contributionURL, String metaDataURL, List<String> dependentContributionURIs, boolean deployDeployables) throws ContributionReadException, ActivationException, ValidationException;
-    void installContribution(Contribution contribution, List<String> dependentContributionURIs, boolean deployDeployables) throws ContributionReadException, ActivationException, ValidationException;
+    void installContribution(String uri, String contributionURL, String metaDataURL, List<String> dependentContributionURIs, boolean runDeployables) throws ContributionReadException, ActivationException, ValidationException;
 
+    /**
+     * Creates an installed contribution from a supplied Contribution object.
+     * See section 10.5.1 of the Assembly Specification.
+     * 
+     * @param contribution  the Contribution object
+     * @param dependentContributionURIs  specifies the contributions that are used to resolve the dependencies of the 
+     *               root contribution and other dependent contributions. May be null.
+     * @param runDeployables  true if the composites defined as deployable in the contributions sca-contribution.xml
+     *               file or supplied metaData file should be run, false if they should not be. 
+     * 
+     * @throws ContributionReadException 
+     * @throws ActivationException 
+     * @throws ValidationException 
+     */
+    void installContribution(Contribution contribution, List<String> dependentContributionURIs, boolean runDeployables) throws ContributionReadException, ActivationException, ValidationException;
+
+    /**
+     * Creates an installed contribution from a supplied root contribution.
+     * See section 10.5.1 of the Assembly Specification.
+     * 
+     * @param contributionURL  the URL where the contribution is located
+     * @return the URI where the contribution was installed
+     * 
+     * @throws ContributionReadException 
+     * @throws ActivationException 
+     * @throws ValidationException 
+     */
     String installContribution(String contributionURL) throws ContributionReadException, ActivationException, ValidationException;
     
-    /* Useful short forms of that for when you don't care or have the others (but leave out for now to keep as simple as possible):
-    void installContribution(String uri, String contributionURL) throws ContributionReadException, ActivationException, ValidationException;
-    String installContribution(String contributionURL, boolean autoDeploy) throws ContributionReadException, ActivationException, ValidationException;
-    */
-    
     /**
      * 4577 10.5.1 install Contribution & update Contribution
      * 4578 Creates or updates an installed contribution with a supplied root contribution, and installed at a supplied
@@ -210,7 +218,7 @@ public interface Node {
      * 4700 wsdl:PortTypeportType). The result is a single definition, in whatever form is appropriate for that
      * 4701 definition type.
      * 4702 Note that this, like all the other domain-level operations, is a conceptual operation. Its capabilities need to
-     * 4703 exist in some form, but not necessarily as a service operation with exactly this signature.     * 
+     * 4703 exist in some form, but not necessarily as a service operation with exactly this signature.     
      * @param contributionURI
      * @param definition
      * @param symbolSpace
@@ -228,11 +236,23 @@ public interface Node {
      */
     <T> T getService(Class<T> interfaze, String serviceURI) throws NoSuchServiceException;    
 
-    /* do we also need these following ones that are mentioned only indirectly in the spec? */
-    
+    /**
+     * Get a contributions deployed composites.
+     * @param contributionURI  the contribution URI
+     * @return the List of deployed composites
+     */
     List<String> getDeployedCompostes(String contributionURI);
+
+    /**
+     * Get the URIs of all the contributions installed on this Node
+     * @return the list of installed contribution URIs
+     */
     List<String> getInstalledContributions();
-    InstalledContribution getInstalledContribution(String uri);
-    Deployer getDeployer();
-    AssemblyFactory getAssemblyFactory();
+
+    /**
+     * Get an installed Contribution
+     * @param uri  the URI of the contribution
+     * @return the Contribution
+     */
+    Contribution getInstalledContribution(String uri);
 }

Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/NodeFactory.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/NodeFactory.java?rev=959582&r1=959581&r2=959582&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/NodeFactory.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/NodeFactory.java Thu Jul  1 10:01:33 2010
@@ -42,6 +42,7 @@ public class NodeFactory {
     private ExtensionPointRegistry extensionPointRegistry;
     private CompositeActivator compositeActivator;
     private ExtensibleDomainRegistryFactory domainRegistryFactory;
+    private RuntimeAssemblyFactory assemblyFactory;
 
     // TODO: keep this method?
     public static Node createNode() {
@@ -76,7 +77,7 @@ public class NodeFactory {
         extensionPointRegistry.start();
 
         FactoryExtensionPoint modelFactories = extensionPointRegistry.getExtensionPoint(FactoryExtensionPoint.class);
-        AssemblyFactory assemblyFactory = new RuntimeAssemblyFactory(extensionPointRegistry);
+        this.assemblyFactory = new RuntimeAssemblyFactory(extensionPointRegistry);
         modelFactories.addFactory(assemblyFactory);
 
         UtilityExtensionPoint utilities = extensionPointRegistry.getExtensionPoint(UtilityExtensionPoint.class);
@@ -94,4 +95,21 @@ public class NodeFactory {
 //        domainRegistryFactory.getEndpointRegistry(config.getProperty("reguri"), config.getProperty("defaultDomainName"));
 
     }
+    /**
+     * Get the Deployer. The Deployer can be used to create contribution artifacts 
+     * when configuring a Node programatically.
+     * @return the Deployer
+     */
+    public Deployer getDeployer() {
+        return deployer;
+    }
+    
+    /**
+     * Get the AssemblyFactory. The AssemblyFactory can be used to create contribution
+     * artifact contents when configuring a Node programatically.
+     * @return the AssemblyFactory
+     */
+    public AssemblyFactory getAssemblyFactory() {
+        return assemblyFactory;
+    }
 }

Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/NodeImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/NodeImpl.java?rev=959582&r1=959581&r2=959582&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/NodeImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/NodeImpl.java Thu Jul  1 10:01:33 2010
@@ -81,14 +81,14 @@ public class NodeImpl implements Node {
         return uri;
     }
     
-    public void installContribution(String uri, String contributionURL, String metaDataURL, List<String> dependentContributionURIs, boolean deployDeployables) throws ContributionReadException, ActivationException, ValidationException {
+    public void installContribution(String uri, String contributionURL, String metaDataURL, List<String> dependentContributionURIs, boolean runDeployables) throws ContributionReadException, ActivationException, ValidationException {
         Monitor monitor = deployer.createMonitor();
         Contribution contribution = deployer.loadContribution(URI.create(uri), IOHelper.getLocationAsURL(contributionURL), monitor);
         monitor.analyzeProblems();
         if (metaDataURL != null) {
             mergeContributionMetaData(metaDataURL, contribution);
         }
-        installContribution(contribution, dependentContributionURIs, deployDeployables);
+        installContribution(contribution, dependentContributionURIs, runDeployables);
     }
 
     private void mergeContributionMetaData(String metaDataURL, Contribution contribution) throws ValidationException {
@@ -105,12 +105,12 @@ public class NodeImpl implements Node {
         contribution.getExports().addAll(metaData.getExports());
     }
     
-    public void installContribution(Contribution contribution, List<String> dependentContributionURIs, boolean deployDeployables) throws ContributionReadException, ActivationException, ValidationException {
+    public void installContribution(Contribution contribution, List<String> dependentContributionURIs, boolean runDeployables) throws ContributionReadException, ActivationException, ValidationException {
         InstalledContribution ic = new InstalledContribution(contribution.getURI(), contribution.getLocation(), contribution, dependentContributionURIs);
         installedContributions.put(contribution.getURI(), ic);
-        if (deployDeployables) {
+        if (runDeployables) {
             for (Composite c : ic.getDefaultDeployables()) {
-                deployComposite(c, ic);
+                runComposite(c, ic);
             }
         }
     }
@@ -128,7 +128,7 @@ public class NodeImpl implements Node {
             throw new IllegalArgumentException("contribution not installed: " + contributionURI);
         }
         String compositeArtifcatURI = deployer.attachDeploymentComposite(ic.getContribution(), composite, true);
-        deployComposite(composite, ic);
+        runComposite(composite, ic);
         return compositeArtifcatURI;
     }
 
@@ -141,7 +141,7 @@ public class NodeImpl implements Node {
         String relativeURI = compositeURI.substring(contributionURI.endsWith("/") ? contributionURI.length() : contributionURI.length()+1);
         for (Artifact a : ic.getContribution().getArtifacts()) {
             if (a.getURI().equals(relativeURI)) {
-                deployComposite((Composite) a.getModel(), ic);
+                runComposite((Composite) a.getModel(), ic);
                 return;
             }
         }
@@ -251,8 +251,11 @@ public class NodeImpl implements Node {
         return new ArrayList<String>(installedContributions.keySet());
     }
 
-    public InstalledContribution getInstalledContribution(String uri) {
-        return installedContributions.get(uri);
+    public Contribution getInstalledContribution(String uri) {
+        if (installedContributions.containsKey(uri)) {
+            return installedContributions.get(uri).getContribution();
+        }
+        throw new IllegalArgumentException("no contribution found for: " + uri);
     }
 
     protected String getContributionUriForArtifact(String artifactURI) {
@@ -269,7 +272,7 @@ public class NodeImpl implements Node {
         return contributionURI;
     }
 
-    protected void deployComposite(Composite c, InstalledContribution ic) throws ActivationException {
+    protected void runComposite(Composite c, InstalledContribution ic) throws ActivationException {
         List<Contribution> dependentContributions = new ArrayList<Contribution>();
         if (ic.getDependentContributionURIs() != null) {
             // if the install specified dependent uris use just those contributions

Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/DeployerTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/DeployerTestCase.java?rev=959582&r1=959581&r2=959582&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/DeployerTestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/DeployerTestCase.java Thu Jul  1 10:01:33 2010
@@ -33,8 +33,6 @@ import org.apache.tuscany.sca.contributi
 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.junit.Test;
 import org.oasisopen.sca.NoSuchDomainException;
@@ -44,32 +42,34 @@ public class DeployerTestCase {
 
     @Test
     public void testInstalledContribution() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, MalformedURLException {
-        Node section10 = NodeFactory.createNode();
+        NodeFactory nodeFactory = new NodeFactory();
+        Node node = nodeFactory.createNode("myDomain");
         
-        Deployer deployer = section10.getDeployer();
+        Deployer deployer = nodeFactory.getDeployer();
         Monitor monitor = deployer.createMonitor();
         Contribution contribution = deployer.loadContribution(URI.create("foo"), new File("src/test/resources/sample-helloworld-nodeployable.jar").toURI().toURL(), monitor);
         monitor.analyzeProblems();
         
-        section10.installContribution(contribution, null, true);
-        List<String> ics = section10.getInstalledContributions();
+        node.installContribution(contribution, null, true);
+        List<String> ics = node.getInstalledContributions();
         Assert.assertEquals(1, ics.size());
         Assert.assertEquals("foo", ics.get(0));
     }
 
     @Test
     public void testAddDeploymentComposite() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, MalformedURLException, XMLStreamException {
-        Node section10 = NodeFactory.createNode();
+        NodeFactory nodeFactory = new NodeFactory();
+        Node node = nodeFactory.createNode("myDomain");
         
-        section10.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true);
+        node.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true);
 
-        Deployer deployer = section10.getDeployer();
+        Deployer deployer = nodeFactory.getDeployer();
         Monitor monitor = deployer.createMonitor();
         Composite composite = deployer.loadXMLDocument(new File("src/test/resources/helloworld2.composite").toURI().toURL(), monitor);
         monitor.analyzeProblems();
         composite.setURI("helloworld2.composite");
-        section10.addDeploymentComposite("foo", composite);
-        List<String> dcs = section10.getDeployedCompostes("foo");
+        node.addDeploymentComposite("foo", composite);
+        List<String> dcs = node.getDeployedCompostes("foo");
         Assert.assertEquals(1, dcs.size());
         Assert.assertEquals("foo/helloworld2.composite", dcs.get(0));
     }