X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.lib.detached%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Flib%2Fdetached%2FDetachedLauncher.java;h=5f2bbd2e977a0aa800ea42d15a700c009a7bf429;hb=bd07be7603d234ac496652aaa07ded77d4a2a292;hp=825a9717d91efec1fbb1cb1b0a2996775a1abd2d;hpb=91ec63b012729bdfa5fb3854bf9e9dd5f6d6ac91;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.lib.detached/src/main/java/org/argeo/slc/lib/detached/DetachedLauncher.java b/runtime/org.argeo.slc.lib.detached/src/main/java/org/argeo/slc/lib/detached/DetachedLauncher.java index 825a9717d..5f2bbd2e9 100644 --- a/runtime/org.argeo.slc.lib.detached/src/main/java/org/argeo/slc/lib/detached/DetachedLauncher.java +++ b/runtime/org.argeo.slc.lib.detached/src/main/java/org/argeo/slc/lib/detached/DetachedLauncher.java @@ -1,7 +1,24 @@ +/* + * Copyright (C) 2007-2012 Argeo GmbH + * + * Licensed 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.argeo.slc.lib.detached; import java.io.File; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -24,10 +41,13 @@ public class DetachedLauncher extends JvmProcess implements BundleContextAware, private ResourceLoader resourceLoader = null; private Resource osgiFramework = null; - private String osgibootBundleName = "org.argeo.slc.osgiboot"; + private String osgibootBundleName = "org.argeo.osgi.boot"; private String equinoxBundleName = "org.eclipse.osgi"; - private String xmlapisBundleName = "com.springsource.org.apache.xmlcommons"; - private String xercesBundleName = "com.springsource.org.apache.xerces"; + private String xmlapisBundleName = "org.apache.xmlcommons"; + private String xercesBundleName = "org.apache.xerces"; + + private List excludeBundleNames = new ArrayList(); + private List includeBundleUrls = new ArrayList(); /** * Required by Spring for JDK 1.4. see @@ -38,7 +58,7 @@ public class DetachedLauncher extends JvmProcess implements BundleContextAware, public DetachedLauncher() { // Override defaults setSynchronous(false); - setMainClass("org.argeo.slc.osgiboot.Launcher"); + setMainClass("org.argeo.osgi.boot.Launcher"); } public void afterPropertiesSet() throws Exception { @@ -56,45 +76,72 @@ public class DetachedLauncher extends JvmProcess implements BundleContextAware, StringBuffer osgiLocations = new StringBuffer(""); bundles: for (Bundle bundle : bundleContext.getBundles()) { String name = bundle.getSymbolicName(); - String location = bundle.getLocation(); + + if (excludeBundleNames.contains(name)) { + if (log.isDebugEnabled()) + log.debug("Exclude bundle " + name); + continue bundles;// skip excluded + } + + String originalLocation = bundle.getLocation(); + if (log.isTraceEnabled()) + log.trace("Original location of bundle " + name + ": " + + originalLocation); + String location = removeInitialReference(originalLocation); // Special bundles if (osgibootBundleName.equals(name)) - getClasspath().add(findOsgiboot(bundle)); + getClasspath().add(asResource(location)); else if (equinoxBundleName.equals(name)) continue bundles;// skip framework else if (xmlapisBundleName.equals(name) && prependXmlJars) - getPBootClasspath().add(asResource(bundle.getLocation())); + getPBootClasspath().add(asResource(location)); else if (xercesBundleName.equals(name) && prependXmlJars) - getPBootClasspath().add(asResource(bundle.getLocation())); + getPBootClasspath().add(asResource(location)); if (location.startsWith("file:")) { File file = new File(location.substring("file:".length())); if (osgiLocations.length() != 0) osgiLocations.append(File.pathSeparatorChar); - osgiLocations.append(file.getPath().replace('/', - File.separatorChar)); + location = file.getPath().replace('/', File.separatorChar); + osgiLocations.append(location); + if (log.isTraceEnabled()) + log.trace("Added bundle " + name + + " to argeo.osgi.locations: " + location); } else { if (osgiBundles.length() != 0) osgiBundles.append(','); - osgiBundles.append(location.replace('/', File.separatorChar)); + location = location.replace('/', File.separatorChar); + osgiBundles.append(location); + if (log.isTraceEnabled()) + log.trace("Added bundle " + name + " to osgi.bundles: " + + location); } } + for (String url : includeBundleUrls) { + if (osgiBundles.length() != 0) + osgiBundles.append(','); + osgiBundles.append(url); + if (log.isDebugEnabled()) + log.debug("Include url" + url); + } + getSystemProperties().setProperty("osgi.bundles", osgiBundles.toString()); - getSystemProperties().setProperty("slc.osgi.locations", + getSystemProperties().setProperty("argeo.osgi.locations", osgiLocations.toString()); + + super.afterPropertiesSet(); } - protected Resource findOsgiboot(Bundle bundle) { - String location = bundle.getLocation(); + protected String removeInitialReference(String location) { if (location.startsWith("initial@reference:file:")) location = System.getProperty("osgi.install.area") + location.substring("initial@reference:file:".length()); if (location.charAt(location.length() - 1) == '/') location.substring(0, location.length() - 1); - return asResource(location); + return location; } protected Resource asResource(String location) { @@ -152,4 +199,12 @@ public class DetachedLauncher extends JvmProcess implements BundleContextAware, this.prependXmlJars = prependXmlJars; } + public void setExcludeBundleNames(List excludeBundleNames) { + this.excludeBundleNames = excludeBundleNames; + } + + public void setIncludeBundleUrls(List includeBundleUrls) { + this.includeBundleUrls = includeBundleUrls; + } + }