refactored to eliminate duplicate names for Bundle, BundleContext,
PackageAdmin, Filter, PermissionAdmin, ServiceReference,
ServiceRegistration, BundleLocalization, PermissionStorage, StartLevel
diff --git a/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandInterpreter.java b/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandInterpreter.java
index 2fcaa89..026d11b 100644
--- a/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandInterpreter.java
+++ b/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandInterpreter.java
@@ -322,7 +322,7 @@
* @param bundle the bundle containing the resource
* @param resource the resource to print
*/
- public void printBundleResource(Bundle bundle, String resource) {
+ public void printBundleResource(AbstractBundle bundle, String resource) {
URL entry = null;
entry = bundle.getEntry(resource);
if (entry != null) {
diff --git a/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandProvider.java b/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandProvider.java
index c50ab12..6d161bd 100644
--- a/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandProvider.java
+++ b/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandProvider.java
@@ -76,7 +76,7 @@
/** The system bundle context */
private org.osgi.framework.BundleContext context;
/** The start level implementation */
- private StartLevelImpl slImpl;
+ private StartLevelManager slImpl;
/** Strings used to format other strings */
private String tab = "\t";
@@ -92,7 +92,7 @@
public FrameworkCommandProvider(OSGi osgi) {
this.osgi = osgi;
context = osgi.getBundleContext();
- slImpl = osgi.framework.startLevelImpl;
+ slImpl = osgi.framework.startLevelManager;
Dictionary props = new Hashtable();
props.put(Constants.SERVICE_RANKING, new Integer(Integer.MAX_VALUE));
context.registerService(CommandProvider.class.getName(), this, props);
@@ -221,7 +221,7 @@
intp.println(ConsoleMsg.formatter.getString("CONSOLE_NO_BUNDLE_SPECIFIED_ERROR"));
}
while (nextArg != null) {
- Bundle bundle = getBundleFromToken(intp, nextArg, true);
+ AbstractBundle bundle = getBundleFromToken(intp, nextArg, true);
if (bundle != null) {
bundle.start();
}
@@ -249,7 +249,7 @@
intp.println(ConsoleMsg.formatter.getString("CONSOLE_NO_BUNDLE_SPECIFIED_ERROR"));
}
while (nextArg != null) {
- Bundle bundle = getBundleFromToken(intp, nextArg, true);
+ AbstractBundle bundle = getBundleFromToken(intp, nextArg, true);
if (bundle != null) {
bundle.stop();
}
@@ -276,7 +276,7 @@
if (url == null) {
intp.println(ConsoleMsg.formatter.getString("CONSOLE_NOTHING_TO_INSTALL_ERROR"));
} else {
- Bundle bundle = (Bundle) context.installBundle(url);
+ AbstractBundle bundle = (AbstractBundle) context.installBundle(url);
intp.print(ConsoleMsg.formatter.getString("CONSOLE_BUNDLE_ID_MESSAGE"));
intp.println(new Long(bundle.getBundleId()));
@@ -314,13 +314,13 @@
while (token != null) {
if ("*".equals(token)) {
- Bundle[] bundles = (Bundle[]) context.getBundles();
+ AbstractBundle[] bundles = (AbstractBundle[]) context.getBundles();
int size = bundles.length;
if (size > 0) {
for (int i = 0; i < size; i++) {
- Bundle bundle = bundles[i];
+ AbstractBundle bundle = bundles[i];
if (bundle.getBundleId() != 0) {
try {
@@ -334,7 +334,7 @@
intp.println(ConsoleMsg.formatter.getString("CONSOLE_NO_INSTALLED_BUNDLES_ERROR"));
}
} else {
- Bundle bundle = getBundleFromToken(intp, token, true);
+ AbstractBundle bundle = getBundleFromToken(intp, token, true);
if (bundle != null) {
String source = intp.nextArgument();
try {
@@ -372,7 +372,7 @@
intp.println(ConsoleMsg.formatter.getString("CONSOLE_NO_BUNDLE_SPECIFIED_ERROR"));
}
while (nextArg != null) {
- Bundle bundle = getBundleFromToken(intp, nextArg, true);
+ AbstractBundle bundle = getBundleFromToken(intp, nextArg, true);
if (bundle != null) {
bundle.uninstall();
}
@@ -402,7 +402,7 @@
}
intp.println();
- Bundle[] bundles = (Bundle[]) context.getBundles();
+ AbstractBundle[] bundles = (AbstractBundle[]) context.getBundles();
int size = bundles.length;
if (size == 0) {
@@ -414,7 +414,7 @@
intp.println(ConsoleMsg.formatter.getString("CONSOLE_BUNDLE_LOCATION_MESSAGE"));
intp.println(ConsoleMsg.formatter.getString("CONSOLE_STATE_BUNDLE_FILE_NAME_HEADER"));
for (int i = 0; i < size; i++) {
- Bundle bundle = bundles[i];
+ AbstractBundle bundle = bundles[i];
intp.print(new Long(bundle.getBundleId()));
intp.print(tab);
intp.println(bundle.getLocation());
@@ -423,7 +423,7 @@
intp.println(bundle.bundledata);
}
- ServiceReference[] services = (ServiceReference[]) context.getServiceReferences(null, null);
+ ServiceReferenceImpl[] services = (ServiceReferenceImpl[]) context.getServiceReferences(null, null);
if (services != null) {
intp.println(ConsoleMsg.formatter.getString("CONSOLE_REGISTERED_SERVICES_MESSAGE"));
size = services.length;
@@ -461,18 +461,18 @@
filter = buf.toString();
}
- ServiceReference[] services = (ServiceReference[]) context.getServiceReferences(null, filter);
+ ServiceReferenceImpl[] services = (ServiceReferenceImpl[]) context.getServiceReferences(null, filter);
if (services != null) {
int size = services.length;
if (size > 0) {
for (int j = 0; j < size; j++) {
- ServiceReference service = services[j];
+ ServiceReferenceImpl service = services[j];
intp.println(service);
intp.print(" ");
intp.print(ConsoleMsg.formatter.getString("CONSOLE_REGISTERED_BY_BUNDLE_MESSAGE"));
intp.print(" ");
intp.println(service.getBundle());
- Bundle[] users = (Bundle[]) service.getUsingBundles();
+ AbstractBundle[] users = (AbstractBundle[]) service.getUsingBundles();
if (users != null) {
intp.print(" ");
intp.println(ConsoleMsg.formatter.getString("CONSOLE_BUNDLES_USING_SERVICE_MESSAGE"));
@@ -580,7 +580,7 @@
* @param intp A CommandInterpreter object containing the command and it's arguments.
*/
public void _bundles(CommandInterpreter intp) throws Exception {
- Bundle[] bundles = (Bundle[]) context.getBundles();
+ AbstractBundle[] bundles = (AbstractBundle[]) context.getBundles();
int size = bundles.length;
if (size == 0) {
@@ -589,7 +589,7 @@
}
for (int i = 0; i < size; i++) {
- Bundle bundle = bundles[i];
+ AbstractBundle bundle = bundles[i];
long id = bundle.getBundleId();
intp.println(bundle);
intp.print(" ");
@@ -606,7 +606,7 @@
intp.println();
}
- ServiceReference[] services = (ServiceReference[]) bundle.getRegisteredServices();
+ ServiceReferenceImpl[] services = (ServiceReferenceImpl[]) bundle.getRegisteredServices();
if (services != null) {
intp.print(" ");
intp.println(ConsoleMsg.formatter.getString("CONSOLE_REGISTERED_SERVICES_MESSAGE"));
@@ -619,7 +619,7 @@
intp.println(ConsoleMsg.formatter.getString("CONSOLE_NO_REGISTERED_SERVICES_MESSAGE"));
}
- services = (ServiceReference[]) bundle.getServicesInUse();
+ services = (ServiceReferenceImpl[]) bundle.getServicesInUse();
if (services != null) {
intp.print(" ");
intp.println(ConsoleMsg.formatter.getString("CONSOLE_SERVICES_IN_USE_MESSAGE"));
@@ -654,7 +654,7 @@
intp.println(ConsoleMsg.formatter.getString("CONSOLE_NO_BUNDLE_SPECIFIED_ERROR"));
}
while (nextArg != null) {
- Bundle bundle = getBundleFromToken(intp, nextArg, true);
+ AbstractBundle bundle = getBundleFromToken(intp, nextArg, true);
if (bundle != null) {
long id = bundle.getBundleId();
intp.println(bundle);
@@ -672,7 +672,7 @@
intp.println();
}
- ServiceReference[] services = (ServiceReference[]) bundle.getRegisteredServices();
+ ServiceReferenceImpl[] services = (ServiceReferenceImpl[]) bundle.getRegisteredServices();
if (services != null) {
intp.print(" ");
intp.println(ConsoleMsg.formatter.getString("CONSOLE_REGISTERED_SERVICES_MESSAGE"));
@@ -685,7 +685,7 @@
intp.println(ConsoleMsg.formatter.getString("CONSOLE_NO_REGISTERED_SERVICES_MESSAGE"));
}
- services = (ServiceReference[]) bundle.getServicesInUse();
+ services = (ServiceReferenceImpl[]) bundle.getServicesInUse();
if (services != null) {
intp.print(" ");
intp.println(ConsoleMsg.formatter.getString("CONSOLE_SERVICES_IN_USE_MESSAGE"));
@@ -774,7 +774,7 @@
}
intp.print(" ");
- if ((packageAdmin.getBundleType(bundle) & PackageAdmin.BUNDLE_TYPE_FRAGMENT) > 0) {
+ if ((packageAdmin.getBundleType(bundle) & PackageAdminImpl.BUNDLE_TYPE_FRAGMENT) > 0) {
org.osgi.framework.Bundle[] hosts = packageAdmin.getHosts(bundle);
if (hosts != null) {
intp.println(ConsoleMsg.formatter.getString("CONSOLE_HOST_MESSAGE"));
@@ -897,7 +897,7 @@
long logid = -1;
String token = intp.nextArgument();
if (token != null) {
- Bundle bundle = getBundleFromToken(intp, token, false);
+ AbstractBundle bundle = getBundleFromToken(intp, token, false);
if (bundle == null) {
try {
@@ -927,7 +927,7 @@
Method getException = clazz.getMethod("getException", null);
while (true) {
- Bundle bundle = (Bundle) getBundle.invoke(logentry, null);
+ AbstractBundle bundle = (AbstractBundle) getBundle.invoke(logentry, null);
if ((logid == -1) || ((bundle != null) && (logid == bundle.getBundleId()))) {
Integer level = (Integer) getLevel.invoke(logentry, null);
@@ -968,7 +968,7 @@
intp.print(getMessage.invoke(logentry, null));
intp.print(" ");
- ServiceReference svcref = (ServiceReference) getServiceReference.invoke(logentry, null);
+ ServiceReferenceImpl svcref = (ServiceReferenceImpl) getServiceReference.invoke(logentry, null);
if (svcref != null) {
intp.print("{");
intp.print(Constants.SERVICE_ID);
@@ -1044,13 +1044,13 @@
return;
}
- Bundle[] bundles = (Bundle[]) context.getBundles();
+ AbstractBundle[] bundles = (AbstractBundle[]) context.getBundles();
int size = bundles.length;
if (size > 0) {
for (int i = 0; i < size; i++) {
- Bundle bundle = bundles[i];
+ AbstractBundle bundle = bundles[i];
if (bundle.getBundleId() != 0) {
try {
@@ -1096,14 +1096,14 @@
org.osgi.service.packageadmin.PackageAdmin packageAdmin = (org.osgi.service.packageadmin.PackageAdmin) context.getService(packageAdminRef);
if (packageAdmin != null) {
try {
- Bundle[] refresh = null;
+ AbstractBundle[] refresh = null;
String token = intp.nextArgument();
if (token != null) {
Vector bundles = new Vector();
while (token != null) {
- Bundle bundle = getBundleFromToken(intp, token, true);
+ AbstractBundle bundle = getBundleFromToken(intp, token, true);
if (bundle != null) {
bundles.addElement(bundle);
@@ -1118,7 +1118,7 @@
return;
}
- refresh = new Bundle[size];
+ refresh = new AbstractBundle[size];
bundles.copyInto(refresh);
}
@@ -1190,7 +1190,7 @@
intp.println(ConsoleMsg.formatter.getString("CONSOLE_NO_BUNDLE_SPECIFIED_ERROR"));
}
while (nextArg != null) {
- Bundle bundle = getBundleFromToken(intp, nextArg, true);
+ AbstractBundle bundle = getBundleFromToken(intp, nextArg, true);
if (bundle != null) {
intp.printDictionary(bundle.getHeaders(), ConsoleMsg.formatter.getString("CONSOLE_BUNDLE_HEADERS_TITLE"));
}
@@ -1274,7 +1274,7 @@
intp.println(ConsoleMsg.formatter.getString("CONSOLE_FRAMEWORK_IS_SHUTDOWN_MESSAGE"));
}
- Bundle[] bundles = (Bundle[]) context.getBundles();
+ AbstractBundle[] bundles = (AbstractBundle[]) context.getBundles();
if (bundles.length == 0) {
intp.println(ConsoleMsg.formatter.getString("CONSOLE_NO_INSTALLED_BUNDLES_ERROR"));
} else {
@@ -1285,20 +1285,20 @@
intp.print(tab);
intp.println(ConsoleMsg.formatter.getString("CONSOLE_STATE_BUNDLE_TITLE"));
for (int i = 0; i < bundles.length; i++) {
- Bundle b = (Bundle) bundles[i];
+ AbstractBundle b = (AbstractBundle) bundles[i];
String type = " ";
// :TODO need to determine the type?
intp.println(b.getBundleId() + "\t" + type + " \t" + getStateName(b.getState()) + b);
if (b.isFragment()) {
- Bundle master = (Bundle) b.getHost();
+ AbstractBundle master = (AbstractBundle) b.getHost();
if (master != null)
intp.println("\t\tMaster=" + master.getBundleId());
} else {
- Bundle fragment;
+ AbstractBundle fragment;
org.osgi.framework.Bundle fragments[] = b.getFragments();
if (fragments != null) {
for (int f = 0; f < fragments.length; f++) {
- fragment = (Bundle) fragments[f];
+ fragment = (AbstractBundle) fragments[f];
intp.println("\t\tFragment=" + fragment.getBundleId());
}
}
@@ -1419,7 +1419,7 @@
public void _setbsl(CommandInterpreter intp) throws Exception {
if (isStartLevelSvcPresent(intp)) {
String token;
- Bundle bundle = null;
+ AbstractBundle bundle = null;
token = intp.nextArgument();
if (token == null) {
intp.println(ConsoleMsg.formatter.getString("STARTLEVEL_NO_STARTLEVEL_OR_BUNDLE_GIVEN"));
@@ -1560,13 +1560,13 @@
* @param A boolean indicating whether or not to output a message
* @return The requested Bundle object
*/
- protected Bundle getBundleFromToken(CommandInterpreter intp, String token, boolean error) {
- Bundle bundle;
+ protected AbstractBundle getBundleFromToken(CommandInterpreter intp, String token, boolean error) {
+ AbstractBundle bundle;
try {
long id = Long.parseLong(token);
- bundle = (Bundle) context.getBundle(id);
+ bundle = (AbstractBundle) context.getBundle(id);
} catch (NumberFormatException nfe) {
- bundle = ((BundleContext) context).getBundleByLocation(token);
+ bundle = ((BundleContextImpl) context).getBundleByLocation(token);
}
if ((bundle == null) && error) {
@@ -1604,22 +1604,22 @@
*/
protected String getStateName(int state) {
switch (state) {
- case Bundle.UNINSTALLED :
+ case AbstractBundle.UNINSTALLED :
return (ConsoleMsg.formatter.getString("CONSOLE_UNINSTALLED_MESSAGE"));
- case Bundle.INSTALLED :
+ case AbstractBundle.INSTALLED :
return (ConsoleMsg.formatter.getString("CONSOLE_INSTALLED_MESSAGE"));
- case Bundle.RESOLVED :
+ case AbstractBundle.RESOLVED :
return (ConsoleMsg.formatter.getString("CONSOLE_RESOLVED_MESSAGE"));
- case Bundle.STARTING :
+ case AbstractBundle.STARTING :
return (ConsoleMsg.formatter.getString("CONSOLE_STARTING_MESSAGE"));
- case Bundle.STOPPING :
+ case AbstractBundle.STOPPING :
return (ConsoleMsg.formatter.getString("CONSOLE_STOPPING_MESSAGE"));
- case Bundle.ACTIVE :
+ case AbstractBundle.ACTIVE :
return (ConsoleMsg.formatter.getString("CONSOLE_ACTIVE_MESSAGE"));
default :
diff --git a/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/framework/util/PermissionStorage.java b/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/framework/util/SecurePermissionStorage.java
similarity index 87%
rename from bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/framework/util/PermissionStorage.java
rename to bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/framework/util/SecurePermissionStorage.java
index b513ec9..d814f1d 100644
--- a/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/framework/util/PermissionStorage.java
+++ b/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/framework/util/SecurePermissionStorage.java
@@ -13,13 +13,14 @@
import java.io.IOException;
import java.security.*;
+import org.eclipse.osgi.framework.adaptor.PermissionStorage;
/**
* PermissionStorage privileged action class.
*/
-public class PermissionStorage implements org.eclipse.osgi.framework.adaptor.PermissionStorage, PrivilegedExceptionAction {
- private org.eclipse.osgi.framework.adaptor.PermissionStorage storage;
+public class SecurePermissionStorage implements PermissionStorage, PrivilegedExceptionAction {
+ private PermissionStorage storage;
private String location;
private String[] data;
private int action;
@@ -27,7 +28,7 @@
private static final int SET = 2;
private static final int LOCATION = 3;
- public PermissionStorage(org.eclipse.osgi.framework.adaptor.PermissionStorage storage) {
+ public SecurePermissionStorage(PermissionStorage storage) {
this.storage = storage;
}
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/console/CommandInterpreter.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/console/CommandInterpreter.java
index b4d2128..55f859b 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/console/CommandInterpreter.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/console/CommandInterpreter.java
@@ -12,7 +12,7 @@
package org.eclipse.osgi.framework.console;
import java.util.Dictionary;
-import org.eclipse.osgi.framework.internal.core.Bundle;
+import org.eclipse.osgi.framework.internal.core.AbstractBundle;
/** A command interpreter is a shell that can interpret command
* lines. This object is passed as parameter when a CommandProvider
@@ -83,6 +83,6 @@
* @param bundle the bundle containing the resource
* @param resource the resource to print
*/
- public void printBundleResource(Bundle bundle, String resource);
+ public void printBundleResource(AbstractBundle bundle, String resource);
}
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Bundle.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/AbstractBundle.java
similarity index 96%
rename from bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Bundle.java
rename to bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/AbstractBundle.java
index 6665d7c..bce9b17 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Bundle.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/AbstractBundle.java
@@ -25,7 +25,7 @@
* is destroyed when a bundle is uninstalled and reused if a bundle is updated.
* This class is abstract and is extended by BundleHost and BundleFragment.
*/
-public abstract class Bundle implements org.osgi.framework.Bundle, Comparable, KeyedElement {
+public abstract class AbstractBundle implements Bundle, Comparable, KeyedElement {
/** The Framework this bundle is part of */
protected Framework framework;
/** The state of the bundle. */
@@ -57,7 +57,7 @@
* @param framework
* Framework this bundle is running in
*/
- protected static Bundle createBundle(BundleData bundledata, Framework framework) throws BundleException {
+ protected static AbstractBundle createBundle(BundleData bundledata, Framework framework) throws BundleException {
if (bundledata.isFragment())
return new BundleFragment(bundledata, framework);
else
@@ -72,7 +72,7 @@
* @param framework
* Framework this bundle is running in
*/
- protected Bundle(BundleData bundledata, Framework framework) throws BundleException {
+ protected AbstractBundle(BundleData bundledata, Framework framework) throws BundleException {
state = INSTALLED;
stateChanging = null;
this.bundledata = bundledata;
@@ -95,7 +95,7 @@
* imported by a bundle
* @exception org.osgi.framework.BundleException
*/
- protected abstract boolean reload(Bundle newBundle) throws BundleException;
+ protected abstract boolean reload(AbstractBundle newBundle) throws BundleException;
/**
* Refresh the bundle. This is called by Framework.refreshPackages. This
* method must be called while holding the bundles lock.
@@ -661,9 +661,9 @@
*/
protected void updateWorker(PrivilegedExceptionAction action) throws BundleException {
boolean bundleActive = false;
- Bundle host = null;
+ AbstractBundle host = null;
if (isFragment()) {
- host = (Bundle) getHost();
+ host = (AbstractBundle) getHost();
bundleActive = (host == null ? false : (host.state == ACTIVE));
} else {
bundleActive = (state == ACTIVE);
@@ -705,18 +705,18 @@
* Update worker. Assumes the caller has the state change lock.
*/
protected void updateWorkerPrivileged(URLConnection source) throws BundleException {
- Bundle oldBundle = Bundle.createBundle(bundledata, framework);
+ AbstractBundle oldBundle = AbstractBundle.createBundle(bundledata, framework);
boolean reloaded = false;
BundleOperation storage = framework.adaptor.updateBundle(this.bundledata, source);
BundleRepository bundles = framework.getBundles();
try {
BundleData newBundleData = storage.begin();
// Must call framework createBundle to check execution environment.
- Bundle newBundle = framework.createBundle(newBundleData);
+ AbstractBundle newBundle = framework.createBundle(newBundleData);
// Check for a bundle already installed with the same symbolicName
// and version.
String symbolicName = newBundle.getSymbolicName();
- Bundle installedBundle = symbolicName == null ? null : framework.getBundleByUniqueId(symbolicName, newBundle.getVersion().toString());
+ AbstractBundle installedBundle = symbolicName == null ? null : framework.getBundleByUniqueId(symbolicName, newBundle.getVersion().toString());
if (installedBundle != null && installedBundle != this) {
throw new BundleException(Msg.formatter.getString("BUNDLE_INSTALL_SAME_UNIQUEID", new Object[] {installedBundle.getSymbolicName(), installedBundle.getVersion(), installedBundle.getLocation()}));
}
@@ -823,9 +823,9 @@
*/
protected void uninstallWorker(PrivilegedExceptionAction action) throws BundleException {
boolean bundleActive = false;
- Bundle host = null;
+ AbstractBundle host = null;
if (isFragment()) {
- host = (Bundle) getHost();
+ host = (AbstractBundle) getHost();
bundleActive = (host == null ? false : (host.state == ACTIVE));
} else {
bundleActive = (state == ACTIVE);
@@ -1031,7 +1031,7 @@
/**
* Retrieve the location identifier of the bundle. This is typically the
* location passed to
- * {@link BundleContext#installBundle(String) BundleContext.installBundle}when the
+ * {@link BundleContextImpl#installBundle(String) BundleContext.installBundle}when the
* bundle was installed. The location identifier of the bundle may change
* during bundle update. Calling this method while framework is updating
* the bundle results in undefined behavior.
@@ -1051,7 +1051,7 @@
return (bundledata.getLocation());
}
/**
- * Provides a list of {@link ServiceReference}s for the services
+ * Provides a list of {@link ServiceReferenceImpl}s for the services
* registered by this bundle or <code>null</code> if the bundle has no
* registered services.
*
@@ -1060,15 +1060,15 @@
* framework is a very dynamic environment and services can be modified or
* unregistered at anytime.
*
- * @return An array of {@link ServiceReference}or <code>null</code>.
+ * @return An array of {@link ServiceReferenceImpl}or <code>null</code>.
* @exception java.lang.IllegalStateException
* If the bundle has been uninstalled.
- * @see ServiceRegistration
- * @see ServiceReference
+ * @see ServiceRegistrationImpl
+ * @see ServiceReferenceImpl
*/
public abstract org.osgi.framework.ServiceReference[] getRegisteredServices();
/**
- * Provides a list of {@link ServiceReference}s for the services this
+ * Provides a list of {@link ServiceReferenceImpl}s for the services this
* bundle is using, or <code>null</code> if the bundle is not using any
* services. A bundle is considered to be using a service if the bundle's
* use count for the service is greater than zero.
@@ -1078,10 +1078,10 @@
* framework is a very dynamic environment and services can be modified or
* unregistered at anytime.
*
- * @return An array of {@link ServiceReference}or <code>null</code>.
+ * @return An array of {@link ServiceReferenceImpl}or <code>null</code>.
* @exception java.lang.IllegalStateException
* If the bundle has been uninstalled.
- * @see ServiceReference
+ * @see ServiceReferenceImpl
*/
public abstract org.osgi.framework.ServiceReference[] getServicesInUse();
/**
@@ -1203,11 +1203,11 @@
* comparable with the receiver.
*/
public int compareTo(Object obj) {
- int slcomp = getStartLevel() - ((Bundle) obj).getStartLevel();
+ int slcomp = getStartLevel() - ((AbstractBundle) obj).getStartLevel();
if (slcomp != 0) {
return slcomp;
}
- long idcomp = getBundleId() - ((Bundle) obj).getBundleId();
+ long idcomp = getBundleId() - ((AbstractBundle) obj).getBundleId();
return (idcomp < 0L) ? -1 : ((idcomp > 0L) ? 1 : 0);
}
/**
@@ -1360,7 +1360,7 @@
*
* @return BundleContext for this bundle.
*/
- abstract protected BundleContext getContext();
+ abstract protected BundleContextImpl getContext();
protected String getResolutionFailureMessage() {
String defaultMessage = Msg.formatter.getString("BUNDLE_UNRESOLVED_EXCEPTION");
// don't spend time if debug info is not needed
@@ -1407,7 +1407,7 @@
return (int) getBundleId();
}
public boolean compare(KeyedElement other) {
- return getBundleId() == ((Bundle) other).getBundleId();
+ return getBundleId() == ((AbstractBundle) other).getBundleId();
}
public Object getKey() {
return new Long(getBundleId());
@@ -1421,7 +1421,7 @@
for (int i = 0; i < pkgs.length; i++) {
// check to make sure the exporter has permissions
BundleDescription supplier = pkgs[i].getSupplier();
- Bundle supplierBundle = supplier == null ? null : framework.getBundle(supplier.getBundleId());
+ AbstractBundle supplierBundle = supplier == null ? null : framework.getBundle(supplier.getBundleId());
if (supplierBundle == null || !supplierBundle.checkExportPackagePermission(pkgs[i].getName())) {
permissionMsg = Msg.formatter.getString("BUNDLE_PERMISSION_EXCEPTION_EXPORT", supplierBundle, pkgs[i].getName());
return false;
@@ -1436,7 +1436,7 @@
for (int i = 0; i < bundles.length; i++) {
// check to make sure the provider has permissions
BundleDescription supplier = bundles[i].getSupplier();
- Bundle supplierBundle = supplier == null ? null : framework.getBundle(supplier.getBundleId());
+ AbstractBundle supplierBundle = supplier == null ? null : framework.getBundle(supplier.getBundleId());
if (supplierBundle == null || !supplierBundle.checkProvideBundlePermission(bundles[i].getName())) {
permissionMsg = Msg.formatter.getString("BUNDLE_PERMISSION_EXCEPTION_PROVIDE", supplierBundle, bundles[i].getName());
return false;
@@ -1451,7 +1451,7 @@
if (host != null) {
// check to make sure the host has permissions
BundleDescription supplier = host.getSupplier();
- Bundle supplierBundle = supplier == null ? null : framework.getBundle(supplier.getBundleId());
+ AbstractBundle supplierBundle = supplier == null ? null : framework.getBundle(supplier.getBundleId());
if (supplierBundle == null || !supplierBundle.checkFragmentHostPermission(host.getName())) {
permissionMsg = Msg.formatter.getString("BUNDLE_PERMISSION_EXCEPTION_HOST", supplierBundle, host.getName());
return false;
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleContext.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleContextImpl.java
similarity index 92%
rename from bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleContext.java
rename to bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleContextImpl.java
index 1867906..796bb92 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleContext.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleContextImpl.java
@@ -27,7 +27,7 @@
* BundleContext object. It is destroyed when a bundle is stopped.
*/
-public class BundleContext implements org.osgi.framework.BundleContext, EventDispatcher {
+public class BundleContextImpl implements BundleContext, EventDispatcher {
/** true if the bundle context is still valid */
private boolean valid;
@@ -69,7 +69,7 @@
*
* @param bundle The bundle we are wrapping.
*/
- protected BundleContext(BundleHost bundle) {
+ protected BundleContextImpl(BundleHost bundle) {
this.bundle = bundle;
valid = true;
framework = bundle.framework;
@@ -108,7 +108,7 @@
/* service's registered by the bundle, if any, are unregistered. */
Vector registeredServices = null;
- ServiceReference[] publishedReferences = null;
+ ServiceReferenceImpl[] publishedReferences = null;
int regSize = 0;
synchronized (framework.serviceRegistry) {
registeredServices = framework.serviceRegistry.lookupServiceReferences(this);
@@ -121,7 +121,7 @@
Debug.println("Unregistering services");
}
- publishedReferences = new ServiceReference[regSize];
+ publishedReferences = new ServiceReferenceImpl[regSize];
registeredServices.copyInto(publishedReferences);
}
}
@@ -139,7 +139,7 @@
/* service's used by the bundle, if any, are released. */
if (servicesInUse != null) {
int usedSize;
- ServiceReference[] usedRefs = null;
+ ServiceReferenceImpl[] usedRefs = null;
synchronized (servicesInUse) {
usedSize = servicesInUse.size();
@@ -149,11 +149,11 @@
Debug.println("Releasing services");
}
- usedRefs = new ServiceReference[usedSize];
+ usedRefs = new ServiceReferenceImpl[usedSize];
Enumeration enum = servicesInUse.keys();
for (int i = 0; i < usedSize; i++) {
- usedRefs[i] = (ServiceReference) enum.nextElement();
+ usedRefs[i] = (ServiceReferenceImpl) enum.nextElement();
}
}
}
@@ -252,7 +252,7 @@
* @return A Bundle object, or <code>null</code>
* if the location doesn't match any installed bundle.
*/
- public Bundle getBundleByLocation(String location) {
+ public AbstractBundle getBundleByLocation(String location) {
return (framework.getBundleByLocation(location));
}
@@ -262,7 +262,7 @@
* of the call to getBundles, but the framework is a very dynamic
* environment and bundles can be installed or uninstalled at anytime.
*
- * @return An array of {@link Bundle} objects, one
+ * @return An array of {@link AbstractBundle} objects, one
* object per installed bundle.
*/
public org.osgi.framework.Bundle[] getBundles() {
@@ -286,7 +286,7 @@
* are considered to match the filter.
* <p>If the Java runtime environment supports permissions, then additional
* filtering is done.
- * {@link Bundle#hasPermission(Object) Bundle.hasPermission} is called for the
+ * {@link AbstractBundle#hasPermission(Object) Bundle.hasPermission} is called for the
* bundle which defines the listener to validate that the listener has the
* {@link ServicePermission} permission to <code>"get"</code> the service
* using at least one of the named classes the service was registered under.
@@ -514,8 +514,8 @@
* Register a service with multiple names.
* This method registers the given service object with the given properties
* under the given class names.
- * A {@link ServiceRegistration} object is returned.
- * The {@link ServiceRegistration} object is for the private use of the bundle
+ * A {@link ServiceRegistrationImpl} object is returned.
+ * The {@link ServiceRegistrationImpl} object is for the private use of the bundle
* registering the service and should not be shared with other bundles.
* The registering bundle is defined to be the context bundle.
* See {@link #getBundle()} for a definition of context bundle.
@@ -538,7 +538,7 @@
* and may now be used by other bundles.
* <li>A {@link ServiceEvent} of type {@link ServiceEvent#REGISTERED}
* is synchronously sent.
- * <li>A {@link ServiceRegistration} object for this registration
+ * <li>A {@link ServiceRegistrationImpl} object for this registration
* is returned.
* </ol>
*
@@ -550,10 +550,10 @@
* The keys in the properties object must all be Strings.
* Changes should not be made to this object after calling this method.
* To update the service's properties call the
- * {@link ServiceRegistration#setProperties ServiceRegistration.setProperties}
+ * {@link ServiceRegistrationImpl#setProperties ServiceRegistration.setProperties}
* method.
* This parameter may be <code>null</code> if the service has no properties.
- * @return A {@link ServiceRegistration} object for use by the bundle
+ * @return A {@link ServiceRegistrationImpl} object for use by the bundle
* registering the service to update the
* service's properties or to unregister the service.
* @exception java.lang.IllegalArgumentException If one of the following is true:
@@ -568,7 +568,7 @@
* and the Java runtime environment supports permissions.
* @exception java.lang.IllegalStateException
* If the context bundle {@link <a href="#context_valid">has stopped</a>}.
- * @see ServiceRegistration
+ * @see ServiceRegistrationImpl
* @see ServiceFactory
*/
public org.osgi.framework.ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties) {
@@ -603,7 +603,7 @@
framework.checkRegisterServicePermission(clazzes);
if (!(service instanceof ServiceFactory)) {
- PackageAdmin packageAdmin = framework.packageAdmin;
+ PackageAdminImpl packageAdmin = framework.packageAdmin;
for (int i = 0; i < size; i++) {
Class clazz = packageAdmin.loadServiceClass(clazzes[i],bundle);
if (clazz == null) {
@@ -632,10 +632,10 @@
* @param clazzes The class names under which the service can be located.
* @param service The service object or a {@link ServiceFactory} object.
* @param properties The properties for this service.
- * @return A {@link ServiceRegistration} object for use by the bundle.
+ * @return A {@link ServiceRegistrationImpl} object for use by the bundle.
*/
- protected ServiceRegistration createServiceRegistration(String[] clazzes, Object service, Dictionary properties) {
- return (new ServiceRegistration(this, clazzes, service, properties));
+ protected ServiceRegistrationImpl createServiceRegistration(String[] clazzes, Object service, Dictionary properties) {
+ return (new ServiceRegistrationImpl(this, clazzes, service, properties));
}
/**
@@ -666,7 +666,7 @@
*
* <p><tt>filter</tt> is used to select the registered service whose
* properties objects contain keys and values which satisfy the filter.
- * See {@link Filter}for a description of the filter string syntax.
+ * See {@link FilterImpl}for a description of the filter string syntax.
*
* <p>If <tt>filter</tt> is <tt>null</tt>, all registered services
* are considered to match the filter.
@@ -711,7 +711,7 @@
/**
* Get a service reference.
- * Retrieves a {@link ServiceReference} for a service
+ * Retrieves a {@link ServiceReferenceImpl} for a service
* which implements the named class.
*
* <p>This reference is valid at the time
@@ -721,11 +721,11 @@
* <p>This method is provided as a convenience for when the caller is
* interested in any service which implements a named class. This method is
* the same as calling {@link #getServiceReferences getServiceReferences}
- * with a <code>null</code> filter string but only a single {@link ServiceReference}
+ * with a <code>null</code> filter string but only a single {@link ServiceReferenceImpl}
* is returned.
*
* @param clazz The class name which the service must implement.
- * @return A {@link ServiceReference} object, or <code>null</code>
+ * @return A {@link ServiceReferenceImpl} object, or <code>null</code>
* if no services are registered which implement the named class.
* @see #getServiceReferences
*/
@@ -737,7 +737,7 @@
}
try {
- ServiceReference[] references = framework.getServiceReferences(clazz, null);
+ ServiceReferenceImpl[] references = framework.getServiceReferences(clazz, null);
if (references != null) {
int index = 0;
@@ -855,11 +855,11 @@
}
}
- ServiceRegistration registration = ((ServiceReference) reference).registration;
+ ServiceRegistrationImpl registration = ((ServiceReferenceImpl) reference).registration;
framework.checkGetServicePermission(registration.clazzes);
- return registration.getService(BundleContext.this);
+ return registration.getService(BundleContextImpl.this);
}
/**
@@ -900,9 +900,9 @@
public boolean ungetService(org.osgi.framework.ServiceReference reference) {
checkValid();
- ServiceRegistration registration = ((ServiceReference) reference).registration;
+ ServiceRegistrationImpl registration = ((ServiceReferenceImpl) reference).registration;
- return registration.ungetService(BundleContext.this);
+ return registration.ungetService(BundleContextImpl.this);
}
/**
@@ -970,7 +970,7 @@
public Object run() throws Exception {
if (bundleActivator != null) {
/* Start the bundle synchronously */
- bundleActivator.start(BundleContext.this);
+ bundleActivator.start(BundleContextImpl.this);
}
return null;
}
@@ -1006,7 +1006,7 @@
public Object run() throws Exception {
if (activator != null) {
/* Stop the bundle synchronously */
- activator.stop(BundleContext.this);
+ activator.stop(BundleContextImpl.this);
}
return null;
}
@@ -1029,7 +1029,7 @@
}
/**
- * Provides a list of {@link ServiceReference}s for the services
+ * Provides a list of {@link ServiceReferenceImpl}s for the services
* registered by this bundle
* or <code>null</code> if the bundle has no registered
* services.
@@ -1038,14 +1038,14 @@
* of the call to this method, but the framework is a very dynamic
* environment and services can be modified or unregistered at anytime.
*
- * @return An array of {@link ServiceReference} or <code>null</code>.
+ * @return An array of {@link ServiceReferenceImpl} or <code>null</code>.
* @exception java.lang.IllegalStateException If the
* bundle has been uninstalled.
- * @see ServiceRegistration
- * @see ServiceReference
+ * @see ServiceRegistrationImpl
+ * @see ServiceReferenceImpl
*/
- protected ServiceReference[] getRegisteredServices() {
- ServiceReference[] references = null;
+ protected ServiceReferenceImpl[] getRegisteredServices() {
+ ServiceReferenceImpl[] references = null;
synchronized (framework.serviceRegistry) {
Vector services = framework.serviceRegistry.lookupServiceReferences(this);
@@ -1054,7 +1054,7 @@
}
for (int i = services.size() - 1; i >= 0; i--) {
- ServiceReference ref = (ServiceReference) services.elementAt(i);
+ ServiceReferenceImpl ref = (ServiceReferenceImpl) services.elementAt(i);
String[] classes = ref.getClasses();
try { /* test for permission to the classes */
framework.checkGetServicePermission(classes);
@@ -1064,7 +1064,7 @@
}
if (services.size() > 0) {
- references = new ServiceReference[services.size()];
+ references = new ServiceReferenceImpl[services.size()];
services.toArray(references);
}
}
@@ -1073,7 +1073,7 @@
}
/**
- * Provides a list of {@link ServiceReference}s for the
+ * Provides a list of {@link ServiceReferenceImpl}s for the
* services this bundle is using,
* or <code>null</code> if the bundle is not using any services.
* A bundle is considered to be using a service if the bundle's
@@ -1083,12 +1083,12 @@
* of the call to this method, but the framework is a very dynamic
* environment and services can be modified or unregistered at anytime.
*
- * @return An array of {@link ServiceReference} or <code>null</code>.
+ * @return An array of {@link ServiceReferenceImpl} or <code>null</code>.
* @exception java.lang.IllegalStateException If the
* bundle has been uninstalled.
- * @see ServiceReference
+ * @see ServiceReferenceImpl
*/
- protected ServiceReference[] getServicesInUse() {
+ protected ServiceReferenceImpl[] getServicesInUse() {
if (servicesInUse == null) {
return (null);
}
@@ -1100,13 +1100,13 @@
return (null);
}
- ServiceReference[] references = new ServiceReference[size];
+ ServiceReferenceImpl[] references = new ServiceReferenceImpl[size];
int refcount = 0;
Enumeration enum = servicesInUse.keys();
for (int i = 0; i < size; i++) {
- ServiceReference reference = (ServiceReference) enum.nextElement();
+ ServiceReferenceImpl reference = (ServiceReferenceImpl) enum.nextElement();
try {
framework.checkGetServicePermission(reference.registration.clazzes);
@@ -1123,8 +1123,8 @@
return (null);
}
- ServiceReference[] refs = references;
- references = new ServiceReference[refcount];
+ ServiceReferenceImpl[] refs = references;
+ references = new ServiceReferenceImpl[refcount];
System.arraycopy(refs, 0, references, 0, refcount);
}
@@ -1144,7 +1144,7 @@
public void dispatchEvent(Object originalListener, Object l, int action, Object object) {
// save the bundle ref to a local variable
// to avoid interference from another thread closing this context
- Bundle tmpBundle = bundle;
+ AbstractBundle tmpBundle = bundle;
try {
if (isValid()) /* if context still valid */ {
switch (action) {
@@ -1220,7 +1220,7 @@
ProtectionDomain domain = bundle.getProtectionDomain();
if (domain != null) {
- ServiceReference reference = (ServiceReference) event.getServiceReference();
+ ServiceReferenceImpl reference = (ServiceReferenceImpl) event.getServiceReference();
String[] names = reference.registration.clazzes;
@@ -1252,7 +1252,7 @@
public org.osgi.framework.Filter createFilter(String filter) throws InvalidSyntaxException {
checkValid();
- return (new Filter(filter));
+ return (new FilterImpl(filter));
}
/**
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleFragment.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleFragment.java
index eec4ea1..86e447c 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleFragment.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleFragment.java
@@ -20,7 +20,7 @@
import org.osgi.framework.*;
import org.osgi.framework.ServiceReference;
-public class BundleFragment extends Bundle {
+public class BundleFragment extends AbstractBundle {
/** The resolved host that this fragment is attached to */
protected BundleHost host;
@@ -111,7 +111,7 @@
* @return true if an exported package is "in use". i.e. it has been imported by a bundle
* @exception org.osgi.framework.BundleException
*/
- protected boolean reload(Bundle newBundle) throws BundleException {
+ protected boolean reload(AbstractBundle newBundle) throws BundleException {
if (Debug.DEBUG && Debug.DEBUG_GENERAL) {
if ((state & (INSTALLED | RESOLVED)) == 0) {
Debug.println("Bundle.reload called when state != INSTALLED | RESOLVED: " + this);
@@ -279,10 +279,10 @@
}
if (Debug.DEBUG && Debug.DEBUG_GENERAL) {
- Debug.println("Bundle: Active sl = " + framework.startLevelImpl.getStartLevel() + "; Bundle " + getBundleId() + " sl = " + getStartLevel());
+ Debug.println("Bundle: Active sl = " + framework.startLevelManager.getStartLevel() + "; Bundle " + getBundleId() + " sl = " + getStartLevel());
}
- if (getStartLevel() <= framework.startLevelImpl.getStartLevel()) {
+ if (getStartLevel() <= framework.startLevelManager.getStartLevel()) {
if (state == UNINSTALLED) {
throw new BundleException(Msg.formatter.getString("BUNDLE_UNINSTALLED_EXCEPTION"));
}
@@ -341,7 +341,7 @@
* @return An array of {@link ServiceReference} or <code>null</code>.
* @exception java.lang.IllegalStateException If the
* bundle has been uninstalled.
- * @see ServiceRegistration
+ * @see ServiceRegistrationImpl
* @see ServiceReference
*/
public ServiceReference[] getRegisteredServices() {
@@ -411,7 +411,7 @@
*
* @return BundleContext for this bundle.
*/
- protected BundleContext getContext() {
+ protected BundleContextImpl getContext() {
// Fragments cannot have a BundleContext.
return null;
}
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleHost.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleHost.java
index fc4a6d8..926a85f 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleHost.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleHost.java
@@ -23,7 +23,7 @@
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleException;
-public class BundleHost extends Bundle {
+public class BundleHost extends AbstractBundle {
/** Loaded state object */
protected BundleLoader loader;
@@ -35,7 +35,7 @@
private BundleLoaderProxy proxy;
/** The BundleContext that represents this Bundle and all of its fragments */
- protected BundleContext context;
+ protected BundleContextImpl context;
/** The List of BundleFragments */
protected BundleFragment[] fragments;
@@ -153,7 +153,7 @@
* @return true if an exported package is "in use". i.e. it has been imported by a bundle
* @exception org.osgi.framework.BundleException
*/
- protected boolean reload(Bundle newBundle) throws BundleException {
+ protected boolean reload(AbstractBundle newBundle) throws BundleException {
if (Debug.DEBUG && Debug.DEBUG_GENERAL) {
if ((state & (INSTALLED | RESOLVED)) == 0) {
Debug.println("Bundle.reload called when state != INSTALLED | RESOLVED: " + this);
@@ -392,10 +392,10 @@
}
if (Debug.DEBUG && Debug.DEBUG_GENERAL) {
- Debug.println("Bundle: Active sl = " + framework.startLevelImpl.getStartLevel() + "; Bundle " + getBundleId() + " sl = " + getStartLevel());
+ Debug.println("Bundle: Active sl = " + framework.startLevelManager.getStartLevel() + "; Bundle " + getBundleId() + " sl = " + getStartLevel());
}
- if (getStartLevel() <= framework.startLevelImpl.getStartLevel()) {
+ if (getStartLevel() <= framework.startLevelManager.getStartLevel()) {
state = STARTING;
context = createContext();
@@ -446,8 +446,8 @@
*
* @return BundleContext for this bundle.
*/
- protected BundleContext createContext() {
- return (new BundleContext(this));
+ protected BundleContextImpl createContext() {
+ return (new BundleContextImpl(this));
}
/**
@@ -455,7 +455,7 @@
*
* @return BundleContext for this bundle.
*/
- protected BundleContext getContext() {
+ protected BundleContextImpl getContext() {
return (context);
}
@@ -496,7 +496,7 @@
}
/**
- * Provides a list of {@link ServiceReference}s for the services
+ * Provides a list of {@link ServiceReferenceImpl}s for the services
* registered by this bundle
* or <code>null</code> if the bundle has no registered
* services.
@@ -505,11 +505,11 @@
* of the call to this method, but the framework is a very dynamic
* environment and services can be modified or unregistered at anytime.
*
- * @return An array of {@link ServiceReference} or <code>null</code>.
+ * @return An array of {@link ServiceReferenceImpl} or <code>null</code>.
* @exception java.lang.IllegalStateException If the
* bundle has been uninstalled.
- * @see ServiceRegistration
- * @see ServiceReference
+ * @see ServiceRegistrationImpl
+ * @see ServiceReferenceImpl
*/
public org.osgi.framework.ServiceReference[] getRegisteredServices() {
checkValid();
@@ -522,7 +522,7 @@
}
/**
- * Provides a list of {@link ServiceReference}s for the
+ * Provides a list of {@link ServiceReferenceImpl}s for the
* services this bundle is using,
* or <code>null</code> if the bundle is not using any services.
* A bundle is considered to be using a service if the bundle's
@@ -532,10 +532,10 @@
* of the call to this method, but the framework is a very dynamic
* environment and services can be modified or unregistered at anytime.
*
- * @return An array of {@link ServiceReference} or <code>null</code>.
+ * @return An array of {@link ServiceReferenceImpl} or <code>null</code>.
* @exception java.lang.IllegalStateException If the
* bundle has been uninstalled.
- * @see ServiceReference
+ * @see ServiceReferenceImpl
*/
public org.osgi.framework.ServiceReference[] getServicesInUse() {
checkValid();
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java
index 78cee02..5929830 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java
@@ -127,7 +127,7 @@
org.osgi.framework.Bundle[] fragmentObjects = bundle.getFragments();
BundleDescription[] fragments = new BundleDescription[fragmentObjects == null ? 0 : fragmentObjects.length];
for (int i = 0; i < fragments.length; i++) {
- fragments[i] = ((Bundle) fragmentObjects[i]).getBundleDescription();
+ fragments[i] = ((AbstractBundle) fragmentObjects[i]).getBundleDescription();
}
// init the imported packages list taking the bundle...
@@ -199,7 +199,7 @@
// ...and its fragments
for (int i = 0; i < fragments.length; i++)
if (fragments[i].isResolved()) {
- spec = ((Bundle) fragmentObjects[i]).getBundleData().getDynamicImports();
+ spec = ((AbstractBundle) fragmentObjects[i]).getBundleData().getDynamicImports();
imports = ManifestElement.parseHeader(Constants.DYNAMICIMPORT_PACKAGE,spec);
addDynamicImportPackage(imports);
}
@@ -208,7 +208,7 @@
}
}
- protected void initializeFragment(Bundle fragment) throws BundleException {
+ protected void initializeFragment(AbstractBundle fragment) throws BundleException {
BundleDescription description = fragment.getBundleDescription();
// if the fragment imports a package not already imported throw an exception
PackageSpecification[] packages = description.getPackages();
@@ -632,7 +632,7 @@
// look in fragments imports ...
for (int i = 0; i < fragments.length; i++) {
- result = ((Bundle) fragments[i]).getBundleData().findLibrary(name);
+ result = ((AbstractBundle) fragments[i]).getBundleData().findLibrary(name);
if (result != null)
return result;
}
@@ -643,7 +643,7 @@
* Return the bundle we are associated with.
*
*/
- protected Bundle getBundle() {
+ protected AbstractBundle getBundle() {
return bundle;
}
@@ -666,7 +666,7 @@
org.osgi.framework.Bundle[] fragments = bundle.getFragments();
if (fragments != null)
for (int i = 0; i < fragments.length; i++) {
- Bundle fragment = (Bundle) fragments[i];
+ AbstractBundle fragment = (AbstractBundle) fragments[i];
try {
bcl.attachFragment(fragment.getBundleData(), fragment.domain, getClassPath(fragment, SecureAction.getProperties()));
}
@@ -1164,7 +1164,7 @@
}
- protected String[] getClassPath(Bundle bundle, Properties props) throws BundleException {
+ protected String[] getClassPath(AbstractBundle bundle, Properties props) throws BundleException {
String spec = bundle.getBundleData().getClassPath();
ManifestElement[] classpathElements = ManifestElement.parseHeader(Constants.BUNDLE_CLASSPATH,spec);
return matchClassPath(classpathElements, props);
@@ -1180,7 +1180,7 @@
ArrayList result = new ArrayList(classpath.length);
for (int i = 0; i < classpath.length; i++) {
- Filter filter;
+ FilterImpl filter;
try {
filter = createFilter(classpath[i].getAttribute(Constants.SELECTION_FILTER_ATTRIBUTE));
if (filter == null || filter.match(props)) {
@@ -1200,14 +1200,14 @@
return (String[]) result.toArray(new String[result.size()]);
}
- protected Filter createFilter(String filterString) throws InvalidSyntaxException, BundleException {
+ protected FilterImpl createFilter(String filterString) throws InvalidSyntaxException, BundleException {
if (filterString == null)
return null;
int length = filterString.length();
if (length <= 2) {
throw new BundleException(Msg.formatter.getString("MANIFEST_INVALID_HEADER_EXCEPTION", Constants.BUNDLE_CLASSPATH, filterString));
}
- return new Filter(filterString);
+ return new FilterImpl(filterString);
}
}
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoaderProxy.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoaderProxy.java
index 25279a7..7169333 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoaderProxy.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoaderProxy.java
@@ -67,7 +67,7 @@
loader = bundle.getBundleLoader();
return loader;
}
- public Bundle getBundle() {
+ public AbstractBundle getBundle() {
return bundle;
}
@@ -112,7 +112,7 @@
return (users.size() > 0);
}
- public Bundle[] getDependentBundles() {
+ public AbstractBundle[] getDependentBundles() {
KeyedElement[] proxyLoaders = users.elements();
KeyedHashSet bundles = new KeyedHashSet(proxyLoaders.length, false);
for (int i = 0; i < proxyLoaders.length; i++) {
@@ -121,7 +121,7 @@
}
KeyedElement[] elements = bundles.elements();
- Bundle[] result = new Bundle[elements.length];
+ AbstractBundle[] result = new AbstractBundle[elements.length];
System.arraycopy(elements, 0, result, 0, elements.length);
return result;
@@ -215,7 +215,7 @@
requiringBundles.add(requiringProxy.getBundle());
}
- return (Bundle[]) requiringBundles.toArray(new Bundle[requiringBundles.size()]);
+ return (AbstractBundle[]) requiringBundles.toArray(new AbstractBundle[requiringBundles.size()]);
}
public String getName() {
return symbolicName;
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleNativeCode.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleNativeCode.java
index 84b4e03..776637c 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleNativeCode.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleNativeCode.java
@@ -340,9 +340,9 @@
if (filterString == null) {
return true;
}
- Filter filter;
+ FilterImpl filter;
try {
- filter = new Filter(filterString);
+ filter = new FilterImpl(filterString);
} catch (InvalidSyntaxException e) {
// TODO Should we log an error???
return false;
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundlePermissions.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundlePermissions.java
index de35074..c908dcd 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundlePermissions.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundlePermissions.java
@@ -32,13 +32,13 @@
private PermissionCollection allPermission;
/** Used to load classes for unresolved permissions */
- private PackageAdmin packageAdmin;
+ private PackageAdminImpl packageAdmin;
/**
* Constructs a new instance of this class.
*
*/
- BundlePermissions(PackageAdmin packageAdmin) {
+ BundlePermissions(PackageAdminImpl packageAdmin) {
super();
this.packageAdmin = packageAdmin;
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleRepository.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleRepository.java
index 1b5e512..0550774 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleRepository.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleRepository.java
@@ -36,9 +36,9 @@
private Hashtable bundlesBySymbolicName; //TODO Does this need to be synchronized
/** PackageAdmin */
- private PackageAdmin packageAdmin;
+ private PackageAdminImpl packageAdmin;
- public BundleRepository(int initialCapacity, PackageAdmin packageAdmin) {
+ public BundleRepository(int initialCapacity, PackageAdminImpl packageAdmin) {
bundlesByInstallOrder = new ArrayList(initialCapacity);
bundlesById = new KeyedHashSet(initialCapacity, true);
bundlesBySymbolicName = new Hashtable(initialCapacity);
@@ -58,17 +58,17 @@
* @param bundleId
* @return
*/
- public Bundle getBundle(long bundleId) {
+ public AbstractBundle getBundle(long bundleId) {
Long key = new Long(bundleId);
- return (Bundle) bundlesById.getByKey(key);
+ return (AbstractBundle) bundlesById.getByKey(key);
}
- public Bundle[] getBundles(String symbolicName) {
- return (Bundle[]) bundlesBySymbolicName.get(symbolicName);
+ public AbstractBundle[] getBundles(String symbolicName) {
+ return (AbstractBundle[]) bundlesBySymbolicName.get(symbolicName);
}
- public Bundle getBundle(String symbolicName, String version) {
- Bundle[] bundles = (Bundle[]) bundlesBySymbolicName.get(symbolicName);
+ public AbstractBundle getBundle(String symbolicName, String version) {
+ AbstractBundle[] bundles = (AbstractBundle[]) bundlesBySymbolicName.get(symbolicName);
if (bundles != null) {
Version ver = new Version(version);
if (bundles.length > 0) {
@@ -82,16 +82,16 @@
return null;
}
- public void add(Bundle bundle) {
+ public void add(AbstractBundle bundle) {
bundlesByInstallOrder.add(bundle);
bundlesById.add(bundle);
String symbolicName = bundle.getSymbolicName();
if (symbolicName != null) {
- Bundle[] bundles = (Bundle[]) bundlesBySymbolicName.get(symbolicName);
+ AbstractBundle[] bundles = (AbstractBundle[]) bundlesBySymbolicName.get(symbolicName);
if (bundles == null) {
// making the initial capacity on this 1 since it
// should be rare that multiple version exist
- bundles = new Bundle[1];
+ bundles = new AbstractBundle[1];
bundles[0] = bundle;
bundlesBySymbolicName.put(symbolicName, bundles);
return;
@@ -102,7 +102,7 @@
Version newVersion = bundle.getVersion();
boolean added = false;
for (int i = 0; i < bundles.length; i++) {
- Bundle oldBundle = bundles[i];
+ AbstractBundle oldBundle = bundles[i];
Version oldVersion = oldBundle.getVersion();
if (!added && newVersion.matchGreaterOrEqualTo(oldVersion)) {
added = true;
@@ -114,13 +114,13 @@
list.add(bundle);
}
- bundles = new Bundle[list.size()];
+ bundles = new AbstractBundle[list.size()];
list.toArray(bundles);
bundlesBySymbolicName.put(symbolicName, bundles);
}
}
- public boolean remove(Bundle bundle) {
+ public boolean remove(AbstractBundle bundle) {
// remove by bundle ID
boolean found = bundlesById.remove(bundle);
if (!found)
@@ -133,7 +133,7 @@
if (symbolicName == null)
return true;
- Bundle[] bundles = (Bundle[]) bundlesBySymbolicName.get(symbolicName);
+ AbstractBundle[] bundles = (AbstractBundle[]) bundlesBySymbolicName.get(symbolicName);
if (bundles == null)
return true;
@@ -152,7 +152,7 @@
bundlesBySymbolicName.remove(symbolicName);
} else {
// create a new array with the null entries removed.
- Bundle[] newBundles = new Bundle[bundles.length - numRemoved];
+ AbstractBundle[] newBundles = new AbstractBundle[bundles.length - numRemoved];
int indexCnt = 0;
for (int i = 0; i < bundles.length; i++) {
if (bundles[i] != null) {
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ExportedPackageImpl.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ExportedPackageImpl.java
index c4b6883..2077f93 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ExportedPackageImpl.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ExportedPackageImpl.java
@@ -44,14 +44,14 @@
return null;
}
- Bundle[] dependentBundles = supplier.getDependentBundles();
+ AbstractBundle[] dependentBundles = supplier.getDependentBundles();
ArrayList importingBundles = new ArrayList();
// always add self
importingBundles.add(supplier.getBundle());
for (int i = 0; i < dependentBundles.length; i++) {
- Bundle bundle = dependentBundles[i];
+ AbstractBundle bundle = dependentBundles[i];
BundleLoader bundleLoader = bundle.getBundleLoader();
/* check to make sure this package is really imported;
* do not call bundleLoader.getPackageExporter() here because we do
@@ -63,7 +63,7 @@
}
}
- Bundle[] result = new Bundle[importingBundles.size()];
+ AbstractBundle[] result = new AbstractBundle[importingBundles.size()];
importingBundles.toArray(result);
return result;
}
@@ -73,7 +73,7 @@
}
public boolean isRemovalPending() {
- Bundle bundle = supplier.getBundle();
+ AbstractBundle bundle = supplier.getBundle();
return bundle.framework.packageAdmin.removalPending.contains(supplier);
}
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Filter.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/FilterImpl.java
similarity index 94%
rename from bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Filter.java
rename to bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/FilterImpl.java
index 04f9394..773c80d 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Filter.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/FilterImpl.java
@@ -15,6 +15,7 @@
import java.util.Vector;
import org.eclipse.osgi.framework.debug.Debug;
import org.eclipse.osgi.framework.util.Headers;
+import org.osgi.framework.Filter;
import org.osgi.framework.InvalidSyntaxException;
/**
@@ -119,12 +120,12 @@
* data type will evaluate to <code>false</code> .
*/
-public class Filter implements org.osgi.framework.Filter /* since Framework 1.1 */ {
+public class FilterImpl implements Filter /* since Framework 1.1 */ {
/* public methods in org.osgi.framework.Filter */
/**
- * Constructs a {@link Filter} object. This filter object may be used
- * to match a {@link ServiceReference} or a Dictionary.
+ * Constructs a {@link FilterImpl} object. This filter object may be used
+ * to match a {@link ServiceReferenceImpl} or a Dictionary.
*
* <p> If the filter cannot be parsed, an {@link InvalidSyntaxException}
* will be thrown with a human readable message where the
@@ -134,7 +135,7 @@
* @exception InvalidSyntaxException If the filter parameter contains
* an invalid filter string that cannot be parsed.
*/
- public Filter(String filter) throws InvalidSyntaxException {
+ public FilterImpl(String filter) throws InvalidSyntaxException {
topLevel = true;
new Parser(filter).parse(this);
}
@@ -150,7 +151,7 @@
* <code>false</code> otherwise.
*/
public boolean match(org.osgi.framework.ServiceReference reference) {
- return (match0(((ServiceReference) reference).registration.properties));
+ return (match0(((ServiceReferenceImpl) reference).registration.properties));
}
/**
@@ -186,7 +187,7 @@
{
filter.append('&');
- Filter[] filters = (Filter[]) value;
+ FilterImpl[] filters = (FilterImpl[]) value;
int size = filters.length;
for (int i = 0; i < size; i++) {
@@ -200,7 +201,7 @@
{
filter.append('|');
- Filter[] filters = (Filter[]) value;
+ FilterImpl[] filters = (FilterImpl[]) value;
int size = filters.length;
for (int i = 0; i < size; i++) {
@@ -306,7 +307,7 @@
return (true);
}
- if (!(obj instanceof Filter)) {
+ if (!(obj instanceof FilterImpl)) {
return (false);
}
@@ -348,7 +349,7 @@
/* true if root Filter object */
protected boolean topLevel;
- protected Filter() {
+ protected FilterImpl() {
topLevel = false;
}
@@ -368,7 +369,7 @@
* @return If the service's properties match the filter,
* return <code>true</code>. Otherwise, return <code>false</code>.
*/
- protected boolean match(ServiceReference reference) {
+ protected boolean match(ServiceReferenceImpl reference) {
return (match0(reference.registration.properties));
}
@@ -385,7 +386,7 @@
switch (operation) {
case AND :
{
- Filter[] filters = (Filter[]) value;
+ FilterImpl[] filters = (FilterImpl[]) value;
int size = filters.length;
for (int i = 0; i < size; i++) {
@@ -399,7 +400,7 @@
case OR :
{
- Filter[] filters = (Filter[]) value;
+ FilterImpl[] filters = (FilterImpl[]) value;
int size = filters.length;
for (int i = 0; i < size; i++) {
@@ -413,7 +414,7 @@
case NOT :
{
- Filter filter = (Filter) value;
+ FilterImpl filter = (FilterImpl) value;
return (!filter.match0(properties));
}
@@ -1253,7 +1254,7 @@
pos = 0;
}
- protected void parse(Filter parent) throws InvalidSyntaxException {
+ protected void parse(FilterImpl parent) throws InvalidSyntaxException {
try {
parse_filter(parent);
} catch (ArrayIndexOutOfBoundsException e) {
@@ -1265,7 +1266,7 @@
}
}
- protected void parse_filter(Filter parent) throws InvalidSyntaxException {
+ protected void parse_filter(FilterImpl parent) throws InvalidSyntaxException {
skipWhiteSpace();
if (filter[pos] != '(') {
@@ -1287,7 +1288,7 @@
skipWhiteSpace();
}
- protected void parse_filtercomp(Filter parent) throws InvalidSyntaxException {
+ protected void parse_filtercomp(FilterImpl parent) throws InvalidSyntaxException {
skipWhiteSpace();
char c = filter[pos];
@@ -1319,7 +1320,7 @@
}
}
- protected void parse_and(Filter parent) throws InvalidSyntaxException {
+ protected void parse_and(FilterImpl parent) throws InvalidSyntaxException {
skipWhiteSpace();
if (filter[pos] != '(') {
@@ -1329,21 +1330,21 @@
Vector operands = new Vector(10, 10);
while (filter[pos] == '(') {
- Filter child = new Filter();
+ FilterImpl child = new FilterImpl();
parse_filter(child);
operands.addElement(child);
}
int size = operands.size();
- Filter[] children = new Filter[size];
+ FilterImpl[] children = new FilterImpl[size];
operands.copyInto(children);
- parent.setFilter(Filter.AND, null, children);
+ parent.setFilter(FilterImpl.AND, null, children);
}
- protected void parse_or(Filter parent) throws InvalidSyntaxException {
+ protected void parse_or(FilterImpl parent) throws InvalidSyntaxException {
skipWhiteSpace();
if (filter[pos] != '(') {
@@ -1353,34 +1354,34 @@
Vector operands = new Vector(10, 10);
while (filter[pos] == '(') {
- Filter child = new Filter();
+ FilterImpl child = new FilterImpl();
parse_filter(child);
operands.addElement(child);
}
int size = operands.size();
- Filter[] children = new Filter[size];
+ FilterImpl[] children = new FilterImpl[size];
operands.copyInto(children);
- parent.setFilter(Filter.OR, null, children);
+ parent.setFilter(FilterImpl.OR, null, children);
}
- protected void parse_not(Filter parent) throws InvalidSyntaxException {
+ protected void parse_not(FilterImpl parent) throws InvalidSyntaxException {
skipWhiteSpace();
if (filter[pos] != '(') {
throw new InvalidSyntaxException(Msg.formatter.getString("FILTER_MISSING_LEFTPAREN", pos), filterstring);
}
- Filter child = new Filter();
+ FilterImpl child = new FilterImpl();
parse_filter(child);
- parent.setFilter(Filter.NOT, null, child);
+ parent.setFilter(FilterImpl.NOT, null, child);
}
- protected void parse_item(Filter parent) throws InvalidSyntaxException {
+ protected void parse_item(FilterImpl parent) throws InvalidSyntaxException {
String attr = parse_attr();
skipWhiteSpace();
@@ -1390,7 +1391,7 @@
{
if (filter[pos + 1] == '=') {
pos += 2;
- parent.setFilter(Filter.APPROX, attr, parse_value());
+ parent.setFilter(FilterImpl.APPROX, attr, parse_value());
return;
}
break;
@@ -1399,7 +1400,7 @@
{
if (filter[pos + 1] == '=') {
pos += 2;
- parent.setFilter(Filter.GREATER, attr, parse_value());
+ parent.setFilter(FilterImpl.GREATER, attr, parse_value());
return;
}
break;
@@ -1408,7 +1409,7 @@
{
if (filter[pos + 1] == '=') {
pos += 2;
- parent.setFilter(Filter.LESS, attr, parse_value());
+ parent.setFilter(FilterImpl.LESS, attr, parse_value());
return;
}
break;
@@ -1420,7 +1421,7 @@
pos += 2;
skipWhiteSpace();
if (filter[pos] == ')') {
- parent.setFilter(Filter.PRESENT, attr, null);
+ parent.setFilter(FilterImpl.PRESENT, attr, null);
return; /* present */
}
pos = oldpos;
@@ -1430,9 +1431,9 @@
Object string = parse_substring();
if (string instanceof String) {
- parent.setFilter(Filter.EQUAL, attr, string);
+ parent.setFilter(FilterImpl.EQUAL, attr, string);
} else {
- parent.setFilter(Filter.SUBSTRING, attr, string);
+ parent.setFilter(FilterImpl.SUBSTRING, attr, string);
}
return;
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/FilteredServiceListener.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/FilteredServiceListener.java
index 5fdd2f7..9f942ae 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/FilteredServiceListener.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/FilteredServiceListener.java
@@ -17,7 +17,7 @@
public class FilteredServiceListener implements ServiceListener
{
/** Filter for listener. */
- protected Filter filter;
+ protected FilterImpl filter;
/** Real listener. */
protected ServiceListener listener;
@@ -32,7 +32,7 @@
protected FilteredServiceListener(String filterstring, ServiceListener listener)
throws InvalidSyntaxException
{
- filter = new Filter(filterstring);
+ filter = new FilterImpl(filterstring);
this.listener = listener;
}
@@ -44,7 +44,7 @@
*/
public void serviceChanged(ServiceEvent event)
{
- ServiceReference reference = (ServiceReference)event.getServiceReference();
+ ServiceReferenceImpl reference = (ServiceReferenceImpl)event.getServiceReference();
if (Debug.DEBUG && Debug.DEBUG_EVENTS)
{
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Framework.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Framework.java
index 4aee62e..1636ef6 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Framework.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Framework.java
@@ -39,16 +39,14 @@
/** The bundles installed in the framework */
protected BundleRepository bundles;
/** Package Admin object. This object manages the exported packages. */
- protected PackageAdmin packageAdmin;
+ protected PackageAdminImpl packageAdmin;
/** Package Admin object. This object manages the exported packages. */
- protected PermissionAdmin permissionAdmin;
+ protected PermissionAdminImpl permissionAdmin;
/**
* Startlevel object. This object manages the framework and bundle
* startlevels
*/
- protected StartLevelImpl startLevelImpl;
- /** Startlevel factory object */
- protected StartLevelFactory startLevelFactory;
+ protected StartLevelManager startLevelManager;
/** The ServiceRegistry */
protected ServiceRegistry serviceRegistry; //TODO This is duplicated from the adaptor, do we really gain ?
/** next free service id. */
@@ -122,18 +120,17 @@
*/
initializeProperties(adaptor.getProperties());
/* initialize admin objects */
- packageAdmin = new PackageAdmin(this);
+ packageAdmin = new PackageAdminImpl(this);
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
try {
- permissionAdmin = new PermissionAdmin(this, adaptor.getPermissionStorage());
+ permissionAdmin = new PermissionAdminImpl(this, adaptor.getPermissionStorage());
} catch (IOException e) /* fatal error */{
e.printStackTrace();
throw new RuntimeException(e.getMessage());
}
}
- startLevelFactory = new StartLevelFactory(this);
- startLevelImpl = new StartLevelImpl(this);
+ startLevelManager = new StartLevelManager(this);
/* create the event manager and top level event dispatchers */
eventManager = new EventManager("Framework Event Dispatcher");
bundleEvent = new EventListeners();
@@ -163,7 +160,7 @@
for (int i = 0; i < size; i++) {
BundleData bundledata = (BundleData) bundleDatas.elementAt(i);
try {
- Bundle bundle = Bundle.createBundle(bundledata, this);
+ AbstractBundle bundle = AbstractBundle.createBundle(bundledata, this);
bundles.add(bundle);
} catch (BundleException be) {
// This is not a fatal error. Publish the framework event, but
@@ -361,7 +358,7 @@
List allBundles = bundles.getBundles();
int size = allBundles.size();
for (int i = 0; i < size; i++) {
- Bundle bundle = (Bundle) allBundles.get(i);
+ AbstractBundle bundle = (AbstractBundle) allBundles.get(i);
bundle.close();
}
bundles.removeAllBundles();
@@ -478,9 +475,9 @@
* @param location
* identity string for the bundle
*/
- public Bundle createBundle(BundleData bundledata) throws BundleException {
+ public AbstractBundle createBundle(BundleData bundledata) throws BundleException {
verifyExecutionEnvironment(bundledata.getManifest());
- return Bundle.createBundle(bundledata, this);
+ return AbstractBundle.createBundle(bundledata, this);
}
/**
* Verifies that the framework supports one of the required Execution
@@ -611,7 +608,7 @@
* The location identifier of the bundle to install.
* @return The Bundle object of the installed bundle.
*/
- protected Bundle installBundle(final String location) throws BundleException {
+ protected AbstractBundle installBundle(final String location) throws BundleException {
if (Debug.DEBUG && Debug.DEBUG_GENERAL) {
Debug.println("install from location: " + location);
}
@@ -639,7 +636,7 @@
* The InputStream from which the bundle will be read.
* @return The Bundle of the installed bundle.
*/
- protected Bundle installBundle(final String location, final InputStream in) throws BundleException {
+ protected AbstractBundle installBundle(final String location, final InputStream in) throws BundleException {
if (Debug.DEBUG && Debug.DEBUG_GENERAL) {
Debug.println("install from inputstream: " + location + ", " + in);
}
@@ -660,15 +657,15 @@
* The location identifier of the bundle to install.
* @param action
* A PrivilegedExceptionAction which calls the real worker.
- * @return The {@link Bundle}of the installed bundle.
+ * @return The {@link AbstractBundle}of the installed bundle.
* @exception BundleException
* If the action throws an error.
*/
- protected Bundle installWorker(String location, PrivilegedExceptionAction action) throws BundleException {
+ protected AbstractBundle installWorker(String location, PrivilegedExceptionAction action) throws BundleException {
synchronized (installLock) {
while (true) {
/* Check that the bundle is not already installed. */
- Bundle bundle = getBundleByLocation(location);
+ AbstractBundle bundle = getBundleByLocation(location);
/* If already installed, return bundle object */
if (bundle != null) {
return bundle;
@@ -698,7 +695,7 @@
}
/* Don't call adaptor while holding the install lock */
try {
- Bundle bundle = (Bundle) AccessController.doPrivileged(action);
+ AbstractBundle bundle = (AbstractBundle) AccessController.doPrivileged(action);
publishBundleEvent(BundleEvent.INSTALLED, bundle);
return bundle;
} catch (PrivilegedActionException e) {
@@ -720,18 +717,18 @@
* The location identifier of the bundle to install.
* @param source
* The URLConnection from which the bundle will be read.
- * @return The {@link Bundle}of the installed bundle.
+ * @return The {@link AbstractBundle}of the installed bundle.
* @exception BundleException
* If the provided stream cannot be read.
*/
- protected Bundle installWorkerPrivileged(String location, URLConnection source) throws BundleException {
+ protected AbstractBundle installWorkerPrivileged(String location, URLConnection source) throws BundleException {
BundleOperation storage = adaptor.installBundle(location, source);
- Bundle bundle;
+ AbstractBundle bundle;
try {
BundleData bundledata = storage.begin();
// Check for a bundle already installed with the same UniqueId and version.
if (bundledata.getSymbolicName() != null) {
- Bundle installedBundle = getBundleByUniqueId(bundledata.getSymbolicName(), bundledata.getVersion().toString());
+ AbstractBundle installedBundle = getBundleByUniqueId(bundledata.getSymbolicName(), bundledata.getVersion().toString());
if (installedBundle != null) {
throw new BundleException(Msg.formatter.getString("BUNDLE_INSTALL_SAME_UNIQUEID", new Object[] {installedBundle.getSymbolicName(), installedBundle.getVersion().toString(), installedBundle.getLocation()})); //$NON-NLS-1$
}
@@ -779,7 +776,7 @@
* If there is no suitable clause.
*/
public String[] selectNativeCode(org.osgi.framework.Bundle bundle) throws BundleException {
- String headerValue = (String) ((Bundle) bundle).getBundleData().getManifest().get(Constants.BUNDLE_NATIVECODE);
+ String headerValue = (String) ((AbstractBundle) bundle).getBundleData().getManifest().get(Constants.BUNDLE_NATIVECODE);
if (headerValue == null) {
return (null);
}
@@ -910,11 +907,11 @@
*
* @param id
* The identifier of the bundle to retrieve.
- * @return A {@link Bundle}object, or <code>null</code> if the
+ * @return A {@link AbstractBundle}object, or <code>null</code> if the
* identifier doesn't match any installed bundle.
*/
// changed visibility to gain access through the adaptor
- public Bundle getBundle(long id) {
+ public AbstractBundle getBundle(long id) {
synchronized (bundles) {
return bundles.getBundle(id);
}
@@ -924,10 +921,10 @@
*
* @param id
* The identifier of the bundle to retrieve.
- * @return A {@link Bundle}object, or <code>null</code> if the
+ * @return A {@link AbstractBundle}object, or <code>null</code> if the
* identifier doesn't match any installed bundle.
*/
- protected Bundle getBundleByUniqueId(String uniqueId, String version) {
+ protected AbstractBundle getBundleByUniqueId(String uniqueId, String version) {
synchronized (bundles) {
return bundles.getBundle(uniqueId, version);
}
@@ -948,17 +945,17 @@
* of the call to getBundleAlls, but the framework is a very dynamic
* environment and bundles can be installed or uninstalled at anytime.
*
- * @return An Array of {@link Bundle}objects, one object per installed
+ * @return An Array of {@link AbstractBundle}objects, one object per installed
* bundle.
*/
- protected Bundle[] getAllBundles() {
+ protected AbstractBundle[] getAllBundles() {
synchronized (bundles) {
List allBundles = bundles.getBundles();
int size = allBundles.size();
if (size == 0) {
return (null);
}
- Bundle[] bundlelist = new Bundle[size];
+ AbstractBundle[] bundlelist = new AbstractBundle[size];
allBundles.toArray(bundlelist);
return (bundlelist);
}
@@ -969,7 +966,7 @@
* @param bundle
* Bundle to resume.
*/
- protected void resumeBundle(Bundle bundle) {
+ protected void resumeBundle(AbstractBundle bundle) {
if (bundle.isActive()) {
// if bundle is active.
return;
@@ -1001,7 +998,7 @@
* this method.
* @return true if bundle was active and is now suspended.
*/
- protected boolean suspendBundle(Bundle bundle, boolean lock) {
+ protected boolean suspendBundle(AbstractBundle bundle, boolean lock) {
boolean changed = false;
if (!bundle.isActive() || bundle.isFragment()) {
// if bundle is not active or is a fragment then do nothing.
@@ -1032,14 +1029,14 @@
* @return Bundle object for bundle with the specified location or null if
* no bundle is installed with the specified location.
*/
- protected Bundle getBundleByLocation(String location) {
+ protected AbstractBundle getBundleByLocation(String location) {
synchronized (bundles) {
// this is not optimized; do not think it will get called
// that much.
List allBundles = bundles.getBundles();
int size = allBundles.size();
for (int i = 0; i < size; i++) {
- Bundle bundle = (Bundle) allBundles.get(i);
+ AbstractBundle bundle = (AbstractBundle) allBundles.get(i);
if (location.equals(bundle.getLocation())) {
return (bundle);
}
@@ -1055,7 +1052,7 @@
* @return Bundle object for bundle with the specified Unique or null if no
* bundle is installed with the specified location.
*/
- protected Bundle[] getBundleByUniqueId(String uniqueId) {
+ protected AbstractBundle[] getBundleByUniqueId(String uniqueId) {
synchronized (bundles) {
return bundles.getBundles(uniqueId);
}
@@ -1074,7 +1071,7 @@
* <p>
* <tt>filter</tt> is used to select the registered service whose
* properties objects contain keys and values which satisfy the filter. See
- * {@link Filter}for a description of the filter string syntax.
+ * {@link FilterImpl}for a description of the filter string syntax.
*
* <p>
* If <tt>filter</tt> is <tt>null</tt>, all registered services are
@@ -1116,9 +1113,9 @@
* If <tt>filter</tt> contains an invalid filter string
* which cannot be parsed.
*/
- protected ServiceReference[] getServiceReferences(String clazz, String filterstring) throws InvalidSyntaxException {
- Filter filter = (filterstring == null) ? null : new Filter(filterstring);
- ServiceReference[] references = null;
+ protected ServiceReferenceImpl[] getServiceReferences(String clazz, String filterstring) throws InvalidSyntaxException {
+ FilterImpl filter = (filterstring == null) ? null : new FilterImpl(filterstring);
+ ServiceReferenceImpl[] references = null;
if (clazz != null) {
try /* test for permission to get clazz */{
checkGetServicePermission(clazz);
@@ -1133,7 +1130,7 @@
}
if (clazz == null) {
for (int i = services.size() - 1; i >= 0; i--) {
- ServiceReference ref = (ServiceReference) services.elementAt(i);
+ ServiceReferenceImpl ref = (ServiceReferenceImpl) services.elementAt(i);
String[] classes = ref.getClasses();
try { /* test for permission to the classes */
checkGetServicePermission(classes);
@@ -1143,7 +1140,7 @@
}
}
if (services.size() > 0) {
- references = new ServiceReference[services.size()];
+ references = new ServiceReferenceImpl[services.size()];
services.toArray(references);
}
}
@@ -1171,7 +1168,7 @@
* obtained by calling this method with the empty string ("") as the
* parameter. See {@link #getBundle()}for a definition of context bundle.
*/
- protected File getDataFile(final Bundle bundle, final String filename) {
+ protected File getDataFile(final AbstractBundle bundle, final String filename) {
return (File) AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
return bundle.getBundleData().getDataFile(filename);
@@ -1420,7 +1417,7 @@
*/
public void dispatchEvent(Object l, Object lo, int action, Object object) {
try {
- BundleContext context = (BundleContext) l;
+ BundleContextImpl context = (BundleContextImpl) l;
if (context.isValid()) /* if context still valid */{
ListenerQueue queue = (ListenerQueue) object;
switch (action) {
@@ -1458,7 +1455,7 @@
break publisherror; /* avoid infinite loop */
}
}
- BundleContext context = (BundleContext) l;
+ BundleContextImpl context = (BundleContextImpl) l;
publishFrameworkEvent(FrameworkEvent.ERROR, context.bundle, t);
}
}
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ManifestLocalization.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ManifestLocalization.java
index e9c2d88..f6bce94 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ManifestLocalization.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ManifestLocalization.java
@@ -19,10 +19,10 @@
* This class is used by the Bundle Class to localize manifest headers.
*/
public class ManifestLocalization {
- private Bundle bundle = null;
+ private AbstractBundle bundle = null;
private Dictionary rawHeaders = null;
private Headers defaultLocaleHeaders = null;
- public ManifestLocalization(Bundle bundle, Dictionary rawHeaders) {
+ public ManifestLocalization(AbstractBundle bundle, Dictionary rawHeaders) {
this.bundle = bundle;
this.rawHeaders = rawHeaders;
}
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdmin.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java
similarity index 92%
rename from bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdmin.java
rename to bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java
index cb5ce56..bf617c3 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdmin.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java
@@ -18,6 +18,7 @@
import org.eclipse.osgi.framework.util.SecureAction;
import org.eclipse.osgi.service.resolver.*;
import org.osgi.framework.*;
+import org.osgi.service.packageadmin.*;
import org.osgi.service.packageadmin.ExportedPackage;
import org.osgi.service.packageadmin.NamedClassSpace;
@@ -44,7 +45,7 @@
* old values, isRemovalPending() returns true, and getExportingBundle()
* and getImportingBundles() return null.
*/
-public class PackageAdmin implements org.osgi.service.packageadmin.PackageAdmin {
+public class PackageAdminImpl implements PackageAdmin {
/** framework object */
protected Framework framework;
@@ -64,7 +65,7 @@
*
* @param framework Framework object.
*/
- protected PackageAdmin(Framework framework) {
+ protected PackageAdminImpl(Framework framework) {
this.framework = framework;
}
@@ -88,7 +89,7 @@
BundleDescription bundleSpec = packageSpecs[i].getSupplier();
if (bundleSpec == null)
continue;
- Bundle bundle = framework.getBundle(bundleSpec.getBundleId());
+ AbstractBundle bundle = framework.getBundle(bundleSpec.getBundleId());
if (bundle == null) {
BundleException be = new BundleException(Msg.formatter.getString("BUNDLE_NOT_IN_FRAMEWORK",bundleSpec)); //$NON-NLS-1$
framework.publishFrameworkEvent(FrameworkEvent.ERROR,framework.systemBundle,be);
@@ -125,7 +126,7 @@
BundleDescription[] bundleDescripts = state.getResolvedBundles();
for (int i = 0; i < bundleDescripts.length; i++) {
BundleDescription bundledes = bundleDescripts[i];
- Bundle bundle = framework.getBundle(bundledes.getBundleId());
+ AbstractBundle bundle = framework.getBundle(bundledes.getBundleId());
if (bundle != null && bundle.isResolved() && bundle.getSymbolicName() != null && bundle instanceof BundleHost && bundle.checkProvideBundlePermission(bundle.getSymbolicName())) {
BundleLoaderProxy loaderProxy = ((BundleHost) bundle).getLoaderProxy();
bundleSet.add(loaderProxy);
@@ -303,18 +304,18 @@
public void refreshPackages(org.osgi.framework.Bundle[] input) {
framework.checkAdminPermission();
- Bundle[] copy = null;
+ AbstractBundle[] copy = null;
if (input != null) {
synchronized (input) {
int size = input.length;
- copy = new Bundle[size];
+ copy = new AbstractBundle[size];
System.arraycopy(input, 0, copy, 0, size);
}
}
- final Bundle[] bundles = copy;
+ final AbstractBundle[] bundles = copy;
Thread refresh = SecureAction.createThread(new Runnable() {
public void run() {
refreshPackages(bundles);
@@ -329,7 +330,7 @@
*
* @param Seed for the graph.
*/
- protected void refreshPackages(Bundle[] refresh) {
+ protected void refreshPackages(AbstractBundle[] refresh) {
try {
Vector graph = null;
synchronized (framework.bundles) {
@@ -365,7 +366,7 @@
private void resumeBundles(Vector graph) {
- Bundle[] refresh = new Bundle[graph.size()];
+ AbstractBundle[] refresh = new AbstractBundle[graph.size()];
boolean[] previouslyResolved = new boolean[graph.size()];
graph.copyInto(refresh);
Util.sort(refresh, 0, graph.size());
@@ -373,14 +374,14 @@
Debug.println("refreshPackages: restart the bundles");
}
for (int i = 0; i < refresh.length; i++) {
- Bundle bundle = (Bundle) refresh[i];
+ AbstractBundle bundle = (AbstractBundle) refresh[i];
if (bundle.isResolved())
framework.resumeBundle(bundle);
}
}
private void processDelta(Vector graph) {
- Bundle[] refresh = new Bundle[graph.size()];
+ AbstractBundle[] refresh = new AbstractBundle[graph.size()];
boolean[] previouslyResolved = new boolean[graph.size()];
graph.copyInto(refresh);
Util.sort(refresh, 0, graph.size());
@@ -395,7 +396,7 @@
Debug.println("refreshPackages: Suspend each bundle and acquire its state change lock");
}
for (int i = refresh.length - 1; i >= 0; i--) {
- Bundle changedBundle = refresh[i];
+ AbstractBundle changedBundle = refresh[i];
previouslyResolved[i] = changedBundle.isResolved();
if (changedBundle.isActive() && !changedBundle.isFragment()) {
boolean suspended = framework.suspendBundle(changedBundle, true);
@@ -432,7 +433,7 @@
}
for (int i = 0; i < refresh.length; i++) {
- Bundle changedBundle = refresh[i];
+ AbstractBundle changedBundle = refresh[i];
changedBundle.refresh();
// send out unresolved events
if (previouslyResolved[i])
@@ -447,7 +448,7 @@
}
for (int i = removalPending.size() - 1; i >= 0; i--) {
BundleLoaderProxy loaderProxy = (BundleLoaderProxy) removalPending.elementAt(i);
- Bundle removedBundle = loaderProxy.getBundle();
+ AbstractBundle removedBundle = loaderProxy.getBundle();
if (graph.contains(removedBundle)) {
deleteRemovalPending(loaderProxy);
@@ -458,7 +459,7 @@
List allBundles = framework.bundles.getBundles();
int size = allBundles.size();
for (int i = 0; i < size; i++) {
- Bundle bundle = (Bundle) allBundles.get(i);
+ AbstractBundle bundle = (AbstractBundle) allBundles.get(i);
if (bundle.isResolved())
continue;
BundleDescription bundleDes = bundle.getBundleDescription();
@@ -490,7 +491,7 @@
Debug.println("refreshPackages: release the state change locks");
}
for (int i = 0; i < refresh.length; i++) {
- Bundle changedBundle = refresh[i];
+ AbstractBundle changedBundle = refresh[i];
changedBundle.completeStateChange();
}
}
@@ -519,7 +520,7 @@
// send out any resolved/unresolved events
for (int i = 0; i < notify.size(); i++) {
- Bundle changedBundle = (Bundle) notify.elementAt(i);
+ AbstractBundle changedBundle = (AbstractBundle) notify.elementAt(i);
framework.publishBundleEvent(changedBundle.isResolved() ? BundleEvent.RESOLVED : BundleEvent.UNRESOLVED, changedBundle);
}
@@ -537,19 +538,19 @@
}
int size = bundles.size();
for (int i = 0; i < size; i++) {
- Bundle bundle = (Bundle) bundles.elementAt(i);
+ AbstractBundle bundle = (AbstractBundle) bundles.elementAt(i);
bundle.unresolvePermissions(packages);
}
}
- private Vector computeAffectedBundles(Bundle[] refresh) {
+ private Vector computeAffectedBundles(AbstractBundle[] refresh) {
Vector graph = new Vector();
if (refresh == null) {
int size = removalPending.size();
for (int i = 0; i < size; i++) {
BundleLoaderProxy loaderProxy = (BundleLoaderProxy) removalPending.elementAt(i);
- Bundle bundle = loaderProxy.getBundle();
+ AbstractBundle bundle = loaderProxy.getBundle();
if (!graph.contains(bundle)) {
if (Debug.DEBUG && Debug.DEBUG_PACKAGEADMIN) {
Debug.println(" refresh: " + bundle);
@@ -557,7 +558,7 @@
graph.addElement(bundle);
// add in any dependents of the removal pending loader.
- Bundle[] dependents = loaderProxy.getDependentBundles();
+ AbstractBundle[] dependents = loaderProxy.getDependentBundles();
for (int j = 0; j < dependents.length; j++) {
if (!graph.contains(dependents[j])) {
graph.addElement(dependents[j]);
@@ -567,7 +568,7 @@
}
} else {
for (int i = 0; i < refresh.length; i++) {
- Bundle bundle = refresh[i];
+ AbstractBundle bundle = refresh[i];
if (bundle == framework.systemBundle) {
continue;
}
@@ -613,12 +614,12 @@
changed = false;
int size = graph.size();
for (int i = size - 1; i >= 0; i--) {
- Bundle bundle = (Bundle) graph.elementAt(i);
+ AbstractBundle bundle = (AbstractBundle) graph.elementAt(i);
if (!bundle.isFragment()) {
BundleLoaderProxy loaderProxy = ((BundleHost) bundle).getLoaderProxy();
if (loaderProxy != null) {
// add any dependents
- Bundle[] dependents = loaderProxy.getDependentBundles();
+ AbstractBundle[] dependents = loaderProxy.getDependentBundles();
for (int j = 0; j < dependents.length; j++) {
if (!graph.contains(dependents[j])) {
graph.addElement(dependents[j]);
@@ -638,7 +639,7 @@
}
} else {
// add in the host.
- Bundle host = (Bundle) bundle.getHost();
+ AbstractBundle host = (AbstractBundle) bundle.getHost();
if (host != null) {
if (!graph.contains(host)) {
graph.addElement(host);
@@ -651,11 +652,11 @@
// look for the bundles in removalPending list
for (int i = removalPending.size() - 1; i >= 0; i--) {
BundleLoaderProxy removedLoaderProxy = (BundleLoaderProxy) removalPending.elementAt(i);
- Bundle removedBundle = removedLoaderProxy.getBundle();
+ AbstractBundle removedBundle = removedLoaderProxy.getBundle();
if (graph.contains(removedBundle)) {
// add in the dependents of the removedLoaderProxy
- Bundle[] dependents = removedLoaderProxy.getDependentBundles();
+ AbstractBundle[] dependents = removedLoaderProxy.getDependentBundles();
for (int k = 0; k < dependents.length; k++) {
if (!graph.contains(dependents[k])) {
graph.addElement(dependents[k]);
@@ -679,7 +680,7 @@
BundleDescription[] descriptions = state.getBundles();
for (int i = 0; i < descriptions.length; i++) {
long bundleId = descriptions[i].getBundleId();
- Bundle bundle = framework.getBundle(bundleId);
+ AbstractBundle bundle = framework.getBundle(bundleId);
if (bundle == null ) {
BundleException be = new BundleException(Msg.formatter.getString("BUNDLE_NOT_IN_FRAMEWORK",descriptions[i])); //$NON-NLS-1$
framework.publishFrameworkEvent(FrameworkEvent.ERROR,framework.systemBundle,be);
@@ -737,7 +738,7 @@
// first check to see if there is anything to resolve
for (int i = 0; i < size; i++) {
- if (!((Bundle) allBundles.get(i)).isResolved())
+ if (!((AbstractBundle) allBundles.get(i)).isResolved())
resolveNeeded = true;
}
if (!resolveNeeded)
@@ -746,7 +747,7 @@
// get the state and resolve it.
framework.adaptor.getState().resolve(false);
for (int i = 0; i < size; i++) {
- Bundle bundle = (Bundle) allBundles.get(i);
+ AbstractBundle bundle = (AbstractBundle) allBundles.get(i);
BundleDescription changedBundleDes = bundle.getBundleDescription();
boolean previouslyResolved = bundle.isResolved();
@@ -780,7 +781,7 @@
exportedBundles = getExportedBundles(exportedBundles);
}
for (int i = 0; i < notify.size(); i++) {
- Bundle bundle = (Bundle) notify.elementAt(i);
+ AbstractBundle bundle = (AbstractBundle) notify.elementAt(i);
if (bundle != null) {
framework.publishBundleEvent(bundle.isResolved() ? BundleEvent.RESOLVED : BundleEvent.UNRESOLVED, bundle);
}
@@ -816,7 +817,7 @@
ArrayList result = new ArrayList();
int size = graph.size();
for (int i = 0; i < size; i++) {
- Bundle bundle = (Bundle) graph.elementAt(i);
+ AbstractBundle bundle = (AbstractBundle) graph.elementAt(i);
BundleDescription bundleDes = bundle.getBundleDescription();
if (bundleDes != null) {
result.add(bundleDes);
@@ -856,7 +857,7 @@
throw new IllegalArgumentException();
}
- Bundle bundles[] = framework.getBundleByUniqueId(symbolicName);
+ AbstractBundle bundles[] = framework.getBundleByUniqueId(symbolicName);
if (bundles == null)
return null;
@@ -876,10 +877,10 @@
if (result.size() == 0)
return null;
else
- return (Bundle[]) result.toArray(new Bundle[result.size()]);
+ return (AbstractBundle[]) result.toArray(new AbstractBundle[result.size()]);
}
- private boolean matchBundle(Bundle bundle, Version version, String match) {
+ private boolean matchBundle(AbstractBundle bundle, Version version, String match) {
match = match == null ? Constants.VERSION_MATCH_GREATERTHANOREQUAL : match;
boolean result = false;
if (match.equalsIgnoreCase(Constants.VERSION_MATCH_QUALIFIER))
@@ -897,11 +898,11 @@
}
public org.osgi.framework.Bundle[] getFragments(org.osgi.framework.Bundle bundle) {
- return ((Bundle) bundle).getFragments();
+ return ((AbstractBundle) bundle).getFragments();
}
public org.osgi.framework.Bundle[] getHosts(org.osgi.framework.Bundle bundle) {
- org.osgi.framework.Bundle host = ((Bundle) bundle).getHost();
+ org.osgi.framework.Bundle host = ((AbstractBundle) bundle).getHost();
if (host == null)
return null;
else
@@ -909,10 +910,10 @@
}
public int getBundleType(org.osgi.framework.Bundle bundle) {
- return ((Bundle) bundle).isFragment() ? PackageAdmin.BUNDLE_TYPE_FRAGMENT : 0;
+ return ((AbstractBundle) bundle).isFragment() ? PackageAdminImpl.BUNDLE_TYPE_FRAGMENT : 0;
}
- protected Class loadServiceClass(String className, Bundle bundle) {
+ protected Class loadServiceClass(String className, AbstractBundle bundle) {
try {
if (restrictServiceClasses || bundle == null)
return framework.adaptor.getBundleClassLoaderParent().loadClass(className);
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PermissionAdmin.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PermissionAdminImpl.java
similarity index 95%
rename from bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PermissionAdmin.java
rename to bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PermissionAdminImpl.java
index 5932bc0..aab5ed6 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PermissionAdmin.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PermissionAdminImpl.java
@@ -17,6 +17,7 @@
import org.eclipse.osgi.framework.adaptor.PermissionStorage;
import org.eclipse.osgi.framework.debug.Debug;
import org.osgi.framework.FrameworkEvent;
+import org.osgi.service.permissionadmin.PermissionAdmin;
import org.osgi.service.permissionadmin.PermissionInfo;
/**
@@ -58,7 +59,7 @@
* are not reflected in the permissions returned by <tt>getPermissions</tt>
* and <tt>getDefaultPermissions</tt>.
*/
-public class PermissionAdmin implements org.osgi.service.permissionadmin.PermissionAdmin {
+public class PermissionAdminImpl implements PermissionAdmin {
/** framework object */
protected Framework framework;
@@ -79,7 +80,7 @@
*
* @param framework Framework object.
*/
- protected PermissionAdmin(Framework framework, PermissionStorage storage) {
+ protected PermissionAdminImpl(Framework framework, PermissionStorage storage) {
this.framework = framework;
this.storage = storage;
@@ -140,7 +141,7 @@
throw new NullPointerException();
}
- PermissionStorage storage = new org.eclipse.osgi.framework.util.PermissionStorage(this.storage);
+ PermissionStorage storage = new org.eclipse.osgi.framework.util.SecurePermissionStorage(this.storage);
try {
String[] data = storage.getPermissionData(location);
@@ -182,7 +183,7 @@
throw new NullPointerException();
}
- PermissionStorage storage = new org.eclipse.osgi.framework.util.PermissionStorage(this.storage);
+ PermissionStorage storage = new org.eclipse.osgi.framework.util.SecurePermissionStorage(this.storage);
try {
String[] data = makePermissionData(permissions);
@@ -205,7 +206,7 @@
return;
}
- Bundle bundle = framework.getBundleByLocation(location);
+ AbstractBundle bundle = framework.getBundleByLocation(location);
if ((bundle != null) && (bundle.getBundleId() != 0)) {
ProtectionDomain domain = bundle.getProtectionDomain();
@@ -231,7 +232,7 @@
* permissions, or <tt>null</tt> if the permission table is empty.
*/
public String[] getLocations() {
- PermissionStorage storage = new org.eclipse.osgi.framework.util.PermissionStorage(this.storage);
+ PermissionStorage storage = new org.eclipse.osgi.framework.util.SecurePermissionStorage(this.storage);
try {
String[] locations = storage.getLocations();
@@ -254,7 +255,7 @@
* permissions have not been defined.
*/
public PermissionInfo[] getDefaultPermissions() {
- PermissionStorage storage = new org.eclipse.osgi.framework.util.PermissionStorage(this.storage);
+ PermissionStorage storage = new org.eclipse.osgi.framework.util.SecurePermissionStorage(this.storage);
try {
String[] data = storage.getPermissionData(null);
@@ -291,7 +292,7 @@
public void setDefaultPermissions(PermissionInfo[] permissions) {
framework.checkAdminPermission();
- PermissionStorage storage = new org.eclipse.osgi.framework.util.PermissionStorage(this.storage);
+ PermissionStorage storage = new org.eclipse.osgi.framework.util.SecurePermissionStorage(this.storage);
try {
String[] data = makePermissionData(permissions);
@@ -369,7 +370,7 @@
* @return BundleCombinedPermission object with the bundle's
* dynamic permissions.
*/
- protected PermissionCollection createPermissionCollection(Bundle bundle) {
+ protected PermissionCollection createPermissionCollection(AbstractBundle bundle) {
BundlePermissionCollection implied = getImpliedPermissions(bundle);
BundleCombinedPermissions combined = new BundleCombinedPermissions(implied);
@@ -409,7 +410,7 @@
* @param bundle The bundle to create the permissions for.
* @return A PermissionCollection of the assigned permissions.
*/
- protected BundlePermissionCollection getAssignedPermissions(Bundle bundle) {
+ protected BundlePermissionCollection getAssignedPermissions(AbstractBundle bundle) {
String location = bundle.getLocation();
PermissionInfo[] info = getPermissions(location);
@@ -432,7 +433,7 @@
* @param bundle The bundle to create the permissions for.
* @return A PermissionCollection of the implied permissions.
*/
- protected BundlePermissionCollection getImpliedPermissions(Bundle bundle) {
+ protected BundlePermissionCollection getImpliedPermissions(AbstractBundle bundle) {
if (Debug.DEBUG && Debug.DEBUG_SECURITY) {
Debug.println("Creating implied permissions for " + bundle);
}
@@ -520,7 +521,7 @@
* @param bundle The target bundle for the permissions.
* @return A PermissionCollection containing Permission objects.
*/
- protected BundlePermissionCollection createPermissions(PermissionInfo[] info, final Bundle bundle) {
+ protected BundlePermissionCollection createPermissions(PermissionInfo[] info, final AbstractBundle bundle) {
BundlePermissionCollection collection = new BundlePermissions(framework.packageAdmin);
/* add the permissions */
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ServiceReference.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ServiceReferenceImpl.java
similarity index 88%
rename from bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ServiceReference.java
rename to bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ServiceReferenceImpl.java
index d4e781d..3e118b5 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ServiceReference.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ServiceReferenceImpl.java
@@ -11,16 +11,18 @@
package org.eclipse.osgi.framework.internal.core;
+import org.osgi.framework.ServiceReference;
+
/**
* A reference to a service.
*
* The framework returns ServiceReference objects from the
- * {@link BundleContext#getServiceReference BundleContext.getServiceReference} and
- * {@link BundleContext#getServiceReferences BundleContext.getServiceReferences} methods.
+ * {@link BundleContextImpl#getServiceReference BundleContext.getServiceReference} and
+ * {@link BundleContextImpl#getServiceReferences BundleContext.getServiceReferences} methods.
* <p>A ServiceReference may be shared between bundles and
* can be used to examine the properties of the service and to
* get the service object
- * (See {@link BundleContext#getService BundleContext.getService}).
+ * (See {@link BundleContextImpl#getService BundleContext.getService}).
* <p>A registered service <i>may</i> have multiple, distinct ServiceReference
* objects which refer to it.
* However these ServiceReference objects will have
@@ -28,15 +30,15 @@
* will return <code>true</code> when compared.
*/
-public class ServiceReference implements org.osgi.framework.ServiceReference, Comparable {
+public class ServiceReferenceImpl implements ServiceReference, Comparable {
/** Registered Service object. */
- protected ServiceRegistration registration;
+ protected ServiceRegistrationImpl registration;
/**
* Construct a reference.
*
*/
- protected ServiceReference(ServiceRegistration registration) {
+ protected ServiceReferenceImpl(ServiceRegistrationImpl registration) {
this.registration = registration;
}
@@ -78,7 +80,7 @@
* determine if the service has been unregistered.
*
* @return The bundle which registered the service.
- * @see BundleContext#registerService
+ * @see BundleContextImpl#registerService
*/
public org.osgi.framework.Bundle getBundle() {
return (registration.getBundle());
@@ -92,7 +94,7 @@
*
* @return The array of bundles using the service or null if
* no bundles are using the service.
- * @see BundleContext#getService
+ * @see BundleContextImpl#getService
*/
public org.osgi.framework.Bundle[] getUsingBundles() {
return (registration.getUsingBundles());
@@ -146,11 +148,11 @@
return (true);
}
- if (!(obj instanceof ServiceReference)) {
+ if (!(obj instanceof ServiceReferenceImpl)) {
return (false);
}
- ServiceReference other = (ServiceReference) obj;
+ ServiceReferenceImpl other = (ServiceReferenceImpl) obj;
return (registration == other.registration);
}
@@ -202,7 +204,7 @@
* receiver.
*/
public int compareTo(Object object) {
- ServiceReference other = (ServiceReference) object;
+ ServiceReferenceImpl other = (ServiceReferenceImpl) object;
int compare = this.getRanking() - other.getRanking();
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ServiceRegistration.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ServiceRegistrationImpl.java
similarity index 93%
rename from bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ServiceRegistration.java
rename to bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ServiceRegistrationImpl.java
index 82f8b8c..c9ab324 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ServiceRegistration.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ServiceRegistrationImpl.java
@@ -15,12 +15,13 @@
import org.eclipse.osgi.framework.debug.Debug;
import org.eclipse.osgi.framework.util.Headers;
import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceRegistration;
/**
* A registered service.
*
* The framework returns a ServiceRegistration object when a
- * {@link BundleContext#registerService BundleContext.registerService}
+ * {@link BundleContextImpl#registerService BundleContext.registerService}
* method is successful. This object is for the private use of
* the registering bundle and should not be shared with other bundles.
* <p>The ServiceRegistration object may be used to update the properties
@@ -32,19 +33,19 @@
* ServiceRegistration object referenced.
*/
-public class ServiceRegistration implements org.osgi.framework.ServiceRegistration
+public class ServiceRegistrationImpl implements ServiceRegistration
{
/** Reference to this registration. */
- protected ServiceReference reference;
+ protected ServiceReferenceImpl reference;
/** Internal framework object. */
protected Framework framework;
/** context which registered this service. */
- protected BundleContext context;
+ protected BundleContextImpl context;
/** bundle which registered this service. */
- protected Bundle bundle;
+ protected AbstractBundle bundle;
/** list of contexts using the service.
* Access to this should be protected by the registrationLock */
@@ -76,7 +77,7 @@
* in the framework's service registry.
*
*/
- protected ServiceRegistration(BundleContext context, String[] clazzes, Object service, Dictionary properties)
+ protected ServiceRegistrationImpl(BundleContextImpl context, String[] clazzes, Object service, Dictionary properties)
{
this.context = context;
this.bundle = context.bundle;
@@ -85,7 +86,7 @@
this.service = service;
this.contextsUsing = null;
this.unregistered = false;
- this.reference = new ServiceReference(this);
+ this.reference = new ServiceReferenceImpl(this);
synchronized (framework.serviceRegistry)
{
@@ -108,14 +109,14 @@
* Unregister the service.
* Remove a service registration from the framework's service
* registry.
- * All {@link ServiceReference} objects for this registration
+ * All {@link ServiceReferenceImpl} objects for this registration
* can no longer be used to interact with the service.
*
* <p>The following steps are followed to unregister a service:
* <ol>
* <li>The service is removed from the framework's service
* registry so that it may no longer be used.
- * {@link ServiceReference}s for the service may no longer be used
+ * {@link ServiceReferenceImpl}s for the service may no longer be used
* to get a service object for the service.
* <li>A {@link ServiceEvent} of type {@link ServiceEvent#UNREGISTERING}
* is synchronously sent so that bundles using this service
@@ -132,7 +133,7 @@
*
* @exception java.lang.IllegalStateException If
* this ServiceRegistration has already been unregistered.
- * @see BundleContext#ungetService
+ * @see BundleContextImpl#ungetService
*/
public void unregister()
{
@@ -164,7 +165,7 @@
unregistered = true;
int size = 0;
- BundleContext[] users = null;
+ BundleContextImpl[] users = null;
synchronized (registrationLock)
{
@@ -179,7 +180,7 @@
Debug.println("unregisterService: releasing users");
}
- users = new BundleContext[size];
+ users = new BundleContextImpl[size];
contextsUsing.copyInto(users);
}
}
@@ -203,12 +204,12 @@
/**
- * Returns a {@link ServiceReference} object for this registration.
- * The {@link ServiceReference} object may be shared with other bundles.
+ * Returns a {@link ServiceReferenceImpl} object for this registration.
+ * The {@link ServiceReferenceImpl} object may be shared with other bundles.
*
* @exception java.lang.IllegalStateException If
* this ServiceRegistration has already been unregistered.
- * @return A {@link ServiceReference} object.
+ * @return A {@link ServiceReferenceImpl} object.
*/
public org.osgi.framework.ServiceReference getReference()
{
@@ -335,9 +336,9 @@
* determine if the service has been unregistered.
*
* @return The bundle which registered the service.
- * @see BundleContext.registerService
+ * @see BundleContextImpl.registerService
*/
- protected Bundle getBundle()
+ protected AbstractBundle getBundle()
{
if (reference == null)
{
@@ -353,7 +354,7 @@
* @param user BundleContext using service.
* @return Service object
*/
- protected Object getService(BundleContext user)
+ protected Object getService(BundleContextImpl user)
{
synchronized (registrationLock)
{
@@ -406,7 +407,7 @@
* is zero or if the service has been unregistered,
* otherwise <code>true</code>.
*/
- protected boolean ungetService(BundleContext user)
+ protected boolean ungetService(BundleContextImpl user)
{
synchronized (registrationLock)
{
@@ -450,7 +451,7 @@
*
* @param user BundleContext using service.
*/
- protected void releaseService(BundleContext user)
+ protected void releaseService(BundleContextImpl user)
{
synchronized (registrationLock)
{
@@ -486,7 +487,7 @@
*
* @return Array of Bundles using this service.
*/
- protected Bundle[] getUsingBundles()
+ protected AbstractBundle[] getUsingBundles()
{
synchronized (registrationLock)
{
@@ -507,12 +508,12 @@
return(null);
}
- Bundle[] bundles = new Bundle[size];
+ AbstractBundle[] bundles = new AbstractBundle[size];
/* Copy vector of BundleContext into an array of Bundle. */
for (int i = 0; i < size; i++)
{
- bundles[i] = ((BundleContext)contextsUsing.elementAt(i)).bundle;
+ bundles[i] = ((BundleContextImpl)contextsUsing.elementAt(i)).bundle;
}
return(bundles);
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ServiceUse.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ServiceUse.java
index bf74709..5d0d730 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ServiceUse.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ServiceUse.java
@@ -30,9 +30,9 @@
ServiceFactory.getService() */
protected Object service;
/** BundleContext associated with this service use */
- protected BundleContext context;
+ protected BundleContextImpl context;
/** ServiceDescription of the registered service */
- protected ServiceRegistration registration;
+ protected ServiceRegistrationImpl registration;
/** bundle's use count for this service */
protected int useCount;
/** Internal framework object. */
@@ -45,7 +45,7 @@
* @param context bundle getting the service
* @param registration ServiceRegistration of the service
*/
- protected ServiceUse(BundleContext context, ServiceRegistration registration) {
+ protected ServiceUse(BundleContextImpl context, ServiceRegistrationImpl registration) {
this.context = context;
this.registration = registration;
this.useCount = 0;
@@ -98,7 +98,7 @@
*/
protected Object getService() {
if ((useCount == 0) && (factory != null)) {
- Bundle factorybundle = registration.context.bundle;
+ AbstractBundle factorybundle = registration.context.bundle;
Object service;
try {
@@ -132,7 +132,7 @@
String[] clazzes = registration.clazzes;
int size = clazzes.length;
- PackageAdmin packageAdmin = context.framework.packageAdmin;
+ PackageAdminImpl packageAdmin = context.framework.packageAdmin;
for (int i = 0; i < size; i++) {
Class clazz = packageAdmin.loadServiceClass(clazzes[i],factorybundle);
if (clazz == null) {
@@ -214,7 +214,7 @@
Debug.printStackTrace(t);
}
- Bundle factorybundle = registration.context.bundle;
+ AbstractBundle factorybundle = registration.context.bundle;
BundleException be = new BundleException(Msg.formatter.getString("SERVICE_FACTORY_EXCEPTION", factory.getClass().getName(), "ungetService"), t);
context.framework.publishFrameworkEvent(FrameworkEvent.ERROR, factorybundle, be);
}
@@ -253,7 +253,7 @@
Debug.printStackTrace(t);
}
- Bundle factorybundle = registration.context.bundle;
+ AbstractBundle factorybundle = registration.context.bundle;
BundleException be = new BundleException(Msg.formatter.getString("SERVICE_FACTORY_EXCEPTION", factory.getClass().getName(), "ungetService"), t);
context.framework.publishFrameworkEvent(FrameworkEvent.ERROR, factorybundle, be);
}
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/StartLevel.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/StartLevel.java
deleted file mode 100644
index efa6628..0000000
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/StartLevel.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.osgi.framework.internal.core;
-
-/**
- * StartLevel service for the OSGi specification.
- *
- * Framework service which allows management of framework and bundle startlevels.
- *
- * If present, there will only be a single instance of this service
- * registered in the framework.
- *
- */
-public class StartLevel implements org.osgi.service.startlevel.StartLevel {
-
- protected StartLevelImpl startLevelImpl;
- protected org.osgi.framework.Bundle callerBundle;
-
- /** This constructor is called by the StartLevel factory */
- protected StartLevel(org.osgi.framework.Bundle callerBundle, Framework framework) {
- this.callerBundle = callerBundle;
- this.startLevelImpl = framework.startLevelImpl;
- }
-
- /**
- * Return the initial start level value that is assigned
- * to a Bundle when it is first installed.
- *
- * @return The initial start level value for Bundles.
- * @see #setInitialBundleStartLevel
- */
- public int getInitialBundleStartLevel() {
- return startLevelImpl.getInitialBundleStartLevel();
- }
-
- /**
- * Set the initial start level value that is assigned
- * to a Bundle when it is first installed.
- *
- * <p>The initial bundle start level will be set to the specified start level. The
- * initial bundle start level value will be persistently recorded
- * by the Framework.
- *
- * <p>When a Bundle is installed via <tt>BundleContext.installBundle</tt>,
- * it is assigned the initial bundle start level value.
- *
- * <p>The default initial bundle start level value is 1
- * unless this method has been
- * called to assign a different initial bundle
- * start level value.
- *
- * <p>This method does not change the start level values of installed
- * bundles.
- *
- * @param startlevel The initial start level for newly installed bundles.
- * @throws IllegalArgumentException If the specified start level is less than or
- * equal to zero.
- * @throws SecurityException if the caller does not have the
- * <tt>AdminPermission</tt> and the Java runtime environment supports
- * permissions.
- */
- public void setInitialBundleStartLevel(int startlevel) {
- startLevelImpl.setInitialBundleStartLevel(startlevel);
- }
-
- /**
- * Return the active start level value of the Framework.
- *
- * If the Framework is in the process of changing the start level
- * this method must return the active start level if this
- * differs from the requested start level.
- *
- * @return The active start level value of the Framework.
- */
- public int getStartLevel() {
- return startLevelImpl.getStartLevel();
- }
- /**
- * Modify the active start level of the Framework.
- *
- * <p>The Framework will move to the requested start level. This method
- * will return immediately to the caller and the start level
- * change will occur asynchronously on another thread.
- *
- * <p>If the specified start level is
- * higher than the active start level, the
- * Framework will continue to increase the start level
- * until the Framework has reached the specified start level,
- * starting bundles at each
- * start level which are persistently marked to be started as described in the
- * <tt>Bundle.start</tt> method.
- *
- * At each intermediate start level value on the
- * way to and including the target start level, the framework must:
- * <ol>
- * <li>Change the active start level to the intermediate start level value.
- * <li>Start bundles at the intermediate start level in
- * ascending order by <tt>Bundle.getBundleId</tt>.
- * </ol>
- * When this process completes after the specified start level is reached,
- * the Framework will broadcast a Framework event of
- * type <tt>FrameworkEvent.STARTLEVEL_CHANGED</tt> to announce it has moved to the specified
- * start level.
- *
- * <p>If the specified start level is lower than the active start level, the
- * Framework will continue to decrease the start level
- * until the Framework has reached the specified start level
- * stopping bundles at each
- * start level as described in the <tt>Bundle.stop</tt> method except that their
- * persistently recorded state indicates that they must be restarted in the
- * future.
- *
- * At each intermediate start level value on the
- * way to and including the specified start level, the framework must:
- * <ol>
- * <li>Stop bundles at the intermediate start level in
- * descending order by <tt>Bundle.getBundleId</tt>.
- * <li>Change the active start level to the intermediate start level value.
- * </ol>
- * When this process completes after the specified start level is reached,
- * the Framework will broadcast a Framework event of
- * type <tt>FrameworkEvent.STARTLEVEL_CHANGED</tt> to announce it has moved to the specified
- * start level.
- *
- * <p>If the specified start level is equal to the active start level, then
- * no bundles are started or stopped, however, the Framework must broadcast
- * a Framework event of type <tt>FrameworkEvent.STARTLEVEL_CHANGED</tt> to
- * announce it has finished moving to the specified start level. This
- * event may arrive before the this method return.
- *
- * @param startlevel The requested start level for the Framework.
- * @throws IllegalArgumentException If the specified start level is less than or
- * equal to zero.
- * @throws SecurityException If the caller does not have the
- * <tt>AdminPermission</tt> and the Java runtime environment supports
- * permissions.
- */
- public void setStartLevel(int newSL) {
- startLevelImpl.setStartLevel(newSL, callerBundle);
- }
-
- /**
- * Return the persistent state of the specified bundle.
- *
- * <p>This method returns the persistent state of a bundle.
- * The persistent state of a bundle indicates whether a bundle
- * is persistently marked to be started when it's start level is
- * reached.
- *
- * @return <tt>true</tt> if the bundle is persistently marked to be started,
- * <tt>false</tt> if the bundle is not persistently marked to be started.
- * @exception java.lang.IllegalArgumentException If the specified bundle has been uninstalled.
- */
- public boolean isBundlePersistentlyStarted(org.osgi.framework.Bundle bundle) {
- return startLevelImpl.isBundlePersistentlyStarted(bundle);
- }
-
- /**
- * Return the assigned start level value for the specified Bundle.
- *
- * @param bundle The target bundle.
- * @return The start level value of the specified Bundle.
- * @exception java.lang.IllegalArgumentException If the specified bundle has been uninstalled.
- */
- public int getBundleStartLevel(org.osgi.framework.Bundle bundle) {
-
- return startLevelImpl.getBundleStartLevel(bundle);
- }
-
- /**
- * Assign a start level value to the specified Bundle.
- *
- * <p>The specified bundle will be assigned the specified start level. The
- * start level value assigned to the bundle will be persistently recorded
- * by the Framework.
- *
- * If the new start level for the bundle is lower than or equal to the active start level of
- * the Framework, the Framework will start the specified bundle as described
- * in the <tt>Bundle.start</tt> method if the bundle is persistently marked
- * to be started. The actual starting of this bundle must occur asynchronously.
- *
- * If the new start level for the bundle is higher than the active start level of
- * the Framework, the Framework will stop the specified bundle as described
- * in the <tt>Bundle.stop</tt> method except that the persistently recorded
- * state for the bundle indicates that the bundle must be restarted in the
- * future. The actual stopping of this bundle must occur asynchronously.
- *
- * @param bundle The target bundle.
- * @param startlevel The new start level for the specified Bundle.
- * @throws IllegalArgumentException
- * If the specified bundle has been uninstalled or
- * if the specified start level is less than or equal to zero, or the specified bundle is
- * the system bundle.
- * @throws SecurityException if the caller does not have the
- * <tt>AdminPermission</tt> and the Java runtime environment supports
- * permissions.
- */
- public void setBundleStartLevel(org.osgi.framework.Bundle bundle, int newSL) {
- startLevelImpl.setBundleStartLevel(bundle, newSL);
-
- }
-
-}
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/StartLevelEvent.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/StartLevelEvent.java
index aff9cc8..e5e2b07 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/StartLevelEvent.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/StartLevelEvent.java
@@ -41,7 +41,7 @@
* For a change in bundle startlevel, this is the bundle to be changed.
* For a change in framework startlevel, this is the bundle requesting the change.
*/
- private transient Bundle bundle;
+ private transient AbstractBundle bundle;
/**
* Creates a StartLevel event regarding the specified bundle.
@@ -50,7 +50,7 @@
* @param int newSl the ultimate requested startlevel we are on our way to
* @param bundle The affected bundle, or system bundle if it is for the framework
*/
- public StartLevelEvent(int type, int newSl, Bundle bundle) {
+ public StartLevelEvent(int type, int newSl, AbstractBundle bundle) {
super(bundle);
this.type = type;
this.newSl = newSl;
@@ -65,7 +65,7 @@
return this.newSl;
}
- public Bundle getBundle() {
+ public AbstractBundle getBundle() {
return this.bundle;
}
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/StartLevelFactory.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/StartLevelFactory.java
deleted file mode 100644
index 7d9e6c8..0000000
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/StartLevelFactory.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) The Open Services Gateway Initiative (2000, 2001).
- * All Rights Reserved.
- *
- * Implementation of certain elements of the Open Services Gateway Initiative (OSGI)
- * Specification may be subject to third party intellectual property rights,
- * including without limitation, patent rights (such a third party may or may
- * not be a member of OSGi). OSGi is not responsible and shall not be held
- * responsible in any manner for identifying or failing to identify any or
- * all such third party intellectual property rights.
- *
- * This document and the information contained herein are provided on an "AS IS"
- * basis and OSGI DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT
- * INFRINGE ANY RIGHTS AND ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS
- * FOR A PARTICULAR PURPOSE. IN NO EVENT WILL OSGI BE LIABLE FOR ANY LOSS OF
- * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF BUSINESS,
- * OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTIAL, PUNITIVE OR
- * CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH THIS DOCUMENT OR THE
- * INFORMATION CONTAINED HEREIN, EVEN IF ADVISED OF THE POSSIBILITY
- * OF SUCH LOSS OR DAMAGE.
- *
- * All Company, brand and product names may be trademarks that are the sole
- * property of their respective owners. All rights reserved.
- */
-package org.eclipse.osgi.framework.internal.core;
-
-import org.osgi.framework.*;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceRegistration;
-
-/**
- * Service Factory class, providing StartLevel objects
- * to those requesting org.osgi.service.startlevel.StartLevel service.
- */
-public class StartLevelFactory implements ServiceFactory {
-
- /** need a reference to the framework */
- Framework framework;
-
- protected StartLevelFactory(Framework framework) {
- this.framework = framework;
- }
-
- /**
- * Returns a StartLevel object, created for each requesting bundle.
- *
- * @param callerBundle bundle, requested to get StartLevel service.
- * @pre callerBundle!=null
- * @param sReg ServiceRegistration of the StartLevel service
- * @pre sReg!=null
- * @return StartLevel object
- */
- public Object getService(Bundle callerBundle, ServiceRegistration sReg) {
- return new StartLevel(callerBundle, framework);
- }
-
- /**
- * Does nothing, as the StartLevel bundle does not keep references to StartLevel objects.
- *
- * @param callerBundle bundle requesting to unget StartLevel service.
- * @param sReg ServiceRegistration of StartLevel
- * @param obj Service object, already been got by this bundle.
- */
- public void ungetService(Bundle callerBundle, ServiceRegistration sReg, Object obj) {
- }
-}
\ No newline at end of file
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/StartLevelImpl.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/StartLevelImpl.java
index e2d0b8d..db7f23f 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/StartLevelImpl.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/StartLevelImpl.java
@@ -11,16 +11,11 @@
package org.eclipse.osgi.framework.internal.core;
-import java.io.IOException;
-import java.util.EventListener;
-import java.util.List;
-import org.eclipse.osgi.framework.debug.Debug;
-import org.eclipse.osgi.framework.eventmgr.*;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.Bundle;
+import org.osgi.service.startlevel.StartLevel;
/**
- * StartLevel service implementation for the OSGi specification.
+ * StartLevel service for the OSGi specification.
*
* Framework service which allows management of framework and bundle startlevels.
*
@@ -28,81 +23,26 @@
* registered in the framework.
*
*/
-public class StartLevelImpl implements EventDispatcher, EventListener {
+public class StartLevelImpl implements StartLevel {
- protected static Framework framework;
- protected static EventManager eventManager;
- protected static EventListeners startLevelListeners;
+ protected StartLevelManager manager;
+ protected Bundle owner;
- /** The framework beginning startlevel. Default is 1 */
- protected int frameworkBeginningStartLevel = 1;
-
- /** The initial bundle start level for newly installed bundles */
- protected int initialBundleStartLevel = 1;
- // default value is 1 for compatibility mode
-
- /** The currently active framework start level */
- private static int activeSL = 0;
-
- /** An object used to lock the active startlevel while it is being referenced */
- private static final Object lock = new Object();
-
- /** This constructor is called by the Framework */
- protected StartLevelImpl(Framework framework) {
- StartLevelImpl.framework = framework;
- }
-
- protected void initialize() {
- initialBundleStartLevel = framework.adaptor.getInitialBundleStartLevel();
-
- // Set Framework Beginning Start Level Property
- String value = framework.getProperty(Constants.OSGI_FRAMEWORKBEGINNINGSTARTLEVEL);
- if (value == null) {
- value = Constants.DEFAULT_STARTLEVEL;
- } else {
- try {
- if (Integer.parseInt(value) <= 0) {
- System.err.println(Msg.formatter.getString("PROPERTIES_INVALID_FW_STARTLEVEL", Constants.DEFAULT_STARTLEVEL));
- value = Constants.DEFAULT_STARTLEVEL;
- }
- } catch (NumberFormatException nfe) {
- System.err.println(Msg.formatter.getString("PROPERTIES_INVALID_FW_STARTLEVEL", Constants.DEFAULT_STARTLEVEL));
- value = Constants.DEFAULT_STARTLEVEL;
- }
- }
- framework.setProperty(Constants.OSGI_FRAMEWORKBEGINNINGSTARTLEVEL, value);
- frameworkBeginningStartLevel = Integer.parseInt(value);
-
- // create an event manager and a start level listener
- eventManager = new EventManager("Start Level Event Dispatcher");
- startLevelListeners = new EventListeners();
- startLevelListeners.addListener(this, this);
- }
-
- protected void cleanup() {
- eventManager = null;
- startLevelListeners.removeAllListeners();
- startLevelListeners = null;
+ /** This constructor is called by the StartLevel factory */
+ protected StartLevelImpl(Bundle owner, Framework framework) {
+ this.owner = owner;
+ this.manager = framework.startLevelManager;
}
/**
- * Return the initial start level value that is assigned
- * to a Bundle when it is first installed.
- *
- * @return The initial start level value for Bundles.
- * @see #setInitialBundleStartLevel
- */
+ * Return the initial start level value that is assigned
+ * to a Bundle when it is first installed.
+ *
+ * @return The initial start level value for Bundles.
+ * @see #setInitialBundleStartLevel
+ */
public int getInitialBundleStartLevel() {
- return initialBundleStartLevel;
- }
-
- /**
- * Return the initial start level used when the framework is started.
- *
- * @return The framework start level.
- */
- public int getFrameworkStartLevel() {
- return frameworkBeginningStartLevel;
+ return manager.getInitialBundleStartLevel();
}
/**
@@ -132,13 +72,9 @@
* permissions.
*/
public void setInitialBundleStartLevel(int startlevel) {
- framework.checkAdminPermission();
- if (startlevel <= 0) {
- throw new IllegalArgumentException();
- }
- initialBundleStartLevel = startlevel;
- framework.adaptor.setInitialBundleStartLevel(startlevel);
+ manager.setInitialBundleStartLevel(startlevel);
}
+
/**
* Return the active start level value of the Framework.
*
@@ -149,7 +85,7 @@
* @return The active start level value of the Framework.
*/
public int getStartLevel() {
- return activeSL;
+ return manager.getStartLevel();
}
/**
* Modify the active start level of the Framework.
@@ -211,89 +147,8 @@
* <tt>AdminPermission</tt> and the Java runtime environment supports
* permissions.
*/
- public void setStartLevel(int newSL, org.osgi.framework.Bundle callerBundle) {
- if (newSL <= 0) {
- throw new IllegalArgumentException(Msg.formatter.getString("STARTLEVEL_EXCEPTION_INVALID_REQUESTED_STARTLEVEL", "" + newSL));
- }
- framework.checkAdminPermission();
-
- if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
- Debug.println("StartLevelImpl: setStartLevel: " + newSL + "; callerBundle = " + callerBundle.getBundleId());
- }
- issueEvent(new StartLevelEvent(StartLevelEvent.CHANGE_FW_SL, newSL, (Bundle) callerBundle));
-
- }
-
- protected void setStartLevel(int newSL) {
- setStartLevel(newSL, framework.systemBundle);
- }
-
- /**
- * Internal method to allow the framework to be launched synchronously by calling the
- * StartLevelListener worker calls directly
- *
- * This method does not return until all bundles that should be started are started
- */
- protected void launch(int startlevel) {
-
- doSetStartLevel(startlevel, framework.systemBundle);
- }
-
- /**
- * Internal method to shut down the framework synchronously by setting the startlevel to zero
- * and calling the StartLevelListener worker calls directly
- *
- * This method does not return until all bundles are stopped and the framework is shut down.
- */
- protected void shutdown() {
-
- doSetStartLevel(0, framework.systemBundle);
- }
-
- /**
- * Internal worker method to set the startlevel
- *
- * @param new start level value
- * @param Bundle - the bundle initiating the change in start level
- */
- private void doSetStartLevel(int newSL, Bundle callerBundle) {
- synchronized (lock) {
- int tempSL = activeSL;
-
- if (newSL > tempSL) {
- for (int i = tempSL; i < newSL; i++) {
- if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
- Debug.println("sync - incrementing Startlevel from " + tempSL);
- }
- tempSL++;
- incFWSL(i + 1, callerBundle);
- }
- } else {
- for (int i = tempSL; i > newSL; i--) {
- if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
- Debug.println("sync - decrementing Startlevel from " + tempSL);
- }
- tempSL--;
- decFWSL(i - 1);
- }
- }
- framework.publishFrameworkEvent(FrameworkEvent.STARTLEVEL_CHANGED, callerBundle, null);
- if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
- Debug.println("StartLevelImpl: doSetStartLevel: STARTLEVEL_CHANGED event published");
- }
- }
- }
-
- /**
- * This method is used within the package to save the actual active startlevel value for the framework.
- * Externally the setStartLevel method must be used.
- *
- * @param newSL - the new startlevel to save
- */
- protected void saveActiveStartLevel(int newSL) {
- synchronized (lock) {
- activeSL = newSL;
- }
+ public void setStartLevel(int newSL) {
+ manager.setStartLevel(newSL, owner);
}
/**
@@ -308,15 +163,10 @@
* <tt>false</tt> if the bundle is not persistently marked to be started.
* @exception java.lang.IllegalArgumentException If the specified bundle has been uninstalled.
*/
- public boolean isBundlePersistentlyStarted(org.osgi.framework.Bundle bundle) {
-
- if (bundle.getState() == Bundle.UNINSTALLED) {
- throw new IllegalArgumentException(Msg.formatter.getString("BUNDLE_UNINSTALLED_EXCEPTION"));
- }
- Bundle b = (Bundle) bundle;
- int status = b.getBundleData().getStatus();
- return ((status & org.eclipse.osgi.framework.internal.core.Constants.BUNDLE_STARTED) == Constants.BUNDLE_STARTED);
+ public boolean isBundlePersistentlyStarted(Bundle bundle) {
+ return manager.isBundlePersistentlyStarted(bundle);
}
+
/**
* Return the assigned start level value for the specified Bundle.
*
@@ -324,12 +174,9 @@
* @return The start level value of the specified Bundle.
* @exception java.lang.IllegalArgumentException If the specified bundle has been uninstalled.
*/
- public int getBundleStartLevel(org.osgi.framework.Bundle bundle) {
+ public int getBundleStartLevel(Bundle bundle) {
- if (bundle.getState() == Bundle.UNINSTALLED) {
- throw new IllegalArgumentException(Msg.formatter.getString("BUNDLE_UNINSTALLED_EXCEPTION"));
- }
- return ((Bundle) bundle).getStartLevel();
+ return manager.getBundleStartLevel(bundle);
}
/**
@@ -360,375 +207,9 @@
* <tt>AdminPermission</tt> and the Java runtime environment supports
* permissions.
*/
- public void setBundleStartLevel(org.osgi.framework.Bundle bundle, int newSL) {
+ public void setBundleStartLevel(Bundle bundle, int newSL) {
+ manager.setBundleStartLevel(bundle, newSL);
- String exceptionText = "";
- if (bundle.getBundleId() == 0) { // system bundle has id=0
- exceptionText = Msg.formatter.getString("STARTLEVEL_CANT_CHANGE_SYSTEMBUNDLE_STARTLEVEL");
- } else if (bundle.getState() == Bundle.UNINSTALLED) {
- exceptionText = Msg.formatter.getString("BUNDLE_UNINSTALLED_EXCEPTION");
- } else if (newSL <= 0) {
- exceptionText = Msg.formatter.getString("STARTLEVEL_EXCEPTION_INVALID_REQUESTED_STARTLEVEL", "" + newSL);
- }
- if (exceptionText.length() > 0) {
- throw new IllegalArgumentException(exceptionText);
- }
-
- try {
- // if the bundle's startlevel is not already at the requested startlevel
- if (newSL != ((org.eclipse.osgi.framework.internal.core.Bundle) bundle).getStartLevel()) {
- Bundle b = (Bundle) bundle;
- b.getBundleData().setStartLevel(newSL);
- b.getBundleData().save();
-
- framework.checkAdminPermission();
-
- // handle starting or stopping the bundle asynchronously
- issueEvent(new StartLevelEvent(StartLevelEvent.CHANGE_BUNDLE_SL, newSL, (Bundle) bundle));
- }
- } catch (IOException e) {
- framework.publishFrameworkEvent(FrameworkEvent.ERROR, bundle, e);
- }
-
- }
-
- /**
- * This method sends the StartLevelEvent to the EventManager for dispatching
- *
- * @param sle The event to be queued to the Event Manager
- */
- private void issueEvent(StartLevelEvent sle) {
-
- /* queue to hold set of listeners */
- ListenerQueue queue = new ListenerQueue(eventManager);
-
- /* add set of StartLevelListeners to queue */
- queue.queueListeners(startLevelListeners, this);
-
- /* dispatch event to set of listeners */
- queue.dispatchEventAsynchronous(sle.getType(), sle);
- }
-
- /**
- * This method is the call back that is called once for each listener.
- * This method must cast the EventListener object to the appropriate listener
- * class for the event type and call the appropriate listener method.
- *
- * @param listener This listener must be cast to the appropriate listener
- * class for the events created by this source and the appropriate listener method
- * must then be called.
- * @param listenerObject This is the optional object that was passed to
- * EventListeners.addListener when the listener was added to the EventListeners.
- * @param eventAction This value was passed to the ListenerQueue object via one of its
- * dispatchEvent* method calls. It can provide information (such
- * as which listener method to call) so that this method
- * can complete the delivery of the event to the listener.
- * @param eventObject This object was passed to the ListenerQueue object via one of its
- * dispatchEvent* method calls. This object was created by the event source and
- * is passed to this method. It should contain all the necessary information (such
- * as what event object to pass) so that this method
- * can complete the delivery of the event to the listener.
- */
- public void dispatchEvent(Object listener, Object listenerObject, int eventAction, Object eventObject) {
- switch (eventAction) {
- case StartLevelEvent.CHANGE_BUNDLE_SL :
- setBundleSL((StartLevelEvent) eventObject);
- break;
- case StartLevelEvent.CHANGE_FW_SL :
- doSetStartLevel(((StartLevelEvent) eventObject).getNewSL(), ((StartLevelEvent) eventObject).getBundle());
- break;
- }
- }
-
- /**
- * Increment the active startlevel by one
- */
- protected void incFWSL(int activeSL, Bundle callerBundle) {
- if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
- Debug.println("SLL: incFWSL: saving activeSL of " + activeSL);
- }
-
- framework.startLevelImpl.saveActiveStartLevel(activeSL);
-
- Bundle[] launch;
- BundleRepository bundles = framework.bundles;
-
- launch = getInstalledBundles(bundles);
-
- if (activeSL == 1) { // framework was not active
-
- /* Load all installed bundles */
- loadInstalledBundles(launch);
-
- /* attempt to resolve all bundles */
- framework.packageAdmin.setResolvedBundles();
-
- /* Resume all bundles */
- resumeBundles(launch, true);
-
- /* publish the framework started event */
- if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
- Debug.println("SLL: Framework started");
- }
-
- framework.publishFrameworkEvent(FrameworkEvent.STARTED, callerBundle, null);
-
- } else {
- // incrementing an already active framework
- resumeBundles(launch, false);
- }
- }
-
- /**
- * Build an array of all installed bundles to be launch.
- * The returned array is sorted by increasing startlevel/id order.
- * @param bundles - the bundles installed in the framework
- * @return A sorted array of bundles
- */
- private Bundle[] getInstalledBundles(BundleRepository bundles) {
-
- /* make copy of bundles vector in case it is modified during launch */
- Bundle[] installedBundles;
-
- synchronized (bundles) {
- List allBundles = bundles.getBundles();
- installedBundles = new Bundle[allBundles.size()];
- allBundles.toArray(installedBundles);
-
- /* sort bundle array in ascending startlevel / bundle id order
- * so that bundles are started in ascending order.
- */
- Util.sort(installedBundles, 0, installedBundles.length);
- }
-
- return installedBundles;
- }
-
- /**
- * Load all bundles in the list
- * @param Bundle[] a list of bundles to load
- */
- private void loadInstalledBundles(Bundle[] installedBundles) {
-
- for (int i = 0; i < installedBundles.length; i++) {
- Bundle bundle = installedBundles[i];
-
- try {
- if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
- Debug.println("SLL: Trying to load bundle " + bundle);
- }
-
- bundle.load();
-
- } catch (BundleException be) {
- if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
- Debug.println("SLL: Bundle load exception: " + be.getMessage());
- Debug.printStackTrace(be.getNestedException());
- }
-
- framework.publishFrameworkEvent(FrameworkEvent.ERROR, bundle, be);
- }
- }
- }
-
- /**
- * Resume all bundles in the launch list
- * @param Bundle[] a list of Bundle Objects to launch
- * @param boolean tells whether or not to launch the framework (system bundle)
- */
- private void resumeBundles(Bundle[] launch, boolean launchingFW) {
- BundleException sbe = null;
- if (launchingFW) {
- /* Start the system bundle */
- try {
- framework.systemBundle.context.start();
- } catch (BundleException be) {
- // TODO: We may have to do something more drastic here if the SystemBundle did not start.
- sbe = be;
- }
-
- }
- /* Resume all bundles that were previously started and whose startlevel is <= the active startlevel */
-
- int fwsl = framework.startLevelImpl.getStartLevel();
- for (int i = 0; i < launch.length; i++) {
- int bsl = launch[i].getStartLevel();
- if (bsl < fwsl) {
- // skip bundles who should have already been started
- continue;
- } else if (bsl == fwsl) {
- if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
- Debug.println("SLL: Active sl = " + fwsl + "; Bundle " + launch[i].getBundleId() + " sl = " + bsl);
- }
- framework.resumeBundle(launch[i]);
- } else {
- // can stop resuming bundles since any remaining bundles have a greater startlevel than the framework active startlevel
- break;
- }
- }
-
- if (sbe == null) {
- framework.systemBundle.state = Bundle.ACTIVE;
- } else {
- if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
- Debug.println("SLL: Bundle resume exception: " + sbe.getMessage());
- Debug.printStackTrace(sbe.getNestedException());
- }
-
- framework.publishFrameworkEvent(FrameworkEvent.ERROR, framework.systemBundle, sbe);
- }
- }
-
- /**
- * Decrement the active startlevel by one
- * @param int activeSL - the startlevel value to set the framework to
- */
- protected void decFWSL(int activeSL) {
- if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
- Debug.println("SLL: decFWSL: saving activeSL of " + activeSL);
- }
-
- framework.startLevelImpl.saveActiveStartLevel(activeSL);
-
- BundleRepository bundles = framework.bundles;
-
- if (activeSL == 0) { // stopping the framework
-
- framework.systemBundle.state = Bundle.STOPPING;
-
- /* stop all running bundles */
-
- suspendAllBundles(bundles);
-
- unloadAllBundles(bundles);
-
- } else {
- // just decrementing the active startlevel - framework is not shutting down
- synchronized (bundles) {
- // get the list of installed bundles, sorted by startlevel
- Bundle[] shutdown = this.getInstalledBundles(bundles);
- for (int i = shutdown.length - 1; i >= 0; i--) {
- int bsl = shutdown[i].getStartLevel();
- if (bsl > activeSL + 1) {
- // don't need to mess with bundles with startlevel > the previous active - they should
- // already have been stopped
- continue;
- } else if (bsl <= activeSL) {
- // don't need to keep going - we've stopped all we're going to stop
- break;
- } else if (shutdown[i].isActive()) {
- // if bundle is active or starting, then stop the bundle
- if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
- Debug.println("SLL: stopping bundle " + shutdown[i].getBundleId());
- }
- framework.suspendBundle(shutdown[i], false);
- }
- }
- }
- }
- }
-
- /**
- * Suspends all bundles in the vector passed in.
- * @param Vector of Bundle objects to be suspended
- */
- private void suspendAllBundles(BundleRepository bundles) {
- synchronized (bundles) {
- boolean changed;
- do {
- changed = false;
-
- Bundle[] shutdown = this.getInstalledBundles(bundles);
-
- // shutdown all running bundles
- for (int i = shutdown.length - 1; i >= 0; i--) {
- Bundle bundle = shutdown[i];
-
- if (framework.suspendBundle(bundle, false)) {
- if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
- Debug.println("SLL: stopped bundle " + bundle.getBundleId());
- }
- changed = true;
- }
- }
- } while (changed);
-
- try {
- framework.systemBundle.context.stop();
- } catch (BundleException sbe) {
- if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
- Debug.println("SLL: Bundle suspend exception: " + sbe.getMessage());
- Debug.printStackTrace(sbe.getNestedException());
- }
-
- framework.publishFrameworkEvent(FrameworkEvent.ERROR, framework.systemBundle, sbe);
- }
-
- framework.systemBundle.state = Bundle.STARTING;
- }
- }
-
- /**
- * Unloads all bundles in the vector passed in.
- * @param Vector of Bundle objects to be unloaded
- */
- private void unloadAllBundles(BundleRepository bundles) {
- synchronized (bundles) {
- /* unload all installed bundles */
- List allBundles = bundles.getBundles();
- int size = allBundles.size();
-
- for (int i = 0; i < size; i++) {
- Bundle bundle = (Bundle) allBundles.get(i);
-
- if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
- Debug.println("SLL: Trying to unload bundle " + bundle);
- }
-
- try {
- bundle.refresh();
- } catch (BundleException e) {
- // do nothing.
- }
- }
- }
- }
-
- /**
- * Set the bundle's startlevel to the new value
- * This may cause the bundle to start or stop based on the active framework startlevel
- * @param StartLevelEvent - the event requesting change in bundle startlevel
- */
- protected void setBundleSL(StartLevelEvent startLevelEvent) {
- synchronized (lock) {
- int activeSL = framework.startLevelImpl.getStartLevel();
- int newSL = startLevelEvent.getNewSL();
- Bundle bundle = startLevelEvent.getBundle();
-
- int bundlestate = bundle.getState();
- if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
- Debug.print("SLL: bundle active=" + bundle.isActive());
- Debug.print("; newSL = " + newSL);
- Debug.println("; activeSL = " + activeSL);
- }
-
- if (bundle.isActive() && (newSL > activeSL)) {
- if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
- Debug.println("SLL: stopping bundle " + bundle.getBundleId());
- }
- framework.suspendBundle(bundle, false);
- } else {
- if (!bundle.isActive() && (newSL <= activeSL)) {
- if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
- Debug.println("SLL: starting bundle " + bundle.getBundleId());
- }
- framework.resumeBundle(bundle);
- }
- }
- if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
- Debug.println("SLL: Bundle Startlevel set to " + newSL);
- }
- }
}
}
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/StartLevelManager.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/StartLevelManager.java
new file mode 100644
index 0000000..2dee051
--- /dev/null
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/StartLevelManager.java
@@ -0,0 +1,759 @@
+/*******************************************************************************
+ * Copyright (c) 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.osgi.framework.internal.core;
+
+import java.io.IOException;
+import java.util.EventListener;
+import java.util.List;
+import org.eclipse.osgi.framework.debug.Debug;
+import org.eclipse.osgi.framework.eventmgr.*;
+import org.osgi.framework.*;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.FrameworkEvent;
+
+/**
+ * StartLevel service implementation for the OSGi specification.
+ *
+ * Framework service which allows management of framework and bundle startlevels.
+ *
+ * This class also acts as the StartLevel service factory class, providing StartLevel objects
+ * to those requesting org.osgi.service.startlevel.StartLevel service.
+ *
+ * If present, there will only be a single instance of this service
+ * registered in the framework.
+ */
+public class StartLevelManager implements EventDispatcher, EventListener, ServiceFactory {
+
+ protected static Framework framework;
+ protected static EventManager eventManager;
+ protected static EventListeners startLevelListeners;
+
+ /** The framework beginning startlevel. Default is 1 */
+ protected int frameworkBeginningStartLevel = 1;
+
+ /** The initial bundle start level for newly installed bundles */
+ protected int initialBundleStartLevel = 1;
+ // default value is 1 for compatibility mode
+
+ /** The currently active framework start level */
+ private static int activeSL = 0;
+
+ /** An object used to lock the active startlevel while it is being referenced */
+ private static final Object lock = new Object();
+
+ /** This constructor is called by the Framework */
+ protected StartLevelManager(Framework framework) {
+ StartLevelManager.framework = framework;
+ }
+
+ protected void initialize() {
+ initialBundleStartLevel = framework.adaptor.getInitialBundleStartLevel();
+
+ // Set Framework Beginning Start Level Property
+ String value = framework.getProperty(Constants.OSGI_FRAMEWORKBEGINNINGSTARTLEVEL);
+ if (value == null) {
+ value = Constants.DEFAULT_STARTLEVEL;
+ } else {
+ try {
+ if (Integer.parseInt(value) <= 0) {
+ System.err.println(Msg.formatter.getString("PROPERTIES_INVALID_FW_STARTLEVEL", Constants.DEFAULT_STARTLEVEL));
+ value = Constants.DEFAULT_STARTLEVEL;
+ }
+ } catch (NumberFormatException nfe) {
+ System.err.println(Msg.formatter.getString("PROPERTIES_INVALID_FW_STARTLEVEL", Constants.DEFAULT_STARTLEVEL));
+ value = Constants.DEFAULT_STARTLEVEL;
+ }
+ }
+ framework.setProperty(Constants.OSGI_FRAMEWORKBEGINNINGSTARTLEVEL, value);
+ frameworkBeginningStartLevel = Integer.parseInt(value);
+
+ // create an event manager and a start level listener
+ eventManager = new EventManager("Start Level Event Dispatcher");
+ startLevelListeners = new EventListeners();
+ startLevelListeners.addListener(this, this);
+ }
+
+ protected void cleanup() {
+ eventManager = null;
+ startLevelListeners.removeAllListeners();
+ startLevelListeners = null;
+ }
+
+ /**
+ * Return the initial start level value that is assigned
+ * to a Bundle when it is first installed.
+ *
+ * @return The initial start level value for Bundles.
+ * @see #setInitialBundleStartLevel
+ */
+ public int getInitialBundleStartLevel() {
+ return initialBundleStartLevel;
+ }
+
+ /**
+ * Return the initial start level used when the framework is started.
+ *
+ * @return The framework start level.
+ */
+ public int getFrameworkStartLevel() {
+ return frameworkBeginningStartLevel;
+ }
+
+ /**
+ * Set the initial start level value that is assigned
+ * to a Bundle when it is first installed.
+ *
+ * <p>The initial bundle start level will be set to the specified start level. The
+ * initial bundle start level value will be persistently recorded
+ * by the Framework.
+ *
+ * <p>When a Bundle is installed via <tt>BundleContext.installBundle</tt>,
+ * it is assigned the initial bundle start level value.
+ *
+ * <p>The default initial bundle start level value is 1
+ * unless this method has been
+ * called to assign a different initial bundle
+ * start level value.
+ *
+ * <p>This method does not change the start level values of installed
+ * bundles.
+ *
+ * @param startlevel The initial start level for newly installed bundles.
+ * @throws IllegalArgumentException If the specified start level is less than or
+ * equal to zero.
+ * @throws SecurityException if the caller does not have the
+ * <tt>AdminPermission</tt> and the Java runtime environment supports
+ * permissions.
+ */
+ public void setInitialBundleStartLevel(int startlevel) {
+ framework.checkAdminPermission();
+ if (startlevel <= 0) {
+ throw new IllegalArgumentException();
+ }
+ initialBundleStartLevel = startlevel;
+ framework.adaptor.setInitialBundleStartLevel(startlevel);
+ }
+ /**
+ * Return the active start level value of the Framework.
+ *
+ * If the Framework is in the process of changing the start level
+ * this method must return the active start level if this
+ * differs from the requested start level.
+ *
+ * @return The active start level value of the Framework.
+ */
+ public int getStartLevel() {
+ return activeSL;
+ }
+ /**
+ * Modify the active start level of the Framework.
+ *
+ * <p>The Framework will move to the requested start level. This method
+ * will return immediately to the caller and the start level
+ * change will occur asynchronously on another thread.
+ *
+ * <p>If the specified start level is
+ * higher than the active start level, the
+ * Framework will continue to increase the start level
+ * until the Framework has reached the specified start level,
+ * starting bundles at each
+ * start level which are persistently marked to be started as described in the
+ * <tt>Bundle.start</tt> method.
+ *
+ * At each intermediate start level value on the
+ * way to and including the target start level, the framework must:
+ * <ol>
+ * <li>Change the active start level to the intermediate start level value.
+ * <li>Start bundles at the intermediate start level in
+ * ascending order by <tt>Bundle.getBundleId</tt>.
+ * </ol>
+ * When this process completes after the specified start level is reached,
+ * the Framework will broadcast a Framework event of
+ * type <tt>FrameworkEvent.STARTLEVEL_CHANGED</tt> to announce it has moved to the specified
+ * start level.
+ *
+ * <p>If the specified start level is lower than the active start level, the
+ * Framework will continue to decrease the start level
+ * until the Framework has reached the specified start level
+ * stopping bundles at each
+ * start level as described in the <tt>Bundle.stop</tt> method except that their
+ * persistently recorded state indicates that they must be restarted in the
+ * future.
+ *
+ * At each intermediate start level value on the
+ * way to and including the specified start level, the framework must:
+ * <ol>
+ * <li>Stop bundles at the intermediate start level in
+ * descending order by <tt>Bundle.getBundleId</tt>.
+ * <li>Change the active start level to the intermediate start level value.
+ * </ol>
+ * When this process completes after the specified start level is reached,
+ * the Framework will broadcast a Framework event of
+ * type <tt>FrameworkEvent.STARTLEVEL_CHANGED</tt> to announce it has moved to the specified
+ * start level.
+ *
+ * <p>If the specified start level is equal to the active start level, then
+ * no bundles are started or stopped, however, the Framework must broadcast
+ * a Framework event of type <tt>FrameworkEvent.STARTLEVEL_CHANGED</tt> to
+ * announce it has finished moving to the specified start level. This
+ * event may arrive before the this method return.
+ *
+ * @param startlevel The requested start level for the Framework.
+ * @throws IllegalArgumentException If the specified start level is less than or
+ * equal to zero.
+ * @throws SecurityException If the caller does not have the
+ * <tt>AdminPermission</tt> and the Java runtime environment supports
+ * permissions.
+ */
+ public void setStartLevel(int newSL, org.osgi.framework.Bundle callerBundle) {
+ if (newSL <= 0) {
+ throw new IllegalArgumentException(Msg.formatter.getString("STARTLEVEL_EXCEPTION_INVALID_REQUESTED_STARTLEVEL", "" + newSL));
+ }
+ framework.checkAdminPermission();
+
+ if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
+ Debug.println("StartLevelImpl: setStartLevel: " + newSL + "; callerBundle = " + callerBundle.getBundleId());
+ }
+ issueEvent(new StartLevelEvent(StartLevelEvent.CHANGE_FW_SL, newSL, (AbstractBundle) callerBundle));
+
+ }
+
+ protected void setStartLevel(int newSL) {
+ setStartLevel(newSL, framework.systemBundle);
+ }
+
+ /**
+ * Internal method to allow the framework to be launched synchronously by calling the
+ * StartLevelListener worker calls directly
+ *
+ * This method does not return until all bundles that should be started are started
+ */
+ protected void launch(int startlevel) {
+
+ doSetStartLevel(startlevel, framework.systemBundle);
+ }
+
+ /**
+ * Internal method to shut down the framework synchronously by setting the startlevel to zero
+ * and calling the StartLevelListener worker calls directly
+ *
+ * This method does not return until all bundles are stopped and the framework is shut down.
+ */
+ protected void shutdown() {
+
+ doSetStartLevel(0, framework.systemBundle);
+ }
+
+ /**
+ * Internal worker method to set the startlevel
+ *
+ * @param new start level value
+ * @param Bundle - the bundle initiating the change in start level
+ */
+ private void doSetStartLevel(int newSL, AbstractBundle callerBundle) {
+ synchronized (lock) {
+ int tempSL = activeSL;
+
+ if (newSL > tempSL) {
+ for (int i = tempSL; i < newSL; i++) {
+ if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
+ Debug.println("sync - incrementing Startlevel from " + tempSL);
+ }
+ tempSL++;
+ incFWSL(i + 1, callerBundle);
+ }
+ } else {
+ for (int i = tempSL; i > newSL; i--) {
+ if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
+ Debug.println("sync - decrementing Startlevel from " + tempSL);
+ }
+ tempSL--;
+ decFWSL(i - 1);
+ }
+ }
+ framework.publishFrameworkEvent(FrameworkEvent.STARTLEVEL_CHANGED, callerBundle, null);
+ if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
+ Debug.println("StartLevelImpl: doSetStartLevel: STARTLEVEL_CHANGED event published");
+ }
+ }
+ }
+
+ /**
+ * This method is used within the package to save the actual active startlevel value for the framework.
+ * Externally the setStartLevel method must be used.
+ *
+ * @param newSL - the new startlevel to save
+ */
+ protected void saveActiveStartLevel(int newSL) {
+ synchronized (lock) {
+ activeSL = newSL;
+ }
+ }
+
+ /**
+ * Return the persistent state of the specified bundle.
+ *
+ * <p>This method returns the persistent state of a bundle.
+ * The persistent state of a bundle indicates whether a bundle
+ * is persistently marked to be started when it's start level is
+ * reached.
+ *
+ * @return <tt>true</tt> if the bundle is persistently marked to be started,
+ * <tt>false</tt> if the bundle is not persistently marked to be started.
+ * @exception java.lang.IllegalArgumentException If the specified bundle has been uninstalled.
+ */
+ public boolean isBundlePersistentlyStarted(org.osgi.framework.Bundle bundle) {
+
+ if (bundle.getState() == AbstractBundle.UNINSTALLED) {
+ throw new IllegalArgumentException(Msg.formatter.getString("BUNDLE_UNINSTALLED_EXCEPTION"));
+ }
+ AbstractBundle b = (AbstractBundle) bundle;
+ int status = b.getBundleData().getStatus();
+ return ((status & org.eclipse.osgi.framework.internal.core.Constants.BUNDLE_STARTED) == Constants.BUNDLE_STARTED);
+ }
+ /**
+ * Return the assigned start level value for the specified Bundle.
+ *
+ * @param bundle The target bundle.
+ * @return The start level value of the specified Bundle.
+ * @exception java.lang.IllegalArgumentException If the specified bundle has been uninstalled.
+ */
+ public int getBundleStartLevel(org.osgi.framework.Bundle bundle) {
+
+ if (bundle.getState() == AbstractBundle.UNINSTALLED) {
+ throw new IllegalArgumentException(Msg.formatter.getString("BUNDLE_UNINSTALLED_EXCEPTION"));
+ }
+ return ((AbstractBundle) bundle).getStartLevel();
+ }
+
+ /**
+ * Assign a start level value to the specified Bundle.
+ *
+ * <p>The specified bundle will be assigned the specified start level. The
+ * start level value assigned to the bundle will be persistently recorded
+ * by the Framework.
+ *
+ * If the new start level for the bundle is lower than or equal to the active start level of
+ * the Framework, the Framework will start the specified bundle as described
+ * in the <tt>Bundle.start</tt> method if the bundle is persistently marked
+ * to be started. The actual starting of this bundle must occur asynchronously.
+ *
+ * If the new start level for the bundle is higher than the active start level of
+ * the Framework, the Framework will stop the specified bundle as described
+ * in the <tt>Bundle.stop</tt> method except that the persistently recorded
+ * state for the bundle indicates that the bundle must be restarted in the
+ * future. The actual stopping of this bundle must occur asynchronously.
+ *
+ * @param bundle The target bundle.
+ * @param startlevel The new start level for the specified Bundle.
+ * @throws IllegalArgumentException
+ * If the specified bundle has been uninstalled or
+ * if the specified start level is less than or equal to zero, or the specified bundle is
+ * the system bundle.
+ * @throws SecurityException if the caller does not have the
+ * <tt>AdminPermission</tt> and the Java runtime environment supports
+ * permissions.
+ */
+ public void setBundleStartLevel(org.osgi.framework.Bundle bundle, int newSL) {
+
+ String exceptionText = "";
+ if (bundle.getBundleId() == 0) { // system bundle has id=0
+ exceptionText = Msg.formatter.getString("STARTLEVEL_CANT_CHANGE_SYSTEMBUNDLE_STARTLEVEL");
+ } else if (bundle.getState() == AbstractBundle.UNINSTALLED) {
+ exceptionText = Msg.formatter.getString("BUNDLE_UNINSTALLED_EXCEPTION");
+ } else if (newSL <= 0) {
+ exceptionText = Msg.formatter.getString("STARTLEVEL_EXCEPTION_INVALID_REQUESTED_STARTLEVEL", "" + newSL);
+ }
+ if (exceptionText.length() > 0) {
+ throw new IllegalArgumentException(exceptionText);
+ }
+
+ try {
+ // if the bundle's startlevel is not already at the requested startlevel
+ if (newSL != ((org.eclipse.osgi.framework.internal.core.AbstractBundle) bundle).getStartLevel()) {
+ AbstractBundle b = (AbstractBundle) bundle;
+ b.getBundleData().setStartLevel(newSL);
+ b.getBundleData().save();
+
+ framework.checkAdminPermission();
+
+ // handle starting or stopping the bundle asynchronously
+ issueEvent(new StartLevelEvent(StartLevelEvent.CHANGE_BUNDLE_SL, newSL, (AbstractBundle) bundle));
+ }
+ } catch (IOException e) {
+ framework.publishFrameworkEvent(FrameworkEvent.ERROR, bundle, e);
+ }
+
+ }
+
+ /**
+ * This method sends the StartLevelEvent to the EventManager for dispatching
+ *
+ * @param sle The event to be queued to the Event Manager
+ */
+ private void issueEvent(StartLevelEvent sle) {
+
+ /* queue to hold set of listeners */
+ ListenerQueue queue = new ListenerQueue(eventManager);
+
+ /* add set of StartLevelListeners to queue */
+ queue.queueListeners(startLevelListeners, this);
+
+ /* dispatch event to set of listeners */
+ queue.dispatchEventAsynchronous(sle.getType(), sle);
+ }
+
+ /**
+ * This method is the call back that is called once for each listener.
+ * This method must cast the EventListener object to the appropriate listener
+ * class for the event type and call the appropriate listener method.
+ *
+ * @param listener This listener must be cast to the appropriate listener
+ * class for the events created by this source and the appropriate listener method
+ * must then be called.
+ * @param listenerObject This is the optional object that was passed to
+ * EventListeners.addListener when the listener was added to the EventListeners.
+ * @param eventAction This value was passed to the ListenerQueue object via one of its
+ * dispatchEvent* method calls. It can provide information (such
+ * as which listener method to call) so that this method
+ * can complete the delivery of the event to the listener.
+ * @param eventObject This object was passed to the ListenerQueue object via one of its
+ * dispatchEvent* method calls. This object was created by the event source and
+ * is passed to this method. It should contain all the necessary information (such
+ * as what event object to pass) so that this method
+ * can complete the delivery of the event to the listener.
+ */
+ public void dispatchEvent(Object listener, Object listenerObject, int eventAction, Object eventObject) {
+ switch (eventAction) {
+ case StartLevelEvent.CHANGE_BUNDLE_SL :
+ setBundleSL((StartLevelEvent) eventObject);
+ break;
+ case StartLevelEvent.CHANGE_FW_SL :
+ doSetStartLevel(((StartLevelEvent) eventObject).getNewSL(), ((StartLevelEvent) eventObject).getBundle());
+ break;
+ }
+ }
+
+ /**
+ * Increment the active startlevel by one
+ */
+ protected void incFWSL(int activeSL, AbstractBundle callerBundle) {
+ if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
+ Debug.println("SLL: incFWSL: saving activeSL of " + activeSL);
+ }
+
+ framework.startLevelManager.saveActiveStartLevel(activeSL);
+
+ AbstractBundle[] launch;
+ BundleRepository bundles = framework.bundles;
+
+ launch = getInstalledBundles(bundles);
+
+ if (activeSL == 1) { // framework was not active
+
+ /* Load all installed bundles */
+ loadInstalledBundles(launch);
+
+ /* attempt to resolve all bundles */
+ framework.packageAdmin.setResolvedBundles();
+
+ /* Resume all bundles */
+ resumeBundles(launch, true);
+
+ /* publish the framework started event */
+ if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
+ Debug.println("SLL: Framework started");
+ }
+
+ framework.publishFrameworkEvent(FrameworkEvent.STARTED, callerBundle, null);
+
+ } else {
+ // incrementing an already active framework
+ resumeBundles(launch, false);
+ }
+ }
+
+ /**
+ * Build an array of all installed bundles to be launch.
+ * The returned array is sorted by increasing startlevel/id order.
+ * @param bundles - the bundles installed in the framework
+ * @return A sorted array of bundles
+ */
+ private AbstractBundle[] getInstalledBundles(BundleRepository bundles) {
+
+ /* make copy of bundles vector in case it is modified during launch */
+ AbstractBundle[] installedBundles;
+
+ synchronized (bundles) {
+ List allBundles = bundles.getBundles();
+ installedBundles = new AbstractBundle[allBundles.size()];
+ allBundles.toArray(installedBundles);
+
+ /* sort bundle array in ascending startlevel / bundle id order
+ * so that bundles are started in ascending order.
+ */
+ Util.sort(installedBundles, 0, installedBundles.length);
+ }
+
+ return installedBundles;
+ }
+
+ /**
+ * Load all bundles in the list
+ * @param Bundle[] a list of bundles to load
+ */
+ private void loadInstalledBundles(AbstractBundle[] installedBundles) {
+
+ for (int i = 0; i < installedBundles.length; i++) {
+ AbstractBundle bundle = installedBundles[i];
+
+ try {
+ if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
+ Debug.println("SLL: Trying to load bundle " + bundle);
+ }
+
+ bundle.load();
+
+ } catch (BundleException be) {
+ if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
+ Debug.println("SLL: Bundle load exception: " + be.getMessage());
+ Debug.printStackTrace(be.getNestedException());
+ }
+
+ framework.publishFrameworkEvent(FrameworkEvent.ERROR, bundle, be);
+ }
+ }
+ }
+
+ /**
+ * Resume all bundles in the launch list
+ * @param Bundle[] a list of Bundle Objects to launch
+ * @param boolean tells whether or not to launch the framework (system bundle)
+ */
+ private void resumeBundles(AbstractBundle[] launch, boolean launchingFW) {
+ BundleException sbe = null;
+ if (launchingFW) {
+ /* Start the system bundle */
+ try {
+ framework.systemBundle.context.start();
+ } catch (BundleException be) {
+ // TODO: We may have to do something more drastic here if the SystemBundle did not start.
+ sbe = be;
+ }
+
+ }
+ /* Resume all bundles that were previously started and whose startlevel is <= the active startlevel */
+
+ int fwsl = framework.startLevelManager.getStartLevel();
+ for (int i = 0; i < launch.length; i++) {
+ int bsl = launch[i].getStartLevel();
+ if (bsl < fwsl) {
+ // skip bundles who should have already been started
+ continue;
+ } else if (bsl == fwsl) {
+ if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
+ Debug.println("SLL: Active sl = " + fwsl + "; Bundle " + launch[i].getBundleId() + " sl = " + bsl);
+ }
+ framework.resumeBundle(launch[i]);
+ } else {
+ // can stop resuming bundles since any remaining bundles have a greater startlevel than the framework active startlevel
+ break;
+ }
+ }
+
+ if (sbe == null) {
+ framework.systemBundle.state = AbstractBundle.ACTIVE;
+ } else {
+ if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
+ Debug.println("SLL: Bundle resume exception: " + sbe.getMessage());
+ Debug.printStackTrace(sbe.getNestedException());
+ }
+
+ framework.publishFrameworkEvent(FrameworkEvent.ERROR, framework.systemBundle, sbe);
+ }
+ }
+
+ /**
+ * Decrement the active startlevel by one
+ * @param int activeSL - the startlevel value to set the framework to
+ */
+ protected void decFWSL(int activeSL) {
+ if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
+ Debug.println("SLL: decFWSL: saving activeSL of " + activeSL);
+ }
+
+ framework.startLevelManager.saveActiveStartLevel(activeSL);
+
+ BundleRepository bundles = framework.bundles;
+
+ if (activeSL == 0) { // stopping the framework
+
+ framework.systemBundle.state = AbstractBundle.STOPPING;
+
+ /* stop all running bundles */
+
+ suspendAllBundles(bundles);
+
+ unloadAllBundles(bundles);
+
+ } else {
+ // just decrementing the active startlevel - framework is not shutting down
+ synchronized (bundles) {
+ // get the list of installed bundles, sorted by startlevel
+ AbstractBundle[] shutdown = this.getInstalledBundles(bundles);
+ for (int i = shutdown.length - 1; i >= 0; i--) {
+ int bsl = shutdown[i].getStartLevel();
+ if (bsl > activeSL + 1) {
+ // don't need to mess with bundles with startlevel > the previous active - they should
+ // already have been stopped
+ continue;
+ } else if (bsl <= activeSL) {
+ // don't need to keep going - we've stopped all we're going to stop
+ break;
+ } else if (shutdown[i].isActive()) {
+ // if bundle is active or starting, then stop the bundle
+ if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
+ Debug.println("SLL: stopping bundle " + shutdown[i].getBundleId());
+ }
+ framework.suspendBundle(shutdown[i], false);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Suspends all bundles in the vector passed in.
+ * @param Vector of Bundle objects to be suspended
+ */
+ private void suspendAllBundles(BundleRepository bundles) {
+ synchronized (bundles) {
+ boolean changed;
+ do {
+ changed = false;
+
+ AbstractBundle[] shutdown = this.getInstalledBundles(bundles);
+
+ // shutdown all running bundles
+ for (int i = shutdown.length - 1; i >= 0; i--) {
+ AbstractBundle bundle = shutdown[i];
+
+ if (framework.suspendBundle(bundle, false)) {
+ if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
+ Debug.println("SLL: stopped bundle " + bundle.getBundleId());
+ }
+ changed = true;
+ }
+ }
+ } while (changed);
+
+ try {
+ framework.systemBundle.context.stop();
+ } catch (BundleException sbe) {
+ if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
+ Debug.println("SLL: Bundle suspend exception: " + sbe.getMessage());
+ Debug.printStackTrace(sbe.getNestedException());
+ }
+
+ framework.publishFrameworkEvent(FrameworkEvent.ERROR, framework.systemBundle, sbe);
+ }
+
+ framework.systemBundle.state = AbstractBundle.STARTING;
+ }
+ }
+
+ /**
+ * Unloads all bundles in the vector passed in.
+ * @param Vector of Bundle objects to be unloaded
+ */
+ private void unloadAllBundles(BundleRepository bundles) {
+ synchronized (bundles) {
+ /* unload all installed bundles */
+ List allBundles = bundles.getBundles();
+ int size = allBundles.size();
+
+ for (int i = 0; i < size; i++) {
+ AbstractBundle bundle = (AbstractBundle) allBundles.get(i);
+
+ if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
+ Debug.println("SLL: Trying to unload bundle " + bundle);
+ }
+
+ try {
+ bundle.refresh();
+ } catch (BundleException e) {
+ // do nothing.
+ }
+ }
+ }
+ }
+
+ /**
+ * Set the bundle's startlevel to the new value
+ * This may cause the bundle to start or stop based on the active framework startlevel
+ * @param StartLevelEvent - the event requesting change in bundle startlevel
+ */
+ protected void setBundleSL(StartLevelEvent startLevelEvent) {
+ synchronized (lock) {
+ int activeSL = framework.startLevelManager.getStartLevel();
+ int newSL = startLevelEvent.getNewSL();
+ AbstractBundle bundle = startLevelEvent.getBundle();
+
+ int bundlestate = bundle.getState();
+ if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
+ Debug.print("SLL: bundle active=" + bundle.isActive());
+ Debug.print("; newSL = " + newSL);
+ Debug.println("; activeSL = " + activeSL);
+ }
+
+ if (bundle.isActive() && (newSL > activeSL)) {
+ if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
+ Debug.println("SLL: stopping bundle " + bundle.getBundleId());
+ }
+ framework.suspendBundle(bundle, false);
+ } else {
+ if (!bundle.isActive() && (newSL <= activeSL)) {
+ if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
+ Debug.println("SLL: starting bundle " + bundle.getBundleId());
+ }
+ framework.resumeBundle(bundle);
+ }
+ }
+ if (Debug.DEBUG && Debug.DEBUG_STARTLEVEL) {
+ Debug.println("SLL: Bundle Startlevel set to " + newSL);
+ }
+ }
+ }
+
+ /**
+ * Returns a StartLevel object, created for each requesting bundle.
+ *
+ * @param owner bundle, requested to get StartLevel service.
+ * @pre callerBundle!=null
+ * @param registration ServiceRegistration of the StartLevel service
+ * @pre sReg!=null
+ * @return StartLevel object
+ */
+ public Object getService(Bundle owner, ServiceRegistration registration) {
+ return new StartLevelImpl(owner, framework);
+ }
+
+ /**
+ * Does nothing, as the StartLevel bundle does not keep references to StartLevel objects.
+ *
+ * @param owner bundle requesting to unget StartLevel service.
+ * @param registration ServiceRegistration of StartLevel
+ * @param service Service object, already been got by this bundle.
+ */
+ public void ungetService(Bundle owner, ServiceRegistration registration, Object service) {
+ }
+}
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/SystemBundle.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/SystemBundle.java
index 049786c..04d30b1 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/SystemBundle.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/SystemBundle.java
@@ -79,7 +79,7 @@
* @param newBundle
* @return false
*/
- protected boolean reload(Bundle newBundle) throws BundleException {
+ protected boolean reload(AbstractBundle newBundle) throws BundleException {
return (false);
}
@@ -162,9 +162,9 @@
*/
protected void resume() throws BundleException {
/* initialize the startlevel service */
- framework.startLevelImpl.initialize();
+ framework.startLevelManager.initialize();
- framework.startLevelImpl.launch(framework.startLevelImpl.getFrameworkStartLevel());
+ framework.startLevelManager.launch(framework.startLevelManager.getFrameworkStartLevel());
}
@@ -194,8 +194,8 @@
*/
protected void suspend() throws BundleException {
- framework.startLevelImpl.shutdown();
- framework.startLevelImpl.cleanup();
+ framework.startLevelManager.shutdown();
+ framework.startLevelManager.cleanup();
/* clean up the exporting loaders */
framework.packageAdmin.cleanup();
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/SystemBundleActivator.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/SystemBundleActivator.java
index 0b63c05..478d0cc 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/SystemBundleActivator.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/SystemBundleActivator.java
@@ -47,8 +47,8 @@
permissionAdmin = register(Constants.OSGI_PERMISSIONADMIN_NAME, framework.permissionAdmin);
}
- if (framework.startLevelImpl != null) {
- startLevel = register(Constants.OSGI_STARTLEVEL_NAME, framework.startLevelFactory);
+ if (framework.startLevelManager != null) {
+ startLevel = register(Constants.OSGI_STARTLEVEL_NAME, framework.startLevelManager);
}
DebugOptions dbgOptions = null;
diff --git a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/adaptor/core/BundleResourceHandler.java b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/adaptor/core/BundleResourceHandler.java
index cf99a22..72c60d0 100644
--- a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/adaptor/core/BundleResourceHandler.java
+++ b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/adaptor/core/BundleResourceHandler.java
@@ -17,7 +17,7 @@
import java.net.URLConnection;
import java.net.URLStreamHandler;
-import org.eclipse.osgi.framework.internal.core.Bundle;
+import org.eclipse.osgi.framework.internal.core.AbstractBundle;
import org.osgi.framework.AdminPermission;
import org.osgi.framework.BundleContext;
@@ -148,10 +148,10 @@
if (bidString == null) {
throw new IOException(AdaptorMsg.formatter.getString("URL_NO_BUNDLE_ID", url.toExternalForm()));
}
- Bundle bundle = null;
+ AbstractBundle bundle = null;
try {
Long bundleID = new Long(bidString);
- bundle = (Bundle) context.getBundle(bundleID.longValue());
+ bundle = (AbstractBundle) context.getBundle(bundleID.longValue());
} catch (NumberFormatException nfe) {
throw new MalformedURLException(AdaptorMsg.formatter.getString("URL_INVALID_BUNDLE_ID", bidString));
}
@@ -171,7 +171,7 @@
* @param url The URL to find the BundleEntry for.
* @return
*/
- abstract protected BundleEntry findBundleEntry(URL url,Bundle bundle) throws IOException;
+ abstract protected BundleEntry findBundleEntry(URL url,AbstractBundle bundle) throws IOException;
/**
* Converts a bundle URL to a String.
diff --git a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/defaultadaptor/DefaultAdaptor.java b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/defaultadaptor/DefaultAdaptor.java
index 4c0d2fb..6fb586a 100644
--- a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/defaultadaptor/DefaultAdaptor.java
+++ b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/defaultadaptor/DefaultAdaptor.java
@@ -52,7 +52,7 @@
protected MetaData fwMetadata;
/** Dictionary containing permission data */
- protected PermissionStorage permissionStore;
+ protected DefaultPermissionStorage permissionStore;
/** next available bundle id */
protected long nextId = 1;
@@ -755,7 +755,7 @@
if (permissionStore == null) {
synchronized (this) {
if (permissionStore == null) {
- permissionStore = new PermissionStorage(this);
+ permissionStore = new DefaultPermissionStorage(this);
}
}
}
diff --git a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/defaultadaptor/PermissionStorage.java b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/defaultadaptor/DefaultPermissionStorage.java
similarity index 97%
rename from bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/defaultadaptor/PermissionStorage.java
rename to bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/defaultadaptor/DefaultPermissionStorage.java
index b18ede8..dc79a6e 100644
--- a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/defaultadaptor/PermissionStorage.java
+++ b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/defaultadaptor/DefaultPermissionStorage.java
@@ -14,6 +14,7 @@
import java.util.Enumeration;
import java.util.Hashtable;
+import org.eclipse.osgi.framework.adaptor.PermissionStorage;
import org.eclipse.osgi.framework.adaptor.core.AdaptorMsg;
import org.eclipse.osgi.framework.debug.Debug;
import org.eclipse.osgi.framework.internal.reliablefile.*;
@@ -23,7 +24,7 @@
*/
//TODO switch this class over to use MetaData instead of ReliableFile
-class PermissionStorage implements org.eclipse.osgi.framework.adaptor.PermissionStorage {
+class DefaultPermissionStorage implements PermissionStorage {
/** Directory into which permission data files are stored. */
protected File permissionDir;
@@ -44,7 +45,7 @@
*
* @throws IOException If an error occurs initializing the object.
*/
- protected PermissionStorage(DefaultAdaptor adaptor) throws IOException {
+ protected DefaultPermissionStorage(DefaultAdaptor adaptor) throws IOException {
permissionDir = new File(adaptor.getBundleStoreRootDir(), "permdata");
permissionFiles = new Hashtable();
diff --git a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/protocol/bundleentry/Handler.java b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/protocol/bundleentry/Handler.java
index e1b9641..18f83b0 100644
--- a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/protocol/bundleentry/Handler.java
+++ b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/protocol/bundleentry/Handler.java
@@ -18,7 +18,7 @@
import org.eclipse.osgi.framework.adaptor.core.AbstractBundleData;
import org.eclipse.osgi.framework.adaptor.core.BundleEntry;
import org.eclipse.osgi.framework.adaptor.core.BundleResourceHandler;
-import org.eclipse.osgi.framework.internal.core.Bundle;
+import org.eclipse.osgi.framework.internal.core.AbstractBundle;
/**
* URLStreamHandler the bundleentry protocol.
@@ -39,7 +39,7 @@
super(bundleEntry);
}
- protected BundleEntry findBundleEntry(URL url, Bundle bundle) throws IOException
+ protected BundleEntry findBundleEntry(URL url, AbstractBundle bundle) throws IOException
{
AbstractBundleData bundleData = (AbstractBundleData) bundle.getBundleData();
BundleEntry entry = bundleData.getBaseBundleFile().getEntry(url.getPath());
diff --git a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/protocol/bundleresource/Handler.java b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/protocol/bundleresource/Handler.java
index c4f4b0e..c6d825c 100644
--- a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/protocol/bundleresource/Handler.java
+++ b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/protocol/bundleresource/Handler.java
@@ -17,7 +17,7 @@
import org.eclipse.osgi.framework.adaptor.core.BundleEntry;
import org.eclipse.osgi.framework.adaptor.core.BundleResourceHandler;
-import org.eclipse.osgi.framework.internal.core.Bundle;
+import org.eclipse.osgi.framework.internal.core.AbstractBundle;
import org.eclipse.osgi.framework.internal.core.BundleLoader;
/**
@@ -39,7 +39,7 @@
super(bundleEntry);
}
- protected BundleEntry findBundleEntry(URL url, Bundle bundle) throws IOException
+ protected BundleEntry findBundleEntry(URL url, AbstractBundle bundle) throws IOException
{
BundleLoader bundleLoader = bundle.getBundleLoader();
if (bundleLoader == null)
diff --git a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/BundleLocalization.java b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/BundleLocalizationImpl.java
similarity index 82%
rename from bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/BundleLocalization.java
rename to bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/BundleLocalizationImpl.java
index 2e4a9f7..eb6619a 100644
--- a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/BundleLocalization.java
+++ b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/BundleLocalizationImpl.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.core.runtime.adaptor;
import java.util.ResourceBundle;
+import org.eclipse.osgi.service.localization.BundleLocalization;
import org.osgi.framework.Bundle;
/**
@@ -17,16 +18,15 @@
* bundle with a given locale.
*/
-public class BundleLocalization implements org.eclipse.osgi.service.localization.BundleLocalization {
+public class BundleLocalizationImpl implements BundleLocalization {
/**
* The getLocalization method gets a ResourceBundle object for the given
* locale and bundle.
*
- *
* @return A <code>ResourceBundle</code> object for the given bundle and locale.
* If null is passed for the locale parameter, the default locale is used.
*/
public ResourceBundle getLocalization(Bundle bundle, String locale) {
- return ((org.eclipse.osgi.framework.internal.core.Bundle) (bundle)).getResourceBundle(locale);
+ return ((org.eclipse.osgi.framework.internal.core.AbstractBundle) (bundle)).getResourceBundle(locale);
}
}
\ No newline at end of file
diff --git a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseAdaptor.java b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseAdaptor.java
index 3c6972e..e5d4f05 100644
--- a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseAdaptor.java
+++ b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseAdaptor.java
@@ -219,7 +219,7 @@
register(URLConverter.class.getName(), new URLConverterImpl(),bundle);
register(CommandProvider.class.getName(), new EclipseCommandProvider(context),bundle);
register(FrameworkLog.class.getName(), getFrameworkLog(), bundle);
- register(org.eclipse.osgi.service.localization.BundleLocalization.class.getName(),new BundleLocalization(),bundle);
+ register(org.eclipse.osgi.service.localization.BundleLocalization.class.getName(),new BundleLocalizationImpl(),bundle);
registerEndorsedXMLParser();
}
@@ -450,7 +450,7 @@
long id = bundles[i].getBundleId();
out.writeLong(id);
if (id != 0) {
- BundleData data = ((org.eclipse.osgi.framework.internal.core.Bundle) bundles[i]).getBundleData();
+ BundleData data = ((org.eclipse.osgi.framework.internal.core.AbstractBundle) bundles[i]).getBundleData();
saveMetaDataFor(data, out);
}
}
diff --git a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseClassLoader.java b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseClassLoader.java
index f6bc63e..3fb56b1 100644
--- a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseClassLoader.java
+++ b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseClassLoader.java
@@ -20,7 +20,7 @@
import org.eclipse.osgi.framework.adaptor.BundleData;
import org.eclipse.osgi.framework.adaptor.ClassLoaderDelegate;
import org.eclipse.osgi.framework.adaptor.core.*;
-import org.eclipse.osgi.framework.internal.core.Bundle;
+import org.eclipse.osgi.framework.internal.core.AbstractBundle;
import org.eclipse.osgi.framework.internal.core.Msg;
import org.eclipse.osgi.framework.internal.defaultadaptor.DefaultClassLoader;
import org.eclipse.osgi.framework.internal.defaultadaptor.DevClassPathHelper;
@@ -75,17 +75,17 @@
boolean found = true;
try {
- Bundle bundle = (Bundle) hostdata.getBundle();
+ AbstractBundle bundle = (AbstractBundle) hostdata.getBundle();
// If the bundle is active, just return the class
- if (bundle.getState() == Bundle.ACTIVE)
+ if (bundle.getState() == AbstractBundle.ACTIVE)
return super.findLocalClass(name);
//If the bundle is uninstalled, classes can still be loaded from it
- if (bundle.getState() == Bundle.UNINSTALLED)
+ if (bundle.getState() == AbstractBundle.UNINSTALLED)
return super.findLocalClass(name);
//If the bundle is stopping, we don't want to reactive it but we still want to be able to load classes from it.
- if (bundle.getState() == Bundle.STOPPING)
+ if (bundle.getState() == AbstractBundle.STOPPING)
return super.findLocalClass(name);
// The bundle is not active and does not require activation, just return the class
@@ -93,7 +93,7 @@
return super.findLocalClass(name);
// The bundle is starting
- if (bundle.getState() == Bundle.STARTING) {
+ if (bundle.getState() == AbstractBundle.STARTING) {
//If the thread trying to load the class is the one trying to activate the bundle, then return the class
if (bundle.testStateChanging(Thread.currentThread()) || bundle.testStateChanging(null))
return super.findLocalClass(name);
@@ -119,7 +119,7 @@
}
timeLeft = start + delay - System.currentTimeMillis();
}
- if (timeLeft <= 0 || bundle.getState() != Bundle.ACTIVE) {
+ if (timeLeft <= 0 || bundle.getState() != AbstractBundle.ACTIVE) {
String message = EclipseAdaptorMsg.formatter.getString("ECLIPSE_CLASSLOADER_CONCURRENT_STARTUP", new Object[] {Thread.currentThread(), name, bundle.getStateChanging().getName(), bundle.getSymbolicName()==null ? Long.toString(bundle.getBundleId()) : bundle.getSymbolicName()}); //$NON-NLS-1$
EclipseAdaptor.getDefault().getFrameworkLog().log(new FrameworkLogEntry(EclipseAdaptorConstants.PI_ECLIPSE_OSGI, message, 0, null, null));
}