tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r686391 [1/2] - in /tuscany/java/sca: ./ itest/callablereferences/ itest/jms/src/main/resources/defaults/ itest/jms/src/main/resources/dynamic/ itest/jms/src/main/resources/external/ itest/jms/src/main/resources/nonSCAclient/ itest/jms/src/...
Date Fri, 15 Aug 2008 22:07:45 GMT
Author: rfeng
Date: Fri Aug 15 15:07:43 2008
New Revision: 686391

URL: http://svn.apache.org/viewvc?rev=686391&view=rev
Log:
Port DefaultSCADomain to use SCA Node impl

Added:
    tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBootStrapper.java   (with props)
    tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBuilder.java   (with props)
    tuscany/java/sca/modules/node2-impl/src/test/java/hello/
    tuscany/java/sca/modules/node2-impl/src/test/java/hello/HelloWorld.java   (with props)
    tuscany/java/sca/modules/node2-impl/src/test/java/hello/HelloWorldImpl.java   (with props)
    tuscany/java/sca/modules/node2-impl/src/test/java/org/
    tuscany/java/sca/modules/node2-impl/src/test/java/org/apache/
    tuscany/java/sca/modules/node2-impl/src/test/java/org/apache/tuscany/
    tuscany/java/sca/modules/node2-impl/src/test/java/org/apache/tuscany/sca/
    tuscany/java/sca/modules/node2-impl/src/test/java/org/apache/tuscany/sca/node/
    tuscany/java/sca/modules/node2-impl/src/test/java/org/apache/tuscany/sca/node/impl/
    tuscany/java/sca/modules/node2-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java   (with props)
    tuscany/java/sca/modules/node2-impl/src/test/resources/HelloWorld.composite
Modified:
    tuscany/java/sca/itest/callablereferences/pom.xml
    tuscany/java/sca/itest/jms/src/main/resources/defaults/client.composite
    tuscany/java/sca/itest/jms/src/main/resources/defaults/service.composite
    tuscany/java/sca/itest/jms/src/main/resources/dynamic/client.composite
    tuscany/java/sca/itest/jms/src/main/resources/external/client.composite
    tuscany/java/sca/itest/jms/src/main/resources/external/service.composite
    tuscany/java/sca/itest/jms/src/main/resources/nonSCAclient/service.composite
    tuscany/java/sca/itest/jms/src/main/resources/oneway/OneWayClient.composite
    tuscany/java/sca/itest/jms/src/main/resources/oneway/OneWayService.composite
    tuscany/java/sca/itest/jms/src/main/resources/simple/client.composite
    tuscany/java/sca/itest/jms/src/main/resources/simple/mpclient.composite
    tuscany/java/sca/itest/jms/src/main/resources/simple/service.composite
    tuscany/java/sca/itest/jms/src/main/resources/simple/uriclient.composite
    tuscany/java/sca/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/DynamicReplyQTestCase.java
    tuscany/java/sca/itest/policy-security-jsr250/pom.xml
    tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java
    tuscany/java/sca/modules/domain-manager/pom.xml
    tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ClasspathServiceDiscoverer.java
    tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java
    tuscany/java/sca/modules/host-embedded/pom.xml
    tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java
    tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomain.java
    tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java
    tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java
    tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java
    tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomainTestCase.java
    tuscany/java/sca/modules/implementation-node/pom.xml
    tuscany/java/sca/modules/node2-impl/pom.xml
    tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
    tuscany/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/DomainManagerLauncher.java
    tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java
    tuscany/java/sca/pom.xml

Modified: tuscany/java/sca/itest/callablereferences/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/callablereferences/pom.xml?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/itest/callablereferences/pom.xml (original)
+++ tuscany/java/sca/itest/callablereferences/pom.xml Fri Aug 15 15:07:43 2008
@@ -42,13 +42,14 @@
             <scope>runtime</scope>
         </dependency>
 
+<!-- 
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
             <artifactId>tuscany-node2-impl</artifactId>
             <version>1.4-SNAPSHOT</version>
             <scope>test</scope>
         </dependency>   
-        
+-->        
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
             <artifactId>tuscany-host-tomcat</artifactId>

Modified: tuscany/java/sca/itest/jms/src/main/resources/defaults/client.composite
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms/src/main/resources/defaults/client.composite?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/itest/jms/src/main/resources/defaults/client.composite (original)
+++ tuscany/java/sca/itest/jms/src/main/resources/defaults/client.composite Fri Aug 15 15:07:43 2008
@@ -18,7 +18,7 @@
  * under the License.    
  -->
 <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
-           name="RPCComposite">
+           name="DefaultClientComposite">
 
     <component name="HelloWorldClient">
         <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldClientImpl"/>

Modified: tuscany/java/sca/itest/jms/src/main/resources/defaults/service.composite
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms/src/main/resources/defaults/service.composite?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/itest/jms/src/main/resources/defaults/service.composite (original)
+++ tuscany/java/sca/itest/jms/src/main/resources/defaults/service.composite Fri Aug 15 15:07:43 2008
@@ -18,7 +18,7 @@
  * under the License.    
  -->
 <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
-           name="RPCComposite">
+           name="DefaultServiceComposite">
 
     <component name="HelloWorldService">
         <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldServiceImpl"/>

Modified: tuscany/java/sca/itest/jms/src/main/resources/dynamic/client.composite
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms/src/main/resources/dynamic/client.composite?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/itest/jms/src/main/resources/dynamic/client.composite (original)
+++ tuscany/java/sca/itest/jms/src/main/resources/dynamic/client.composite Fri Aug 15 15:07:43 2008
@@ -18,7 +18,7 @@
  * under the License.    
  -->
 <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
-           name="RPCComposite">
+           name="DynamicComposite">
 
     <component name="HelloWorldClient">
         <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldClientImpl"/>

Modified: tuscany/java/sca/itest/jms/src/main/resources/external/client.composite
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms/src/main/resources/external/client.composite?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/itest/jms/src/main/resources/external/client.composite (original)
+++ tuscany/java/sca/itest/jms/src/main/resources/external/client.composite Fri Aug 15 15:07:43 2008
@@ -18,7 +18,7 @@
  * under the License.    
  -->
 <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
-           name="RPCComposite">
+           name="ExternalClientComposite">
 
     <component name="HelloWorldClient">
         <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldClientImpl"/>

Modified: tuscany/java/sca/itest/jms/src/main/resources/external/service.composite
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms/src/main/resources/external/service.composite?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/itest/jms/src/main/resources/external/service.composite (original)
+++ tuscany/java/sca/itest/jms/src/main/resources/external/service.composite Fri Aug 15 15:07:43 2008
@@ -18,7 +18,7 @@
  * under the License.    
  -->
 <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
-           name="RPCComposite">
+           name="ExternalServiceComposite">
 
     <component name="HelloWorldService">
         <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldServiceImpl"/>

