You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jb...@apache.org on 2007/01/09 20:29:45 UTC

svn commit: r494534 - in /incubator/tuscany/java/sca: kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/ plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/ runtime/standalone/launcher/src/main/java/org/apache/tuscany/la...

Author: jboynes
Date: Tue Jan  9 11:29:45 2007
New Revision: 494534

URL: http://svn.apache.org/viewvc?view=rev&rev=494534
Log:
separate deployment of application from runtime initiaization for standalone runtime
uses a temporary hack until we get all the deployment services running

Added:
    incubator/tuscany/java/sca/runtime/standalone/smoketest/src/main/resources/
    incubator/tuscany/java/sca/runtime/standalone/smoketest/src/main/resources/META-INF/
    incubator/tuscany/java/sca/runtime/standalone/smoketest/src/main/resources/META-INF/sca/
    incubator/tuscany/java/sca/runtime/standalone/smoketest/src/main/resources/META-INF/sca/default.scdl   (with props)
Modified:
    incubator/tuscany/java/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/TuscanyRuntime.java
    incubator/tuscany/java/sca/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedRuntime.java
    incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/java/org/apache/tuscany/launcher/Main.java
    incubator/tuscany/java/sca/runtime/standalone/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java
    incubator/tuscany/java/sca/runtime/webapp/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java

Modified: incubator/tuscany/java/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/TuscanyRuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/TuscanyRuntime.java?view=diff&rev=494534&r1=494533&r2=494534
==============================================================================
--- incubator/tuscany/java/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/TuscanyRuntime.java (original)
+++ incubator/tuscany/java/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/TuscanyRuntime.java Tue Jan  9 11:29:45 2007
@@ -20,6 +20,7 @@
 
 import java.net.URL;
 
+import org.osoa.sca.CompositeContext;
 import org.osoa.sca.SCA;
 
 import org.apache.tuscany.host.MonitorFactory;
@@ -171,4 +172,16 @@
      */
     @Deprecated
     void setApplicationClassLoader(ClassLoader applicationClassLoader);
+
+    /**
+     * Temporary API to allow and application to be deployed until we get the proper deployment services running.
+     *
+     * @param name the name of the component for the application
+     * @param scdlLocation the location of a SCDL composite document to use as the component's implementation
+     * @param classLoader the classloader to associated with the application component
+     * @return the context for the application's composite component
+     */
+    @Deprecated
+    CompositeContext deployApplication(String name, URL scdlLocation, ClassLoader classLoader)
+        throws InitializationException;
 }

Modified: incubator/tuscany/java/sca/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedRuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedRuntime.java?view=diff&rev=494534&r1=494533&r2=494534
==============================================================================
--- incubator/tuscany/java/sca/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedRuntime.java (original)
+++ incubator/tuscany/java/sca/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedRuntime.java Tue Jan  9 11:29:45 2007
@@ -25,6 +25,7 @@
 import javax.xml.stream.XMLInputFactory;
 
 import org.osoa.sca.SCA;
+import org.osoa.sca.CompositeContext;
 
 import org.apache.tuscany.spi.bootstrap.ComponentNames;
 import org.apache.tuscany.spi.bootstrap.RuntimeComponent;
@@ -171,6 +172,11 @@
         Component component = deployer.deploy(composite, definition);
 
         component.start();
