diff options
14 files changed, 56 insertions, 39 deletions
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IAppContext.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IAppContext.java index 50a221635..9f8c7666d 100755 --- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IAppContext.java +++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IAppContext.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -40,16 +40,19 @@ public interface IAppContext { * Indicates the application is stopped for this context */ public int STOPPED = 0x04; + /** * Returns the arguments to use when launching an application. * @return the arguments to use when launching an applicaiton, null may be returned. */ public Map getArguments(); + /** * Returns the application descriptor for this context. * @return the application descriptor for this context. */ public ApplicationDescriptor getApplicationDescriptor(); + /** * Returns the configuration element for this context. * @return the configuration element for this context. diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IApplication.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IApplication.java index 402eb6209..e83c0a87e 100755 --- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IApplication.java +++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IApplication.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.equinox.app; + /** * Bootstrap type for an application. An IApplication represent executable * entry points into an application. An IApplication can be configured into @@ -54,6 +55,7 @@ public interface IApplication { * @exception Exception if there is a problem running this application. */ public Object run(Object args) throws Exception; + /** * Forces a running application to exit. This method must block until the * running application has completely stopped. diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IContainer.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IContainer.java index e8e08098d..79b6fb9bb 100755 --- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IContainer.java +++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IContainer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -30,6 +30,7 @@ public interface IContainer { * @throws Exception if any errors occur while launching the application */ IApplication launch(IAppContext context) throws Exception; + /** * returns true if this container only allows one running application * at a time. 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 cb103b0ae..dbd354062 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,13 +17,14 @@ import org.osgi.framework.*; import org.osgi.util.tracker.ServiceTracker; import org.osgi.util.tracker.ServiceTrackerCustomizer; -public class Activator implements BundleActivator, ServiceTrackerCustomizer{ +public class Activator implements BundleActivator, ServiceTrackerCustomizer { public static final String PI_APP = "org.eclipse.equinox.app"; //$NON-NLS-1$ public static boolean DEBUG = false; private BundleContext bContext; private ContainerManager containerMgr; // tracks the extension registry private ServiceTracker registryTracker; + public void start(BundleContext context) throws Exception { this.bContext = context; getDebugOptions(context); @@ -34,7 +35,7 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer{ // start the app commands for the console try { AppCommands.create(context); - } catch(NoClassDefFoundError e) { + } catch (NoClassDefFoundError e) { // catch incase CommandProvider is not available } } @@ -43,7 +44,7 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer{ // stop the app commands for the console try { AppCommands.destroy(context); - } catch(NoClassDefFoundError e) { + } catch (NoClassDefFoundError e) { // catch incase CommandProvider is not available } // close the registry tracker; this will stop the containerMgr if it was started 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 51f0b5e3d..701ecc62e 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -238,6 +238,6 @@ public class AppCommands implements CommandProvider { context.ungetService(scheds[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/AppManager.java index 5803ff89e..e1c6b7ad8 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/AppManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,13 +24,14 @@ import org.osgi.service.application.ScheduledApplication; import org.osgi.service.event.*; import org.osgi.service.packageadmin.PackageAdmin; import org.osgi.util.tracker.ServiceTracker; + /** * Managers all persistent data for ApplicationDescriptors (lock status, * scheduled applications etc.) */ public class AppManager { 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$ static final String FILE_APPLOCKS = ".locks"; //$NON-NLS-1$ static final String FILE_APPSCHEDULED = ".scheduled"; //$NON-NLS-1$ @@ -165,7 +166,7 @@ public class AppManager { if (scheduledApps.remove(scheduledApp.getID()) != null) { timerApps.remove(scheduledApp); dirty = true; - } + } } /** @@ -198,7 +199,7 @@ public class AppManager { scheduledApps.put(scheduledApp.getID(), scheduledApp); Hashtable serviceProps = new Hashtable(); if (scheduledApp.getTopic() != null) - serviceProps.put(EventConstants.EVENT_TOPIC ,new String[] {scheduledApp.getTopic()}); + serviceProps.put(EventConstants.EVENT_TOPIC, new String[] {scheduledApp.getTopic()}); if (scheduledApp.getEventFilter() != null) serviceProps.put(EventConstants.EVENT_FILTER, scheduledApp.getEventFilter()); ServiceRegistration sr = context.registerService(new String[] {ScheduledApplication.class.getName(), EVENT_HANDLER}, scheduledApp, serviceProps); @@ -501,7 +502,7 @@ public class AppManager { // consume args not used by app container if (args[i - 1].equalsIgnoreCase(KEYRING)) - found = true; + found = true; if (args[i - 1].equalsIgnoreCase(PASSWORD)) found = true; @@ -511,7 +512,6 @@ public class AppManager { if (args[i - 1].equalsIgnoreCase(BOOT)) found = true; // ignore - // look for the product to run // treat -feature as a synonym for -product for compatibility. if (args[i - 1].equalsIgnoreCase(PRODUCT) || args[i - 1].equalsIgnoreCase(FEATURE)) { @@ -555,17 +555,18 @@ public class AppManager { if (System.getSecurityManager() == null) tracker.open(allServices); else - AccessController.doPrivileged(new PrivilegedAction(){ + AccessController.doPrivileged(new PrivilegedAction() { public Object run() { tracker.open(allServices); return null; } }); } + static Object getService(final ServiceTracker tracker) { if (System.getSecurityManager() == null) return tracker.getService(); - return AccessController.doPrivileged(new PrivilegedAction(){ + return AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return tracker.getService(); } 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 91132a8b3..a81466d95 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -169,11 +169,13 @@ public class ContainerManager implements IRegistryChangeListener, SynchronousBun String serviceClass; Object serviceObject; Dictionary serviceProps; + RegisterService(String serviceClass, Object serviceObject, Dictionary serviceProps) { this.serviceClass = serviceClass; this.serviceObject = serviceObject; this.serviceProps = serviceProps; } + public Object run() { return context.registerService(serviceClass, serviceObject, serviceProps); } @@ -365,7 +367,7 @@ public class ContainerManager implements IRegistryChangeListener, SynchronousBun } void launch(EclipseAppHandle appHandle) throws Exception { - String type = ((EclipseAppDescriptor)appHandle.getApplicationDescriptor()).getType(); + String type = ((EclipseAppDescriptor) appHandle.getApplicationDescriptor()).getType(); if (type == null) type = APP_TYPE_MAIN_SINGLETON; IContainer container = getContainer(type); @@ -423,7 +425,7 @@ public class ContainerManager implements IRegistryChangeListener, SynchronousBun ServiceReference[] runningRefs = context.getServiceReferences(ApplicationHandle.class.getName(), "(!(application.state=STOPPING))"); //$NON-NLS-1$ if (runningRefs == null) return; - for (int i = 0; i <runningRefs.length; i++) { + for (int i = 0; i < runningRefs.length; i++) { ApplicationHandle handle = (ApplicationHandle) context.getService(runningRefs[i]); try { handle.destroy(); @@ -434,6 +436,6 @@ public class ContainerManager implements IRegistryChangeListener, SynchronousBun } catch (InvalidSyntaxException e) { // do nothing; we already tested the filter string above } - + } } 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 e98b02078..a98312069 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -44,6 +44,7 @@ public class EclipseAppDescriptor extends ApplicationDescriptor { this(namespace, pid, type, containerMgr); this.error = error; } + protected Map getPropertiesSpecific(String locale) { // just use the service properties; for now we do not localize any properties return getServiceProperties(); @@ -64,7 +65,7 @@ public class EclipseAppDescriptor extends ApplicationDescriptor { // be sure to destroy the appHandle if an error occurs appHandle.destroy(); if (t instanceof Exception) - throw (Exception)t; + throw (Exception) t; throw (Error) t; } return appHandle; 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 e211a6d86..b200b567c 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -50,7 +50,6 @@ public class EclipseAppHandle extends ApplicationHandle implements IAppContext { return state; } - protected void destroySpecific() { // when this method is called we must force the application to exit. // first set the status to stopping @@ -101,7 +100,7 @@ public class EclipseAppHandle extends ApplicationHandle implements IAppContext { // if the status is stopped then unregister the service if ((status & IAppContext.STOPPED) != 0 && (this.status & IAppContext.STOPPED) == 0) { sr.unregister(); - ((EclipseAppDescriptor)getApplicationDescriptor()).appHandleDestroyed(); + ((EclipseAppDescriptor) getApplicationDescriptor()).appHandleDestroyed(); } this.status = status; } @@ -119,7 +118,7 @@ public class EclipseAppHandle extends ApplicationHandle implements IAppContext { } public IConfigurationElement getConfiguration() { - IExtension applicationExtension = ((EclipseAppDescriptor)getApplicationDescriptor()).getContainerManager().getAppExtension(getApplicationDescriptor().getApplicationId()); + IExtension applicationExtension = ((EclipseAppDescriptor) getApplicationDescriptor()).getContainerManager().getAppExtension(getApplicationDescriptor().getApplicationId()); IConfigurationElement[] configs = applicationExtension.getConfigurationElements(); if (configs.length == 0) throw new RuntimeException(NLS.bind(Messages.application_invalidExtension, getApplicationDescriptor().getApplicationId())); 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 e9e71fb77..179e82251 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -86,7 +86,7 @@ public class EclipseScheduledApplication implements ScheduledApplication, EventH public synchronized void remove() { if (removed) return; - removed = true; + removed = true; AppManager.removeScheduledApp(this); if (sr != null) sr.unregister(); @@ -115,6 +115,7 @@ public class EclipseScheduledApplication implements ScheduledApplication, EventH public class TriggerGuard implements Guard { String eventTopic; + public TriggerGuard(String topic) { this.eventTopic = topic; } diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainSingletonApplication.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainSingletonApplication.java index 5eca65bf2..3b1116c72 100755 --- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainSingletonApplication.java +++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainSingletonApplication.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -29,7 +29,7 @@ public class MainSingletonApplication implements ApplicationRunnable { application = appContext.getConfiguration().createExecutableExtension("run"); //$NON-NLS-1$ } catch (Exception e) { this.launchException = e; - } + } } public Object run(Object context) throws Exception { @@ -43,7 +43,7 @@ public class MainSingletonApplication implements ApplicationRunnable { throw launchException; if (application instanceof IApplication) { result = ((IApplication) application).run(context); - } else + } else result = ContainerManager.execMethod(application, "run", Object.class, context); //$NON-NLS-1$ } finally { application = null; @@ -61,7 +61,7 @@ public class MainSingletonApplication implements ApplicationRunnable { public void stop() { // we can only handle forced stops if this application is an IApplication if (application instanceof IApplication) - ((IApplication)application).stop(); + ((IApplication) application).stop(); } IApplication getApplication() { diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainSingletonContainer.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainSingletonContainer.java index 5a931100d..37ec48459 100755 --- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainSingletonContainer.java +++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainSingletonContainer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -28,6 +28,7 @@ public class MainSingletonContainer implements IContainer, ServiceTrackerCustomi appLauncherTracker = new ServiceTracker(containerMgr.getBundleContext(), ApplicationLauncher.class.getName(), this); appLauncherTracker.open(); } + public IApplication launch(IAppContext appContext) { // use the ApplicationLauncher provided by the framework // to ensure it is launched on the main thread @@ -37,6 +38,7 @@ public class MainSingletonContainer implements IContainer, ServiceTrackerCustomi appLauncher.launch(app, appContext.getArguments() == null ? null : appContext.getArguments().get(ContainerManager.PROP_ECLIPSE_APPLICATION_ARGS)); return app.getApplication(); } + public Object addingService(ServiceReference reference) { if (appLauncher != null) return null; @@ -53,9 +55,10 @@ public class MainSingletonContainer implements IContainer, ServiceTrackerCustomi } return appLauncher; } + public void modifiedService(ServiceReference reference, Object service) { // TODO Auto-generated method stub - + } public synchronized void removedService(ServiceReference reference, Object service) { @@ -64,6 +67,7 @@ public class MainSingletonContainer implements IContainer, ServiceTrackerCustomi containerMgr.getBundleContext().ungetService(reference); } } + public boolean isSingletonContainer() { return true; } diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/Messages.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/Messages.java index dafdaa875..61938d0ef 100755 --- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/Messages.java +++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/Messages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,7 +12,7 @@ package org.eclipse.equinox.internal.app; import org.eclipse.osgi.util.NLS; -public class Messages extends NLS{ +public class Messages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.equinox.internal.app.messages"; //$NON-NLS-1$ // application diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/SingletonContainerMgr.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/SingletonContainerMgr.java index 53ea8d49e..9377ff276 100755 --- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/SingletonContainerMgr.java +++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/SingletonContainerMgr.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,12 +17,13 @@ public class SingletonContainerMgr implements IContainer { private String type; private IContainer singletonContainer; private ContainerManager containerManager; - + public SingletonContainerMgr(IContainer singletonContainer, String type, ContainerManager containerManager) { this.singletonContainer = singletonContainer; this.type = type; this.containerManager = containerManager; } + public synchronized IApplication launch(IAppContext context) throws Exception { if (context != singletonHandle) throw new IllegalStateException("Only one application of type \"" + type + "\" is allowed to run at a time"); @@ -43,6 +44,7 @@ public class SingletonContainerMgr implements IContainer { singletonHandle = appHandle; refreshAppDescriptors(); } + synchronized void unlock() { singletonHandle = null; refreshAppDescriptors(); |