Modified: tuscany/java/sca/itest/jms/src/main/resources/nonSCAclient/service.composite
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms/src/main/resources/nonSCAclient/service.composite?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/itest/jms/src/main/resources/nonSCAclient/service.composite (original)
+++ tuscany/java/sca/itest/jms/src/main/resources/nonSCAclient/service.composite Fri Aug 15 15:07:43 2008
@@ -18,7 +18,7 @@
  * under the License.
  -->
 <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
-           name="RPCComposite">
+           name="ServiceComposite">
 
     <component name="DefaultService">
         <implementation.java class="org.apache.tuscany.sca.binding.jms.OneWayServiceImpl"/>

Modified: tuscany/java/sca/itest/jms/src/main/resources/oneway/OneWayClient.composite
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms/src/main/resources/oneway/OneWayClient.composite?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/itest/jms/src/main/resources/oneway/OneWayClient.composite (original)
+++ tuscany/java/sca/itest/jms/src/main/resources/oneway/OneWayClient.composite Fri Aug 15 15:07:43 2008
@@ -18,7 +18,7 @@
  * under the License.    
  -->
 <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
-           name="OneWayComposite">
+           name="OneWayClientComposite">
 
     <component name="OneWayClient">
         <implementation.java class="org.apache.tuscany.sca.binding.jms.OneWayClientImpl"/>

Modified: tuscany/java/sca/itest/jms/src/main/resources/oneway/OneWayService.composite
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms/src/main/resources/oneway/OneWayService.composite?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/itest/jms/src/main/resources/oneway/OneWayService.composite (original)
+++ tuscany/java/sca/itest/jms/src/main/resources/oneway/OneWayService.composite Fri Aug 15 15:07:43 2008
@@ -18,7 +18,7 @@
  * under the License.    
  -->
 <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
-           name="OneWayComposite">
+           name="OneWayServiceComposite">
 
     <component name="OneWayService">
         <implementation.java class="org.apache.tuscany.sca.binding.jms.OneWayServiceImpl"/>

Modified: tuscany/java/sca/itest/jms/src/main/resources/simple/client.composite
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms/src/main/resources/simple/client.composite?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/itest/jms/src/main/resources/simple/client.composite (original)
+++ tuscany/java/sca/itest/jms/src/main/resources/simple/client.composite Fri Aug 15 15:07:43 2008
@@ -18,7 +18,7 @@
  * under the License.    
  -->
 <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
-           name="RPCComposite">
+           name="SimpleClientComposite">
 
     <component name="HelloWorldClient">
         <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldClientImpl"/>

Modified: tuscany/java/sca/itest/jms/src/main/resources/simple/mpclient.composite
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms/src/main/resources/simple/mpclient.composite?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/itest/jms/src/main/resources/simple/mpclient.composite (original)
+++ tuscany/java/sca/itest/jms/src/main/resources/simple/mpclient.composite Fri Aug 15 15:07:43 2008
@@ -18,7 +18,7 @@
  * under the License.    
  -->
 <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
-           name="RPCComposite">
+           name="MPClientComposite">
 
     <component name="HelloWorldClient">
         <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldClientImpl"/>

Modified: tuscany/java/sca/itest/jms/src/main/resources/simple/service.composite
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms/src/main/resources/simple/service.composite?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/itest/jms/src/main/resources/simple/service.composite (original)
+++ tuscany/java/sca/itest/jms/src/main/resources/simple/service.composite Fri Aug 15 15:07:43 2008
@@ -18,7 +18,7 @@
  * under the License.    
  -->
 <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
-           name="RPCComposite">
+           name="SimpleServiceComposite">
 
     <component name="HelloWorldService">
         <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldServiceImpl"/>

Modified: tuscany/java/sca/itest/jms/src/main/resources/simple/uriclient.composite
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms/src/main/resources/simple/uriclient.composite?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/itest/jms/src/main/resources/simple/uriclient.composite (original)
+++ tuscany/java/sca/itest/jms/src/main/resources/simple/uriclient.composite Fri Aug 15 15:07:43 2008
@@ -18,7 +18,7 @@
  * under the License.    
  -->
 <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
-           name="RPCComposite">
+           name="URIClientComposite">
 
     <component name="HelloWorldClient">
         <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldClientImpl"/>

Modified: tuscany/java/sca/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/DynamicReplyQTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/DynamicReplyQTestCase.java?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/DynamicReplyQTestCase.java (original)
+++ tuscany/java/sca/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/DynamicReplyQTestCase.java Fri Aug 15 15:07:43 2008
@@ -35,7 +35,7 @@
     @Before
     public void init() {
         scaDomain =
-            SCADomain.newInstance("http://localhost", "/dynamic", "dynamic/client.composite", "simple/service.composite");
+            SCADomain.newInstance("http://localhost", "/", "dynamic/client.composite", "simple/service.composite");
     }
 
     @Test

Modified: tuscany/java/sca/itest/policy-security-jsr250/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/policy-security-jsr250/pom.xml?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/itest/policy-security-jsr250/pom.xml (original)
+++ tuscany/java/sca/itest/policy-security-jsr250/pom.xml Fri Aug 15 15:07:43 2008
@@ -47,7 +47,7 @@
             <groupId>org.apache.tuscany.sca</groupId>
             <artifactId>tuscany-policy-security-jsr250</artifactId>
             <version>1.4-SNAPSHOT</version>
-            <scope>runtime</scope>
+            <scope>compile</scope>
         </dependency>
 
         <dependency>

Modified: tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java (original)
+++ tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java Fri Aug 15 15:07:43 2008
@@ -36,7 +36,6 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.monitor.Monitor;
 import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
@@ -45,6 +44,7 @@
 import org.apache.tuscany.sca.contribution.service.ContributionReadException;
 import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
 import org.apache.tuscany.sca.definitions.SCADefinitions;
+import org.apache.tuscany.sca.monitor.Monitor;
 import org.apache.tuscany.sca.policy.PolicySet;
 import org.apache.tuscany.sca.policy.util.PolicyComputationUtils;
 
