Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2003, 2009 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: IBM Corporation - initial API and implementation /
 
 
 package org.eclipse.osgi.internal.loader;
 
 import java.net.URL;
The System Bundle's BundleLoader. This BundleLoader is used by ImportClassLoaders to load a resource that is exported by the System Bundle.
 
 public class SystemBundleLoader extends BundleLoader {
 	public static final String EQUINOX_EE = "x-equinox-ee"//$NON-NLS-1$
 	private final ClassLoader classLoader;
 	private final HashSet eePackages;
 	private final HashSet extPackages;
 	private final ClassLoader extClassLoader;

Parameters:
bundle The system bundle.
proxy The BundleLoaderProxy for the system bundle
Throws:
org.osgi.framework.BundleException On any error.
 
 	protected SystemBundleLoader(BundleHost bundleBundleLoaderProxy proxythrows BundleException {
 		super(bundleproxy);
 		if (exports == null || exports.length == 0)
 			 = null;
 		else {
 			 = new HashSet(exports.length);
 			for (int i = 0; i < exports.lengthi++)
 				if (((Integerexports[i].getDirective()).intValue() >= 0)
 					.add(exports[i].getName());
 		}
 		 = new HashSet(0); // not common; start with 0
 		BundleFragment[] fragments = bundle.getFragments();
 		if (fragments != null)
 			for (int i = 0; i < fragments.lengthi++)
 				addExtPackages(fragments[i]);
 		ClassLoader extCL = ClassLoader.getSystemClassLoader();
 		if (extCL == null)
 			 = null;
 		else {
 			while (extCL.getParent() != null)
 				extCL = extCL.getParent();
 			// make sure extCL is not already on the parent chain of the system classloader
 			boolean found = false;
 			ClassLoader systemExtCL = this.;
 			while (systemExtCL.getParent() != null && !found) {
 				if (systemExtCL.getParent() == extCL)
 					found = true;
 				else
 					systemExtCL = systemExtCL.getParent();
 			}
 			 = found ? null : extCL;
 		}
 	}
 
 	private void addExtPackages(BundleFragment fragment) {
 			return;
 		for (int j = 0; j < extExports.lengthj++)
 			.add(extExports[j].getName());
 	}
 
 	synchronized public void attachFragment(BundleFragment fragmentthrows BundleException {
 		super.attachFragment(fragment);
 		synchronized () {
 			addExtPackages(fragment);
 		}
 	}

The ClassLoader that loads OSGi framework classes is used to find the class. This method never gets called because there is no BundleClassLoader for the framework.
 
 	public Class findClass(String namethrows ClassNotFoundException {
 		Class result = findLocalClass(name);
 		if (result == null)
			throw new ClassNotFoundException(name);
		return result;
	}

This method will always return null. This method never gets called because there is no BundleClassLoader for the framework.
	public String findLibrary(String name) {
		return null;
	}

The ClassLoader that loads OSGi framework classes is used to find the class.
		try {
			return .loadClass(name);
catch (ClassNotFoundException e) {
			if ( != null)
				synchronized () {
					if (.size() > 0 && .contains(BundleLoader.getPackageName(name)))
						try {
catch (ClassNotFoundException e2) {
							return null;
						}
				}
		}
		return null;
	}

The ClassLoader that loads OSGi framework classes is used to find the resource.
		URL result = .getResource(name);
		if (result == null &&  != null)
			synchronized () {
				if (.size() > 0 && .contains(BundleLoader.getResourcePackageName(name)))
					result = .getResource(name);
			}
		return result;
	}

The ClassLoader that loads OSGi framework classes is used to find the resource.
		Enumeration result = null;
		try {
			result = .getResources(name);
catch (IOException e) {
			// do nothing
		}
		if ((result == null || !result.hasMoreElements()) &&  != null)
			synchronized () {
				if (.size() > 0 && .contains(BundleLoader.getResourcePackageName(name)))
					try {
						result = .getResources(name);
catch (IOException e) {
						// do nothing
					}
			}
		return result;
	}

The ClassLoader that loads OSGi framework classes is used to find the resource. This method never gets called because there is no BundleClassLoader for the framework.
	public URL findResource(String name) {
		return findLocalResource(name);
	}

The ClassLoader that loads OSGi framework classes is used to find the resource. This method never gets called because there is no BundleClassLoader for the framework.
	public Enumeration findResources(String namethrows IOException {
		return findLocalResources(name);
	}

Do nothing on a close.
	protected void close() {
		// Do nothing.
	}
	public boolean isEEPackage(String pkgName) {
		return .contains(pkgName);
	}
		return new BundleClassLoader() {
			public Bundle getBundle() {
			}
			public Class loadClass(String namethrows ClassNotFoundException {
				return SystemBundleLoader.this.loadClass(name);
			}
			public void initialize() {
				// nothing
			}
			public Enumeration getResources(String namethrows IOException {
				return findLocalResources(name);
			}
			public URL getResource(String name) {
			}
			public ClassLoader getParent() {
			}
				return SystemBundleLoader.this;
			}
			public Enumeration findLocalResources(String resource) {
				return SystemBundleLoader.this.findLocalResources(resource);
			}
			public URL findLocalResource(String resource) {
				return getResource(resource);
			}
			public Class findLocalClass(String classnamethrows ClassNotFoundException {
				return SystemBundleLoader.this.findLocalClass(classname);
			}
			public void close() {
				// nothing
			}
			public void attachFragment(BundleData bundledataProtectionDomain domainString[] classpath) {
				// nothing
			}
		};
	}
New to GrepCode? Check out our FAQ X