+    }
+
+    @Deprecated
+    public CompositeContext deployApplication(String name, URL scdlLocation, ClassLoader classLoader) throws InitializationException {
+        throw new UnsupportedOperationException();
     }
 
     public void destroy() {

Modified: incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/java/org/apache/tuscany/launcher/Main.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/java/org/apache/tuscany/launcher/Main.java?view=diff&rev=494534&r1=494533&r2=494534
==============================================================================
--- incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/java/org/apache/tuscany/launcher/Main.java (original)
+++ incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/java/org/apache/tuscany/launcher/Main.java Tue Jan  9 11:29:45 2007
@@ -29,6 +29,7 @@
 import java.util.jar.JarFile;
 import java.util.jar.Manifest;
 
+import org.osoa.sca.CompositeContext;
 import org.osoa.sca.SCA;
 
 import org.apache.tuscany.host.runtime.TuscanyRuntime;
@@ -55,30 +56,44 @@
 
         StandaloneRuntimeInfo runtimeInfo = createRuntimeInfo();
         TuscanyRuntime runtime = createRuntime(runtimeInfo);
-
-        File applicationJar = new File(args[0]);
-        URL applicationURL = applicationJar.toURI().toURL();
-        String[] appArgs = new String[args.length - 1];
-        System.arraycopy(args, 1, appArgs, 0, appArgs.length);
-
-        ClassLoader applicationClassLoader =
-            new URLClassLoader(new URL[]{applicationURL}, runtime.getHostClassLoader());
-
-        URL applicationScdl = getApplicationScdl(applicationClassLoader);
-
-        runtime.setApplicationName("application");
-        runtime.setApplicationScdl(applicationScdl);
-        runtime.setApplicationClassLoader(applicationClassLoader);
         runtime.initialize();
-        SCA context = runtime.getContext();
-
         try {
-            context.start();
-            runApplication(applicationJar, applicationClassLoader, appArgs);
+            File applicationJar = new File(args[0]);
+            URL applicationURL = applicationJar.toURI().toURL();
+            String[] appArgs = new String[args.length - 1];
+            System.arraycopy(args, 1, appArgs, 0, appArgs.length);
+
+            ClassLoader applicationClassLoader =
+                new URLClassLoader(new URL[]{applicationURL}, runtime.getHostClassLoader());
+
+            URL applicationScdl = getApplicationScdl(applicationClassLoader);
+
+            final CompositeContext context = runtime.deployApplication("application",
+                                                                       applicationScdl,
+                                                                       applicationClassLoader);
+
+            // FIXME JNB we should replace this with CurrentCompositeContext.setContext(...)
+            SCA sca = new SCA() {
+
+                public void start() {
+                    setCompositeContext(context);
+                }
+
+                public void stop() {
+                    setCompositeContext(null);
+                }
+            };
+
+            sca.start();
+            try {
+                runApplication(applicationJar, applicationClassLoader, appArgs);
+            } finally {
+                sca.stop();
+            }
         } finally {
-            context.stop();
             runtime.destroy();
         }
+
     }
 
     static StandaloneRuntimeInfo createRuntimeInfo() throws IOException {
@@ -116,7 +131,7 @@
         String className = runtimeInfo.getProperty("tuscany.runtimeClass",
                                                    "org.apache.tuscany.runtime.standalone.host.StandaloneRuntimeImpl");
         Class<?> implClass = Class.forName(className, true, bootClassLoader);
-        
+
         TuscanyRuntime runtime = (TuscanyRuntime) implClass.newInstance();
         runtime.setMonitorFactory(runtime.createDefaultMonitorFactory());
         runtime.setHostClassLoader(hostClassLoader);

Added: incubator/tuscany/java/sca/runtime/standalone/smoketest/src/main/resources/META-INF/sca/default.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/standalone/smoketest/src/main/resources/META-INF/sca/default.scdl?view=auto&rev=494534
==============================================================================
--- incubator/tuscany/java/sca/runtime/standalone/smoketest/src/main/resources/META-INF/sca/default.scdl (added)
+++ incubator/tuscany/java/sca/runtime/standalone/smoketest/src/main/resources/META-INF/sca/default.scdl Tue Jan  9 11:29:45 2007
@@ -0,0 +1,22 @@
+<?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"
+           name="SmoketestComposite">
+</composite>

Propchange: incubator/tuscany/java/sca/runtime/standalone/smoketest/src/main/resources/META-INF/sca/default.scdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/runtime/standalone/smoketest/src/main/resources/META-INF/sca/default.scdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/runtime/standalone/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/standalone/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java?view=diff&rev=494534&r1=494533&r2=494534
==============================================================================
--- incubator/tuscany/java/sca/runtime/standalone/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java (original)
+++ incubator/tuscany/java/sca/runtime/standalone/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java Tue Jan  9 11:29:45 2007
@@ -18,9 +18,11 @@
  */
 package org.apache.tuscany.runtime.standalone.host;
 
+import java.net.URL;
 import javax.xml.stream.XMLInputFactory;
 
 import org.osoa.sca.SCA;
+import org.osoa.sca.CompositeContext;
 
 import org.apache.tuscany.spi.bootstrap.ComponentNames;
 import org.apache.tuscany.spi.bootstrap.RuntimeComponent;
@@ -48,11 +50,11 @@
  * @version $Rev$ $Date$
  */
 public class StandaloneRuntimeImpl extends AbstractRuntime {
-    private CompositeContextImpl context;
     private RuntimeComponent runtime;
     private CompositeComponent systemComponent;
     private CompositeComponent tuscanySystem;
-    private CompositeComponent application;
+    private Deployer deployer;
+    private WireService wireService;
 
     public void initialize() throws InitializationException {
         ClassLoader bootClassLoader = getClass().getClassLoader();
@@ -100,25 +102,34 @@
             if (!(deployerComponent instanceof AtomicComponent)) {
                 throw new InitializationException("Deployer must be an atomic component");
             }
-            deployer = (Deployer)((AtomicComponent)deployerComponent).getTargetInstance();
+            this.deployer = (Deployer)((AtomicComponent)deployerComponent).getTargetInstance();
 
             SCAObject wireServiceComponent = tuscanySystem.getSystemChild(ComponentNames.TUSCANY_WIRE_SERVICE);
             if (!(wireServiceComponent instanceof AtomicComponent)) {
                 throw new InitializationException("WireService must be an atomic component");
             }
-            WireService wireService = (WireService)((AtomicComponent)wireServiceComponent).getTargetInstance();
+            wireService = (WireService)((AtomicComponent)wireServiceComponent).getTargetInstance();
+        } catch (LoaderException ex) {
+            throw new InitializationException(ex);
+        } catch (BuilderException ex) {
+            throw new InitializationException(ex);
+        } catch (ComponentException ex) {
+            throw new InitializationException(ex);
+        }
+    }
 
-            if (getApplicationScdl() != null) {
-                application =
-                    deployApplicationScdl(deployer,
-                                          runtime.getRootComponent(),
-                                          getApplicationName(),
-                                          getApplicationScdl(),
-                                          getApplicationClassLoader());
-                application.start();
-            }
 
-            context = new CompositeContextImpl(application, wireService);
+    @Deprecated
+    public CompositeContext deployApplication(String name, URL scdlLocation, ClassLoader classLoader)
+        throws InitializationException {
+        try {
+            CompositeComponent application = deployApplicationScdl(deployer,
+                                                                   runtime.getRootComponent(),
+                                                                   name,
+                                                                   scdlLocation,
+                                                                   classLoader);
+            application.start();
+            return new CompositeContextImpl(application, wireService);
         } catch (LoaderException ex) {
             throw new InitializationException(ex);
         } catch (BuilderException ex) {
@@ -129,11 +140,6 @@
     }
 
     public void destroy() {
-        context = null;
-        if (application != null) {
-            application.stop();
-            application = null;
-        }
         if (tuscanySystem != null) {
             tuscanySystem.stop();
             tuscanySystem = null;
@@ -149,7 +155,7 @@
     }
 
     public SCA getContext() {
-        return context;
+        throw new UnsupportedOperationException();
     }
 
 }

Modified: incubator/tuscany/java/sca/runtime/webapp/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java?view=diff&rev=494534&r1=494533&r2=494534
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java (original)
+++ incubator/tuscany/java/sca/runtime/webapp/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java Tue Jan  9 11:29:45 2007
@@ -19,11 +19,13 @@
 package org.apache.tuscany.runtime.webapp;
 
 import java.util.StringTokenizer;
+import java.net.URL;
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpSessionEvent;
 import javax.xml.stream.XMLInputFactory;
 
 import org.osoa.sca.SCA;
+import org.osoa.sca.CompositeContext;
 
 import org.apache.tuscany.spi.bootstrap.ComponentNames;
 import org.apache.tuscany.spi.bootstrap.RuntimeComponent;
@@ -182,6 +184,12 @@
         }
     }
 