@@ -86,6 +86,19 @@
     public Composite read(URL contributionURL, URI uri, URL url) throws ContributionReadException {
         InputStream scdlStream = null;
         try {
+            URLConnection connection = url.openConnection();
+            connection.setUseCaches(false);
+            scdlStream = connection.getInputStream();
+        } catch (IOException e) {
+            ContributionReadException ce = new ContributionReadException(e);
+            error("ContributionReadException", url, ce);
+            throw ce;
+        }
+        return read(uri, scdlStream);
+    }
+
+    public Composite read(URI uri, InputStream scdlStream) throws ContributionReadException {
+        try {
             if (scaDefnSink != null ) {
                 fillDomainPolicySets(scaDefnSink);
             }
@@ -96,13 +109,9 @@
             try {
                 if ( domainPolicySets != null ) {
                     transformedArtifactContent =
-                        PolicyComputationUtils.addApplicablePolicySets(url, domainPolicySets);
+                        PolicyComputationUtils.addApplicablePolicySets(scdlStream, domainPolicySets);
                     scdlStream = new ByteArrayInputStream(transformedArtifactContent);
-                } else {
-                    URLConnection connection = url.openConnection();
-                    connection.setUseCaches(false);
-                    scdlStream = connection.getInputStream();
-                }
+                } 
             } catch ( IOException e ) {
             	ContributionReadException ce = new ContributionReadException(e);
             	error("ContributionReadException", scdlStream, ce);

Modified: tuscany/java/sca/modules/domain-manager/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/domain-manager/pom.xml?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/modules/domain-manager/pom.xml (original)
+++ tuscany/java/sca/modules/domain-manager/pom.xml Fri Aug 15 15:07:43 2008
@@ -73,6 +73,12 @@
         
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-core</artifactId>
+            <version>1.4-SNAPSHOT</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
             <artifactId>tuscany-node2-impl</artifactId>
             <version>1.4-SNAPSHOT</version>
             <scope>runtime</scope>

Modified: tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ClasspathServiceDiscoverer.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ClasspathServiceDiscoverer.java?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ClasspathServiceDiscoverer.java (original)
+++ tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ClasspathServiceDiscoverer.java Fri Aug 15 15:07:43 2008
@@ -30,6 +30,7 @@
 import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
@@ -107,12 +108,14 @@
     }
 
     private WeakReference<ClassLoader> classLoaderReference;
+    private boolean useTCCL = false;
     private static final Logger logger = Logger.getLogger(ClasspathServiceDiscoverer.class.getName());
 
     public ClasspathServiceDiscoverer() {
         // ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
         ClassLoader classLoader = ClasspathServiceDiscoverer.class.getClassLoader();
         this.classLoaderReference = new WeakReference<ClassLoader>(classLoader);
+        this.useTCCL = true;
     }
 
     public ClasspathServiceDiscoverer(ClassLoader classLoader) {
@@ -128,10 +131,33 @@
                         if (url != null) {
                             return Arrays.asList(url);
                         } else {
+                            if (useTCCL) {
+                                // Try thread context classloader
+                                ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+                                if (tccl != getContextClassLoader()) {
+                                    url = tccl.getResource(name);
+                                }
+                                if (url != null) {
+                                    return Arrays.asList(url);
+                                }
+                            }
                             return Collections.emptyList();
                         }
                     } else {
-                        return Collections.list(getContextClassLoader().getResources(name));
+                        List<URL> urls = Collections.list(getContextClassLoader().getResources(name));
+                        if (!useTCCL) {
+                            return urls;
+                        }
+                        // Try thread context classloader
+                        ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+                        if (tccl != getContextClassLoader()) {
+                            urls.addAll(Collections.list(tccl.getResources(name)));
+                            // Remove duplicate entries
+                            Set<URL> urlSet = new HashSet<URL>(urls);
+                            return new ArrayList<URL>(urlSet);
+                        } else {
+                            return urls;
+                        }
                     }
                 }
             });
@@ -143,9 +169,9 @@
     public ClassLoader getContextClassLoader() {
         return classLoaderReference.get();
     }
-    
+
     public <T> T getContext() {
-        return (T) getContextClassLoader();
+        return (T)getContextClassLoader();
     }
 
     /**

Modified: tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java (original)
+++ tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java Fri Aug 15 15:07:43 2008
@@ -68,20 +68,24 @@
     }
 
     /**
+     * @deprecated
      * Register a ClassLoader with this discovery mechanism. Tuscany extension
      * ClassLoaders are registered here.
      * 
      * @param classLoader
      */
+    @Deprecated
     public synchronized void registerClassLoader(ClassLoader classLoader) {
         registeredClassLoaders.add(classLoader);
     }
 
     /**
+     * @deprecated
      * Unregister a ClassLoader with this discovery mechanism. 
      * 
      * @param classLoader
      */
+    @Deprecated
     public synchronized void unregisterClassLoader(ClassLoader classLoader) {
         registeredClassLoaders.remove(classLoader);
     }
@@ -127,9 +131,15 @@
         });
         if (className != null) {
             try {
-                return Class.forName(className, false, Thread.currentThread().getContextClassLoader());
+                // Try the classloader for the service interface first 
+                return Class.forName(className, false, serviceInterface.getClassLoader());
             } catch (ClassNotFoundException e) {
-                logger.log(Level.WARNING, e.getMessage(), e);
+                try {
+                    // Try the thread context classloader
+                    return Class.forName(className, false, Thread.currentThread().getContextClassLoader());
+                } catch (ClassNotFoundException ex) {
+                    logger.log(Level.WARNING, ex.getMessage(), ex);
+                }
             }
         }
         Set<ServiceDeclaration> services = getServiceDiscoverer().discover(serviceInterface.getName(), true);

Modified: tuscany/java/sca/modules/host-embedded/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-embedded/pom.xml?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/modules/host-embedded/pom.xml (original)
+++ tuscany/java/sca/modules/host-embedded/pom.xml Fri Aug 15 15:07:43 2008
@@ -29,6 +29,11 @@
     <name>Apache Tuscany SCA Embedded Host</name>
 
     <dependencies>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-node2-impl</artifactId>
+            <version>1.4-SNAPSHOT</version>
+        </dependency>
     	<dependency>
             <groupId>org.apache.tuscany.sca</groupId>
             <artifactId>tuscany-extensibility</artifactId>

Modified: tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java (original)
+++ tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java Fri Aug 15 15:07:43 2008
@@ -18,16 +18,9 @@
 
 package org.apache.tuscany.sca.host.embedded;
 
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.lang.reflect.Constructor;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
 
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
 import org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain;
 import org.apache.tuscany.sca.host.embedded.management.ComponentManager;
 import org.osoa.sca.CallableReference;
