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/08/14 21:47:18 UTC
svn commit: r431420 - in /incubator/tuscany/java:
distribution/sca/standalone/src/main/assembly/ sca/commands/launcher/
sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/
sca/hostutil/src/main/java/org/apache/tuscany/hostutil/
Author: jboynes
Date: Mon Aug 14 12:47:18 2006
New Revision: 431420
URL: http://svn.apache.org/viewvc?rev=431420&view=rev
Log:
update launcher to use support from hostutil
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/hostutil/src/main/java/org/apache/tuscany/hostutil/LaunchHelper.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?rev=431420&r1=431419&r2=431420&view=diff
==============================================================================
--- incubator/tuscany/java/distribution/sca/standalone/src/main/assembly/standalone.xml (original)
+++ incubator/tuscany/java/distribution/sca/standalone/src/main/assembly/standalone.xml Mon Aug 14 12:47:18 2006
@@ -45,6 +45,7 @@
</includes>
<excludes>
<exclude>org.osoa:sca-api</exclude>
+ <exclude>org.apache.tuscany:hostutil</exclude>
</excludes>
<fileMode>755</fileMode>
</dependencySet>
@@ -54,6 +55,7 @@
<outputDirectory>bin</outputDirectory>
<includes>
<include>org.osoa:sca-api</include>
+ <include>org.apache.tuscany:hostutil</include>
</includes>
<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?rev=431420&r1=431419&r2=431420&view=diff
==============================================================================
--- incubator/tuscany/java/sca/commands/launcher/pom.xml (original)
+++ incubator/tuscany/java/sca/commands/launcher/pom.xml Mon Aug 14 12:47:18 2006
@@ -28,14 +28,20 @@
<name>Apache Tuscany SCA Application Launcher</name>
<description>Standalone executable jar that can be used to launch a SCA application.</description>
+ <!--
+ This library will typically be added to the application's classpath and so should
+ should have as few dependencies as possible and nothing from the Tuscany runtime.
+ -->
<dependencies>
- <!--
- To keep implementation artifacts from creeping onto the application's classpath
- no Tuscany jars should be added as dependencies here.
- -->
<dependency>
<groupId>org.osoa</groupId>
<artifactId>sca-api-r0.95</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>hostutil</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
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?rev=431420&r1=431419&r2=431420&view=diff
==============================================================================
--- 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 Mon Aug 14 12:47:18 2006
@@ -18,16 +18,16 @@
*/
package org.apache.tuscany.launcher;
+import java.beans.Beans;
import java.io.File;
-import java.io.FilenameFilter;
import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ResourceBundle;
+import org.apache.tuscany.hostutil.LaunchHelper;
+
/**
* Launcher for launcher runtime environment that invokes a jar's Main class.
*
@@ -40,39 +40,15 @@
* @param args the command line args
*/
public static void main(String[] args) throws Throwable {
- // The classpath to load the launcher should not contain any of
- // Tuscany jar files except the launcher.
+ // The classpath to load the launcher should not any jars from the Tuscany runtime
MainLauncherBooter booter = new MainLauncherBooter();
ClassLoader tuscanyCL = booter.getTuscanyClassLoader();
- Class<?> launcherClass;
- try {
- String className = System.getProperty("tuscany.launcherClass",
- "org.apache.tuscany.core.launcher.MainLauncher");
- launcherClass = tuscanyCL.loadClass(className);
- } catch (ClassNotFoundException e) {
- System.err.println("Tuscany bootstrap class not found: " + e.getMessage());
- System.exit(2);
- throw new AssertionError();
- }
-
- Method mainMethod;
- try {
- mainMethod = launcherClass.getMethod("boot", String[].class);
- } catch (NoSuchMethodException e) {
- // this is our class so the method should be there
- throw new AssertionError(e);
- }
-
+ String className = System.getProperty("tuscany.launcherClass",
+ "org.apache.tuscany.core.launcher.MainLauncher");
+ Object launcher = Beans.instantiate(tuscanyCL, className);
try {
- Object launcher = launcherClass.newInstance();
- mainMethod.invoke(launcher, new Object[] {args});
- } catch (InstantiationException e) {
- throw new AssertionError(e);
- } catch (IllegalAccessException e) {
- throw new AssertionError(e);
- } catch (IllegalArgumentException e) {
- throw new AssertionError(e);
+ LaunchHelper.invoke(launcher, "boot", new Class<?>[]{String[].class}, (Object[]) new Object[]{args});
} catch (InvocationTargetException e) {
throw e.getCause();
}
@@ -80,34 +56,10 @@
protected ClassLoader getTuscanyClassLoader() {
File tuscanylib = findBootDir();
- URL[] urls = scanDirectory(tuscanylib);
+ URL[] urls = LaunchHelper.scanDirectoryForJars(tuscanylib);
return new URLClassLoader(urls, getClass().getClassLoader());
}
- /**
- * Scan a directory for jar files to be added to the classpath.
- *
- * @param tuscanylib the directory to scan
- * @return the URLs or jar files in that directory
- */
- protected URL[] scanDirectory(File tuscanylib) {
- File[] jars = tuscanylib.listFiles(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.endsWith(".jar");
- }
- });
-
- URL[] urls = new URL[jars.length];
- for (int i = 0; i < jars.length; i++) {
- try {
- urls[i] = jars[i].toURI().toURL();
- } catch (MalformedURLException e) {
- // toURI should have escaped the URL
- throw new AssertionError();
- }
- }
- return urls;
- }
/**
* Find the directory containing the bootstrap jars.
Modified: incubator/tuscany/java/sca/hostutil/src/main/java/org/apache/tuscany/hostutil/LaunchHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/hostutil/src/main/java/org/apache/tuscany/hostutil/LaunchHelper.java?rev=431420&r1=431419&r2=431420&view=diff
==============================================================================
--- incubator/tuscany/java/sca/hostutil/src/main/java/org/apache/tuscany/hostutil/LaunchHelper.java (original)
+++ incubator/tuscany/java/sca/hostutil/src/main/java/org/apache/tuscany/hostutil/LaunchHelper.java Mon Aug 14 12:47:18 2006
@@ -89,11 +89,11 @@
* @return the value returned by the method
* @throws InvocationTargetException if the method throw an Exception
*/
- public static Object invoke(Object instance, String name, Object... args) throws InvocationTargetException {
- Class<?>[] paramTypes = new Class<?>[args.length];
+ public static Object invoke(Object instance, String name, Class<?>[] paramTypes, Object... args)
+ throws InvocationTargetException {
try {
Method method = instance.getClass().getMethod(name, paramTypes);
- return method.invoke(instance, args);
+ return method.invoke(instance, (Object[]) args);
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException(e);
} catch (IllegalAccessException e) {
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org