Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2008-10-08 21:21:33 +0000
committerThomas Watson2008-10-08 21:21:33 +0000
commit35c62c8776316cf694ac8af7a20ff5e6c5b84c37 (patch)
tree2a4791575a4d3dfe1bfd47f6d8c906c13fe17dd3
parentee6ccf350b150aa07181ad0c3cd5ad27cbf7dd1b (diff)
downloadrt.equinox.framework-35c62c8776316cf694ac8af7a20ff5e6c5b84c37.tar.gz
rt.equinox.framework-35c62c8776316cf694ac8af7a20ff5e6c5b84c37.tar.xz
rt.equinox.framework-35c62c8776316cf694ac8af7a20ff5e6c5b84c37.zip
Refactor SystemBundle classes (RFC 132).
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/EquinoxLauncher.java (renamed from bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/EquinoxSystemBundle.java)15
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Framework.java4
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/InternalSystemBundle.java (renamed from bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/SystemBundle.java)13
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java4
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/SystemBundleActivator.java4
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/launch/Equinox.java17
6 files changed, 26 insertions, 31 deletions
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/EquinoxSystemBundle.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/EquinoxLauncher.java
index b179c1663..911e92a71 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/EquinoxSystemBundle.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/EquinoxLauncher.java
@@ -21,14 +21,14 @@ import org.eclipse.osgi.framework.adaptor.FrameworkAdaptor;
import org.osgi.framework.*;
import org.osgi.framework.launch.SystemBundle;
-public class EquinoxSystemBundle implements SystemBundle {
+public class EquinoxLauncher implements SystemBundle {
private static String FULLPATH = " [fullpath]"; //$NON-NLS-1$
private volatile Framework framework;
private volatile Bundle systemBundle;
private final Map configuration;
- public EquinoxSystemBundle(Map configuration) {
+ public EquinoxLauncher(Map configuration) {
this.configuration = configuration;
}
@@ -36,10 +36,12 @@ public class EquinoxSystemBundle implements SystemBundle {
internalInit();
}
- private Framework internalInit() {
+ private synchronized Framework internalInit() {
+ if ((getState() & (Bundle.ACTIVE | Bundle.STARTING | Bundle.STOPPING)) != 0)
+ return framework; // no op
+
Framework current = framework;
if (current != null) {
- // this is not really necessary because the Equinox class will
current.close();
framework = null;
systemBundle = null;
@@ -223,11 +225,10 @@ public class EquinoxSystemBundle implements SystemBundle {
* @throws BundleException
*/
public void start() throws BundleException {
- Framework current = framework;
if (getState() == Bundle.ACTIVE)
return;
- if (getState() != Bundle.STARTING)
- current = internalInit();
+ Framework current = internalInit();
+ // TODO should consult the org.osgi.framework.startlevel property
current.startLevelManager.doSetStartLevel(1);
}
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 76b4c0a4c..fcc52349d 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
@@ -99,7 +99,7 @@ public class Framework implements EventDispatcher, EventPublisher, Runnable {
/* Reservation object for install synchronization */
protected Hashtable installLock;
/** System Bundle object */
- protected SystemBundle systemBundle;
+ protected InternalSystemBundle systemBundle;
private String[] bootDelegation;
private String[] bootDelegationStems;
private boolean bootDelegateAll = false;
@@ -273,7 +273,7 @@ public class Framework implements EventDispatcher, EventPublisher, Runnable {
private void createSystemBundle() {
try {
- systemBundle = new SystemBundle(this);
+ systemBundle = new InternalSystemBundle(this);
systemBundle.getBundleData().setBundle(systemBundle);
} catch (BundleException e) { // fatal error
e.printStackTrace();
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/InternalSystemBundle.java
index 084e013d4..60c6996e8 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/InternalSystemBundle.java
@@ -20,6 +20,7 @@ import java.util.Dictionary;
import java.util.Enumeration;
import org.eclipse.osgi.framework.debug.Debug;
import org.osgi.framework.*;
+import org.osgi.framework.launch.SystemBundle;
/**
* This class subclasses Bundle to provide a system Bundle
@@ -27,7 +28,7 @@ import org.osgi.framework.*;
* can access the services provided by other bundles.
*/
-public class SystemBundle extends BundleHost {
+public class InternalSystemBundle extends BundleHost implements SystemBundle {
class SystemBundleHeaders extends Dictionary {
private final Dictionary headers;
@@ -85,7 +86,7 @@ public class SystemBundle extends BundleHost {
*
* @param framework Framework this bundle is running in
*/
- protected SystemBundle(Framework framework) throws BundleException {
+ protected InternalSystemBundle(Framework framework) throws BundleException {
super(framework.adaptor.createSystemBundleData(), framework); // startlevel=0 means framework stopped
Constants.setInternalSymbolicName(bundledata.getSymbolicName());
state = Bundle.RESOLVED;
@@ -373,4 +374,12 @@ public class SystemBundle extends BundleHost {
return new SystemBundleHeaders(super.getHeaders(localeString));
}
+ public void init() {
+ // no op for internal representation
+ }
+
+ public void waitForStop(long timeout) throws InterruptedException {
+ framework.waitForStop(timeout);
+ }
+
}
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java
index a74ca3933..f68021b90 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java
@@ -592,7 +592,7 @@ public class PackageAdminImpl implements PackageAdmin {
protected void cleanup() { //This is only called when the framework is shutting down
}
- protected void setResolvedBundles(SystemBundle systemBundle) {
+ protected void setResolvedBundles(InternalSystemBundle systemBundle) {
checkSystemBundle(systemBundle);
// Now set the actual state of the bundles from the persisted state.
State state = framework.adaptor.getState();
@@ -605,7 +605,7 @@ public class PackageAdminImpl implements PackageAdmin {
}
}
- private void checkSystemBundle(SystemBundle systemBundle) {
+ private void checkSystemBundle(InternalSystemBundle systemBundle) {
try {
// first check that the system bundle has not changed since last saved state.
State state = framework.adaptor.getState();
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 7364ed159..491c22962 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
@@ -23,7 +23,7 @@ import org.osgi.service.condpermadmin.ConditionalPermissionAdmin;
public class SystemBundleActivator implements BundleActivator {
protected BundleContext context;
- protected SystemBundle bundle;
+ protected InternalSystemBundle bundle;
protected Framework framework;
protected ServiceRegistration packageAdmin;
protected ServiceRegistration securityAdmin;
@@ -35,7 +35,7 @@ public class SystemBundleActivator implements BundleActivator {
public void start(BundleContext context) throws Exception {
this.context = context;
- bundle = (SystemBundle) context.getBundle();
+ bundle = (InternalSystemBundle) context.getBundle();
framework = bundle.framework;
if (framework.packageAdmin != null)
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/launch/Equinox.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/launch/Equinox.java
index b9dfd9691..93cf281de 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/launch/Equinox.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/launch/Equinox.java
@@ -27,7 +27,7 @@ import org.osgi.framework.launch.SystemBundle;
* @since 3.5
*/
public class Equinox implements SystemBundle {
- private static final String implName = "org.eclipse.osgi.framework.internal.core.EquinoxSystemBundle";
+ private static final String implName = "org.eclipse.osgi.framework.internal.core.EquinoxLauncher";
/**@GuardedBy this*/
private SystemBundle impl;
private final boolean useSeparateCL;
@@ -72,21 +72,6 @@ public class Equinox implements SystemBundle {
}
public void init() throws BundleException {
- if ((getState() & (Bundle.ACTIVE | Bundle.STARTING | Bundle.STOPPING)) != 0)
- return; // no op
- synchronized (this) {
- if (impl != null && impl.getState() != Bundle.INSTALLED) {
- try {
- impl.stop();
- impl.waitForStop(30000); // timeout after 30 seconds
- } catch (BundleException e) {
- // ignore
- } catch (InterruptedException e) {
- // continue
- }
- impl = null;
- }
- }
getImpl().init();
}

Back to the top