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 2008/07/13 10:31:53 UTC

svn commit: r676277 - /tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java

Author: antelder
Date: Sun Jul 13 01:31:53 2008
New Revision: 676277

URL: http://svn.apache.org/viewvc?rev=676277&view=rev
Log:
Add another createSCANode method while TUSCANY-2409 is looked at further

Modified:
    tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java

Modified: tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java?rev=676277&r1=676276&r2=676277&view=diff
==============================================================================
--- tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java (original)
+++ tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java Sun Jul 13 01:31:53 2008
@@ -19,9 +19,13 @@
 
 package org.apache.tuscany.sca.node.impl;
 
+import java.io.File;
+import java.net.MalformedURLException;
+
 import org.apache.tuscany.sca.node.SCAContribution;
 import org.apache.tuscany.sca.node.SCANode2;
 import org.apache.tuscany.sca.node.SCANode2Factory;
+import org.osoa.sca.ServiceRuntimeException;
 
 /**
  * Default implementation of an SCA node factory.
@@ -51,4 +55,27 @@
     public SCANode2 createSCANode(String compositeURI, String compositeContent, SCAContribution... contributions) {
         return new NodeImpl(compositeURI, compositeContent, contributions);
     }
+
+    @Override
+    public SCANode2 createSCANode(String compositeURI) {
+        try {
+
+            File compositeFile = new File(compositeURI);
+            if (!compositeFile.exists()) {
+                throw new IllegalArgumentException("composite not found: " + compositeURI);
+            }
+
+            File compositeFolder = compositeFile.getParentFile();
+            SCAContribution contribution = new SCAContribution(compositeFolder.getName(), compositeFolder.toURL().toString());
+
+            SCANode2 node = createSCANode(compositeFile.getName(), contribution);
+
+            node.start();
+
+            return node;
+
+        } catch (MalformedURLException e) {
+            throw new ServiceRuntimeException(e);
+        }
+    }
 }



Re: svn commit: r676277 - /tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java

Posted by Raymond Feng <en...@gmail.com>.
Hi,

I have some concerns about this change.

I assume you are referring to the case where the root of the contribution is 
the direct parent of the composite file but not the root of the class path. 
Let me take the validation itest [1] as an example:

1) In this case, we can call the following method:

createSCANode("Calculator.composite", new 
SCAContribution("TestContribution", new 
File("src/main/resources/NoMatchingBinding")
                 .toURL().toString()));

Please note that the "Calculator.composite" is a URI relative to the SCA 
contribution.

One of the itests is working this way in the trunk [2]. I don't think we 
should add a new method for this case.

2) I'm not very sure if I like the folder structure used by the itest to 
support multiple contributions. It invents a strange packaging scheme and 
there are more than one contributions that overlap against each other in the 
same tree.

3) In the new method createSCANode(String compositeURI), the compositeURI is 
not consistent with other APIs where the compositeURI is not required to be 
a file.

4) We should not call the start() method as part of the node creation.

[1] https://svn.apache.org/repos/asf/tuscany/java/sca/itest/validation/
[2] 
https://svn.apache.org/repos/asf/tuscany/java/sca/itest/validation/src/test/java/calculator/warning/NoMatchingBindingTestCase.java

Thanks,
Raymond
--------------------------------------------------
From: <an...@apache.org>
Sent: Sunday, July 13, 2008 1:31 AM
To: <co...@tuscany.apache.org>
Subject: svn commit: r676277 - 
/tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java

> Author: antelder
> Date: Sun Jul 13 01:31:53 2008
> New Revision: 676277
>
> URL: http://svn.apache.org/viewvc?rev=676277&view=rev
> Log:
> Add another createSCANode method while TUSCANY-2409 is looked at further
>
> Modified:
> 
> tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
>
> Modified: 
> tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
> URL: 
> http://svn.apache.org/viewvc/tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java?rev=676277&r1=676276&r2=676277&view=diff
> ==============================================================================
> ---  
> tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java 
> (original)
> +++ 
> tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java 
> Sun Jul 13 01:31:53 2008
> @@ -19,9 +19,13 @@
>
> package org.apache.tuscany.sca.node.impl;
>
> +import java.io.File;
> +import java.net.MalformedURLException;
> +
> import org.apache.tuscany.sca.node.SCAContribution;
> import org.apache.tuscany.sca.node.SCANode2;
> import org.apache.tuscany.sca.node.SCANode2Factory;
> +import org.osoa.sca.ServiceRuntimeException;
>
> /**
>  * Default implementation of an SCA node factory.
> @@ -51,4 +55,27 @@
>     public SCANode2 createSCANode(String compositeURI, String 
> compositeContent, SCAContribution... contributions) {
>         return new NodeImpl(compositeURI, compositeContent, 
> contributions);
>     }
> +
> +    @Override
> +    public SCANode2 createSCANode(String compositeURI) {
> +        try {
> +
> +            File compositeFile = new File(compositeURI);
> +            if (!compositeFile.exists()) {
> +                throw new IllegalArgumentException("composite not found: 
> " + compositeURI);
> +            }
> +
> +            File compositeFolder = compositeFile.getParentFile();
> +            SCAContribution contribution = new 
> SCAContribution(compositeFolder.getName(), 
> compositeFolder.toURL().toString());
> +
> +            SCANode2 node = createSCANode(compositeFile.getName(), 
> contribution);
> +
> +            node.start();
> +
> +            return node;
> +
> +        } catch (MalformedURLException e) {
> +            throw new ServiceRuntimeException(e);
> +        }
> +    }
> }
>
>