Author: jboynes
Date: Tue Oct 17 18:28:24 2006
New Revision: 465117

URL: http://svn.apache.org/viewvc?view=rev&rev=465117
Log:
have the start mojo boot a runtime

Added:
    
incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedArtifactRepository.java
   (with props)
    
incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedRuntime.java
   (with props)
    
incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenRuntimeInfo.java
   (with props)
    incubator/tuscany/sandbox/testing/itest/src/main/resources/
    incubator/tuscany/sandbox/testing/itest/src/main/resources/META-INF/
    incubator/tuscany/sandbox/testing/itest/src/main/resources/META-INF/tuscany/
    
incubator/tuscany/sandbox/testing/itest/src/main/resources/META-INF/tuscany/embeddedMaven.scdl
   (with props)
Modified:
    incubator/tuscany/sandbox/testing/itest/pom.xml
    
incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyStartMojo.java

Modified: incubator/tuscany/sandbox/testing/itest/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/sandbox/testing/itest/pom.xml?view=diff&rev=465117&r1=465116&r2=465117
==============================================================================
--- incubator/tuscany/sandbox/testing/itest/pom.xml (original)
+++ incubator/tuscany/sandbox/testing/itest/pom.xml Tue Oct 17 18:28:24 2006
@@ -26,6 +26,7 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>org.apache.tuscany.sca.plugins</groupId>
     <artifactId>tuscany-itest-plugin</artifactId>
+    <version>1.0-incubator-M2-SNAPSHOT</version>
     <packaging>maven-plugin</packaging>
     <name>Tuscany Integration Test Plugin</name>
 
@@ -34,6 +35,12 @@
             <groupId>org.apache.maven</groupId>
             <artifactId>maven-plugin-api</artifactId>
             <version>2.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca.kernel</groupId>
+            <artifactId>core</artifactId>
+            <version>1.0-incubator-M2-SNAPSHOT</version>
         </dependency>
     </dependencies>
 </project>

Added: 
incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedArtifactRepository.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedArtifactRepository.java?view=auto&rev=465117
==============================================================================
--- 
incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedArtifactRepository.java
 (added)
+++ 
incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedArtifactRepository.java
 Tue Oct 17 18:28:24 2006
