tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r686391 [2/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
Modified: tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java (original)
+++ tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java Fri Aug 15 15:07:43 2008
@@ -19,10 +19,10 @@
 
 package org.apache.tuscany.sca.node.impl;
 
+import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.StringReader;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
@@ -47,6 +47,7 @@
 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.xml.CompositeDocumentProcessor;
 import org.apache.tuscany.sca.contribution.Artifact;
 import org.apache.tuscany.sca.contribution.Contribution;
 import org.apache.tuscany.sca.contribution.ContributionFactory;
@@ -54,6 +55,8 @@
 import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
 import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
 import org.apache.tuscany.sca.contribution.service.ContributionService;
 import org.apache.tuscany.sca.contribution.service.util.FileHelper;
@@ -61,7 +64,6 @@
 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.host.embedded.impl.ReallySmallRuntime;
 import org.apache.tuscany.sca.implementation.node.ConfiguredNodeImplementation;
 import org.apache.tuscany.sca.implementation.node.NodeImplementationFactory;
 import org.apache.tuscany.sca.monitor.Monitor;
@@ -90,13 +92,15 @@
     private String configurationName;
 
     // The Tuscany runtime that does the hard work
-    private ReallySmallRuntime runtime;
+    private RuntimeBootStrapper runtime;
     private CompositeActivator compositeActivator;
     private XMLInputFactory inputFactory;
     private ModelFactoryExtensionPoint modelFactories;
     private StAXArtifactProcessorExtensionPoint artifactProcessors;
+    private URLArtifactProcessorExtensionPoint documentProcessors;
     private Monitor monitor;
 
+    private List<Contribution> contributions;
     private ContributionMetadata metadata;
 
     // The composite loaded into this node
@@ -147,6 +151,12 @@
         configurationName = compositeURI;
         logger.log(Level.INFO, "Creating node: " + configurationName);
 
+        if (compositeURI != null) {
+            URI uri = URI.create(compositeURI);
+            if (uri.isAbsolute()) {
+                throw new IllegalArgumentException("Composite URI must be a resource name: " + compositeURI);
+            }
+        }
         try {
             // Initialize the runtime
             initRuntime();
@@ -174,7 +184,8 @@
             if (contributionArtifactURL == null) {
                 throw new IllegalArgumentException("Composite not found: " + contributionArtifactPath);
             }
-            composite = createComposite(contributionArtifactURL.toString());
+            // Set to relative URI to avoid duplicate loading
+            Composite composite = createComposite(compositeURI);
             config.setComposite(composite);
         } else {
 
@@ -199,12 +210,15 @@
                 StAXArtifactProcessor<ContributionMetadata> processor =
                     artifactProcessors.getProcessor(ContributionMetadata.class);
                 XMLStreamReader reader = inputFactory.createXMLStreamReader(contributionArtifactURL.openStream());
+                reader.nextTag();
                 metadata = processor.read(reader);
                 reader.close();
                 if (metadata.getDeployables().isEmpty()) {
                     throw new IllegalArgumentException(
                                                        "No deployable composite is declared in " + contributionArtifactPath);
                 }
+                Composite composite = metadata.getDeployables().get(0);
+                config.setComposite(composite);
             }
         }
 
@@ -229,7 +243,7 @@
         return c;
     }
 
