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 2006/09/29 01:27:54 UTC
svn commit: r451054 - in /incubator/tuscany/java:
distribution/sca/standalone/src/main/assembly/ sca/commands/launcher/
sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/
sca/kernel/core/src/main/java/org/apache/tuscany/core/runtime/ sca/...
Author: jboynes
Date: Thu Sep 28 16:27:53 2006
New Revision: 451054
URL: http://svn.apache.org/viewvc?view=rev&rev=451054
Log:
clean up standalone bootstrap
Added:
incubator/tuscany/java/sca/runtime/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java (with props)
incubator/tuscany/java/sca/runtime/standalone/src/main/java/org/
incubator/tuscany/java/sca/runtime/standalone/src/main/java/org/apache/
incubator/tuscany/java/sca/runtime/standalone/src/main/java/org/apache/tuscany/
incubator/tuscany/java/sca/runtime/standalone/src/main/java/org/apache/tuscany/runtime/
incubator/tuscany/java/sca/runtime/standalone/src/main/java/org/apache/tuscany/runtime/standalone/
incubator/tuscany/java/sca/runtime/standalone/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntimeInfo.java (contents, props changed)
- copied, changed from r450913, incubator/tuscany/java/sca/runtime/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeInfo.java
incubator/tuscany/java/sca/runtime/standalone/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntimeInfoImpl.java (with props)
Removed:
incubator/tuscany/java/sca/runtime/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeInfo.java
Modified:
incubator/tuscany/java/distribution/sca/standalone/src/main/assembly/standalone.xml
incubator/tuscany/java/sca/commands/launcher/pom.xml
incubator/tuscany/java/sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/MainLauncherBooter.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java
incubator/tuscany/java/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/TuscanyRuntime.java
incubator/tuscany/java/sca/runtime/standalone-host/pom.xml
incubator/tuscany/java/sca/runtime/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/DirectoryScanExtender.java
incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java
incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImplTestCase.java
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyContextListener.java
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntime.java
incubator/tuscany/java/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyContextListenerTestCase.java
Modified: incubator/tuscany/java/distribution/sca/standalone/src/main/assembly/standalone.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/distribution/sca/standalone/src/main/assembly/standalone.xml?view=diff&rev=451054&r1=451053&r2=451054
==============================================================================
--- incubator/tuscany/java/distribution/sca/standalone/src/main/assembly/standalone.xml (original)
+++ incubator/tuscany/java/distribution/sca/standalone/src/main/assembly/standalone.xml Thu Sep 28 16:27:53 2006
@@ -45,7 +45,7 @@
</includes>
<excludes>
<exclude>org.osoa:sca-api</exclude>
- <exclude>org.apache.tuscany.sca.kernel:tuscany-host-api</exclude>
+ <exclude>org.apache.tuscany.sca.runtime:standalone</exclude>
</excludes>
<fileMode>755</fileMode>
</dependencySet>
@@ -55,8 +55,11 @@
<outputDirectory>bin</outputDirectory>
<includes>
<include>org.osoa:sca-api</include>
- <include>org.apache.tuscany.sca.kernel:tuscany-host-api</include>
+ <include>org.apache.tuscany.sca.runtime:standalone</include>
</includes>
+ <excludes>
+ <exclude>org.apache.tuscany.sca.runtime:standalone-host</exclude>
+ </excludes>
<fileMode>644</fileMode>
</dependencySet>
Modified: incubator/tuscany/java/sca/commands/launcher/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/commands/launcher/pom.xml?view=diff&rev=451054&r1=451053&r2=451054
==============================================================================
--- incubator/tuscany/java/sca/commands/launcher/pom.xml (original)
+++ incubator/tuscany/java/sca/commands/launcher/pom.xml Thu Sep 28 16:27:53 2006
@@ -38,8 +38,8 @@
<artifactId>sca-api-r0.95</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.tuscany.sca.kernel</groupId>
- <artifactId>tuscany-host-api</artifactId>
+ <groupId>org.apache.tuscany.sca.runtime</groupId>
+ <artifactId>standalone</artifactId>
<version>${sca.version}</version>
<scope>compile</scope>
</dependency>
Modified: incubator/tuscany/java/sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/MainLauncherBooter.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/MainLauncherBooter.java?view=diff&rev=451054&r1=451053&r2=451054
==============================================================================
--- incubator/tuscany/java/sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/MainLauncherBooter.java (original)
+++ incubator/tuscany/java/sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/MainLauncherBooter.java Thu Sep 28 16:27:53 2006
@@ -21,12 +21,20 @@
import java.beans.Beans;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ResourceBundle;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import org.osoa.sca.SCA;
+
+import org.apache.tuscany.host.runtime.TuscanyRuntime;
import org.apache.tuscany.host.util.LaunchHelper;
+import org.apache.tuscany.runtime.standalone.StandaloneRuntimeInfo;
+import org.apache.tuscany.runtime.standalone.StandaloneRuntimeInfoImpl;
/**
* Launcher for launcher runtime environment that invokes a jar's Main class.
@@ -40,27 +48,72 @@
* @param args the command line args
*/
public static void main(String[] args) throws Throwable {
- // The classpath to load the launcher should not any jars from the Tuscany runtime
MainLauncherBooter booter = new MainLauncherBooter();
- ClassLoader tuscanyCL = booter.getTuscanyClassLoader();
+
+ File installDir = getInstallDirectory();
+ URL baseUrl = installDir.toURI().toURL();
+ File bootDir = getBootDirectory(installDir);
+ StandaloneRuntimeInfo runtimeInfo = new StandaloneRuntimeInfoImpl(baseUrl, installDir, installDir);
+
+ 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 hostClassLoader = ClassLoader.getSystemClassLoader();
+ ClassLoader bootClassLoader = booter.getTuscanyClassLoader(bootDir);
+ ClassLoader applicationClassLoader = new URLClassLoader(new URL[]{applicationURL}, hostClassLoader);
+
+ URL systemScdl = booter.getSystemScdl(bootClassLoader);
+ URL applicationScdl = booter.getApplicationScdl(applicationClassLoader);
String className = System.getProperty("tuscany.launcherClass",
- "org.apache.tuscany.core.launcher.MainLauncherImpl");
- Object launcher = Beans.instantiate(tuscanyCL, className);
+ "org.apache.tuscany.runtime.standalone.host.StandaloneRuntimeImpl");
+ TuscanyRuntime runtime = (TuscanyRuntime) Beans.instantiate(bootClassLoader, className);
+ 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();
+
+ try {
+ context.start();
+ booter.runApplication(applicationJar, applicationClassLoader, appArgs);
+ } finally {
+ context.stop();
+ runtime.destroy();
+ }
+ }
+
+ protected void runApplication(File applicationJar, ClassLoader applicationClassLoader, String[] args)
+ throws Throwable {
+
+ Manifest manifest = new JarFile(applicationJar).getManifest();
+ String mainClassName = manifest.getMainAttributes().getValue("Main-Class");
+ Class<?> mainClass = applicationClassLoader.loadClass(mainClassName);
+ Method main = mainClass.getMethod("main", String[].class);
+
+
+ ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
try {
- LaunchHelper.invoke(launcher, "boot", new Class<?>[]{String[].class}, (Object[]) new Object[]{args});
+ Thread.currentThread().setContextClassLoader(applicationClassLoader);
+ main.invoke(null, new Object[]{args});
} catch (InvocationTargetException e) {
throw e.getCause();
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldCL);
}
}
- protected ClassLoader getTuscanyClassLoader() {
- File tuscanylib = findBootDir();
- URL[] urls = LaunchHelper.scanDirectoryForJars(tuscanylib);
+ protected ClassLoader getTuscanyClassLoader(File bootDir) {
+ URL[] urls = LaunchHelper.scanDirectoryForJars(bootDir);
return new URLClassLoader(urls, getClass().getClassLoader());
}
-
/**
* Find the directory containing the bootstrap jars.
* If the <code>tuscany.bootDir</code> system property is set then its value is used as the boot directory.
@@ -93,5 +146,47 @@
ResourceBundle bundle = ResourceBundle.getBundle(MainLauncherBooter.class.getName());
System.err.print(bundle.getString("org.apache.tuscany.launcher.Usage"));
System.exit(1);
+ }
+
+ protected URL getSystemScdl(ClassLoader bootClassLoader) {
+ String resource = System.getProperty("tuscany.systemScdlPath", "META-INF/tuscany/system.scdl");
+ return bootClassLoader.getResource(resource);
+ }
+
+ protected URL getApplicationScdl(ClassLoader applicationClassLoader) {
+ String resource = System.getProperty("tuscany.applicationScdlPath", "META-INF/sca/default.scdl");
+ return applicationClassLoader.getResource(resource);
+ }
+
+ public static File getInstallDirectory() {
+ // use system property if defined
+ String property = System.getProperty("tuscany.installDir");
+ if (property != null) {
+ return new File(property);
+ }
+
+ // use the parent of directory containing this command
+ URL url = MainLauncherBooter.class.getResource("MainLauncherBooter.class");
+ if (!"jar".equals(url.getProtocol())) {
+ throw new IllegalStateException("Must be run from a jar: " + url);
+ }
+
+ String jarLocation = url.toString();
+ jarLocation = jarLocation.substring(4, jarLocation.lastIndexOf("!/"));
+ if (!jarLocation.startsWith("file:")) {
+ throw new IllegalStateException("Must be run from a local filesystem: " + jarLocation);
+ }
+
+ File jarFile = new File(URI.create(jarLocation));
+ return jarFile.getParentFile().getParentFile();
+ }
+
+ public static File getBootDirectory(File installDirectory) {
+ // use system property if defined
+ String property = System.getProperty("tuscany.bootDir");
+ if (property != null) {
+ return new File(property);
+ }
+ return new File(installDirectory, "boot");
}
}
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java?view=diff&rev=451054&r1=451053&r2=451054
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java Thu Sep 28 16:27:53 2006
@@ -22,7 +22,9 @@
import org.apache.tuscany.core.implementation.system.component.SystemCompositeComponent;
import org.apache.tuscany.core.implementation.system.model.SystemCompositeImplementation;
+import org.apache.tuscany.core.monitor.NullMonitorFactory;
import org.apache.tuscany.host.RuntimeInfo;
+import org.apache.tuscany.host.MonitorFactory;
import org.apache.tuscany.host.runtime.TuscanyRuntime;
import org.apache.tuscany.spi.component.CompositeComponent;
import org.apache.tuscany.spi.deployer.Deployer;
@@ -38,7 +40,9 @@
private String applicationName;
private URL applicationScdl;
private ClassLoader hostClassLoader;
+ private ClassLoader applicationClassLoader;
private RuntimeInfo runtimeInfo;
+ private MonitorFactory monitorFactory;
public URL getSystemScdl() {
return systemScdl;
@@ -64,6 +68,14 @@
this.applicationScdl = applicationScdl;
}
+ public ClassLoader getApplicationClassLoader() {
+ return applicationClassLoader;
+ }
+
+ public void setApplicationClassLoader(ClassLoader applicationClassLoader) {
+ this.applicationClassLoader = applicationClassLoader;
+ }
+
public ClassLoader getHostClassLoader() {
return hostClassLoader;
}
@@ -78,6 +90,18 @@
public void setRuntimeInfo(RuntimeInfo runtimeInfo) {
this.runtimeInfo = runtimeInfo;
+ }
+
+ public MonitorFactory getMonitorFactory() {
+ return monitorFactory;
+ }
+
+ public void setMonitorFactory(MonitorFactory monitorFactory) {
+ this.monitorFactory = monitorFactory;
+ }
+
+ public MonitorFactory createDefaultMonitorFactory() {
+ return new NullMonitorFactory();
}
protected SystemCompositeComponent deploySystemScdl(Deployer deployer,
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=451054&r1=451053&r2=451054
==============================================================================
--- 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 Thu Sep 28 16:27:53 2006
@@ -20,7 +20,10 @@
import java.net.URL;
+import org.osoa.sca.SCA;
+
import org.apache.tuscany.host.RuntimeInfo;
+import org.apache.tuscany.host.MonitorFactory;
/**
* @version $Rev$ $Date$
@@ -96,6 +99,25 @@
*/
void setRuntimeInfo(RuntimeInfo runtimeInfo);
+ /** Returns the MonitorFactory that this runtime is using.
+ *
+ * @return the MonitorFactory that this runtime is using
+ */
+ MonitorFactory getMonitorFactory();
+
+ /**
+ * Sets the MonitorFactory that this runtime should use.
+ * @param monitorFactory the MonitorFactory that this runtime should use
+ */
+ void setMonitorFactory(MonitorFactory monitorFactory);
+
+ /**
+ * Create the default MonitorFactory for this runtime.
+ *
+ * @return the default MonitorFactory for this runtime
+ */
+ MonitorFactory createDefaultMonitorFactory();
+
/**
* Initialize a runtime.
*
@@ -106,4 +128,13 @@
* Destroy the runtime. Any further invocations should result in an error.
*/
void destroy();
+
+ /**
+ * Returns the current SCA context
+ */
+ SCA getContext();
+
+ ClassLoader getApplicationClassLoader();
+
+ void setApplicationClassLoader(ClassLoader applicationClassLoader);
}
Modified: incubator/tuscany/java/sca/runtime/standalone-host/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/standalone-host/pom.xml?view=diff&rev=451054&r1=451053&r2=451054
==============================================================================
--- incubator/tuscany/java/sca/runtime/standalone-host/pom.xml (original)
+++ incubator/tuscany/java/sca/runtime/standalone-host/pom.xml Thu Sep 28 16:27:53 2006
@@ -36,5 +36,11 @@
<version>${sca.version}</version>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.runtime</groupId>
+ <artifactId>standalone</artifactId>
+ <version>${sca.version}</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
Modified: incubator/tuscany/java/sca/runtime/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/DirectoryScanExtender.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/DirectoryScanExtender.java?view=diff&rev=451054&r1=451053&r2=451054
==============================================================================
--- incubator/tuscany/java/sca/runtime/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/DirectoryScanExtender.java (original)
+++ incubator/tuscany/java/sca/runtime/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/DirectoryScanExtender.java Thu Sep 28 16:27:53 2006
@@ -26,6 +26,7 @@
import org.apache.tuscany.core.services.extension.AbstractExtensionDeployer;
import org.apache.tuscany.spi.annotation.Autowire;
import org.apache.tuscany.spi.services.VoidService;
+import org.apache.tuscany.runtime.standalone.StandaloneRuntimeInfo;
/**
* Service that extends the runtime by loading composites located in a directory.
Added: incubator/tuscany/java/sca/runtime/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-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java?view=auto&rev=451054
==============================================================================
--- incubator/tuscany/java/sca/runtime/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java (added)
+++ incubator/tuscany/java/sca/runtime/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java Thu Sep 28 16:27:53 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.runtime.standalone.host;
+
+import javax.xml.stream.XMLInputFactory;
+
+import org.osoa.sca.SCA;
+
+import org.apache.tuscany.core.runtime.AbstractRuntime;
+import org.apache.tuscany.core.bootstrap.Bootstrapper;
+import org.apache.tuscany.core.bootstrap.DefaultBootstrapper;
+import org.apache.tuscany.core.implementation.system.component.SystemCompositeComponent;
+import org.apache.tuscany.core.launcher.CompositeContextImpl;
+import org.apache.tuscany.host.MonitorFactory;
+import org.apache.tuscany.host.RuntimeInfo;
+import org.apache.tuscany.spi.deployer.Deployer;
+import org.apache.tuscany.spi.bootstrap.ComponentNames;
+import org.apache.tuscany.spi.bootstrap.RuntimeComponent;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.runtime.standalone.StandaloneRuntimeInfo;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StandaloneRuntimeImpl extends AbstractRuntime {
+ private CompositeContextImpl context;
+ private RuntimeComponent runtime;
+ private SystemCompositeComponent systemComponent;
+ private SystemCompositeComponent 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 = (SystemCompositeComponent) runtime.getSystemComponent();
+
+ // register the runtime info provided by the host
+ systemComponent.registerJavaObject(RuntimeInfo.COMPONENT_NAME,
+ StandaloneRuntimeInfo.class,
+ (StandaloneRuntimeInfo) getRuntimeInfo());
+
+ // 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.getChild("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() {
+/* FIXME shutdown hangs due to problems with event publication
+ 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/java/sca/runtime/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/runtime/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Copied: incubator/tuscany/java/sca/runtime/standalone/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntimeInfo.java (from r450913, incubator/tuscany/java/sca/runtime/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeInfo.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/standalone/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntimeInfo.java?view=diff&rev=451054&p1=incubator/tuscany/java/sca/runtime/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeInfo.java&r1=450913&p2=incubator/tuscany/java/sca/runtime/standalone/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntimeInfo.java&r2=451054
==============================================================================
--- incubator/tuscany/java/sca/runtime/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeInfo.java (original)
+++ incubator/tuscany/java/sca/runtime/standalone/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntimeInfo.java Thu Sep 28 16:27:53 2006
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.runtime.standalone.host;
+package org.apache.tuscany.runtime.standalone;
import org.apache.tuscany.host.RuntimeInfo;
Propchange: incubator/tuscany/java/sca/runtime/standalone/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntimeInfo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/runtime/standalone/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntimeInfo.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/runtime/standalone/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntimeInfoImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/standalone/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntimeInfoImpl.java?view=auto&rev=451054
==============================================================================
--- incubator/tuscany/java/sca/runtime/standalone/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntimeInfoImpl.java (added)
+++ incubator/tuscany/java/sca/runtime/standalone/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntimeInfoImpl.java Thu Sep 28 16:27:53 2006
@@ -0,0 +1,49 @@
+/*
+ * 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.runtime.standalone;
+
+import java.io.File;
+import java.net.URL;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StandaloneRuntimeInfoImpl implements StandaloneRuntimeInfo {
+ private final File installDirectory;
+ private final File applicationRootDirectory;
+ private final URL baseURL;
+
+ public StandaloneRuntimeInfoImpl(URL baseURL, File installDirectory, File applicationRootDirectory) {
+ this.baseURL = baseURL;
+ this.installDirectory = installDirectory;
+ this.applicationRootDirectory = applicationRootDirectory;
+ }
+
+ public File getInstallDirectory() {
+ return installDirectory;
+ }
+
+ public File getApplicationRootDirectory() {
+ return applicationRootDirectory;
+ }
+
+ public URL getBaseURL() {
+ return baseURL;
+ }
+}
Propchange: incubator/tuscany/java/sca/runtime/standalone/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntimeInfoImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/runtime/standalone/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntimeInfoImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java?view=diff&rev=451054&r1=451053&r2=451054
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java (original)
+++ incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java Thu Sep 28 16:27:53 2006
@@ -40,7 +40,6 @@
import org.apache.tuscany.host.MonitorFactory;
import org.apache.tuscany.host.RuntimeInfo;
import org.apache.tuscany.host.servlet.ServletRequestInjector;
-import static org.apache.tuscany.runtime.webapp.Constants.SYSTEM_MONITORING_PARAM;
import org.apache.tuscany.spi.bootstrap.ComponentNames;
import org.apache.tuscany.spi.bootstrap.RuntimeComponent;
import org.apache.tuscany.spi.component.CompositeComponent;
@@ -67,9 +66,9 @@
private ServletContext servletContext;
private ServletLauncherMonitor monitor;
- private CompositeContextImpl context;
private ServletRequestInjector requestInjector;
+ private CompositeContextImpl context;
private RuntimeComponent runtime;
private SystemCompositeComponent systemComponent;
private SystemCompositeComponent tuscanySystem;
@@ -87,8 +86,7 @@
ClassLoader bootClassLoader = getClass().getClassLoader();
// Read optional system monitor factory classname
- String systemLogging = servletContext.getInitParameter(SYSTEM_MONITORING_PARAM);
- MonitorFactory mf = getMonitorFactory(systemLogging);
+ MonitorFactory mf = getMonitorFactory();
monitor = mf.getMonitor(ServletLauncherMonitor.class);
XMLInputFactory xmlFactory = XMLInputFactory.newInstance("javax.xml.stream.XMLInputFactory", bootClassLoader);
@@ -107,7 +105,7 @@
systemComponent.registerJavaObject("MonitorFactory", MonitorFactory.class, mf);
systemComponent.start();
-
+
try {
// deploy the system scdl
Deployer deployer = bootstrapper.createDeployer();
Modified: incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImplTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImplTestCase.java?view=diff&rev=451054&r1=451053&r2=451054
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImplTestCase.java (original)
+++ incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImplTestCase.java Thu Sep 28 16:27:53 2006
@@ -29,6 +29,8 @@
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
+import org.apache.tuscany.core.monitor.NullMonitorFactory;
+
/**
* @version $Rev$ $Date$
*/
@@ -42,7 +44,6 @@
* Verifies the web app host is configured properly to perform a basic boot
*/
public void testBootWithDefaults() throws Exception {
- expect(context.getInitParameter(Constants.SYSTEM_MONITORING_PARAM)).andReturn(null);
expect(context.getResourcePaths("/WEB-INF/tuscany/extensions/")).andReturn(null);
replay(context);
runtime.initialize();
@@ -57,6 +58,7 @@
runtime = new WebappRuntimeImpl();
runtime.setRuntimeInfo(new WebappRuntimeInfoImpl(context, null));
+ runtime.setMonitorFactory(new NullMonitorFactory());
runtime.setHostClassLoader(getClass().getClassLoader());
runtime.setServletContext(context);
runtime.setSystemScdl(systemScdl);
Modified: incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyContextListener.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyContextListener.java?view=diff&rev=451054&r1=451053&r2=451054
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyContextListener.java (original)
+++ incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyContextListener.java Thu Sep 28 16:27:53 2006
@@ -71,6 +71,7 @@
String name = getApplicationName(servletContext);
runtime.setServletContext(servletContext);
+ runtime.setMonitorFactory(runtime.createDefaultMonitorFactory());
runtime.setRuntimeInfo(info);
runtime.setHostClassLoader(webappClassLoader);
runtime.setSystemScdl(systemScdl);
Modified: incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntime.java?view=diff&rev=451054&r1=451053&r2=451054
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntime.java (original)
+++ incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntime.java Thu Sep 28 16:27:53 2006
@@ -21,10 +21,8 @@
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSessionListener;
-import org.osoa.sca.SCA;
-
-import org.apache.tuscany.host.servlet.ServletRequestInjector;
import org.apache.tuscany.host.runtime.TuscanyRuntime;
+import org.apache.tuscany.host.servlet.ServletRequestInjector;
/**
* The contract for artifacts loaded in the web application classloader to comminicate with the Tuscany runtime loaded
@@ -49,11 +47,6 @@
* @param servletContext the ServletContext associated with this runtime
*/
void setServletContext(ServletContext servletContext);
-
- /**
- * Returns the current SCA context
- */
- SCA getContext();
/**
* Returns the request injector for the runtime
Modified: incubator/tuscany/java/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyContextListenerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyContextListenerTestCase.java?view=diff&rev=451054&r1=451053&r2=451054
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyContextListenerTestCase.java (original)
+++ incubator/tuscany/java/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyContextListenerTestCase.java Thu Sep 28 16:27:53 2006
@@ -27,6 +27,8 @@
import junit.framework.TestCase;
import static org.easymock.classextension.EasyMock.*;
+import org.apache.tuscany.host.MonitorFactory;
+
/**
* @version $Rev$ $Date$
*/
@@ -37,6 +39,7 @@
private URL systemUrl;
private URL applicationUrl;
private Method getRuntimeMethod;
+ private MonitorFactory monitorFactory;
public void testInitializationUsingDefaults() throws Exception {
ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
@@ -61,6 +64,8 @@
expect(listener.getRuntime(context, cl)).andReturn(runtime);
replay(listener);
runtime.setServletContext(context);
+ expect(runtime.createDefaultMonitorFactory()).andReturn(monitorFactory);
+ runtime.setMonitorFactory(monitorFactory);
runtime.setRuntimeInfo(isA(WebappRuntimeInfo.class));
runtime.setHostClassLoader(cl);
runtime.setSystemScdl(systemUrl);
@@ -167,12 +172,13 @@
protected void setUp() throws Exception {
super.setUp();
getRuntimeMethod = TuscanyContextListener.class.getDeclaredMethod("getRuntime",
- ServletContext.class,
- ClassLoader.class);
+ ServletContext.class,
+ ClassLoader.class);
listener = new TuscanyContextListener();
context = createMock(ServletContext.class);
cl = createMock(ClassLoader.class);
systemUrl = new URL("file:/system.scdl");
applicationUrl = new URL("file:/application.scdl");
+ monitorFactory = createMock(MonitorFactory.class);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org