@@ -0,0 +1,37 @@
+/*
+ * 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.plugin.itest;
+
+import java.util.Collection;
+
+import org.apache.tuscany.spi.services.artifact.ArtifactRepository;
+import org.apache.tuscany.spi.services.artifact.Artifact;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MavenEmbeddedArtifactRepository implements ArtifactRepository {
+    public void resolve(Artifact artifact) {
+        throw new UnsupportedOperationException();
+    }
+
+    public void resolve(Collection artifacts) {
+        throw new UnsupportedOperationException();
+    }
+}

Propchange: 
incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedArtifactRepository.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedArtifactRepository.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedRuntime.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedRuntime.java?view=auto&rev=465117
==============================================================================
--- 
incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedRuntime.java
 (added)
+++ 
incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedRuntime.java
 Tue Oct 17 18:28:24 2006
@@ -0,0 +1,125 @@
+/*
+ * 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.plugin.itest;
+
+import javax.xml.stream.XMLInputFactory;
+
+import org.osoa.sca.SCA;
+
+import org.apache.tuscany.core.runtime.AbstractRuntime;
+import org.apache.tuscany.core.launcher.CompositeContextImpl;
+import org.apache.tuscany.core.bootstrap.Bootstrapper;
+import org.apache.tuscany.core.bootstrap.DefaultBootstrapper;
+import org.apache.tuscany.spi.bootstrap.RuntimeComponent;
+import org.apache.tuscany.spi.bootstrap.ComponentNames;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.Deployer;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.host.MonitorFactory;
+import org.apache.tuscany.host.RuntimeInfo;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MavenEmbeddedRuntime extends AbstractRuntime {
+    private CompositeContextImpl context;
+    private RuntimeComponent runtime;
+    private CompositeComponent systemComponent;
+    private CompositeComponent tuscanySystem;
+    private CompositeComponent application;
+
+    public void initialize() {
+        ClassLoader bootClassLoader = getClass().getClassLoader();
+
+        // Read optional system monitor factory classname
+        MonitorFactory mf = getMonitorFactory();
+
+        XMLInputFactory xmlFactory = 
XMLInputFactory.newInstance("javax.xml.stream.XMLInputFactory", 
bootClassLoader);
+
+        Bootstrapper bootstrapper = new DefaultBootstrapper(mf, xmlFactory);
+        runtime = bootstrapper.createRuntime();
+        runtime.start();
+        systemComponent = runtime.getSystemComponent();
+
+        // register the runtime info provided by the host
+        RuntimeInfo runtimeInfo = getRuntimeInfo();
+        systemComponent.registerJavaObject(RuntimeInfo.COMPONENT_NAME, 
RuntimeInfo.class, runtimeInfo);
+        systemComponent.registerJavaObject(MavenRuntimeInfo.COMPONENT_NAME,
+                                           MavenRuntimeInfo.class,
+                                           (MavenRuntimeInfo) runtimeInfo);
+
+        // register the monitor factory provided by the host
+        systemComponent.registerJavaObject("MonitorFactory", 
MonitorFactory.class, mf);
+
+        systemComponent.start();
+
+        try {
+            // deploy the system scdl
+            Deployer deployer = bootstrapper.createDeployer();
+            tuscanySystem = deploySystemScdl(deployer,
+                systemComponent,
+                ComponentNames.TUSCANY_SYSTEM,
+                getSystemScdl(),
+                bootClassLoader);
+            tuscanySystem.start();
+
+            // switch to the system deployer
+            deployer = (Deployer) 
tuscanySystem.getSystemChild("deployer").getServiceInstance();
+
+/*
+            application = deployApplicationScdl(deployer,
+                runtime.getRootComponent(),
+                getApplicationName(),
+                getApplicationScdl(),
+                getApplicationClassLoader());
+            application.start();
+
+            context = new CompositeContextImpl(application);
+*/
+        } catch (LoaderException e) {
+            // FIXME do something with this
+            e.printStackTrace();
+        }
+    }
+
+    public void destroy() {
+        context = null;
+        if (application != null) {
+            application.stop();
+            application = null;
+        }
+        if (tuscanySystem != null) {
+            tuscanySystem.stop();
+            tuscanySystem = null;
+        }
+        if (systemComponent != null) {
+            systemComponent.stop();
+            systemComponent = null;
+        }
+        if (runtime != null) {
+            runtime.stop();
+            runtime = null;
+        }
+    }
+
+    public SCA getContext() {
+        return context;
+    }
+
+}

Propchange: 
incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedRuntime.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedRuntime.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenRuntimeInfo.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenRuntimeInfo.java?view=auto&rev=465117
==============================================================================
--- 
incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenRuntimeInfo.java
 (added)
+++ 
incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenRuntimeInfo.java
 Tue Oct 17 18:28:24 2006
@@ -0,0 +1,47 @@
+/*
+ * 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.plugin.itest;
+
+import java.io.File;
+import java.net.URL;
+
+import org.apache.tuscany.host.RuntimeInfo;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MavenRuntimeInfo implements RuntimeInfo {
+    public static final String COMPONENT_NAME = "MavenRuntimeInfo";
+    
+    public File getInstallDirectory() {
+        throw new UnsupportedOperationException();
+    }
+
+    public File getApplicationRootDirectory() {
+        throw new UnsupportedOperationException();
+    }
+
+    public URL getBaseURL() {
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean isOnline() {
+        throw new UnsupportedOperationException();
+    }
+}

Propchange: 
incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenRuntimeInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenRuntimeInfo.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: 
incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyStartMojo.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyStartMojo.java?view=diff&rev=465117&r1=465116&r2=465117
==============================================================================
--- 
incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyStartMojo.java
 (original)
+++ 
incubator/tuscany/sandbox/testing/itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyStartMojo.java
 Tue Oct 17 18:28:24 2006
@@ -18,17 +18,51 @@
  */
 package org.apache.tuscany.sca.plugin.itest;
 