-    private URL getContributionURL(URL contributionArtifactURL, String contributionArtifactPath) {
+    public static URL getContributionURL(URL contributionArtifactURL, String contributionArtifactPath) {
         URL contributionURL = null;
         // "jar:file://....../something.jar!/a/b/c/app.composite"
         try {
@@ -300,8 +314,12 @@
             // Initialize the runtime
             initRuntime();
 
+            URI uri = URI.create(compositeURI);
             ConfiguredNodeImplementation configuration = null;
             if (contributions == null || contributions.length == 0) {
+                if (uri.getScheme() != null) {
+                    throw new IllegalArgumentException("No SCA contributions are provided");
+                }
                 configuration = findNodeConfiguration(compositeURI, null);
             } else {
 
@@ -358,16 +376,23 @@
                 configuration = findNodeConfiguration(compositeURI, null);
             } else {
                 // Create a node configuration
-                NodeImplementationFactory nodeImplementationFactory = modelFactories.getFactory(NodeImplementationFactory.class);
+                NodeImplementationFactory nodeImplementationFactory =
+                    modelFactories.getFactory(NodeImplementationFactory.class);
                 configuration = nodeImplementationFactory.createConfiguredNodeImplementation();
 
                 // Read the composite model
                 StAXArtifactProcessor<Composite> compositeProcessor = artifactProcessors.getProcessor(Composite.class);
-                URL compositeURL = new URL(compositeURI);
-                logger.log(Level.INFO, "Loading composite: " + compositeURL);
-                XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(compositeContent));
-                Composite composite = compositeProcessor.read(reader);
-                reader.close();
+                // URL compositeURL = new URL(compositeURI);
+                logger.log(Level.INFO, "Loading composite: " + compositeURI);
+
+                CompositeDocumentProcessor compositeDocProcessor =
+                    (CompositeDocumentProcessor)documentProcessors.getProcessor(Composite.class);
+                composite =
+                    compositeDocProcessor.read(URI.create(compositeURI), new ByteArrayInputStream(compositeContent
+                        .getBytes("UTF-8")));
+
+                analyzeProblems();
+
                 configuration.setComposite(composite);
 
                 // Create contribution models
@@ -402,7 +427,7 @@
     private void initRuntime() throws Exception {
 
         // Create a node runtime
-        runtime = new ReallySmallRuntime(Thread.currentThread().getContextClassLoader());
+        runtime = new RuntimeBootStrapper(Thread.currentThread().getContextClassLoader());
         runtime.start();
 
         // Get the various factories we need
@@ -413,6 +438,8 @@
         // Create the required artifact processors
         artifactProcessors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
 
+        documentProcessors = registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+
         // Save the composite activator
         compositeActivator = runtime.getCompositeActivator();
 
@@ -421,7 +448,7 @@
         MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
         monitor = monitorFactory.createMonitor();
     }
-    
+
     /**
      * Escape the space in URL string
      * @param uri
@@ -441,7 +468,7 @@
 
         // Load the specified contributions
         ContributionService contributionService = runtime.getContributionService();
-        List<Contribution> contributions = new ArrayList<Contribution>();
+        contributions = new ArrayList<Contribution>();
         for (Contribution contribution : configuration.getContributions()) {
             URI uri = createURI(contribution.getLocation());
             if (uri.getScheme() == null) {
@@ -468,9 +495,12 @@
             contributions.add(contributionService.contribute(contribution.getURI(), contributionURL, false));
             analyzeProblems();
         }
-        
+
+        composite = configuration.getComposite();
+
         // Resolve the metadata within the context of the contribution
-        //FIXME This doesn't seem to make sense here 
+        // FIXME The deployable composite should have been picked by the SCA Domain Manager already and we should not
+        // pollute the Node impl to deal with this 
         if (metadata != null) {
             StAXArtifactProcessor<ContributionMetadata> processor =
                 artifactProcessors.getProcessor(ContributionMetadata.class);
@@ -481,55 +511,65 @@
                 }
             }
             List<Composite> composites = metadata.getDeployables();
-            configuration.setComposite(composites.get(0));
-        }
-
-        // Load the specified composite
-        Contribution contribution;
-        URL compositeURL;
-        
-        URI uri = createURI(configuration.getComposite().getURI());
-        if (uri.getScheme() == null) {
-            
-            // If the composite URI is a relative URI, try to resolve it within the contributions
-            contribution = contribution(contributions, uri.toString());
-            if (contribution == null) {
-                throw new IllegalArgumentException("Composite is not found in contributions: " + uri);
-            }
-            compositeURL = new URL(location(contribution, uri.toString()));
-            
-        } else {
-            
-            // If the composite URI is an absolute URI, use it as is
-            compositeURL = uri.toURL();
-            
-            // And resolve the composite within the scope of the last contribution
-            if (contributions.size() != 0) {
-                contribution = contributions.get(contributions.size() -1);
+            if (composites.size() == 0) {
+                throw new IllegalArgumentException("No deployable composite is declared");
+            } else if (composites.size() == 1) {
+                composite = composites.get(0);
             } else {
-                contribution = null;
+                // This is temporary to include all composites
+                AssemblyFactory assemblyFactory = runtime.getAssemblyFactory();
+                Composite tempComposite = assemblyFactory.createComposite();
+                tempComposite.setName(new QName("http://tempuri.org", "aggregated"));
+                tempComposite.setURI("http://tempuri.org/aggregated");
+                tempComposite.getIncludes().addAll(composites);
+                composite = tempComposite;
             }
+            configuration.setComposite(composite);
         }
-            
-        // Read the composite
-        StAXArtifactProcessor<Composite> compositeProcessor = artifactProcessors.getProcessor(Composite.class);
-        composite = configuration.getComposite();
+
+        Contribution contribution = null;
         if (composite.getName() == null) {
+            // Load the specified composite
+            URL compositeURL;
+
+            URI uri = createURI(configuration.getComposite().getURI());
+            if (uri.getScheme() == null) {
+
+                // If the composite URI is a relative URI, try to resolve it within the contributions
+                contribution = contribution(contributions, uri.toString());
+                if (contribution == null) {
+                    throw new IllegalArgumentException("Composite is not found in contributions: " + uri);
+                }
+                compositeURL = new URL(location(contribution, uri.toString()));
+
+            } else {
+
+                // If the composite URI is an absolute URI, use it as is
+                compositeURL = uri.toURL();
+            }
+
+            URLArtifactProcessor<Composite> compositeDocProcessor = documentProcessors.getProcessor(Composite.class);
+            // Read the composite
             logger.log(Level.INFO, "Loading composite: " + compositeURL);
-            InputStream is = compositeURL.openStream();
-            XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
-            composite = compositeProcessor.read(reader);
-            reader.close();
+            // InputStream is = compositeURL.openStream();
+            // XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+            composite = compositeDocProcessor.read(null, uri, compositeURL);
+            // reader.close();
 
             analyzeProblems();
+
+        }
+        // And resolve the composite within the scope of the last contribution
+        if (contribution == null && contributions.size() != 0) {
+            contribution = contributions.get(contributions.size() - 1);
         }
 
         // Resolve the given composite within the scope of the selected contribution
         if (contribution != null) {
+            StAXArtifactProcessor<Composite> compositeProcessor = artifactProcessors.getProcessor(Composite.class);
             compositeProcessor.resolve(composite, contribution.getModelResolver());
             analyzeProblems();
         }
-
         // Create a top level composite to host our composite
         // This is temporary to make the activator happy
         AssemblyFactory assemblyFactory = runtime.getAssemblyFactory();
@@ -550,7 +590,7 @@
 
         analyzeProblems();
     }
-    
+
     /**
      * Returns the artifact representing the given composite.
      * 
@@ -640,6 +680,7 @@
             // Deactivate the composite
             compositeActivator.deactivate(composite);
 
+            runtime.stop();
         } catch (ActivationException e) {
             throw new ServiceRuntimeException(e);
         }
@@ -774,4 +815,9 @@
         // Collect JARs from the parent ClassLoader
         collectJARs(urls, cl.getParent());
     }
+
+    public CompositeActivator getCompositeActivator() {
+        return compositeActivator;
+    }
+
 }

Added: tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBootStrapper.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBootStrapper.java?rev=686391&view=auto
==============================================================================
--- tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBootStrapper.java (added)
+++ tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBootStrapper.java Fri Aug 15 15:07:43 2008
@@ -0,0 +1,385 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.node.impl;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Composite;
+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.CompositeBuilderException;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.service.ContributionService;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ModuleActivator;
+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.RuntimeAssemblyFactory;
+import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.scope.ScopeRegistry;
+import org.apache.tuscany.sca.definitions.SCADefinitions;
+import org.apache.tuscany.sca.definitions.impl.SCADefinitionsImpl;
+import org.apache.tuscany.sca.definitions.util.SCADefinitionsUtil;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.apache.tuscany.sca.monitor.impl.DefaultMonitorFactoryImpl;
+import org.apache.tuscany.sca.policy.DefaultIntentAttachPointTypeFactory;
+import org.apache.tuscany.sca.policy.DefaultPolicyFactory;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.provider.SCADefinitionsProvider;
+import org.apache.tuscany.sca.provider.SCADefinitionsProviderExtensionPoint;
+import org.apache.tuscany.sca.work.WorkScheduler;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class RuntimeBootStrapper {
+    private static final Logger logger = Logger.getLogger(RuntimeBootStrapper.class.getName());
+    private List<ModuleActivator> modules;
+    private ExtensionPointRegistry registry;
+
+    private ClassLoader classLoader;
+    private AssemblyFactory assemblyFactory;
+    private ContributionService contributionService;
+    private CompositeActivator compositeActivator;
+    private CompositeBuilder compositeBuilder;
+    // private DomainBuilder domainBuilder;
+    private WorkScheduler workScheduler;
+    private ScopeRegistry scopeRegistry;
+    private ProxyFactory proxyFactory;
+    private List<SCADefinitions> policyDefinitions;
+    private ModelResolver policyDefinitionsResolver;
+    private Monitor monitor;
+
+    public RuntimeBootStrapper(ClassLoader classLoader) {
+        this.classLoader = classLoader;
+    }
+
+    public void start() throws ActivationException {
+        long start = System.currentTimeMillis();
+
+        // Create our extension point registry
+        registry = new DefaultExtensionPointRegistry();
+        UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+
+        // Get work scheduler
+        workScheduler = utilities.getUtility(WorkScheduler.class);
+
+        // Create an interface contract mapper
+        InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class);
+
+        // Get factory extension point
+        ModelFactoryExtensionPoint factories = registry.getExtensionPoint(ModelFactoryExtensionPoint.class);
+
+        // Get Message factory
+        MessageFactory messageFactory = factories.getFactory(MessageFactory.class);
+
+        // Get proxy factory
+        ProxyFactoryExtensionPoint proxyFactories = registry.getExtensionPoint(ProxyFactoryExtensionPoint.class);
+        proxyFactory = new ExtensibleProxyFactory(proxyFactories);
+
+        // Create model factories
+        assemblyFactory = new RuntimeAssemblyFactory();
+        factories.addFactory(assemblyFactory);
+        PolicyFactory policyFactory = new DefaultPolicyFactory();
+        factories.addFactory(policyFactory);
+
+        // Load the runtime modules
+        modules = loadModules(registry);
+
+        // Start the runtime modules
+        startModules(registry, modules);
+
+        SCABindingFactory scaBindingFactory = factories.getFactory(SCABindingFactory.class);
+        IntentAttachPointTypeFactory intentAttachPointTypeFactory = new DefaultIntentAttachPointTypeFactory();
+        factories.addFactory(intentAttachPointTypeFactory);
+        ContributionFactory contributionFactory = factories.getFactory(ContributionFactory.class);
+
+        // Create a monitor
+        MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
+
+        if (monitorFactory != null) {
+            monitor = monitorFactory.createMonitor();
+        } else {
+            monitorFactory = new DefaultMonitorFactoryImpl();
+            monitor = monitorFactory.createMonitor();
+            utilities.addUtility(monitorFactory);
+            //logger.fine("No MonitorFactory is found on the classpath.");
+        }
+
+        // Create a contribution service
+        policyDefinitions = new ArrayList<SCADefinitions>();
+        policyDefinitionsResolver = new DefaultModelResolver();
+        contributionService =
+            RuntimeBuilder.createContributionService(classLoader,
+                                                     registry,
+                                                     contributionFactory,
+                                                     assemblyFactory,
+                                                     policyFactory,
+                                                     mapper,
+                                                     policyDefinitions,
+                                                     policyDefinitionsResolver,
+                                                     monitor);
+
+        // Create the ScopeRegistry
+        scopeRegistry = RuntimeBuilder.createScopeRegistry(registry);
+
+        // Create a composite activator
+        compositeActivator =
+            RuntimeBuilder.createCompositeActivator(registry,
+                                                    assemblyFactory,
+                                                    messageFactory,
+                                                    scaBindingFactory,
+                                                    mapper,
+                                                    proxyFactory,
+                                                    scopeRegistry,
+                                                    workScheduler);
+
+        // Load the definitions.xml
+        loadSCADefinitions();
+
+        if (logger.isLoggable(Level.FINE)) {
+            long end = System.currentTimeMillis();
+            logger.fine("The tuscany runtime is started in " + (end - start) + " ms.");
+        }
+    }
+
+    public void stop() throws ActivationException {
+        long start = System.currentTimeMillis();
+
+        // Stop the runtime modules
+        stopModules(registry, modules);
+
+        // Stop and destroy the work manager
+        workScheduler.destroy();
+
+        // Cleanup
+        modules = null;
+        registry = null;
+        assemblyFactory = null;
+        contributionService = null;
+        compositeActivator = null;
+        workScheduler = null;
+        scopeRegistry = null;
+
+        if (logger.isLoggable(Level.FINE)) {
+            long end = System.currentTimeMillis();
+            logger.fine("The tuscany runtime is stopped in " + (end - start) + " ms.");
+        }
+    }
+
+    public void buildComposite(Composite composite) throws CompositeBuilderException {
+        //Get factory extension point
+        ModelFactoryExtensionPoint factories = registry.getExtensionPoint(ModelFactoryExtensionPoint.class);
+        SCABindingFactory scaBindingFactory = factories.getFactory(SCABindingFactory.class);
+        IntentAttachPointTypeFactory intentAttachPointTypeFactory =
+            factories.getFactory(IntentAttachPointTypeFactory.class);
+        EndpointFactory endpointFactory = factories.getFactory(EndpointFactory.class);
+        UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+        InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class);
+
+        //Create a composite builder
+        SCADefinitions aggregatedDefinitions = new SCADefinitionsImpl();
+        for (SCADefinitions definition : ((List<SCADefinitions>)policyDefinitions)) {
+            SCADefinitionsUtil.aggregateSCADefinitions(definition, aggregatedDefinitions);
+        }
+        compositeBuilder =
+            RuntimeBuilder.createCompositeBuilder(monitor,
+                                                  assemblyFactory,
+                                                  scaBindingFactory,
+                                                  endpointFactory,
+                                                  intentAttachPointTypeFactory,
+                                                  mapper,
+                                                  aggregatedDefinitions);
+        compositeBuilder.build(composite);
+
+    }
+
+    public ContributionService getContributionService() {
+        return contributionService;
+    }
+
+    public CompositeActivator getCompositeActivator() {
+        return compositeActivator;
+    }
+
+    public CompositeBuilder getCompositeBuilder() {
+        return compositeBuilder;
+    }
+
+    public AssemblyFactory getAssemblyFactory() {
+        return assemblyFactory;
+    }
+
+    private void loadSCADefinitions() throws ActivationException {
+        try {
+            URLArtifactProcessorExtensionPoint documentProcessors =
+                registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+            URLArtifactProcessor<SCADefinitions> definitionsProcessor =
+                documentProcessors.getProcessor(SCADefinitions.class);
+            SCADefinitionsProviderExtensionPoint scaDefnProviders =
+                registry.getExtensionPoint(SCADefinitionsProviderExtensionPoint.class);
+
+            SCADefinitions systemSCADefinitions = new SCADefinitionsImpl();
+            SCADefinitions aSCADefn = null;
+            for (SCADefinitionsProvider aProvider : scaDefnProviders.getSCADefinitionsProviders()) {
+                aSCADefn = aProvider.getSCADefinition();
+                SCADefinitionsUtil.aggregateSCADefinitions(aSCADefn, systemSCADefinitions);
+            }
+
+            policyDefinitions.add(systemSCADefinitions);
+
+            //we cannot expect that providers will add the intents and policysets into the resolver
+            //so we do this here explicitly
+            for (Intent intent : systemSCADefinitions.getPolicyIntents()) {
+                policyDefinitionsResolver.addModel(intent);
+            }
+
+            for (PolicySet policySet : systemSCADefinitions.getPolicySets()) {
+                policyDefinitionsResolver.addModel(policySet);
+            }
+
+            for (IntentAttachPointType attachPoinType : systemSCADefinitions.getBindingTypes()) {
+                policyDefinitionsResolver.addModel(attachPoinType);
+            }
+
+            for (IntentAttachPointType attachPoinType : systemSCADefinitions.getImplementationTypes()) {
+                policyDefinitionsResolver.addModel(attachPoinType);
+            }
+
+            //now that all system sca definitions have been read, lets resolve them right away
+            definitionsProcessor.resolve(systemSCADefinitions, policyDefinitionsResolver);
+        } catch (Exception e) {
+            throw new ActivationException(e);
+        }
+    }
+
+    private List<ModuleActivator> loadModules(ExtensionPointRegistry registry) throws ActivationException {
+
+        // Load and instantiate the modules found on the classpath (or any registered ClassLoaders)
+        modules = new ArrayList<ModuleActivator>();
+        try {
+            Set<ServiceDeclaration> moduleActivators =
+                ServiceDiscovery.getInstance().getServiceDeclarations(ModuleActivator.class);
+            Set<String> moduleClasses = new HashSet<String>();
+            for (ServiceDeclaration moduleDeclarator : moduleActivators) {
+                if (moduleClasses.contains(moduleDeclarator.getClassName())) {
+                    continue;
+                }
+                moduleClasses.add(moduleDeclarator.getClassName());
+                Class<?> moduleClass = moduleDeclarator.loadClass();
+                ModuleActivator module = (ModuleActivator)moduleClass.newInstance();
+                modules.add(module);
+            }
+        } catch (IOException e) {
+            throw new ActivationException(e);
+        } catch (ClassNotFoundException e) {
+            throw new ActivationException(e);
+        } catch (InstantiationException e) {
+            throw new ActivationException(e);
+        } catch (IllegalAccessException e) {
+            throw new ActivationException(e);
+        }
+
+        return modules;
+    }
+
+    private void startModules(ExtensionPointRegistry registry, List<ModuleActivator> modules)
+        throws ActivationException {
+        boolean debug = logger.isLoggable(Level.FINE);
+        // Start all the extension modules
+        for (ModuleActivator module : modules) {
+            long start = 0L;
+            if (debug) {
+                logger.fine(module.getClass().getName() + " is starting.");
+                start = System.currentTimeMillis();
+            }
+            try {
+                module.start(registry);
+                if (debug) {
+                    long end = System.currentTimeMillis();
+                    logger.fine(module.getClass().getName() + " is started in " + (end - start) + " ms.");
+                }
+            } catch (Throwable e) {
+                logger.log(Level.WARNING, "Exception starting module " + module.getClass().getName()
+                    + " :"
+                    + e.getMessage());
+                logger.log(Level.FINE, "Exception starting module " + module.getClass().getName(), e);
+            }
+        }
+    }
+
+    private void stopModules(final ExtensionPointRegistry registry, List<ModuleActivator> modules) {
+        boolean debug = logger.isLoggable(Level.FINE);
+        for (ModuleActivator module : modules) {
+            long start = 0L;
+            if (debug) {
+                logger.fine(module.getClass().getName() + " is stopping.");
+                start = System.currentTimeMillis();
+            }
+            module.stop(registry);
+            if (debug) {
+                long end = System.currentTimeMillis();
+                logger.fine(module.getClass().getName() + " is stopped in " + (end - start) + " ms.");
+            }
+        }
+    }
+
+    /**
+     * @return the proxyFactory
+     */
+    public ProxyFactory getProxyFactory() {
+        return proxyFactory;
+    }
+
+    /**
+     * @return the registry
+     */
+    public ExtensionPointRegistry getExtensionPointRegistry() {
+        return registry;
+    }
+
+}

Propchange: tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBootStrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBootStrapper.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBuilder.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBuilder.java?rev=686391&view=auto
==============================================================================
--- tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBuilder.java (added)
+++ tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBuilder.java Fri Aug 15 15:07:43 2008
@@ -0,0 +1,261 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.node.impl;
+
+import java.io.IOException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.List;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Composite;
+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.impl.CompositeBuilderImpl;
+import org.apache.tuscany.sca.assembly.xml.CompositeDocumentProcessor;
+import org.apache.tuscany.sca.context.ContextFactoryExtensionPoint;
+import org.apache.tuscany.sca.context.RequestContextFactory;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.DefaultValidatingXMLInputFactory;
+import org.apache.tuscany.sca.contribution.processor.DefaultValidationSchemaExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensiblePackageProcessor;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.PackageProcessor;
+import org.apache.tuscany.sca.contribution.processor.PackageProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint;
+import org.apache.tuscany.sca.contribution.service.ContributionListenerExtensionPoint;
+import org.apache.tuscany.sca.contribution.service.ContributionRepository;
+import org.apache.tuscany.sca.contribution.service.ContributionService;
+import org.apache.tuscany.sca.contribution.service.ExtensibleContributionListener;
+import org.apache.tuscany.sca.contribution.service.TypeDescriber;
+import org.apache.tuscany.sca.contribution.service.impl.ContributionRepositoryImpl;
+import org.apache.tuscany.sca.contribution.service.impl.ContributionServiceImpl;
+import org.apache.tuscany.sca.contribution.service.impl.PackageTypeDescriberImpl;
+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.CompositeActivatorImpl;
+import org.apache.tuscany.sca.core.conversation.ConversationManager;
+import org.apache.tuscany.sca.core.invocation.ExtensibleWireProcessor;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.core.scope.CompositeScopeContainerFactory;
+import org.apache.tuscany.sca.core.scope.ConversationalScopeContainerFactory;
+import org.apache.tuscany.sca.core.scope.RequestScopeContainerFactory;
+import org.apache.tuscany.sca.core.scope.ScopeContainerFactory;
+import org.apache.tuscany.sca.core.scope.ScopeRegistry;
+import org.apache.tuscany.sca.core.scope.ScopeRegistryImpl;
+import org.apache.tuscany.sca.core.scope.StatelessScopeContainerFactory;
+import org.apache.tuscany.sca.definitions.SCADefinitions;
+import org.apache.tuscany.sca.endpointresolver.EndpointResolverFactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
+import org.apache.tuscany.sca.runtime.RuntimeWireProcessor;
+import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint;
+import org.apache.tuscany.sca.work.WorkScheduler;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class RuntimeBuilder {
+
+    // private static final Logger logger = Logger.getLogger(RuntimeBuilder.class.getName());
+
+    public static CompositeActivator createCompositeActivator(ExtensionPointRegistry registry,
+                                                              AssemblyFactory assemblyFactory,
+                                                              MessageFactory messageFactory,
+                                                              SCABindingFactory scaBindingFactory,
+                                                              InterfaceContractMapper mapper,
+                                                              ProxyFactory proxyFactory,
+                                                              ScopeRegistry scopeRegistry,
+                                                              WorkScheduler workScheduler) {
+
+        // Create a wire post processor extension point
+        RuntimeWireProcessorExtensionPoint wireProcessors =
+            registry.getExtensionPoint(RuntimeWireProcessorExtensionPoint.class);
+        RuntimeWireProcessor wireProcessor = new ExtensibleWireProcessor(wireProcessors);
+
+        // Retrieve the processors extension point
+        StAXArtifactProcessorExtensionPoint processors =
+            registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+
+        // Create a provider factory extension point
+        ProviderFactoryExtensionPoint providerFactories =
+            registry.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+
+        // Create a endpoint resolver factory extension point
+        EndpointResolverFactoryExtensionPoint endpointResolverFactories =
+            registry.getExtensionPoint(EndpointResolverFactoryExtensionPoint.class);
+
+        JavaInterfaceFactory javaInterfaceFactory =
+            registry.getExtensionPoint(ModelFactoryExtensionPoint.class).getFactory(JavaInterfaceFactory.class);
+        RequestContextFactory requestContextFactory =
+            registry.getExtensionPoint(ContextFactoryExtensionPoint.class).getFactory(RequestContextFactory.class);
+
+        UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+        ConversationManager conversationManager = utilities.getUtility(ConversationManager.class);
+
+        // Create the composite activator
+        CompositeActivator compositeActivator =
+            new CompositeActivatorImpl(assemblyFactory, messageFactory, javaInterfaceFactory, scaBindingFactory,
+                                       mapper, scopeRegistry, workScheduler, wireProcessor, requestContextFactory,
+                                       proxyFactory, providerFactories, endpointResolverFactories, processors,
+                                       conversationManager);
+
+        return compositeActivator;
+    }
+
+    public static CompositeBuilder createCompositeBuilder(Monitor monitor,
+                                                          AssemblyFactory assemblyFactory,
+                                                          SCABindingFactory scaBindingFactory,
+                                                          EndpointFactory endpointFactory,
+                                                          IntentAttachPointTypeFactory intentAttachPointTypeFactory,
+                                                          InterfaceContractMapper interfaceContractMapper,
+                                                          SCADefinitions policyDefinitions) {
+
+        return new CompositeBuilderImpl(assemblyFactory, endpointFactory, scaBindingFactory,
+                                        intentAttachPointTypeFactory, interfaceContractMapper, policyDefinitions,
+                                        monitor);
+    }
+
+    /**
+     * Create the contribution service used by this domain.
+     * 
+     * @throws ActivationException
+     */
+    public static ContributionService createContributionService(ClassLoader classLoader,
+                                                                ExtensionPointRegistry registry,
+                                                                ContributionFactory contributionFactory,
+                                                                AssemblyFactory assemblyFactory,
+                                                                PolicyFactory policyFactory,
+                                                                InterfaceContractMapper mapper,
+                                                                List<SCADefinitions> policyDefinitions,
+                                                                ModelResolver policyDefinitionResolver,
+                                                                Monitor monitor) throws ActivationException {
+
+        // Get the model factory extension point
+        ModelFactoryExtensionPoint modelFactories = registry.getExtensionPoint(ModelFactoryExtensionPoint.class);
+
+        // Create a new XML input factory
+        // Allow privileged access to factory. Requires RuntimePermission in security policy file.
+        XMLInputFactory inputFactory = AccessController.doPrivileged(new PrivilegedAction<XMLInputFactory>() {
+            public XMLInputFactory run() {
+                return XMLInputFactory.newInstance();
+            }
+        });
+        modelFactories.addFactory(inputFactory);
+
+        // Create a validation XML schema extension point
+        ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint();
+
+        // Create a validating XML input factory
+        XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas, monitor);
+        modelFactories.addFactory(validatingInputFactory);
+
+        // Create StAX artifact processor extension point
+        StAXArtifactProcessorExtensionPoint staxProcessors =
+            registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+
+        // Create and register StAX processors for SCA assembly XML
+        // Allow privileged access to factory. Requires RuntimePermission in security policy file.
+        XMLOutputFactory outputFactory = AccessController.doPrivileged(new PrivilegedAction<XMLOutputFactory>() {
+            public XMLOutputFactory run() {
+                return XMLOutputFactory.newInstance();
+            }
+        });
+        ExtensibleStAXArtifactProcessor staxProcessor =
+            new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory, monitor);
+
+        // Create URL artifact processor extension point
+        URLArtifactProcessorExtensionPoint documentProcessors =
+            registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+
+        // Create and register document processors for SCA assembly XML
+        documentProcessors.getProcessor(Composite.class);
+        documentProcessors.addArtifactProcessor(new CompositeDocumentProcessor(staxProcessor, validatingInputFactory,
+                                                                               policyDefinitions, monitor));
+
+        // Create Model Resolver extension point
+        ModelResolverExtensionPoint modelResolvers = registry.getExtensionPoint(ModelResolverExtensionPoint.class);
+
+        // Create contribution package processor extension point
+        TypeDescriber describer = new PackageTypeDescriberImpl();
+        PackageProcessor packageProcessor =
+            new ExtensiblePackageProcessor(registry.getExtensionPoint(PackageProcessorExtensionPoint.class), describer,
+                                           monitor);
+
+        // Create contribution listener
+        ExtensibleContributionListener contributionListener =
+            new ExtensibleContributionListener(registry.getExtensionPoint(ContributionListenerExtensionPoint.class));
+
+        // Create a contribution repository
+        ContributionRepository repository;
+        try {
+            repository = new ContributionRepositoryImpl("target", inputFactory, monitor);
+        } catch (IOException e) {
+            throw new ActivationException(e);
+        }
+
+        ExtensibleURLArtifactProcessor documentProcessor =
+            new ExtensibleURLArtifactProcessor(documentProcessors, monitor);
+
+        // Create the contribution service
+        ContributionService contributionService =
+            new ContributionServiceImpl(repository, packageProcessor, documentProcessor, staxProcessor,
+                                        contributionListener, policyDefinitionResolver, modelResolvers, modelFactories,
+                                        assemblyFactory, contributionFactory, inputFactory, policyDefinitions, monitor);
+        return contributionService;
+    }
+
+    public static ScopeRegistry createScopeRegistry(ExtensionPointRegistry registry) {
+        ScopeRegistry scopeRegistry = new ScopeRegistryImpl();
+        ScopeContainerFactory[] factories =
+            new ScopeContainerFactory[] {new CompositeScopeContainerFactory(), new StatelessScopeContainerFactory(),
+                                         new RequestScopeContainerFactory(),
+                                         new ConversationalScopeContainerFactory(null),
+            // new HttpSessionScopeContainer(monitor)
+            };
+        for (ScopeContainerFactory f : factories) {
+            scopeRegistry.register(f);
+        }
+
+        //FIXME Pass the scope container differently as it's not an extension point
+        registry.addExtensionPoint(scopeRegistry);
+
+        return scopeRegistry;
+    }
+
+}

