You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by me...@apache.org on 2006/12/26 23:21:13 UTC
svn commit: r490389 - in
/incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server:
TuscanyServer.java TuscanyServerException.java
Author: meerajk
Date: Tue Dec 26 14:21:12 2006
New Revision: 490389
URL: http://svn.apache.org/viewvc?view=rev&rev=490389
Log:
Added code to boot runtime.
Added:
incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/TuscanyServerException.java (with props)
Modified:
incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/TuscanyServer.java
Modified: incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/TuscanyServer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/TuscanyServer.java?view=diff&rev=490389&r1=490388&r2=490389
==============================================================================
--- incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/TuscanyServer.java (original)
+++ incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/TuscanyServer.java Tue Dec 26 14:21:12 2006
@@ -18,10 +18,22 @@
*/
package org.apache.tuscany.standalone.server;
+import java.beans.Beans;
import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Arrays;
+import org.apache.tuscany.host.runtime.InitializationException;
+import org.apache.tuscany.host.runtime.ShutdownException;
+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;
import org.apache.tuscany.standalone.server.management.jmx.Agent;
import org.apache.tuscany.standalone.server.management.jmx.RmiAgent;
+import org.osoa.sca.SCA;
/**
* This class provides the commandline interface for starting the
@@ -56,6 +68,12 @@
/** Agent */
private Agent agent = RmiAgent.getInstance();
+ /** Context */
+ private SCA context;
+
+ /** Runtime */
+ private TuscanyRuntime runtime;
+
/**
*
* @param args Commandline arguments.
@@ -74,9 +92,6 @@
agent.start();
agent.register(this, "tuscanyServer");
- File installDirectory = DirectoryHelper.getInstallDirectory();
- File bootDirectory = DirectoryHelper.getBootDirectory(installDirectory);
-
}
/**
@@ -84,16 +99,79 @@
*
*/
public void start() {
+
+ try {
+
+ File installDirectory = DirectoryHelper.getInstallDirectory();
+ URL baseUrl = installDirectory.toURI().toURL();
+ File bootDirectory = DirectoryHelper.getBootDirectory(installDirectory);boolean online = !Boolean.parseBoolean(System.getProperty("offline", Boolean.FALSE.toString()));
+ StandaloneRuntimeInfo runtimeInfo = new StandaloneRuntimeInfoImpl(baseUrl, installDirectory, installDirectory, online);
+
+ ClassLoader hostClassLoader = ClassLoader.getSystemClassLoader();
+ ClassLoader bootClassLoader = getTuscanyClassLoader(bootDirectory);
+
+ URL systemScdl = getSystemScdl(bootClassLoader);
+
+ String className = System.getProperty("tuscany.launcherClass",
+ "org.apache.tuscany.runtime.standalone.host.StandaloneRuntimeImpl");
+ runtime = (TuscanyRuntime) Beans.instantiate(bootClassLoader, className);
+ runtime.setMonitorFactory(runtime.createDefaultMonitorFactory());
+ runtime.setSystemScdl(systemScdl);
+ runtime.setHostClassLoader(hostClassLoader);
+
+ runtime.setRuntimeInfo(runtimeInfo);
+ runtime.initialize();
+ context = runtime.getContext();
+
+ context.start();
+
+ } catch (IOException ex) {
+ throw new TuscanyServerException(ex);
+ } catch (ClassNotFoundException ex) {
+ throw new TuscanyServerException(ex);
+ } catch (InitializationException ex) {
+ throw new TuscanyServerException(ex);
+ }
+
System.err.println("Started");
+
}
/**
* Starts the server.
*
*/
- public void shutdown() {
- agent.shutdown();
+ public void shutdown() {
+
+ try {
+ context.stop();
+ runtime.destroy();
+ agent.shutdown();
+ } catch (ShutdownException ex) {
+ throw new TuscanyServerException(ex);
+ }
System.err.println("Shutdown");
+ }
+
+ /**
+ * Gets the tuscany classloader.
+ * @param bootDir Boot directory.
+ * @return Tuscany classloader.
+ */
+ private ClassLoader getTuscanyClassLoader(File bootDir) {
+ URL[] urls = LaunchHelper.scanDirectoryForJars(bootDir);
+ System.err.println(Arrays.asList(urls));
+ return new URLClassLoader(urls, getClass().getClassLoader());
+ }
+
+ /**
+ * Gets the system SCDL.
+ * @param bootClassLoader Boot classloader.
+ * @return URL to the system SCDL.
+ */
+ private URL getSystemScdl(ClassLoader bootClassLoader) {
+ String resource = System.getProperty("tuscany.systemScdlPath", "META-INF/tuscany/system.scdl");
+ return bootClassLoader.getResource(resource);
}
}
Added: incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/TuscanyServerException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/TuscanyServerException.java?view=auto&rev=490389
==============================================================================
--- incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/TuscanyServerException.java (added)
+++ incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/TuscanyServerException.java Tue Dec 26 14:21:12 2006
@@ -0,0 +1,23 @@
+package org.apache.tuscany.standalone.server;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+
+/**
+ * Exception thrown by the tuscany server during startup and shutdown.
+ *
+ * @version $Revisiion$ $Date$
+ *
+ */
+
+@SuppressWarnings("serial")
+public class TuscanyServerException extends TuscanyRuntimeException {
+
+ /**
+ * Initializes the cause.
+ * @param cause Root cause of the exception.
+ */
+ public TuscanyServerException(Throwable cause) {
+ super(cause);
+ }
+
+}
Propchange: incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/TuscanyServerException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/TuscanyServerException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org