+import java.net.URL;
+
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.osoa.sca.SCA;
+
+import org.apache.tuscany.host.runtime.TuscanyRuntime;
 
 /**
+ * @version $Rev$ $Date$
  * @goal start
  * @phase pre-integration-test
- * @version $Rev$ $Date$
  */
 public class TuscanyStartMojo extends AbstractMojo {
+    /**
+     * @parameter
+     */
+    private URL systemScdl;
+
+    /**
+     * @parameter
+     */
+    private URL applicationScdl;
+
     public void execute() throws MojoExecutionException, MojoFailureException {
         System.out.println("Starting Tuscany!");
+
+        ClassLoader hostClassLoader = getClass().getClassLoader();
+        if (systemScdl == null) {
+            systemScdl = 
hostClassLoader.getResource("META-INF/tuscany/embeddedMaven.scdl");
+        }
+
+        MavenRuntimeInfo runtimeInfo = new MavenRuntimeInfo();
+        TuscanyRuntime runtime = new MavenEmbeddedRuntime();
+        runtime.setMonitorFactory(runtime.createDefaultMonitorFactory());
+        runtime.setSystemScdl(systemScdl);
+        runtime.setHostClassLoader(hostClassLoader);
+/*
+        runtime.setApplicationName("application");
+        runtime.setApplicationScdl(applicationScdl);
+        runtime.setApplicationClassLoader(applicationClassLoader);
+*/
+        runtime.setRuntimeInfo(runtimeInfo);
+        runtime.initialize();
+        SCA context = runtime.getContext();
     }
 }

Added: 
incubator/tuscany/sandbox/testing/itest/src/main/resources/META-INF/tuscany/embeddedMaven.scdl
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/sandbox/testing/itest/src/main/resources/META-INF/tuscany/embeddedMaven.scdl?view=auto&rev=465117
==============================================================================
--- 
incubator/tuscany/sandbox/testing/itest/src/main/resources/META-INF/tuscany/embeddedMaven.scdl
 (added)
+++ 
incubator/tuscany/sandbox/testing/itest/src/main/resources/META-INF/tuscany/embeddedMaven.scdl
 Tue Oct 17 18:28:24 2006