@@ -158,49 +151,6 @@
     public abstract <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String serviceName);
 
     /**
-     * Read the service name from a configuration file
-     * 
-     * @param classLoader
-     * @param name The name of the service class
-     * @return A class name which extends/implements the service class
-     * @throws IOException
-     */
-    private static String getServiceName(final ClassLoader classLoader, final String name) throws IOException {
-        InputStream is;
-        // Allow privileged access to open stream. Requires FilePermission in security policy.
-        try {
-            is = AccessController.doPrivileged(new PrivilegedExceptionAction<InputStream>() {
-                public InputStream run() throws IOException {
-                    return classLoader.getResourceAsStream("META-INF/services/" + name);
-                }
-            });
-        } catch (PrivilegedActionException e) {
-            throw (IOException)e.getException();
-        }
-                
-        if (is == null) {
-            return null;
-        }
-        BufferedReader reader = null;
-        try {
-            reader = new BufferedReader(new InputStreamReader(is));
-            while (true) {
-                String line = reader.readLine();
-                if (line == null) {
-                    break;
-                } else if (!line.startsWith("#")) {
-                    return line.trim();
-                }
-            }
-        } finally {
-            if (reader != null) {
-                reader.close();
-            }
-        }
-        return null;
-    }
-
-    /**
      * Returns an SCADomain instance. If the system property
      * "org.apache.tuscany.sca.host.embedded.SCADomain" is set, its value is used as
      * the name of the implementation class. Otherwise, if the resource
@@ -223,53 +173,45 @@
             // Determine the runtime and application ClassLoader
             final ClassLoader runtimeClassLoader = SCADomain.class.getClassLoader();
             final ClassLoader applicationClassLoader = Thread.currentThread().getContextClassLoader();
-            
-            // Discover the SCADomain implementation
-            final String name = SCADomain.class.getName();
-            String className = AccessController.doPrivileged(new PrivilegedAction<String>() {
-                public String run() {
-                    return System.getProperty(name);
-                }
-            });
 
-            if (className == null) {
-                className = getServiceName(runtimeClassLoader, name);
-            }
-            
-            if (className == null) {
-                
+            Class<?> implClass = ServiceDiscovery.getInstance().loadFirstServiceClass(SCADomain.class);
+
+            if (implClass == null) {
+
                 // Create a default SCA domain implementation
                 domain =
-                    new DefaultSCADomain(runtimeClassLoader,
-                                         applicationClassLoader,
-                                         domainURI,
-                                         contributionLocation,
+                    new DefaultSCADomain(runtimeClassLoader, applicationClassLoader, domainURI, contributionLocation,
                                          composites);
             } else {
-                
+
                 // Create an instance of the discovered SCA domain implementation
-                Class cls = Class.forName(className, true, runtimeClassLoader);
                 Constructor<?> constructor = null;
                 try {
-                    constructor = cls.getConstructor(ClassLoader.class, ClassLoader.class,
-                                                     String.class, String.class, String[].class);
-                } catch (NoSuchMethodException e) {}
+                    constructor =
+                        implClass.getConstructor(ClassLoader.class,
+                                                 ClassLoader.class,
+                                                 String.class,
+                                                 String.class,
+                                                 String[].class);
+                } catch (NoSuchMethodException e) {
+                }
                 if (constructor != null) {
-                    domain = (SCADomain)constructor.newInstance(runtimeClassLoader,
-                                                                applicationClassLoader,
-                                                                domainURI,
-                                                                contributionLocation,
-                                                                composites);
+                    domain =
+                        (SCADomain)constructor.newInstance(runtimeClassLoader,
+                                                           applicationClassLoader,
+                                                           domainURI,
+                                                           contributionLocation,
+                                                           composites);
                 } else {
-                    
-                    constructor = cls.getConstructor(ClassLoader.class, String.class);
+
+                    constructor = implClass.getConstructor(ClassLoader.class, String.class);
                     domain = (SCADomain)constructor.newInstance(runtimeClassLoader, domainURI);
                 }
             }
-            
+
             // FIXME: temporary support for connect() API
             theDomain = domain;
-            
+
             return domain;
 
         } catch (Exception e) {

Modified: tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomain.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomain.java?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomain.java (original)
+++ tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomain.java Fri Aug 15 15:07:43 2008
@@ -19,63 +19,35 @@
 
 package org.apache.tuscany.sca.host.embedded.impl;
 
-import java.io.File;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
 import java.net.URL;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
+import java.net.URLConnection;
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.CopyOnWriteArrayList;
 
-import javax.xml.namespace.QName;
+import javax.xml.XMLConstants;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
 
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
 import org.apache.tuscany.sca.assembly.Component;
-import org.apache.tuscany.sca.assembly.ComponentService;
 import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.assembly.CompositeService;
-import org.apache.tuscany.sca.assembly.SCABinding;
-import org.apache.tuscany.sca.assembly.SCABindingFactory;
-import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
 import org.apache.tuscany.sca.assembly.xml.Constants;
-import org.apache.tuscany.sca.contribution.Artifact;
-import org.apache.tuscany.sca.contribution.Contribution;
-import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
-import org.apache.tuscany.sca.contribution.service.ContributionException;
-import org.apache.tuscany.sca.contribution.service.ContributionService;
-import org.apache.tuscany.sca.contribution.service.util.FileHelper;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.UtilityExtensionPoint;
 import org.apache.tuscany.sca.core.assembly.ActivationException;
 import org.apache.tuscany.sca.core.assembly.CompositeActivator;
 import org.apache.tuscany.sca.core.assembly.RuntimeComponentImpl;
-import org.apache.tuscany.sca.core.context.ServiceReferenceImpl;
 import org.apache.tuscany.sca.host.embedded.SCADomain;
 import org.apache.tuscany.sca.host.embedded.management.ComponentListener;
 import org.apache.tuscany.sca.host.embedded.management.ComponentManager;
-import org.apache.tuscany.sca.interfacedef.InterfaceContract;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
-import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.monitor.MonitorFactory;
-import org.apache.tuscany.sca.monitor.Problem;
-import org.apache.tuscany.sca.monitor.Problem.Severity;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.apache.tuscany.sca.runtime.RuntimeComponentContext;
-import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.node.SCAClient;
+import org.apache.tuscany.sca.node.SCAContribution;
+import org.apache.tuscany.sca.node.SCANode2;
+import org.apache.tuscany.sca.node.SCANode2Factory;
+import org.apache.tuscany.sca.node.impl.NodeImpl;
 import org.osoa.sca.CallableReference;
 import org.osoa.sca.ServiceReference;
-import org.osoa.sca.ServiceRuntimeException;
 
 /**
  * A default SCA domain facade implementation.
@@ -86,16 +58,18 @@
 
     private String uri;
     private String[] composites;
-    private Composite domainComposite;
-    private List<Contribution> contributions;
+    // private Composite domainComposite;
+    // private List<Contribution> contributions;
     private Map<String, Component> components;
-    private ReallySmallRuntime runtime;
     private ComponentManager componentManager;
-    private ClassLoader runtimeClassLoader;
+    // private ClassLoader runtimeClassLoader;
     private ClassLoader applicationClassLoader;
     private String domainURI;
-    private String contributionLocation;
-    private Monitor monitor;
+    private List<String> contributionURLs;
+
+    private CompositeActivator compositeActivator;
+    private SCANode2 node;
+    private SCAClient client;
 
     /**
      * Constructs a new domain facade.
@@ -111,477 +85,135 @@
                             String... composites) {
         this.uri = domainURI;
         this.composites = composites;
-        this.runtimeClassLoader = runtimeClassLoader;
+        // this.runtimeClassLoader = runtimeClassLoader;
         this.applicationClassLoader = applicationClassLoader;
         this.domainURI = domainURI;
-        this.contributionLocation = contributionLocation;
+        this.contributionURLs = new ArrayList<String>();
+        if (contributionLocation != null && !"/".equals(contributionLocation)) {
+            this.contributionURLs.add(contributionLocation);
+        }
         this.composites = composites;
 
         init();
 
-    }
-
-    public void init() {
-        contributions = new ArrayList<Contribution>();
-        components = new HashMap<String, Component>();
-        runtime = new ReallySmallRuntime(runtimeClassLoader);
-        try {
-            runtime.start();
+        this.componentManager = new DefaultSCADomainComponentManager(this);
 
-        } catch (ActivationException e) {
-            throw new ServiceRuntimeException(e);
-        }
-        
-        ExtensionPointRegistry registry = runtime.getExtensionPointRegistry();
-        UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
-        MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
-        monitor = monitorFactory.createMonitor();
-
-        // Contribute the given contribution to an in-memory repository
-        ContributionService contributionService = runtime.getContributionService();
-        URL contributionURL;
-        try {
-            contributionURL = getContributionLocation(applicationClassLoader, contributionLocation, this.composites);
-            if (contributionURL != null) {
-                // Make sure the URL is correctly encoded (for example, escape the space characters) 
-                contributionURL = contributionURL.toURI().toURL();
-            }
-        } catch (Exception e) {
-            throw new ServiceRuntimeException(e);
-        }
+    }
 
+    /**
+     * A hack to create an aggregated composite
+     * @param classLoader
+     * @param composites
+     * @return
+     */
+    private String createDeploymentComposite(ClassLoader classLoader, String composites[]) {
         try {
-            String scheme = contributionURL.toURI().getScheme();
-            if (scheme == null || scheme.equalsIgnoreCase("file")) {
-                final File contributionFile = new File(contributionURL.toURI());
-                // Allow privileged access to test file. Requires FilePermission in security policy.
-                Boolean isDirectory = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
-                    public Boolean run() {
-                        return contributionFile.isDirectory();
-                    }
-                });
-                if (isDirectory) {
-                    // Allow privileged access to create file list. Requires FilePermission in
-                    // security policy.
-                    String[] contributions = AccessController.doPrivileged(new PrivilegedAction<String[]>() {
-                        public String[] run() {
-                            return contributionFile.list(new FilenameFilter() {
-                                public boolean accept(File dir, String name) {
-                                    return name.endsWith(".jar");
-                                }
-                            });
-                        }
-                    });
-
-                    if (contributions != null && contributions.length > 0
-                        && contributions.length == contributionFile.list().length) {
-                        for (String contribution : contributions) {
-                            addContribution(contributionService, new File(contributionFile, contribution).toURI()
-                                .toURL());
-                        }
-                    } else {
-                        addContribution(contributionService, contributionURL);
-                    }
+            StringBuffer xml =
+                new StringBuffer("<sca:composite xmlns:sca=\"http://www.osoa.org/xmlns/sca/1.0\"")
+                    .append(" targetNamespace=\"http://tempuri.org\" name=\"aggregated\">\n");
+            XMLInputFactory factory = XMLInputFactory.newInstance();
+            for (int i = 0; i < composites.length; i++) {
+                URL url = classLoader.getResource(composites[i]);
+                if (url == null) {
+                    continue;
+                }
+                String location = NodeImpl.getContributionURL(url, composites[i]).toString();
+                if (!contributionURLs.contains(location)) {
+                    contributionURLs.add(location);
+                }
+                URLConnection connection = url.openConnection();
+                connection.setUseCaches(false);
+                XMLStreamReader reader = factory.createXMLStreamReader(connection.getInputStream());
+                reader.nextTag();
+
+                assert Constants.COMPOSITE_QNAME.equals(reader.getName());
+                String ns = reader.getAttributeValue(null, "targetNamespace");
+                if (ns == null) {
+                    ns = XMLConstants.NULL_NS_URI;
+                }
+                String name = reader.getAttributeValue(null, "name");
+                reader.close();
+                if (XMLConstants.NULL_NS_URI.equals(ns)) {
+                    xml.append("<sca:include name=\"").append(name).append("\"/>\n");
                 } else {
-                    addContribution(contributionService, contributionURL);
-                }
-            } else {
-                addContribution(contributionService, contributionURL);
-            }
-        } catch (IOException e) {
-            throw new ServiceRuntimeException(e);
-        } catch (URISyntaxException e) {
-            throw new ServiceRuntimeException(e);
-        }
-
-        // Create an in-memory domain level composite
-        AssemblyFactory assemblyFactory = runtime.getAssemblyFactory();
-        domainComposite = assemblyFactory.createComposite();
-        domainComposite.setName(new QName(Constants.SCA10_NS, "domain"));
-        domainComposite.setURI(domainURI);
-
-        //when the deployable composites were specified when initializing the runtime
-        if (composites != null && composites.length > 0 && composites[0].length() > 0) {
-            // Include all specified deployable composites in the SCA domain
-            Map<String, Composite> compositeArtifacts = new HashMap<String, Composite>();
-            for (Contribution contribution : contributions) {
-                for (Artifact artifact : contribution.getArtifacts()) {
-                    if (artifact.getModel() instanceof Composite) {
-                        compositeArtifacts.put(artifact.getURI(), (Composite)artifact.getModel());
-                    }
-                }
-            }
-            for (String compositePath : composites) {
-                Composite composite = compositeArtifacts.get(compositePath);
-                if (composite == null) {
-                    throw new ServiceRuntimeException("Composite not found: " + compositePath);
-                }
-                domainComposite.getIncludes().add(composite);
-            }
-        } else {
-            // in this case, a sca-contribution.xml should have been specified
-            for (Contribution contribution : contributions) {
-                for (Composite composite : contribution.getDeployables()) {
-                    domainComposite.getIncludes().add(composite);
+                    xml.append("<sca:include xmlns:ns").append(i).append("=\"").append(ns).append("\"");
+                    xml.append(" name=\"").append("ns").append(i).append(":").append(name).append("\"/>\n");
                 }
             }
+            xml.append("</sca:composite>");
+            // System.out.println(xml.toString());
+            return xml.toString();
+        } catch (Exception e) {
+            throw new IllegalArgumentException(e);
         }
+    }
 
