summaryrefslogtreecommitdiffstats
path: root/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2008-09-12 23:12:40 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2008-09-12 23:12:40 +0000
commit0802754b54c8f79030e2f040a11544de88523e2d (patch)
treea2b607c08e42f15cb1393aa5fddbbcd132ed44f8 /branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org
parent434fc5236e4d6dc7420f6ce8118427566cbb4e48 (diff)
Moved construction of 3rd party bundle from BundleFileFactoryHook to LauncherBundleHelper.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@694839 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHookConfigurator.java72
-rw-r--r--branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java3
-rw-r--r--branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxLauncherBundleHelper.java36
-rw-r--r--branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/LibrariesBundleFileFactoryHook.java148
-rw-r--r--branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java7
5 files changed, 27 insertions, 239 deletions
diff --git a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHookConfigurator.java b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHookConfigurator.java
deleted file mode 100644
index efe4d7bf8a..0000000000
--- a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHookConfigurator.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.sca.node.equinox.launcher;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.jar.Manifest;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.eclipse.osgi.baseadaptor.HookConfigurator;
-import org.eclipse.osgi.baseadaptor.HookRegistry;
-
-/**
- * Hook Configurator for Equinox.
- *
- * @version $Rev: $ $Date: $
- */
-public class EquinoxHookConfigurator implements HookConfigurator {
- private static Logger logger = Logger.getLogger(HookConfigurator.class.getName());
-
- private String[] jarFiles;
- private Manifest manifest;
-
- public EquinoxHookConfigurator() {
-
- // Get the list of JAR files to install
- String jarFilesProperty = System.getProperty("org.apache.tuscany.sca.node.launcher.equinox.jarFiles");
- jarFiles = jarFilesProperty.split(";");
-
- // Create a single 'library' bundle for them
- long libraryStart = System.currentTimeMillis();
- manifest = NodeLauncherUtil.libraryManifest(jarFiles);
-
- if (logger.isLoggable(Level.FINE)) {
- try {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- manifest.write(bos);
- bos.close();
- logger.fine(new String(bos.toByteArray()));
- } catch (IOException e) {
- }
- }
-
- logger.info("Third-party library manifest generated in " + (System.currentTimeMillis() - libraryStart) + " ms");
-
- }
-
- public void addHooks(HookRegistry registry) {
-
- // Register our BundleFileFactory hook
- registry.addBundleFileFactoryHook(new LibrariesBundleFileFactoryHook(manifest));
- }
-
-}
diff --git a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
index 63313b6f39..6efdcb0da5 100644
--- a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
+++ b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
@@ -101,9 +101,6 @@ public class EquinoxHost {
// Use the boot classloader as the parent classloader
props.put("osgi.contextClassLoaderParent", "boot");
- // Set the extension bundle
- props.put("osgi.framework.extensions", "org.apache.tuscany.sca.node.launcher.equinox");
-
// Set startup properties
props.put(EclipseStarter.PROP_CLEAN, "true");
diff --git a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxLauncherBundleHelper.java b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxLauncherBundleHelper.java
index 97cc094f2b..3f88bd89e9 100644
--- a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxLauncherBundleHelper.java
+++ b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxLauncherBundleHelper.java
@@ -1,6 +1,12 @@
package org.apache.tuscany.sca.node.equinox.launcher;
-import java.io.ByteArrayInputStream;
+import static java.lang.System.currentTimeMillis;
+import static java.lang.System.getProperty;
+import static java.lang.System.setProperty;
+import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.libraryBundle;
+import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.string;
+
+import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -32,20 +38,22 @@ public class EquinoxLauncherBundleHelper implements BundleListener {
this.bundleContext.addBundleListener(this);
// Install the Tuscany bundles
- long start = System.currentTimeMillis();
+ long start = currentTimeMillis();
// FIXME: SDO bundles dont have the correct dependencies
- System.setProperty("commonj.sdo.impl.HelperProvider", "org.apache.tuscany.sdo.helper.HelperProviderImpl");
+ setProperty("commonj.sdo.impl.HelperProvider", "org.apache.tuscany.sdo.helper.HelperProviderImpl");
// Get the list of JAR files to install
- String jarFilesProperty = System.getProperty("org.apache.tuscany.sca.node.launcher.equinox.jarFiles");
+ String jarFilesProperty = getProperty("org.apache.tuscany.sca.node.launcher.equinox.jarFiles");
String[] jarFiles = jarFilesProperty.split(";");
// Create a single 'library' bundle for them
- long libraryStart = System.currentTimeMillis();
- //InputStream library = NodeLauncherUtil.libraryBundle(jarFiles);
- Bundle libraryBundle = bundleContext.installBundle("org.apache.tuscany.sca.node.launcher.equinox.libraries", new ByteArrayInputStream(new byte[0]));
- logger.info("Third-party library bundle installed in " + (System.currentTimeMillis() - libraryStart) + " ms: " + NodeLauncherUtil.string(libraryBundle, false));
+ long libraryStart = currentTimeMillis();
+ InputStream library = libraryBundle(jarFiles);
+ logger.info("Third-party library bundle generated in " + (currentTimeMillis() - libraryStart) + " ms.");
+ libraryStart = currentTimeMillis();
+ Bundle libraryBundle = bundleContext.installBundle("org.apache.tuscany.sca.node.launcher.equinox.libraries", library);
+ logger.info("Third-party library bundle installed in " + (currentTimeMillis() - libraryStart) + " ms: " + string(libraryBundle, false));
installedBundles.add(libraryBundle);
// Get the set of already installed bundles
@@ -55,9 +63,9 @@ public class EquinoxLauncherBundleHelper implements BundleListener {
}
// Get the list of bundle files and names to install
- String bundleFilesProperty = System.getProperty("org.apache.tuscany.sca.node.launcher.equinox.bundleFiles");
+ String bundleFilesProperty = getProperty("org.apache.tuscany.sca.node.launcher.equinox.bundleFiles");
String[] bundleFiles = bundleFilesProperty.split(";");
- String bundleNamesProperty = System.getProperty("org.apache.tuscany.sca.node.launcher.equinox.bundleNames");
+ String bundleNamesProperty = getProperty("org.apache.tuscany.sca.node.launcher.equinox.bundleNames");
String[] bundleNames = bundleNamesProperty.split(";");
// Install all the bundles that are not already installed
@@ -68,14 +76,14 @@ public class EquinoxLauncherBundleHelper implements BundleListener {
if (bundleName.contains("org.eclipse.jdt.junit")) {
continue;
}
- long installStart = System.currentTimeMillis();
+ long installStart = currentTimeMillis();
Bundle bundle = bundleContext.installBundle(bundleFile);
- logger.info("Bundle installed in " + (System.currentTimeMillis() - installStart) + " ms: " + NodeLauncherUtil.string(bundle, false));
+ logger.info("Bundle installed in " + (currentTimeMillis() - installStart) + " ms: " + string(bundle, false));
installedBundles.add(bundle);
}
}
- long end = System.currentTimeMillis();
+ long end = currentTimeMillis();
logger.info("Tuscany bundles are installed in " + (end - start) + " ms.");
}
@@ -86,7 +94,7 @@ public class EquinoxLauncherBundleHelper implements BundleListener {
Bundle bundle = installedBundles.get(i);
try {
//if (logger.isLoggable(Level.FINE)) {
- logger.info("Uninstalling bundle: " + NodeLauncherUtil.string(bundle, false));
+ logger.info("Uninstalling bundle: " + string(bundle, false));
//}
bundle.uninstall();
} catch (Exception e) {
diff --git a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/LibrariesBundleFileFactoryHook.java b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/LibrariesBundleFileFactoryHook.java
deleted file mode 100644
index 4ff93ea84b..0000000000
--- a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/LibrariesBundleFileFactoryHook.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * 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.sca.node.equinox.launcher;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.jar.Manifest;
-
-import org.eclipse.osgi.baseadaptor.BaseData;
-import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry;
-import org.eclipse.osgi.baseadaptor.bundlefile.BundleFile;
-
-/**
- * A bundle file factory hook that.
- *
- * @version $Rev: $ $Date: $
-*/
-public class LibrariesBundleFileFactoryHook implements org.eclipse.osgi.baseadaptor.hooks.BundleFileFactoryHook {
-
- private Manifest manifest;
-
- private static class LibrariesBundleFile extends BundleFile {
-
- private static class ManifestBundleEntry extends BundleEntry {
-
- private byte[] bytes;
-
- public ManifestBundleEntry(Manifest manifest) {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- try {
- manifest.write(bos);
- bytes = bos.toByteArray();
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
- }
-
- @Override
- public URL getFileURL() {
- return null;
- }
-
- @Override
- public InputStream getInputStream() throws IOException {
- return new ByteArrayInputStream(bytes);
- }
-
- @Override
- public URL getLocalURL() {
- return null;
- }
-
- @Override
- public String getName() {
- return "META-INF/MANIFEST.MF";
- }
-
- @Override
- public long getSize() {
- return bytes.length;
- }
-
- @Override
- public long getTime() {
- return -1;
- }
-
- @Override
- public byte[] getBytes() throws IOException {
- return bytes;
- }
- }
-
- private Manifest manifest;
-
- public LibrariesBundleFile(Object baseFile, Manifest manifest) {
- super((File)baseFile);
- this.manifest = manifest;
- }
-
- @Override
- public void close() throws IOException {
- }
-
- @Override
- public boolean containsDir(String dir) {
- return false;
- }
-
- @Override
- public BundleEntry getEntry(String path) {
- if ("META-INF/MANIFEST.MF".equals(path)) {
- return new ManifestBundleEntry(manifest);
- }
- return null;
- }
-
- @Override
- public Enumeration getEntryPaths(String path) {
- return null;
- }
-
- @Override
- public File getFile(String path, boolean nativeCode) {
- return null;
- }
-
- @Override
- public void open() throws IOException {
- }
- }
-
- public LibrariesBundleFileFactoryHook(Manifest manifest) {
- this.manifest = manifest;
- }
-
- public BundleFile createBundleFile(Object content, BaseData data, boolean base) throws IOException {
- // Equinox will resolve external classpath against the base bundle
- if ("org.apache.tuscany.sca.node.launcher.equinox.libraries".equals(data.getLocation()) && base) {
- return new LibrariesBundleFile(content, manifest);
- } else {
- return null;
- }
- }
-
-}
diff --git a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java
index b422651244..bf65c3f323 100644
--- a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java
+++ b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java
@@ -26,11 +26,13 @@ import static org.osgi.framework.Constants.DYNAMICIMPORT_PACKAGE;
import static org.osgi.framework.Constants.EXPORT_PACKAGE;
import static org.osgi.framework.Constants.IMPORT_PACKAGE;
+import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.net.URI;
import java.net.URISyntaxException;
@@ -308,11 +310,12 @@ final class NodeLauncherUtil {
}
}
- static byte[] generateBundle(Manifest mf) throws IOException {
+ static InputStream libraryBundle(String[] jarFiles) throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ Manifest mf = libraryManifest(jarFiles);
JarOutputStream jos = new JarOutputStream(bos, mf);
jos.close();
- return bos.toByteArray();
+ return new ByteArrayInputStream(bos.toByteArray());
}
/**