Propchange: tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/java/sca/modules/node2-impl/src/test/java/hello/HelloWorld.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node2-impl/src/test/java/hello/HelloWorld.java?rev=686391&view=auto
==============================================================================
--- tuscany/java/sca/modules/node2-impl/src/test/java/hello/HelloWorld.java (added)
+++ tuscany/java/sca/modules/node2-impl/src/test/java/hello/HelloWorld.java Fri Aug 15 15:07:43 2008
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package hello;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * HelloWorld interface
+ */
+@Remotable
+public interface HelloWorld {
+    String hello(String name);
+}

Propchange: tuscany/java/sca/modules/node2-impl/src/test/java/hello/HelloWorld.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/node2-impl/src/test/java/hello/HelloWorld.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/java/sca/modules/node2-impl/src/test/java/hello/HelloWorldImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node2-impl/src/test/java/hello/HelloWorldImpl.java?rev=686391&view=auto
==============================================================================
--- tuscany/java/sca/modules/node2-impl/src/test/java/hello/HelloWorldImpl.java (added)
+++ tuscany/java/sca/modules/node2-impl/src/test/java/hello/HelloWorldImpl.java Fri Aug 15 15:07:43 2008
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package hello;
+
+/**
+ * HelloWorldImpl
+ */
+public class HelloWorldImpl implements HelloWorld {
+    public String hello(String name) {
+        System.out.println("Hello: " + name);
+        return "Hello, " + name;
+    }
+}