-        //update the runtime for all SCA Definitions processed from the contribution..
-        //so that the policyset determination done during 'build' has the all the defined
-        //intents and policysets
-        //runtime.updateSCADefinitions(null);
+    public void init() {
+        SCANode2Factory factory = SCANode2Factory.newInstance();
 
-        // Build the SCA composites
-        for (Composite composite : domainComposite.getIncludes()) {
-            try {
-                runtime.buildComposite(composite);
-                analyseProblems();
-            } catch (CompositeBuilderException e) {
-                throw new ServiceRuntimeException(e);
-            }
-        }
+        List<SCAContribution> contributions = new ArrayList<SCAContribution>();
 
-        // Activate and start composites
-        CompositeActivator compositeActivator = runtime.getCompositeActivator();
-        compositeActivator.setDomainComposite(domainComposite);
-        for (Composite composite : domainComposite.getIncludes()) {
-            try {
-                compositeActivator.activate(composite);
-            } catch (Exception e) {
-                throw new ServiceRuntimeException(e);
+        if (composites != null && composites.length > 1) {
+            // Create an aggregated composite that includes all the composites as Node API only takes one composite
+            String content = createDeploymentComposite(applicationClassLoader, composites);
+            // Create SCA contributions
+            for (String location : contributionURLs) {
+                contributions.add(new SCAContribution(location, location));
+            }
+            node =
+                factory.createSCANode("http://tempuri.org/aggregated", content, contributions
+                    .toArray(new SCAContribution[contributions.size()]));
+        } else {
+            for (String location : contributionURLs) {
+                contributions.add(new SCAContribution(location, location));
             }
-        }
-        for (Composite composite : domainComposite.getIncludes()) {
-            try {
-                for (Component component : composite.getComponents()) {
-                    compositeActivator.start(component);
-                }
-            } catch (Exception e) {
-                throw new ServiceRuntimeException(e);
+            String composite = (composites != null && composites.length >= 1) ? composites[0] : null;
+            if (!contributions.isEmpty()) {
+                node =
+                    factory.createSCANode(composite, contributions.toArray(new SCAContribution[contributions.size()]));
+            } else {
+                node = factory.createSCANodeFromClassLoader(composite, applicationClassLoader);
             }
         }
+        client = (SCAClient)node;
+        compositeActivator = ((NodeImpl)node).getCompositeActivator();
+        components = new HashMap<String, Component>();
 
-        // Index the top level components
-        for (Composite composite : domainComposite.getIncludes()) {
-            for (Component component : composite.getComponents()) {
-                components.put(component.getName(), component);
-            }
-        }
+        node.start();
 
-        this.componentManager = new DefaultSCADomainComponentManager(this);
+        getComponents(compositeActivator.getDomainComposite());
+    }
 
-        // For debugging purposes, print the composites
-        //        ExtensionPointRegistry extensionPoints = runtime.getExtensionPointRegistry();
-        //        StAXArtifactProcessorExtensionPoint artifactProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
-        //        StAXArtifactProcessor processor = artifactProcessors.getProcessor(Composite.class);
-        //        for (Composite composite : domainComposite.getIncludes()) {
-        //            try {
-        //                ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        //                XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
-        //                outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
-        //                processor.write(composite, outputFactory.createXMLStreamWriter(bos));
-        //                Document document =
-        //                    DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(bos
-        //                        .toByteArray()));
-        //                OutputFormat format = new OutputFormat();
-        //                format.setIndenting(true);
-        //                format.setIndent(2);
-        //                XMLSerializer serializer = new XMLSerializer(System.out, format);
-        //                serializer.serialize(document);
-        //            } catch (Exception e) {
-        //                e.printStackTrace();
-        //            }
-        //        }
-    }
-    
-    private void analyseProblems() throws ServiceRuntimeException {
-        
-        for (Problem problem : monitor.getProblems()){
-            // look for any reported errors. Schema errors are filtered
-            // out as there are several that are generally reported at the
-            // moment and we don't want to stop 
-            if ((problem.getSeverity() == Severity.ERROR) &&
-                 (!problem.getMessageId().equals("SchemaError"))){
-                if (problem.getCause() != null){
-                    throw new ServiceRuntimeException(problem.getCause());
-                } else {
-                    throw new ServiceRuntimeException(problem.toString());
-                }    
-            }
+    private void getComponents(Composite composite) {
+        for (Component c : composite.getComponents()) {
+            components.put(c.getName(), c);
         }
-    }    
-
-    protected void addContribution(final ContributionService contributionService, final URL contributionURL) throws IOException {
-        String contributionURI = FileHelper.getName(contributionURL.getPath());
-        if (contributionURI == null || contributionURI.length() == 0) {
-            contributionURI = contributionURL.toString();
-        }
-        // Allow privileged access to load resources. Requires RuntimePermission in security
-        // policy.
-        final String finalContributionURI = contributionURI;
-        try {
-            AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
-                public Object run() throws ContributionException, IOException {
-                    contributions.add(contributionService.contribute(finalContributionURI, contributionURL, false));
-                    return null;
-                }
-            });
-        } catch (PrivilegedActionException e) {
-            throw new ServiceRuntimeException(e.getException());
+        for (Composite cp : composite.getIncludes()) {
+            getComponents(cp);
         }
-        
-        analyseProblems();
     }
 
     @Override
     public void close() {
-
         super.close();
+        node.stop();
 
-        // Stop and deactivate composites
-        CompositeActivator compositeActivator = runtime.getCompositeActivator();
-        for (Composite composite : domainComposite.getIncludes()) {
-            try {
-                for (Component component : composite.getComponents()) {
-                    compositeActivator.stop(component);
-                }
-            } catch (ActivationException e) {
-                throw new ServiceRuntimeException(e);
-            }
-        }
-        for (Composite composite : domainComposite.getIncludes()) {
-            try {
-                compositeActivator.deactivate(composite);
-            } catch (ActivationException e) {
-                throw new ServiceRuntimeException(e);
-            }
-        }
-
-        // Remove the contribution from the in-memory repository
-        ContributionService contributionService = runtime.getContributionService();
-        for (Contribution contribution : contributions) {
-            try {
-                contributionService.remove(contribution.getURI());
-            } catch (ContributionException e) {
-                throw new ServiceRuntimeException(e);
-            }
-        }
-
-        // Stop the runtime
-        try {
-            runtime.stop();
-        } catch (ActivationException e) {
-            throw new ServiceRuntimeException(e);
-        }
-    }
-
-    /**
-     * Determine the location of a contribution, given a contribution path and a
-     * list of composites.
-     * 
-     * @param contributionPath
-     * @param composites
-     * @param classLoader
-     * @return
-     * @throws MalformedURLException
-     */
-    protected URL getContributionLocation(ClassLoader classLoader, String contributionPath, String[] composites)
-        throws MalformedURLException {
-        if (contributionPath != null && contributionPath.length() > 0) {
-            //encode spaces as they would cause URISyntaxException
-            contributionPath = contributionPath.replace(" ", "%20");
-            URI contributionURI = URI.create(contributionPath);
-            if (contributionURI.isAbsolute() || composites.length == 0) {
-                return new URL(contributionPath);
-            }
-        }
-
-        String contributionArtifactPath = null;
-        URL contributionArtifactURL = null;
-        if (composites != null && composites.length > 0 && composites[0].length() > 0) {
-
-            // Here the SCADomain was started with a reference to a composite file
-            contributionArtifactPath = composites[0];
-            contributionArtifactURL = classLoader.getResource(contributionArtifactPath);
-            if (contributionArtifactURL == null) {
-                throw new IllegalArgumentException("Composite not found: " + contributionArtifactPath);
-            }
-        } else {
-
-            // Here the SCADomain was started without any reference to a composite file
-            // We are going to look for an sca-contribution.xml or sca-contribution-generated.xml
-
-            // Look for META-INF/sca-contribution.xml
-            contributionArtifactPath = Contribution.SCA_CONTRIBUTION_META;
-            contributionArtifactURL = classLoader.getResource(contributionArtifactPath);
-
-            // Look for META-INF/sca-contribution-generated.xml
-            if (contributionArtifactURL == null) {
-                contributionArtifactPath = Contribution.SCA_CONTRIBUTION_GENERATED_META;
-                contributionArtifactURL = classLoader.getResource(contributionArtifactPath);
-            }
-
-            // Look for META-INF/sca-deployables directory
-            if (contributionArtifactURL == null) {
-                contributionArtifactPath = Contribution.SCA_CONTRIBUTION_DEPLOYABLES;
-                contributionArtifactURL = classLoader.getResource(contributionArtifactPath);
-            }
-        }
-
-        if (contributionArtifactURL == null) {
-            throw new IllegalArgumentException(
-                                               "Can't determine contribution deployables. Either specify a composite file, or use an sca-contribution.xml file to specify the deployables.");
-        }
-
-        URL contributionURL = null;
-        // "jar:file://....../something.jar!/a/b/c/app.composite"
-        try {
-            String url = contributionArtifactURL.toExternalForm();
-            String protocol = contributionArtifactURL.getProtocol();
-            if ("file".equals(protocol)) {
-                // directory contribution
-                if (url.endsWith(contributionArtifactPath)) {
-                    final String location = url.substring(0, url.lastIndexOf(contributionArtifactPath));
-                    // workaround from evil URL/URI form Maven
-                    // contributionURL = FileHelper.toFile(new URL(location)).toURI().toURL();
-                    // Allow privileged access to open URL stream. Add FilePermission to added to
-                    // security policy file.
-                    try {
-                        contributionURL = AccessController.doPrivileged(new PrivilegedExceptionAction<URL>() {
-                            public URL run() throws IOException {
-                                return FileHelper.toFile(new URL(location)).toURI().toURL();
-                            }
-                        });
-                    } catch (PrivilegedActionException e) {
-                        throw (MalformedURLException)e.getException();
-                    }
-                }
-
-            } else if ("jar".equals(protocol)) {
-                // jar contribution
-                String location = url.substring(4, url.lastIndexOf("!/"));
-                // workaround for evil URL/URI from Maven
-                contributionURL = FileHelper.toFile(new URL(location)).toURI().toURL();
-
-            } else if ("wsjar".equals(protocol)) {
-                // See https://issues.apache.org/jira/browse/TUSCANY-2219
-                // wsjar contribution 
-                String location = url.substring(6, url.lastIndexOf("!/"));
-                // workaround for evil url/uri from maven 
-                contributionURL = FileHelper.toFile(new URL(location)).toURI().toURL();
-
-            } else if (protocol != null && (protocol.equals("bundle") || protocol.equals("bundleresource"))) {
-                contributionURL =
-                    new URL(contributionArtifactURL.getProtocol(), contributionArtifactURL.getHost(),
-                            contributionArtifactURL.getPort(), "/");
-            }
-        } catch (MalformedURLException mfe) {
-            throw new IllegalArgumentException(mfe);
-        }
-
-        return contributionURL;
     }
 
     @Override
     @SuppressWarnings("unchecked")
     public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException {
-        return (R)runtime.getProxyFactory().cast(target);
+        return (R)client.cast(target);
     }
 
     @Override
     public <B> B getService(Class<B> businessInterface, String serviceName) {
-        ServiceReference<B> serviceReference = getServiceReference(businessInterface, serviceName);
-        if (serviceReference == null) {
-            throw new ServiceRuntimeException("Service not found: " + serviceName);
-        }
-        return serviceReference.getService();
-    }
-
-    private <B> ServiceReference<B> createServiceReference(Class<B> businessInterface, String targetURI) {
-        try {
-            AssemblyFactory assemblyFactory = runtime.getAssemblyFactory();
-            Composite composite = assemblyFactory.createComposite();
-            composite.setName(new QName(Constants.SCA10_TUSCANY_NS, "default"));
-            RuntimeComponent component = (RuntimeComponent)assemblyFactory.createComponent();
-            component.setName("default");
-            component.setURI("default");
-            runtime.getCompositeActivator().configureComponentContext(component);
-            composite.getComponents().add(component);
-            RuntimeComponentReference reference = (RuntimeComponentReference)assemblyFactory.createComponentReference();
-            reference.setName("default");
-            ModelFactoryExtensionPoint factories =
-                runtime.getExtensionPointRegistry().getExtensionPoint(ModelFactoryExtensionPoint.class);
-            JavaInterfaceFactory javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
-            InterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
-            interfaceContract.setInterface(javaInterfaceFactory.createJavaInterface(businessInterface));
-            reference.setInterfaceContract(interfaceContract);
-            component.getReferences().add(reference);
-            reference.setComponent(component);
-            SCABindingFactory scaBindingFactory = factories.getFactory(SCABindingFactory.class);
-            SCABinding binding = scaBindingFactory.createSCABinding();
-            binding.setURI(targetURI);
-            reference.getBindings().add(binding);
-            return new ServiceReferenceImpl<B>(businessInterface, component, reference, binding, runtime
-                .getProxyFactory(), runtime.getCompositeActivator());
-        } catch (Exception e) {
-            throw new ServiceRuntimeException(e);
-        }
+        return client.getService(businessInterface, serviceName);
     }
 
     @Override
     public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String name) {
-
-        // Extract the component name
-        String componentName;
-        String serviceName;
-        int i = name.indexOf('/');
-        if (i != -1) {
-            componentName = name.substring(0, i);
-            serviceName = name.substring(i + 1);
-
-        } else {
-            componentName = name;
-            serviceName = null;
-        }
-
-        // Lookup the component in the domain
-        Component component = components.get(componentName);
-        if (component == null) {
-            // The component is not local in the partition, try to create a remote service ref
-            return createServiceReference(businessInterface, name);
-        }
-        RuntimeComponentContext componentContext = null;
-
-        // If the component is a composite, then we need to find the
-        // non-composite component that provides the requested service
-        if (component.getImplementation() instanceof Composite) {
-            for (ComponentService componentService : component.getServices()) {
-                if (serviceName == null || serviceName.equals(componentService.getName())) {
-                    CompositeService compositeService = (CompositeService)componentService.getService();
-                    if (compositeService != null) {
-                        if (serviceName != null) {
-                            serviceName = "$promoted$." + component.getName() + "." + serviceName;
-                        }
-                        componentContext =
-                            ((RuntimeComponent)compositeService.getPromotedComponent()).getComponentContext();
-                        return componentContext.createSelfReference(businessInterface, compositeService
-                            .getPromotedService());
-                    }
-                    break;
-                }
-            }
-            // No matching service is found
-            throw new ServiceRuntimeException("Composite service not found: " + name);
-        } else {
-            componentContext = ((RuntimeComponent)component).getComponentContext();
-            if (serviceName != null) {
-                return componentContext.createSelfReference(businessInterface, serviceName);
-            } else {
-                return componentContext.createSelfReference(businessInterface);
-            }
-        }
-
+        return client.getServiceReference(businessInterface, name);
     }
 
     @Override
@@ -595,6 +227,8 @@
     }
 
     public Set<String> getComponentNames() {
+        return components.keySet();
+        /*
         Set<String> componentNames = new HashSet<String>();
         for (Contribution contribution : contributions) {
             for (Artifact artifact : contribution.getArtifacts()) {
@@ -606,9 +240,12 @@
             }
         }
         return componentNames;
+        */
     }
 
     public Component getComponent(String componentName) {
+        return components.get(componentName);
+        /*
         for (Contribution contribution : contributions) {
             for (Artifact artifact : contribution.getArtifacts()) {
                 if (artifact.getModel() instanceof Composite) {
@@ -621,6 +258,7 @@
             }
         }
         return null;
+        */
     }
 
     public void startComponent(String componentName) throws ActivationException {
@@ -628,7 +266,6 @@
         if (component == null) {
             throw new IllegalArgumentException("no component: " + componentName);
         }
-        CompositeActivator compositeActivator = runtime.getCompositeActivator();
         compositeActivator.start(component);
     }
 
@@ -637,7 +274,6 @@
         if (component == null) {
             throw new IllegalArgumentException("no component: " + componentName);
         }
-        CompositeActivator compositeActivator = runtime.getCompositeActivator();
         compositeActivator.stop(component);
     }
 }

