Author: gawor Date: Wed Mar 3 20:47:11 2010 New Revision: 918677 URL: http://svn.apache.org/viewvc?rev=918677&view=rev Log: GERONIMO-5166: Enable car-maven-plugin to use Equinox or Felix as the OSGi framework Modified: geronimo/server/trunk/framework/buildsupport/car-maven-plugin/pom.xml geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/AbstractCarMojo.java geronimo/server/trunk/framework/buildsupport/geronimo-osgi-plugin/pom.xml geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java geronimo/server/trunk/framework/pom.xml Modified: geronimo/server/trunk/framework/buildsupport/car-maven-plugin/pom.xml URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/buildsupport/car-maven-plugin/pom.xml?rev=918677&r1=918676&r2=918677&view=diff ============================================================================== --- geronimo/server/trunk/framework/buildsupport/car-maven-plugin/pom.xml (original) +++ geronimo/server/trunk/framework/buildsupport/car-maven-plugin/pom.xml Wed Mar 3 20:47:11 2010 @@ -217,11 +217,6 @@ org.apache.felix - org.apache.felix.framework - - - - org.apache.felix org.osgi.compendium @@ -239,5 +234,46 @@ + + + felix + + + + framework + felix + + true + + + + + org.apache.felix + org.apache.felix.framework + + + + + + + equinox + + + + framework + equinox + + + + + + org.eclipse + osgi + + + + + + Modified: geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/AbstractCarMojo.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/AbstractCarMojo.java?rev=918677&r1=918676&r2=918677&view=diff ============================================================================== --- geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/AbstractCarMojo.java (original) +++ geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/AbstractCarMojo.java Wed Mar 3 20:47:11 2010 @@ -23,6 +23,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.lang.reflect.Field; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -826,11 +827,11 @@ "org.apache.geronimo.kernel.basic," + "org.apache.geronimo.kernel.classloader," + "org.apache.geronimo.kernel.config," + - "org.apache.geronimo.kernel.config.classloading," + "org.apache.geronimo.kernel.config.xstream," + "org.apache.geronimo.kernel.lifecycle," + "org.apache.geronimo.kernel.management," + "org.apache.geronimo.kernel.osgi," + + "org.apache.geronimo.kernel.osgi.jar," + "org.apache.geronimo.kernel.proxy," + "org.apache.geronimo.kernel.repository," + "org.apache.geronimo.kernel.rmi," + @@ -853,7 +854,7 @@ "org.apache.geronimo.system.sharedlib," + "org.apache.geronimo.system.threads," + "org.apache.geronimo.system.util," + - "org.apache.geronimo.mavenplugins.car," + + "org.apache.geronimo.mavenplugins.car" + ""); /* @@ -941,12 +942,33 @@ "javax.enterprise.deploy.shared," + "javax.enterprise.deploy.spi"); */ + File storageDir = new File(basedir, "target/bundle-cache"); properties.put(Constants.FRAMEWORK_STORAGE, storageDir.getAbsolutePath()); + + /* + * A hack for Equinox to restore FrameworkProperties to the initial state. + * If the FrameworkProperties is not restored to the initial state, Equinox + * will create a separate classloader and load the Geronimo kernel classes + * from deployed geronimo-kernel bundle instead of the system bundle. + * That will result in ClassCastException. + */ + resetFrameworkProperties(); + ServiceLoader loader = ServiceLoader.load(FrameworkFactory.class); Framework framework = loader.iterator().next().newFramework(properties); framework.start(); return framework; } + private static void resetFrameworkProperties() { + try { + Class clazz = Class.forName("org.eclipse.osgi.framework.internal.core.FrameworkProperties"); + Field f = clazz.getDeclaredField("properties"); + f.setAccessible(true); + f.set(null, null); + } catch (Throwable e) { + e.printStackTrace(); + } + } } Modified: geronimo/server/trunk/framework/buildsupport/geronimo-osgi-plugin/pom.xml URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/buildsupport/geronimo-osgi-plugin/pom.xml?rev=918677&r1=918676&r2=918677&view=diff ============================================================================== --- geronimo/server/trunk/framework/buildsupport/geronimo-osgi-plugin/pom.xml (original) +++ geronimo/server/trunk/framework/buildsupport/geronimo-osgi-plugin/pom.xml Wed Mar 3 20:47:11 2010 @@ -31,21 +31,6 @@ Geronimo Build Support :: OSGi Plugin maven-plugin - - - - tuscany.repo - Tuscany Maven 2.x Repository - http://svn.apache.org/repos/asf/tuscany/maven - - true - - - false - - - - @@ -78,7 +63,6 @@ org.eclipse osgi - 3.5.0-v20090520 compile Modified: geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java?rev=918677&r1=918676&r2=918677&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java Wed Mar 3 20:47:11 2010 @@ -25,7 +25,6 @@ import java.io.PrintWriter; import java.net.URI; import java.net.URL; -import java.net.URLEncoder; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -197,7 +196,7 @@ createTempManifest(); createPluginMetadata(); JarUtils.jarDirectory(baseDir, tempBundleFile); - String location = "reference:file:" + URLEncoder.encode(tempBundleFile.getAbsolutePath(), "UTF-8"); + String location = "reference:" + tempBundleFile.toURI().toURL(); tempBundle = bundleContext.installBundle(location); if (BundleUtils.canStart(tempBundle)) { tempBundle.start(Bundle.START_TRANSIENT); Modified: geronimo/server/trunk/framework/pom.xml URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/pom.xml?rev=918677&r1=918676&r2=918677&view=diff ============================================================================== --- geronimo/server/trunk/framework/pom.xml (original) +++ geronimo/server/trunk/framework/pom.xml Wed Mar 3 20:47:11 2010 @@ -37,6 +37,11 @@ + org.eclipse + osgi + 3.5.0.v20090520 + + org.apache.felix org.apache.felix.framework 2.1.0-SNAPSHOT