Propchange: tuscany/java/sca/modules/node2-impl/src/test/java/hello/HelloWorldImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/node2-impl/src/test/java/hello/HelloWorldImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/java/sca/modules/node2-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node2-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java?rev=686391&view=auto
==============================================================================
--- tuscany/java/sca/modules/node2-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java (added)
+++ tuscany/java/sca/modules/node2-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java Fri Aug 15 15:07:43 2008
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * \"License\"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.node.impl;
+
+import hello.HelloWorld;
+
+import java.io.File;
+
+import junit.framework.Assert;
+
+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.junit.Test;
+
+/**
+ * 
+ */
+public class NodeImplTestCase {
+    private static String composite =
+        "<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\"" + " xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.0\""
+            + " targetNamespace=\"http://sample/composite\""
+            + " xmlns:sc=\"http://sample/composite\""
+            + " name=\"HelloWorld\">"
+            + " <component name=\"HelloWorld\">"
+            + " <implementation.java class=\"hello.HelloWorldImpl\"/>"
+            + " </component>"
+            + " </composite>";
+
+    @Test
+    public void testNodeWithCompositeContent() {
+        SCANode2Factory factory = new NodeFactoryImpl();
+        SCAContribution contribution = new SCAContribution("c1", new File("target/classes").toURI().toString());
+        SCANode2 node = factory.createSCANode("HelloWorld.composite", composite, contribution);
+        node.start();
+        HelloWorld hw = ((SCAClient)node).getService(HelloWorld.class, "HelloWorld");
+        Assert.assertEquals("Hello, Node", hw.hello("Node"));
+        node.stop();
+    }
+
+    @Test
+    public void testNodeWithCompositeURI() {
+        SCANode2Factory factory = new NodeFactoryImpl();
+        SCAContribution contribution = new SCAContribution("c1", new File("target/classes").toURI().toString());
+        String compositeURI = new File("target/test-classes/HelloWorld.composite").toURI().toString();
+        SCANode2 node = factory.createSCANode(compositeURI, contribution);
+        node.start();
+        HelloWorld hw = ((SCAClient)node).getService(HelloWorld.class, "HelloWorld");
+        Assert.assertEquals("Hello, Node", hw.hello("Node"));
+        node.stop();
+    }
+
+    @Test
+    public void testNodeWithRelativeCompositeURI() {
+        SCANode2Factory factory = new NodeFactoryImpl();
+        SCAContribution contribution = new SCAContribution("c1", new File("target/test-classes").toURI().toString());
+        String compositeURI = "HelloWorld.composite";
+        SCANode2 node = factory.createSCANode(compositeURI, contribution);
+        node.start();
+        HelloWorld hw = ((SCAClient)node).getService(HelloWorld.class, "HelloWorld");
+        Assert.assertEquals("Hello, Node", hw.hello("Node"));
+        node.stop();
+    }
+
+    @Test
+    public void testNodeWithRelativeCompositeURIAndNoContribution() {
+        SCANode2Factory factory = new NodeFactoryImpl();
+        String compositeURI = "HelloWorld.composite";
+        SCANode2 node = factory.createSCANode(compositeURI, new SCAContribution[0]);
+        node.start();
+        HelloWorld hw = ((SCAClient)node).getService(HelloWorld.class, "HelloWorld");
+        Assert.assertEquals("Hello, Node", hw.hello("Node"));
+        node.stop();
+    }
+
+    @Test
+    public void testNodeWithClassLoader() {
+        SCANode2Factory factory = new NodeFactoryImpl();
+        String compositeURI = "HelloWorld.composite";
+        SCANode2 node = factory.createSCANodeFromClassLoader(compositeURI, HelloWorld.class.getClassLoader());
+        node.start();
+        HelloWorld hw = ((SCAClient)node).getService(HelloWorld.class, "HelloWorld");
+        Assert.assertEquals("Hello, Node", hw.hello("Node"));
+        node.stop();
+    }
+}