+    @Deprecated
+    public CompositeContext deployApplication(String name, URL scdlLocation, ClassLoader classLoader)
+        throws InitializationException {
+        throw new UnsupportedOperationException("Not yet implemented");
+    }
+
     public void destroy() {
         context = null;
         if (application != null) {
@@ -242,28 +250,4 @@
     public void stopRequest() {
         application.publish(new RequestEnd(this));
     }
-
-    /**
-     * Returns a monitor factory for the funtime
-     *
-     * @param loggingLevel
-     */
-//    private MonitorFactory getMonitorFactory(String loggingLevel) {
-//        String factoryName = "org.apache.tuscany.core.monitor.NullMonitorFactory";
-//        Map<String, Object> props = null;
-//        if (loggingLevel != null) {
-//            factoryName = "org.apache.tuscany.core.monitor.JavaLoggingMonitorFactory";
-//            props = new HashMap<String, Object>();
-//            Level level = Level.SEVERE;
-//            try {
-//                level = Level.parse(loggingLevel);
-//            } catch (IllegalArgumentException e) {
-//                // ignore bad loggingLevel
-//            }
-//            props.put("bundleName", "SystemMessages");
-//            props.put("defaultLevel", level);
-//        }
-//
-//        return MonitorFactoryUtil.createMonitorFactory(factoryName, props);
-//    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org