Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Bartel2014-12-10 08:57:16 -0500
committerJan Bartel2014-12-10 08:57:48 -0500
commit0db02049adea11184ceadf7be274e7e243d7dde1 (patch)
treed876900a3f60ec296ca8f81bec7d5d3746a2c01e /jetty-osgi/jetty-osgi-boot/src
parentf3791a9b06d65bfc3482b682cf9d8e98ce031889 (diff)
downloadorg.eclipse.jetty.project-0db02049adea11184ceadf7be274e7e243d7dde1.tar.gz
org.eclipse.jetty.project-0db02049adea11184ceadf7be274e7e243d7dde1.tar.xz
org.eclipse.jetty.project-0db02049adea11184ceadf7be274e7e243d7dde1.zip
440506 Jetty OSGi boot bundle does not support OSGi framework Eclipse Concierge
Diffstat (limited to 'jetty-osgi/jetty-osgi-boot/src')
-rw-r--r--jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/DefaultBundleClassLoaderHelper.java81
1 files changed, 78 insertions, 3 deletions
diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/DefaultBundleClassLoaderHelper.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/DefaultBundleClassLoaderHelper.java
index 199bde3c35..27db331ab5 100644
--- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/DefaultBundleClassLoaderHelper.java
+++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/DefaultBundleClassLoaderHelper.java
@@ -37,7 +37,7 @@ import org.osgi.framework.Bundle;
public class DefaultBundleClassLoaderHelper implements BundleClassLoaderHelper
{
private static final Logger LOG = Log.getLogger(BundleClassLoaderHelper.class);
- private static enum OSGiContainerType {EquinoxOld, EquinoxLuna, FelixOld, Felix403};
+ private static enum OSGiContainerType {EquinoxOld, EquinoxLuna, FelixOld, Felix403, Concierge};
private static OSGiContainerType osgiContainer;
private static Class Equinox_BundleHost_Class;
private static Class Equinox_EquinoxBundle_Class;
@@ -56,6 +56,12 @@ public class DefaultBundleClassLoaderHelper implements BundleClassLoaderHelper
private static Field Felix_ModuleImpl_m_ClassLoader_Field;
private static Method Felix_BundleWiring_getClassLoader_Method;
+ // Concierge
+ private static Class Concierge_BundleImpl_Class;
+ private static Class Concierge_BundleWiring_Class;
+ private static Method Concierge_BundleImpl_Adapt_Method;
+ private static Method Concierge_BundleWiring_getClassLoader_Method;
+
private static void checkContainerType (Bundle bundle)
{
@@ -102,10 +108,22 @@ public class DefaultBundleClassLoaderHelper implements BundleClassLoaderHelper
}
catch (ClassNotFoundException e)
{
- LOG.warn("Unknown OSGi container type");
- return;
+ LOG.ignore(e);
}
+ try
+ {
+ Concierge_BundleImpl_Class = bundle.getClass().getClassLoader().loadClass("org.eclipse.concierge.BundleImpl");
+ osgiContainer = OSGiContainerType.Concierge;
+ return;
+ }
+ catch (ClassNotFoundException e)
+ {
+ LOG.ignore(e);
+ }
+
+ LOG.warn("Unknown OSGi container type");
+ return;
}
@@ -168,6 +186,12 @@ public class DefaultBundleClassLoaderHelper implements BundleClassLoaderHelper
{
return internalGetFelixBundleClassLoader(bundle);
}
+
+ case Concierge:
+ {
+ return internalGetConciergeBundleClassLoader(bundle);
+ }
+
default:
{
LOG.warn("No classloader found for bundle "+bundle.getSymbolicName());
@@ -363,4 +387,55 @@ public class DefaultBundleClassLoaderHelper implements BundleClassLoaderHelper
LOG.warn("No classloader for felix platform for bundle "+bundle.getSymbolicName());
return null;
}
+
+ /**
+ * @param bundle
+ * @return
+ */
+ private static ClassLoader internalGetConciergeBundleClassLoader(Bundle bundle)
+ {
+ if (osgiContainer == OSGiContainerType.Concierge)
+ {
+ try
+ {
+ /**
+ * In Concierge:
+ *
+ * Option A:
+ * <pre>
+ * Concierge concierge = new Concierge(...);
+ * BundleWiring bundleWiring = concierge.getWiring(); // method is public
+ * </pre>
+ * Problem: getWiring not yet implementd
+ *
+ * Option B:
+ * <pre>
+ * Concierge concierge = new Concierge(...);
+ * BundleWiring bundleWiring = concierge.adapt(org.osgi.framework.wiring.BundleWiring);
+ * </pre>
+ * Same approach as done in Felix.
+ *
+ */
+ if (Concierge_BundleWiring_Class == null) {
+ Concierge_BundleWiring_Class = bundle.getClass().getClassLoader().loadClass("org.osgi.framework.wiring.BundleWiring");
+ Concierge_BundleImpl_Adapt_Method = Concierge_BundleImpl_Class.getMethod("adapt", new Class[] {Class.class});
+ Concierge_BundleImpl_Adapt_Method.setAccessible(true);
+ Concierge_BundleWiring_getClassLoader_Method = Concierge_BundleWiring_Class.getMethod("getClassLoader");
+ Concierge_BundleWiring_getClassLoader_Method.setAccessible(true);
+ }
+
+ Object wiring = Concierge_BundleImpl_Adapt_Method.invoke(bundle, new Object[] {Concierge_BundleWiring_Class});
+ ClassLoader cl = (ClassLoader)Concierge_BundleWiring_getClassLoader_Method.invoke(wiring);
+ return cl;
+ }
+ catch (Exception e)
+ {
+ LOG.warn(e);
+ return null;
+ }
+ }
+
+ LOG.warn("No classloader for Concierge platform for bundle "+bundle.getSymbolicName());
+ return null;
+ }
}

Back to the top