Propchange: tuscany/java/sca/modules/node2-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/node2-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/java/sca/modules/node2-impl/src/test/resources/HelloWorld.composite
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node2-impl/src/test/resources/HelloWorld.composite?rev=686391&view=auto
==============================================================================
--- tuscany/java/sca/modules/node2-impl/src/test/resources/HelloWorld.composite (added)
+++ tuscany/java/sca/modules/node2-impl/src/test/resources/HelloWorld.composite Fri Aug 15 15:07:43 2008
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    * Licensed to the Apache Software Foundation (ASF) under one
+    * or more contributor license agreements.  See the NOTICE file
+    * distributed with this work for additional information
+    * regarding copyright ownership.  The ASF licenses this file
+    * to you under the Apache License, Version 2.0 (the
+    * "License"); you may not use this file except in compliance
+    * with the License.  You may obtain a copy of the License at
+    * 
+    *   http://www.apache.org/licenses/LICENSE-2.0
+    * 
+    * Unless required by applicable law or agreed to in writing,
+    * software distributed under the License is distributed on an
+    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    * KIND, either express or implied.  See the License for the
+    * specific language governing permissions and limitations
+    * under the License.    
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+    xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+	targetNamespace="http://sample/composite"
+	xmlns:sc="http://sample/composite"
+	name="HelloWorld">
+
+    <component name="HelloWorld">
+        <implementation.java class="hello.HelloWorldImpl"/>
+    </component>
+
+</composite>

