Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2006-01-16 20:31:46 +0000
committerThomas Watson2006-01-16 20:31:46 +0000
commit8616d93241eef839cf0162cbc37fed922f4112b8 (patch)
tree5e709067424aa1607caefb5e9bf088132cf76aa6
parentfdb3b95b147f6f8a68c795c5e52853938be15fa4 (diff)
downloadrt.equinox.bundles-8616d93241eef839cf0162cbc37fed922f4112b8.tar.gz
rt.equinox.bundles-8616d93241eef839cf0162cbc37fed922f4112b8.tar.xz
rt.equinox.bundles-8616d93241eef839cf0162cbc37fed922f4112b8.zip
Updates from bug 109893 commentsv20060718-before-refactor
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/Activator.java4
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppCommands.java10
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppPersistenceUtil.java (renamed from bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppManager.java)12
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/ContainerManager.java28
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppDescriptor.java10
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppHandle.java1
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseScheduledApplication.java6
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainThreadApplication.java2
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainThreadContainer.java6
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationDescriptor.java10
10 files changed, 62 insertions, 27 deletions
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/Activator.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/Activator.java
index 7311f24cb..99da716f1 100755
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/Activator.java
+++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/Activator.java
@@ -29,7 +29,7 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer {
this.bContext = context;
getDebugOptions(context);
// set the app manager context before starting the containerMgr
- AppManager.setBundleContext(context);
+ AppPersistenceUtil.setBundleContext(context);
registryTracker = new ServiceTracker(context, IExtensionRegistry.class.getName(), this);
registryTracker.open();
// start the app commands for the console
@@ -51,7 +51,7 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer {
registryTracker.close();
registryTracker = null;
// unset the app manager context after the containerMgr has been stopped
- AppManager.setBundleContext(null);
+ AppPersistenceUtil.setBundleContext(null);
bContext = null;
}
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppCommands.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppCommands.java
index 701ecc62e..06258a566 100755
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppCommands.java
+++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppCommands.java
@@ -132,9 +132,17 @@ public class AppCommands implements CommandProvider {
for (int i = 0; i < apps.length; i++)
if (appId.equals(apps[i].getProperty(ApplicationDescriptor.APPLICATION_PID))) {
if (launchableApp.match(getServiceProps(apps[i]))) {
+ ArrayList argList = new ArrayList();
+ String arg = null;
+ while ((arg = intp.nextArgument()) != null)
+ argList.add(arg);
+ String[] args = argList.size() == 0 ? null : (String[]) argList.toArray(new String[argList.size()]);
ApplicationDescriptor appDesc = (ApplicationDescriptor) context.getService(apps[i]);
try {
- appDesc.launch(new HashMap(0));
+ HashMap launchArgs = new HashMap(1);
+ if (args != null)
+ launchArgs.put(ContainerManager.PROP_ECLIPSE_APPLICATION_ARGS, args);
+ appDesc.launch(launchArgs);
intp.println("Launched application: " + appId); //$NON-NLS-1$
} finally {
context.ungetService(apps[i]);
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppManager.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppPersistenceUtil.java
index 7c9d4bb9b..e95118bf0 100755
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppManager.java
+++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppPersistenceUtil.java
@@ -26,10 +26,10 @@ import org.osgi.service.packageadmin.PackageAdmin;
import org.osgi.util.tracker.ServiceTracker;
/**
- * Managers all persistent data for ApplicationDescriptors (lock status,
+ * Manages all persistent data for ApplicationDescriptors (lock status,
* scheduled applications etc.)
*/
-public class AppManager {
+public class AppPersistenceUtil {
private static final String PROP_CONFIG_AREA = "osgi.configuration.area"; //$NON-NLS-1$
private static final String FILTER_PREFIX = "(&(objectClass=org.eclipse.osgi.service.datalocation.Location)(type="; //$NON-NLS-1$
@@ -77,11 +77,11 @@ public class AppManager {
static synchronized void setBundleContext(BundleContext context) {
if (context != null) {
- AppManager.context = context;
+ AppPersistenceUtil.context = context;
init();
} else {
shutdown();
- AppManager.context = context;
+ AppPersistenceUtil.context = context;
}
}
@@ -190,7 +190,7 @@ public class AppManager {
return result;
}
- static void addScheduledApp(EclipseScheduledApplication scheduledApp) {
+ private static void addScheduledApp(EclipseScheduledApplication scheduledApp) {
if (EVENT_TIMER_TOPIC.equals(scheduledApp.getTopic())) {
timerApps.add(scheduledApp);
if (timerThread == null)
@@ -389,7 +389,7 @@ public class AppManager {
props.put("hour_of_day", new Integer(cal.get(Calendar.HOUR_OF_DAY))); //$NON-NLS-1$
props.put("minute", new Integer(minute)); //$NON-NLS-1$
Event timerEvent = new Event(EVENT_TIMER_TOPIC, props);
- synchronized (AppManager.class) {
+ synchronized (AppPersistenceUtil.class) {
// poor mans implementation of dispatching events; the spec will not allow us to use event admin to dispatch the virtual timer events; boo!!
if (timerApps.size() == 0)
continue;
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/ContainerManager.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/ContainerManager.java
index a7a447812..8920964fd 100755
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/ContainerManager.java
+++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/ContainerManager.java
@@ -288,9 +288,16 @@ public class ContainerManager implements IRegistryChangeListener, SynchronousBun
String type = configs[0].getAttribute(PT_APP_TYPE);
if (type == null)
return null;
+ // stop all applications for the container first
+ stopAllApplications(type);
+ IContainer result = null;
synchronized (containers) {
- return (IContainer) containers.get(type);
+ result = (IContainer) containers.remove(type);
}
+ // shutdown the container
+ if (result != null)
+ result.shutdown();
+ return result;
}
/*
@@ -343,7 +350,7 @@ public class ContainerManager implements IRegistryChangeListener, SynchronousBun
}
private FrameworkLog getFrameworkLog() {
- return (FrameworkLog) AppManager.getService(frameworkLog);
+ return (FrameworkLog) AppPersistenceUtil.getService(frameworkLog);
}
private String getProductAppId() {
@@ -450,6 +457,23 @@ public class ContainerManager implements IRegistryChangeListener, SynchronousBun
stopAll();
}
+ private void stopAllApplications(String type) {
+ try {
+ ServiceReference[] runningRefs = context.getServiceReferences(ApplicationHandle.class.getName(), "(&(eclipse.application.type=" + type + ")(!(application.state=STOPPING)))"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (runningRefs != null)
+ for (int i = 0; i < runningRefs.length; i++) {
+ ApplicationHandle handle = (ApplicationHandle) context.getService(runningRefs[i]);
+ try {
+ handle.destroy();
+ } catch (Throwable t) {
+ // just ignore; nothing we can really do and we need to continue
+ }
+ }
+ } catch (InvalidSyntaxException e) {
+ // do nothing; we already tested the filter string above
+ }
+ }
+
private void stopAll() {
// get a stapshot of running applications
try {
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppDescriptor.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppDescriptor.java
index e0cd87123..02e0f45f8 100755
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppDescriptor.java
+++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppDescriptor.java
@@ -24,6 +24,7 @@ import org.osgi.service.condpermadmin.ConditionInfo;
* An ApplicationDescriptor for an eclipse application.
*/
public class EclipseAppDescriptor extends ApplicationDescriptor {
+ static final String APP_TYPE = "eclipse.application.type"; //$NON-NLS-1$
private ServiceRegistration sr;
private Boolean locked = Boolean.FALSE;
private SingletonContainer singletonMgr;
@@ -37,7 +38,7 @@ public class EclipseAppDescriptor extends ApplicationDescriptor {
this.type = type == null ? ContainerManager.APP_TYPE_MAIN_THREAD : type;
this.namespace = namespace;
this.containerMgr = containerMgr;
- this.locked = AppManager.isLocked(this) ? Boolean.TRUE : Boolean.FALSE;
+ this.locked = AppPersistenceUtil.isLocked(this) ? Boolean.TRUE : Boolean.FALSE;
this.visible = visible;
}
@@ -111,14 +112,15 @@ public class EclipseAppDescriptor extends ApplicationDescriptor {
props.put(ApplicationDescriptor.APPLICATION_LAUNCHABLE, singletonMgr == null ? Boolean.TRUE : singletonMgr.isLocked() ? Boolean.FALSE : Boolean.TRUE);
props.put(ApplicationDescriptor.APPLICATION_LOCKED, locked);
props.put(ApplicationDescriptor.APPLICATION_VISIBLE, visible ? Boolean.TRUE : Boolean.FALSE);
+ props.put(EclipseAppDescriptor.APP_TYPE, getType());
return props;
}
private String getLocation() {
- final Bundle bundle = AppManager.getBundle(namespace);
+ final Bundle bundle = AppPersistenceUtil.getBundle(namespace);
if (bundle == null)
return ""; //$NON-NLS-1$
- return AppManager.getLocation(bundle);
+ return AppPersistenceUtil.getLocation(bundle);
}
/*
@@ -141,7 +143,7 @@ public class EclipseAppDescriptor extends ApplicationDescriptor {
}
public boolean matchDNChain(String pattern) {
- Bundle bundle = AppManager.getBundle(namespace);
+ Bundle bundle = AppPersistenceUtil.getBundle(namespace);
if (bundle == null)
return false;
return BundleSignerCondition.getCondition(bundle, new ConditionInfo(BundleSignerCondition.class.getName(), new String[] {pattern})).isSatisfied();
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppHandle.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppHandle.java
index fccf2ae6b..9d4b96376 100755
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppHandle.java
+++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppHandle.java
@@ -68,6 +68,7 @@ public class EclipseAppHandle extends ApplicationHandle implements IAppContext {
props.put(ApplicationHandle.APPLICATION_PID, getInstanceId());
props.put(ApplicationHandle.APPLICATION_STATE, getState());
props.put(ApplicationHandle.APPLICATION_DESCRIPTOR, getApplicationDescriptor().getApplicationId());
+ props.put(EclipseAppDescriptor.APP_TYPE, ((EclipseAppDescriptor) getApplicationDescriptor()).getType());
return props;
}
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseScheduledApplication.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseScheduledApplication.java
index 179e82251..33a75cac2 100755
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseScheduledApplication.java
+++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseScheduledApplication.java
@@ -44,7 +44,7 @@ public class EclipseScheduledApplication implements ScheduledApplication, EventH
this.eventFilter = eventFilter;
this.recurring = recurring;
appTracker = new ServiceTracker(context, context.createFilter(FILTER_PREFIX + appPid + FILTER_POSTFIX), null);
- AppManager.openTracker(appTracker, false);
+ AppPersistenceUtil.openTracker(appTracker, false);
}
Integer getID() {
@@ -70,7 +70,7 @@ public class EclipseScheduledApplication implements ScheduledApplication, EventH
public synchronized ApplicationDescriptor getApplicationDescriptor() {
if (removed)
throw new IllegalStateException(Messages.EclipseScheduledApplication_7);
- return (ApplicationDescriptor) AppManager.getService(appTracker);
+ return (ApplicationDescriptor) AppPersistenceUtil.getService(appTracker);
}
public Map getArguments() {
@@ -87,7 +87,7 @@ public class EclipseScheduledApplication implements ScheduledApplication, EventH
if (removed)
return;
removed = true;
- AppManager.removeScheduledApp(this);
+ AppPersistenceUtil.removeScheduledApp(this);
if (sr != null)
sr.unregister();
appTracker.close();
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainThreadApplication.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainThreadApplication.java
index 1752b18a7..d4a6e7da6 100755
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainThreadApplication.java
+++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainThreadApplication.java
@@ -35,7 +35,7 @@ public class MainThreadApplication implements ApplicationRunnable {
public Object run(Object context) throws Exception {
// if the given arg is null then pass in the left over command line args.
if (context == null)
- context = AppManager.getApplicationArgs();
+ context = AppPersistenceUtil.getApplicationArgs();
Object result;
try {
if (launchException != null)
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainThreadContainer.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainThreadContainer.java
index b25db2424..203aa96fb 100755
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainThreadContainer.java
+++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainThreadContainer.java
@@ -25,7 +25,7 @@ public class MainThreadContainer implements IContainer, ServiceTrackerCustomizer
private EclipseAppDescriptor defaultDesc;
public MainThreadContainer() {
- appLauncherTracker = new ServiceTracker(AppManager.getContext(), ApplicationLauncher.class.getName(), this);
+ appLauncherTracker = new ServiceTracker(AppPersistenceUtil.getContext(), ApplicationLauncher.class.getName(), this);
appLauncherTracker.open();
}
@@ -42,7 +42,7 @@ public class MainThreadContainer implements IContainer, ServiceTrackerCustomizer
public Object addingService(ServiceReference reference) {
if (appLauncher != null)
return null;
- appLauncher = (ApplicationLauncher) AppManager.getContext().getService(reference);
+ appLauncher = (ApplicationLauncher) AppPersistenceUtil.getContext().getService(reference);
if (defaultDesc != null)
// launch the default application
try {
@@ -61,7 +61,7 @@ public class MainThreadContainer implements IContainer, ServiceTrackerCustomizer
public synchronized void removedService(ServiceReference reference, Object service) {
if (service == appLauncher) {
appLauncher = null;
- AppManager.getContext().ungetService(reference);
+ AppPersistenceUtil.getContext().ungetService(reference);
}
}
diff --git a/bundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationDescriptor.java b/bundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationDescriptor.java
index e3b003ff3..4b60d7305 100755
--- a/bundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationDescriptor.java
+++ b/bundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationDescriptor.java
@@ -1,5 +1,5 @@
/*
- * $Header: /cvsroot/eclipse/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationDescriptor.java,v 1.2 2005/12/20 21:26:05 twatson Exp $
+ * $Header: /cvsroot/eclipse/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationDescriptor.java,v 1.3 2006/01/16 19:45:25 twatson Exp $
*
* Copyright (c) OSGi Alliance (2004, 2005). All Rights Reserved.
*
@@ -12,7 +12,7 @@ package org.osgi.service.application;
import java.util.Iterator;
import java.util.Map;
-import org.eclipse.equinox.internal.app.AppManager;
+import org.eclipse.equinox.internal.app.AppPersistenceUtil;
import org.osgi.framework.Constants;
import org.osgi.framework.InvalidSyntaxException;
@@ -390,7 +390,7 @@ public abstract class ApplicationDescriptor {
String eventFilter, boolean recurring) throws InvalidSyntaxException {
checkArgs(arguments);
isLaunchableSpecific(); // checks if the ApplicationDescriptor was already unregistered
- return AppManager.addScheduledApp(this, arguments, topic, eventFilter, recurring);
+ return AppPersistenceUtil.addScheduledApp(this, arguments, topic, eventFilter, recurring);
}
/**
@@ -477,11 +477,11 @@ public abstract class ApplicationDescriptor {
}
private void saveLock(boolean locked) {
- AppManager.saveLock(this, locked);
+ AppPersistenceUtil.saveLock(this, locked);
}
private boolean isLocked() {
- return AppManager.isLocked(this);
+ return AppPersistenceUtil.isLocked(this);
}
private void checkArgs(Map arguments) {

Back to the top