From bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a Mon Sep 17 00:00:00 2001 From: dims Date: Tue, 17 Jun 2008 00:23:01 +0000 Subject: Move Tuscany from Incubator to top level. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/tuscany/launcher/Main.java | 98 ++++++++++++++++++++++ .../org/apache/tuscany/launcher/Main.properties | 23 +++++ 2 files changed, 121 insertions(+) create mode 100644 sandbox/old/contrib/runtime-standalone/launcher/src/main/java/org/apache/tuscany/launcher/Main.java create mode 100644 sandbox/old/contrib/runtime-standalone/launcher/src/main/resources/org/apache/tuscany/launcher/Main.properties (limited to 'sandbox/old/contrib/runtime-standalone/launcher/src/main') diff --git a/sandbox/old/contrib/runtime-standalone/launcher/src/main/java/org/apache/tuscany/launcher/Main.java b/sandbox/old/contrib/runtime-standalone/launcher/src/main/java/org/apache/tuscany/launcher/Main.java new file mode 100644 index 0000000000..e011c5a3a5 --- /dev/null +++ b/sandbox/old/contrib/runtime-standalone/launcher/src/main/java/org/apache/tuscany/launcher/Main.java @@ -0,0 +1,98 @@ +/* + * 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.launcher; + +import java.io.File; +import java.net.URL; +import java.net.URLClassLoader; +import java.text.MessageFormat; +import java.util.ResourceBundle; + +import org.apache.tuscany.runtime.standalone.DirectoryHelper; +import org.apache.tuscany.runtime.standalone.StandaloneRuntime; +import org.apache.tuscany.runtime.standalone.StandaloneRuntimeInfo; + +/** + * Main class for launcher runtime environment. + * usage: java [jvm-options] -jar launcher.jar + * + * where the componentURI identifies a component in the assembly that should be + * called. + * + * @version $Rev$ $Date$ + */ +public class Main { + + /** + * Main method. + * + * @param args the command line args + * @throws Throwable if there are problems launching the runtime or + * application + */ + public static void main(String[] args) throws Throwable { + + if (args.length < 1) { + usage(); + throw new AssertionError(); + } + + File applicationFile = new File(args[0]); + if (!applicationFile.exists()) { + System.err.println(getMessage("org.apache.tuscany.launcher.NoComposite", applicationFile)); + System.exit(2); + } + + String[] appArgs = new String[0]; + if(args.length > 1) { + appArgs = new String[args.length - 1]; + System.arraycopy(args, 1, appArgs, 0, appArgs.length); + } + + StandaloneRuntimeInfo runtimeInfo = DirectoryHelper.createRuntimeInfo("launcher", Main.class); + StandaloneRuntime runtime = (StandaloneRuntime)DirectoryHelper.createRuntime(runtimeInfo); + + URL applicationJar = applicationFile.toURL(); + ClassLoader applicationClassLoader = + new URLClassLoader(new URL[] {applicationJar}, runtime.getHostClassLoader()); + String applicationScdl = System.getProperty("launcher.scdl", "META-INF/sca/default.scdl"); + URL applicationScdlURL = applicationClassLoader.getResource(applicationScdl); + if (applicationScdlURL == null) { + System.err.println(getMessage("org.apache.tuscany.launcher.NoApplicationSCDL", applicationScdl)); + System.exit(2); + } + + // boot the runtime + runtime.initialize(); + + int status = runtime.deployAndRun(applicationScdlURL, applicationClassLoader, appArgs); + System.exit(status); + } + + private static void usage() { + System.err.println(getMessage("org.apache.tuscany.launcher.Usage")); + System.exit(1); + } + + private static String getMessage(String id, Object... params) { + ResourceBundle bundle = ResourceBundle.getBundle(Main.class.getName()); + String message = bundle.getString(id); + return MessageFormat.format(message, params); + } +} diff --git a/sandbox/old/contrib/runtime-standalone/launcher/src/main/resources/org/apache/tuscany/launcher/Main.properties b/sandbox/old/contrib/runtime-standalone/launcher/src/main/resources/org/apache/tuscany/launcher/Main.properties new file mode 100644 index 0000000000..51cdb7087a --- /dev/null +++ b/sandbox/old/contrib/runtime-standalone/launcher/src/main/resources/org/apache/tuscany/launcher/Main.properties @@ -0,0 +1,23 @@ +# 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. +# +# $Rev$ $Date$ +# +org.apache.tuscany.launcher.Usage=usage: java [jvm-options] -jar launcher.jar [apparg1, apparg2, ...] +org.apache.tuscany.launcher.NoComponent=No component found with id "{0}" +org.apache.tuscany.launcher.NoComposite=No composite archive found: {0} +org.apache.tuscany.launcher.NoApplicationSCDL=No application SCDL found: {0} -- cgit v1.2.3