Modified: tuscany/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/DomainManagerLauncher.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/DomainManagerLauncher.java?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/DomainManagerLauncher.java (original)
+++ tuscany/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/DomainManagerLauncher.java Fri Aug 15 15:07:43 2008
@@ -72,7 +72,7 @@
     }
     
     public static void main(String[] args) throws Exception {
-        logger.info("Apache Tuscany SCA Domain Manager starting...");
+        logger.info("Apache Tuscany SCA Domain Manager is starting...");
 
         // Create a domain manager
         DomainManagerLauncher launcher = newInstance();
@@ -85,9 +85,13 @@
             logger.log(Level.SEVERE, "SCA Domain Manager could not be started", e);
             throw e;
         }
-        logger.info("SCA Domain Manager started.");
+        logger.info("SCA Domain Manager is now started.");
+        
+        ShutdownThread hook = new ShutdownThread(domainManager);
+        Runtime.getRuntime().addShutdownHook(hook);
         
         logger.info("Press enter to shutdown.");
+
         try {
             System.in.read();
         } catch (IOException e) {
@@ -98,13 +102,40 @@
                 lock.wait();
             }
         }
+        
+        stop(domainManager);
+        // Remove the hook
+        Runtime.getRuntime().removeShutdownHook(hook);
+    }
 
