Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Bartel2012-05-09 07:33:44 +0000
committerJan Bartel2012-05-09 07:33:44 +0000
commiteae1b011222bdc67a7d47efd278275e9aeafefca (patch)
tree22e4587bae6bd8b923137f60b177da35165efd9e /jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/DefaultBundleClassLoaderHelper.java
parentd0f35d10fd7f50d921daf9ff1c8e7a33f8cc7a17 (diff)
downloadorg.eclipse.jetty.project-eae1b011222bdc67a7d47efd278275e9aeafefca.tar.gz
org.eclipse.jetty.project-eae1b011222bdc67a7d47efd278275e9aeafefca.tar.xz
org.eclipse.jetty.project-eae1b011222bdc67a7d47efd278275e9aeafefca.zip
Reformat and reindent code.
Diffstat (limited to 'jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/DefaultBundleClassLoaderHelper.java')
-rw-r--r--jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/DefaultBundleClassLoaderHelper.java42
1 files changed, 22 insertions, 20 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 905285b71c..8a80f6173b 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
@@ -29,7 +29,9 @@ public class DefaultBundleClassLoaderHelper implements BundleClassLoaderHelper
{
private static boolean identifiedOsgiImpl = false;
+
private static boolean isEquinox = false;
+
private static boolean isFelix = false;
private static void init(Bundle bundle)
@@ -66,10 +68,10 @@ public class DefaultBundleClassLoaderHelper implements BundleClassLoaderHelper
*/
public ClassLoader getBundleClassLoader(Bundle bundle)
{
- String bundleActivator = (String)bundle.getHeaders().get("Bundle-Activator");
+ String bundleActivator = (String) bundle.getHeaders().get("Bundle-Activator");
if (bundleActivator == null)
{
- bundleActivator = (String)bundle.getHeaders().get("Jetty-ClassInBundle");
+ bundleActivator = (String) bundle.getHeaders().get("Jetty-ClassInBundle");
}
if (bundleActivator != null)
{
@@ -93,14 +95,12 @@ public class DefaultBundleClassLoaderHelper implements BundleClassLoaderHelper
{
return internalGetEquinoxBundleClassLoader(bundle);
}
- else if (isFelix)
- {
- return internalGetFelixBundleClassLoader(bundle);
- }
+ else if (isFelix) { return internalGetFelixBundleClassLoader(bundle); }
return null;
}
private static Method Equinox_BundleHost_getBundleLoader_method;
+
private static Method Equinox_BundleLoader_createClassLoader_method;
private static ClassLoader internalGetEquinoxBundleClassLoader(Bundle bundle)
@@ -111,17 +111,18 @@ public class DefaultBundleClassLoaderHelper implements BundleClassLoaderHelper
if (Equinox_BundleHost_getBundleLoader_method == null)
{
Equinox_BundleHost_getBundleLoader_method = bundle.getClass().getClassLoader().loadClass("org.eclipse.osgi.framework.internal.core.BundleHost")
- .getDeclaredMethod("getBundleLoader",new Class[] {});
+ .getDeclaredMethod("getBundleLoader", new Class[] {});
Equinox_BundleHost_getBundleLoader_method.setAccessible(true);
}
- Object bundleLoader = Equinox_BundleHost_getBundleLoader_method.invoke(bundle,new Object[] {});
+ Object bundleLoader = Equinox_BundleHost_getBundleLoader_method.invoke(bundle, new Object[] {});
if (Equinox_BundleLoader_createClassLoader_method == null && bundleLoader != null)
{
- Equinox_BundleLoader_createClassLoader_method = bundleLoader.getClass().getClassLoader().loadClass(
- "org.eclipse.osgi.internal.loader.BundleLoader").getDeclaredMethod("createClassLoader",new Class[] {});
+ Equinox_BundleLoader_createClassLoader_method = bundleLoader.getClass().getClassLoader()
+ .loadClass("org.eclipse.osgi.internal.loader.BundleLoader")
+ .getDeclaredMethod("createClassLoader", new Class[] {});
Equinox_BundleLoader_createClassLoader_method.setAccessible(true);
}
- return (ClassLoader)Equinox_BundleLoader_createClassLoader_method.invoke(bundleLoader,new Object[] {});
+ return (ClassLoader) Equinox_BundleLoader_createClassLoader_method.invoke(bundleLoader, new Object[] {});
}
catch (Throwable t)
{
@@ -131,6 +132,7 @@ public class DefaultBundleClassLoaderHelper implements BundleClassLoaderHelper
}
private static Field Felix_BundleImpl_m_modules_field;
+
private static Field Felix_ModuleImpl_m_classLoader_field;
private static ClassLoader internalGetFelixBundleClassLoader(Bundle bundle)
@@ -142,8 +144,8 @@ public class DefaultBundleClassLoaderHelper implements BundleClassLoaderHelper
// and return the private field m_classLoader of ModuleImpl
if (Felix_BundleImpl_m_modules_field == null)
{
- Felix_BundleImpl_m_modules_field = bundle.getClass().getClassLoader().loadClass("org.apache.felix.framework.BundleImpl").getDeclaredField(
- "m_modules");
+ Felix_BundleImpl_m_modules_field = bundle.getClass().getClassLoader().loadClass("org.apache.felix.framework.BundleImpl")
+ .getDeclaredField("m_modules");
Felix_BundleImpl_m_modules_field.setAccessible(true);
}
@@ -151,26 +153,26 @@ public class DefaultBundleClassLoaderHelper implements BundleClassLoaderHelper
Object currentModuleImpl;
try
{
- Object[] moduleArray = (Object[])Felix_BundleImpl_m_modules_field.get(bundle);
+ Object[] moduleArray = (Object[]) Felix_BundleImpl_m_modules_field.get(bundle);
currentModuleImpl = moduleArray[moduleArray.length - 1];
}
catch (Throwable t2)
{
@SuppressWarnings("unchecked")
- List<Object> moduleArray = (List<Object>)Felix_BundleImpl_m_modules_field.get(bundle);
+ List<Object> moduleArray = (List<Object>) Felix_BundleImpl_m_modules_field.get(bundle);
currentModuleImpl = moduleArray.get(moduleArray.size() - 1);
}
-
+
if (Felix_ModuleImpl_m_classLoader_field == null && currentModuleImpl != null)
{
- Felix_ModuleImpl_m_classLoader_field = bundle.getClass().getClassLoader().loadClass("org.apache.felix.framework.ModuleImpl").getDeclaredField(
- "m_classLoader");
+ Felix_ModuleImpl_m_classLoader_field = bundle.getClass().getClassLoader().loadClass("org.apache.felix.framework.ModuleImpl")
+ .getDeclaredField("m_classLoader");
Felix_ModuleImpl_m_classLoader_field.setAccessible(true);
}
// first make sure that the classloader is ready:
// the m_classLoader field must be initialized by the
// ModuleImpl.getClassLoader() private method.
- ClassLoader cl = (ClassLoader)Felix_ModuleImpl_m_classLoader_field.get(currentModuleImpl);
+ ClassLoader cl = (ClassLoader) Felix_ModuleImpl_m_classLoader_field.get(currentModuleImpl);
if (cl == null)
{
// looks like it was not ready:
@@ -178,7 +180,7 @@ public class DefaultBundleClassLoaderHelper implements BundleClassLoaderHelper
// ModuleImpl.getClassLoader() private method.
// this call will do that.
bundle.loadClass("java.lang.Object");
- cl = (ClassLoader)Felix_ModuleImpl_m_classLoader_field.get(currentModuleImpl);
+ cl = (ClassLoader) Felix_ModuleImpl_m_classLoader_field.get(currentModuleImpl);
// System.err.println("Got the bundle class loader of felix_: "
// + cl);
return cl;

Back to the top