diff options
Diffstat (limited to 'sandbox/slaws/runtimecompat/combinedlauncher/src/main/java/launcher/CombinedLauncher.java')
-rw-r--r-- | sandbox/slaws/runtimecompat/combinedlauncher/src/main/java/launcher/CombinedLauncher.java | 95 |
1 files changed, 18 insertions, 77 deletions
diff --git a/sandbox/slaws/runtimecompat/combinedlauncher/src/main/java/launcher/CombinedLauncher.java b/sandbox/slaws/runtimecompat/combinedlauncher/src/main/java/launcher/CombinedLauncher.java index 44579125ff..40adc833e2 100644 --- a/sandbox/slaws/runtimecompat/combinedlauncher/src/main/java/launcher/CombinedLauncher.java +++ b/sandbox/slaws/runtimecompat/combinedlauncher/src/main/java/launcher/CombinedLauncher.java @@ -33,13 +33,8 @@ import org.osgi.framework.BundleContext; public class CombinedLauncher { - private static final String TWO_X_NODE_LAUNCHER_EQUINOX_BUNDLE = "org.apache.tuscany.sca.node.launcher.equinox"; - private static final String TWO_X_NODE_LAUNCHER_UTIL = "org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil"; - private static final String TWO_X_CONTRIBUTION = "org.apache.tuscany.sca.node.equinox.launcher.Contribution"; - - private static final String TWO_X_NODE_API_BUNDLE = "org.apache.tuscany.sca.node.api"; - private static final String TWO_X_NODE = "org.apache.tuscany.sca.node.Node"; + private static final String TWO_X_LAUNCHER = "launcher.TwoXLauncher"; private static final String ONE_X_LAUNCHER = "launcher.OneXLauncher"; public static void main(String[] args) throws Exception { @@ -55,89 +50,35 @@ public class CombinedLauncher { "../../../java-2.x/distribution/all/target/apache-tuscany-sca-all-2.0-SNAPSHOT-dir/tuscany-sca-2.0-SNAPSHOT"); // To get to the console run with -Dosgi.console=<port> + // If running in Eclipse specifying just -Dosgi.console will bring up osgi> in the eclipse console EquinoxHost equinoxHost = new EquinoxHost(); BundleContext bundleContext = equinoxHost.start(); - // need to add in the 1.x bundle(s) also - Bundle oneXbundle = equinoxHost.installBundle(new URL("file:///C:/simon/tuscany/sandbox/runtimecompat/1xbundle/target/1.x-osgi-bundle-1.6-SNAPSHOT.jar"), "1xbundle"); - Bundle oneXLauncherbundle = equinoxHost.installBundle(new URL("file:///C:/simon/tuscany/sandbox/runtimecompat/1xlauncher/target/1x-launcher.jar"), "1xlauncherbundle"); + // the 2.x equinoz host will have added all the Tuscany 2x bundles to the OSGi + // environment. Now add the 2.x launcher bundle + Bundle twoXLauncherbundle = equinoxHost.installBundle(new URL("file:///C:/simon/tuscany/sandbox/runtimecompat/2xlauncher/target/2x-launcher-1.0-SNAPSHOT.jar"), "2xlauncherbundle"); + // add in the 1.x bundles also + Bundle oneXbundle = equinoxHost.installBundle(new URL("file:///C:/simon/tuscany/sandbox/runtimecompat/1xbundle/target/1.x-osgi-bundle-1.6-SNAPSHOT.jar"), "1xbundle"); + Bundle oneXLauncherbundle = equinoxHost.installBundle(new URL("file:///C:/simon/tuscany/sandbox/runtimecompat/1xlauncher/target/1x-launcher-1.0-SNAPSHOT.jar"), "1xlauncherbundle"); + System.out.println("Bundles loaded"); - // load 2xcalculator - // find the the 2.x node launcher util - // Get the node runtime bundle. -/* - Bundle twoXbundle = null; - for (Bundle b : bundleContext.getBundles()) { - if (TWO_X_NODE_LAUNCHER_EQUINOX_BUNDLE.equals(b.getSymbolicName())) { - twoXbundle = b; - break; - } - } - if (twoXbundle == null) { - throw new IllegalStateException("Bundle " + TWO_X_NODE_LAUNCHER_EQUINOX_BUNDLE + " is not installed"); - } - - // All this reflection not strictly needed given the current - // module dependencies. Just experimenting - Class<?> contributionClass = twoXbundle.loadClass(TWO_X_CONTRIBUTION); - Constructor<?> constructor = contributionClass.getConstructor(String.class, String.class); - - Class<?> bootstrapClass = twoXbundle.loadClass(TWO_X_NODE_LAUNCHER_UTIL); - Class<?> contributionArrayClass = Array.newInstance(contributionClass, 0).getClass(); - Method nodeMethod = bootstrapClass.getMethod("node", String.class, String.class, String.class, contributionArrayClass, BundleContext.class); - - twoXbundle = null; - for (Bundle b : bundleContext.getBundles()) { - if (TWO_X_NODE_API_BUNDLE.equals(b.getSymbolicName())) { - twoXbundle = b; - break; - } - } - if (twoXbundle == null) { - throw new IllegalStateException("Bundle " + TWO_X_NODE_API_BUNDLE + " is not installed"); - } - - Class<?> nodeClass = twoXbundle.loadClass(TWO_X_NODE); - Method startMethod = nodeClass.getMethod("start"); - - String configurationURI = null; - String compositeURI = null; - String compositeContent = null; - Object contribution = constructor.newInstance("calculator", "../2xcalculator.jar"); - Object[] contributions = (Object[])Array.newInstance(contributionClass, 1); - contributions[0] = contribution; - - Object node = nodeMethod.invoke(null, - configurationURI, - compositeURI, - compositeContent, - contributionArrayClass.cast(contributions), - bundleContext); - - startMethod.invoke(node); - - System.out.println("2.x Running"); -*/ + // find the the 2.x node launcher and get it to run the calculator app + Class<?> twoXLauncherClass = twoXLauncherbundle.loadClass(TWO_X_LAUNCHER); + Method twoXLaunchNodeMethod = twoXLauncherClass.getMethod("launchNode"); + twoXLaunchNodeMethod.invoke(null); + System.out.println("2.x run complete"); - // load 1xcalculator - // find the the 1.x node launcher + // find the the 1.x node launcher and get it to run the calculator app Class<?> oneXLauncherClass = oneXLauncherbundle.loadClass(ONE_X_LAUNCHER); - Method launchNodeMethod = oneXLauncherClass.getMethod("launchNode"); - launchNodeMethod.invoke(null); - - System.out.println("1.x Running"); + Method oneXLaunchNodeMethod = oneXLauncherClass.getMethod("launchNode"); + oneXLaunchNodeMethod.invoke(null); - try { - System.out.println("Press a key"); - System.in.read(); - } catch (Exception ex) { - } + System.out.println("1.x run complete"); equinoxHost.stop(); } - } |