+    private static void stop(Object domainManager) throws Exception {
         // Stop the domain manager
+        if (domainManager == null) {
+            return;
+        }
         try {
             domainManager.getClass().getMethod("stop").invoke(domainManager);
+            logger.info("SCA Domain Manager is now stopped.");
         } catch (Exception e) {
             logger.log(Level.SEVERE, "SCA Domain Manager could not be stopped", e);
             throw e;
         }
     }
+    
+    private static class ShutdownThread extends Thread {
+        private Object domainManager;
+
+        public ShutdownThread(Object domainManager) {
+            super();
+            this.domainManager = domainManager;
+        }
+
+        public void run() {
+            try {
+                DomainManagerLauncher.stop(domainManager);
+            } catch (Exception e) {
+                // Ignore
+            }
+        }
+    }
 }

Modified: tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java (original)
+++ tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java Fri Aug 15 15:07:43 2008
@@ -21,8 +21,8 @@
 
 import static javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
 
+import java.io.InputStream;
 import java.io.StringWriter;
-import java.net.URL;
 import java.security.AccessController;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
@@ -341,11 +341,12 @@
         }
     }
 
-    public static byte[] addApplicablePolicySets(URL artifactUrl, Collection<PolicySet> domainPolicySets) throws Exception {
+    public static byte[] addApplicablePolicySets(InputStream is, Collection<PolicySet> domainPolicySets) throws Exception {
         DocumentBuilderFactory dbFac = DocumentBuilderFactory.newInstance();
         dbFac.setNamespaceAware(true);
         DocumentBuilder db = dbFac.newDocumentBuilder();
-        Document doc = db.parse(artifactUrl.toURI().toString());
+        Document doc = db.parse(is);
+        is.close();
         return addApplicablePolicySets(doc, domainPolicySets);
     }
     

Modified: tuscany/java/sca/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/pom.xml?rev=686391&r1=686390&r2=686391&view=diff
==============================================================================
--- tuscany/java/sca/pom.xml (original)
+++ tuscany/java/sca/pom.xml Fri Aug 15 15:07:43 2008
@@ -235,6 +235,37 @@
         </profile>
 
         <profile>
+            <id>osgi</id>
+            <activation>
+                <activeByDefault>false</activeByDefault>
+            </activation>
+            <modules>
+                <module>calculator</module>
+            </modules>
+            <properties>
+                <maven.test.skip.exec>true</maven.test.skip.exec>
+            </properties>
+            <build>
+                <plugins>
+                <plugin>
+                    <groupId>org.apache.tuscany.sca</groupId>
+                    <artifactId>tuscany-maven-osgi-junit</artifactId>
+                    <version>1.4-SNAPSHOT</version>
+                    <executions>
+                        <execution>
+                            <id>osgi-test</id>
+                            <phase>integration-test</phase>
+                            <goals>
+                                <goal>test</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                 </plugin>            
+                 </plugins>       
+            </build> 
+        </profile>  
+
+        <profile>
             <id>dependencies</id>
             <modules>
                 <module>modules</module>



Mime
View raw message