Modified: tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java (original)
+++ tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java Fri Aug 15 15:07:43 2008
@@ -40,6 +40,7 @@
 import org.apache.tuscany.sca.host.embedded.management.ComponentManager;
 import org.apache.tuscany.sca.interfacedef.InterfaceContract;
 import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.node.impl.RuntimeBootStrapper;
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
 import org.apache.tuscany.sca.runtime.RuntimeComponentContext;
 import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
@@ -56,7 +57,7 @@
 
     private String uri;
     private Composite domainComposite;
-    private ReallySmallRuntime runtime;
+    private RuntimeBootStrapper runtime;
     private ComponentManagerImpl componentManager = new ComponentManagerImpl(this);
     
     /**
@@ -70,7 +71,7 @@
         this.uri = domainURI;
         
         // Create a runtime
-        runtime = new ReallySmallRuntime(runtimeClassLoader);
+        runtime = new RuntimeBootStrapper(runtimeClassLoader);
     }
     
     public void start() throws ActivationException {

Modified: tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java (original)
+++ tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java Fri Aug 15 15:07:43 2008
@@ -33,7 +33,6 @@
 import org.apache.tuscany.sca.assembly.SCABindingFactory;
 import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
 import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
-import org.apache.tuscany.sca.assembly.builder.DomainBuilder;
 import org.apache.tuscany.sca.contribution.ContributionFactory;
 import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
 import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
@@ -87,7 +86,7 @@
     private ContributionService contributionService;
     private CompositeActivator compositeActivator;
     private CompositeBuilder compositeBuilder;
-    private DomainBuilder domainBuilder;    
+    // private DomainBuilder domainBuilder;    
     private WorkScheduler workScheduler;
     private ScopeRegistry scopeRegistry;
     private ProxyFactory proxyFactory;

Modified: tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java (original)
+++ tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java Fri Aug 15 15:07:43 2008
@@ -23,7 +23,6 @@
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.List;
-import java.util.logging.Logger;
 
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLOutputFactory;
@@ -33,7 +32,6 @@
 import org.apache.tuscany.sca.assembly.EndpointFactory;
 import org.apache.tuscany.sca.assembly.SCABindingFactory;
 import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
-import org.apache.tuscany.sca.assembly.builder.DomainBuilder;
 import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl;
 import org.apache.tuscany.sca.assembly.xml.CompositeDocumentProcessor;
 import org.apache.tuscany.sca.context.ContextFactoryExtensionPoint;
@@ -66,7 +64,6 @@
 import org.apache.tuscany.sca.core.assembly.CompositeActivator;
 import org.apache.tuscany.sca.core.assembly.CompositeActivatorImpl;
 import org.apache.tuscany.sca.core.conversation.ConversationManager;
-import org.apache.tuscany.sca.core.conversation.ConversationManagerImpl;
 import org.apache.tuscany.sca.core.invocation.ExtensibleWireProcessor;
 import org.apache.tuscany.sca.core.invocation.ProxyFactory;
 import org.apache.tuscany.sca.core.scope.CompositeScopeContainerFactory;
@@ -95,7 +92,7 @@
  */
 public class ReallySmallRuntimeBuilder {
     
-    private static final Logger logger = Logger.getLogger(ReallySmallRuntimeBuilder.class.getName());
+    // private static final Logger logger = Logger.getLogger(ReallySmallRuntimeBuilder.class.getName());
 	
     public static CompositeActivator createCompositeActivator(ExtensionPointRegistry registry,
                                                               AssemblyFactory assemblyFactory,

Modified: tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomainTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomainTestCase.java?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomainTestCase.java (original)
+++ tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomainTestCase.java Fri Aug 15 15:07:43 2008
@@ -36,7 +36,7 @@
     @Override
     protected void setUp() throws Exception {
         domain = new DefaultSCADomain(getClass().getClassLoader(), getClass().getClassLoader(),
-                                      "http://localhost", ".", "test.composite");
+                                      "http://localhost", "./target/test-classes", "test.composite");
     }
 
     public void testStart() throws Exception {

Modified: tuscany/java/sca/modules/implementation-node/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-node/pom.xml?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-node/pom.xml (original)
+++ tuscany/java/sca/modules/implementation-node/pom.xml Fri Aug 15 15:07:43 2008
@@ -50,7 +50,14 @@
 
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-host-embedded</artifactId>
+            <artifactId>tuscany-binding-sca</artifactId>
+            <version>1.4-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-binding-sca-xml</artifactId>
             <version>1.4-SNAPSHOT</version>
             <scope>test</scope>
         </dependency>

Modified: tuscany/java/sca/modules/node2-impl/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node2-impl/pom.xml?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/modules/node2-impl/pom.xml (original)
+++ tuscany/java/sca/modules/node2-impl/pom.xml Fri Aug 15 15:07:43 2008
@@ -58,17 +58,78 @@
         
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-host-embedded</artifactId>
+            <artifactId>tuscany-core</artifactId>
             <version>1.4-SNAPSHOT</version>
         </dependency>
         
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-contribution-impl</artifactId>
+            <version>1.4-SNAPSHOT</version>
+        </dependency>
+                
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
             <artifactId>tuscany-assembly-xml</artifactId>
             <version>1.4-SNAPSHOT</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-definitions-xml</artifactId>
+            <version>1.4-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-binding-sca</artifactId>
+            <version>1.4-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-binding-sca-xml</artifactId>
+            <version>1.4-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-policy-xml</artifactId>
+            <version>1.4-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-core-databinding</artifactId>
+            <version>1.4-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-assembly-xsd</artifactId>
+            <version>1.4-SNAPSHOT</version>
             <scope>runtime</scope>
         </dependency>
         
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-endpoint</artifactId>
+            <version>1.4-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency> 
+               
+       <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-implementation-java-runtime</artifactId>
+            <version>1.4-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>  
+              
     </dependencies>
 
 



Mime
View raw message