@@ -0,0 +1,126 @@
+<?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.    
+-->
+<!--
+    Default system configuration for the launcher environment.
+
+    $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0";
+           xmlns:system="http://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT";
+           name="org.apache.tuscany.sca.plugins.itest.EmbeddedMaven">
+
+    <!-- Component that provides the Deployer service -->
+    <component name="deployer">
+        <system:implementation.system 
class="org.apache.tuscany.core.deployer.DeployerImpl"/>
+    </component>
+
+    <!-- Work management -->
+    <component name="workContext">
+        <system:implementation.system 
class="org.apache.tuscany.core.component.WorkContextImpl"/>
+    </component>
+
+    <!-- Wire service -->
+    <component name="wireService">
+        <system:implementation.system 
class="org.apache.tuscany.core.wire.jdk.JDKWireService"/>
+    </component>
+
+    <!-- Scope infrastructure -->
+    <component name="scopeRegistry">
+        <system:implementation.system 
class="org.apache.tuscany.core.component.scope.ScopeRegistryImpl"/>
+    </component>
+
+    <!-- Builder and BuilderRegistry -->
+    <component name="builder">
+        <system:implementation.system 
class="org.apache.tuscany.core.builder.BuilderRegistryImpl"/>
+    </component>
+
+    <!-- Loader and LoaderRegistry -->
+    <component name="loader">
+        <system:implementation.system 
class="org.apache.tuscany.core.loader.LoaderRegistryImpl"/>
+    </component>
+
+    <!-- Introspector and IntrospectionRegistry -->
+    <component name="interfaceProcessorRegistry">
+        <system:implementation.system 
class="org.apache.tuscany.core.implementation.IntrospectionRegistryImpl"/>
+    </component>
+
+    <!-- Connector infrastructure -->
+    <component name="connector">
+        <system:implementation.system 
class="org.apache.tuscany.core.builder.ConnectorImpl"/>
+    </component>
+
+    <component name="wirePostProcessorRegistry">
+        <system:implementation.system 
class="org.apache.tuscany.core.builder.WirePostProcessorRegistryImpl"/>
+    </component>
+    
+    <!-- Default scopes -->
+    <component name="scope.module">
+        <system:implementation.system 
class="org.apache.tuscany.core.component.scope.ModuleScopeObjectFactory"/>
+    </component>
+    <component name="scope.stateless">
+        <system:implementation.system 
class="org.apache.tuscany.core.component.scope.StatelessScopeObjectFactory"/>
+    </component>
+
+    <!-- include loader configuration -->
+    <include name="org.apache.tuscany.core.Loader" 
scdlResource="org/apache/tuscany/core/loader.scdl"/>
+
+    <!-- include databinding configuration -->
+    <include name="org.apache.tuscany.core.DataBinding" 
scdlResource="org/apache/tuscany/core/databinding.scdl"/>
+
+    <!-- include implementation processor configuration -->
+    <include name="org.apache.tuscany.core.Implementation" 
scdlResource="org/apache/tuscany/core/implementation.scdl"/>
+
+    <!-- Java interface definition language -->
+    <include name="org.apache.tuscany.core.InterfaceJava" 
scdlResource="org/apache/tuscany/core/interfaceJava.scdl"/>
+
+    <!-- include omposite implementation type -->
+    <include name="org.apache.tuscany.core.Composite" 
scdlResource="org/apache/tuscany/core/composite.scdl"/>
+
+    <!-- System implementation type -->
+    <include name="org.apache.tuscany.core.SystemImplementation" 
scdlResource="org/apache/tuscany/core/systemImplementation.scdl"/>
+
+    <!-- Java implementation type -->
+    <include name="org.apache.tuscany.core.JavaImplementation" 
scdlResource="org/apache/tuscany/core/javaImplementation.scdl"/>
+
+    <!-- service for resolving artifacts using Maven repositories -->
+    <component name="artifactRepository">
+        <system:implementation.system 
class="org.apache.tuscany.sca.plugin.itest.MavenEmbeddedArtifactRepository"/>
+    </component>
+
+    <!-- WorkScheduler service -->
+    <component name="workManager">
+        <system:implementation.system
+            
class="org.apache.tuscany.core.services.work.jsr237.workmanager.ThreadPoolWorkManager"/>
+        <property name="poolSize">10</property>
+    </component>
+
+    <component name="workScheduler">
+        <system:implementation.system 
class="org.apache.tuscany.core.services.work.jsr237.Jsr237WorkScheduler"/>
+    </component>
+
+    <component name="policyBuilderRegistry">
+        <system:implementation.system 
class="org.apache.tuscany.core.policy.PolicyBuilderRegistryImpl"/>
+    </component>
+
+    <component name="propertyFactory">
+        <system:implementation.system 
class="org.apache.tuscany.core.property.PropertyObjectFactoryImpl"/>
+    </component>
+
+</composite>

Propchange: 
incubator/tuscany/sandbox/testing/itest/src/main/resources/META-INF/tuscany/embeddedMaven.scdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/sandbox/testing/itest/src/main/resources/META-INF/tuscany/embeddedMaven.scdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to