Hello.

I need some tips in narrowing down the cause of a problem We've been having in 
our RCP/OSGi application.

Our project is using Declarative Services to manage several bundles of 
services, and Eclipse Plug-in Extensions for various RCP components.
Everything seems to be running ok, but I'm having trouble with one thing: 
getting the OSGi framework and all of the bundles to shut down when the user 
closes the RCP Application window. 

First, a few questions:
-----------------------------

I read articles like 
http://www.eclipsezone.com/articles/extensions-vs-services/ and start to worry 
if our use of both DS and RCP plug-ins is somehow fundamentally problematic. 
There is a lot of functional overlap, but do these two approaches ever 
conflict? Is there a standard way to get them to work together to close down 
when the application is done?

Is it remotely possible that the org.eclipse.equinox.ds resolver's 
ConcurrentModificationException during the startup of an OSGi framework could 
have anything to do with preventing the entire OSGi framework from shutting 
down automatically after the RCP Application is closed?

Eclipse automatically seems to understand that we want the framework to shut 
down when the application closes, but when we take our jars out into the real 
world, the framework doesn't stop. I suppose this is understandable, since we 
tell OSGi to start the applications and to start the bundles and services. How 
do we tell OSGi that they are linked, and must be shut down when the 
Application closes? 

About our configuration:
----------------------------------
The framework is started up with the following command:
java -cp . -jar org.eclipse.osgi_3.3.0.v20070530.jar -console

Our setup contains one RCP application (using the eclipse plugin extension 
system), and multiple bundles with many services (using declarative services).
The bundle containing the Application also has a service (to modify a tree 
view, and manage a progress bar).
The declarative service has no explicit connection to the application defined 
by DS -- they just happen to float in the same bundle and access each other 
sloppily through static class references (this feels like a problem area now 
that I reflect on it).

The following equinox/eclipse bundles are used:

org.apache.commons.logging_1.0.4.v200706111724.jar
org.eclipse.equinox.ds_1.0.0.v20070226.jar
org.eclipse.equinox.event_1.0.100.v20070516.jar
org.eclipse.equinox.log_1.0.100.v20070226.jar
org.eclipse.osgi.services_3.1.200.v20070605.jar
org.eclipse.osgi_3.3.0.v20070530.jar

com.ibm.icu_3.6.1.v20070417.jar
org.eclipse.core.commands_3.3.0.I20070605-0010.jar
org.eclipse.core.contenttype_3.2.100.v20070319.jar
org.eclipse.core.databinding.beans_1.0.0.I20070606-0010.jar
org.eclipse.core.databinding_1.0.0.I20070606-0010.jar
org.eclipse.core.expressions_3.3.0.v20070606-0010.jar
org.eclipse.core.jobs_3.3.0.v20070423.jar
org.eclipse.core.runtime.compatibility.auth_3.2.100.v20070502.jar
org.eclipse.core.runtime_3.3.100.v20070530.jar
org.eclipse.equinox.app_1.0.0.v20070606.jar
org.eclipse.equinox.common_3.3.0.v20070426.jar
org.eclipse.equinox.launcher_1.0.0.v20070606.jar
org.eclipse.equinox.preferences_3.2.100.v20070522.jar
org.eclipse.equinox.registry_3.3.0.v20070522.jar
org.eclipse.help_3.3.0.v20070524.jar
org.eclipse.jface.databinding_1.1.0.I20070606-0010.jar
org.eclipse.jface.text_3.3.0.v20070606-0010.jar
org.eclipse.jface_3.3.0.I20070606-0010.jar
org.eclipse.rcp_3.2.0.v20070612.jar
org.eclipse.swt.win32.win32.x86_3.3.0.v3346.jar
org.eclipse.swt_3.3.0.v3346.jar
org.eclipse.text_3.3.0.v20070606-0010.jar
org.eclipse.ui.workbench_3.3.0.I20070608-1100.jar
org.eclipse.ui_3.3.0.I20070614-0800.jar
org.eclipse.update.configurator_3.2.100.v20070615.jar

It's becoming a problem because our EXE launcher doesn't display the OSGi 
console, and the bundles and framework silently remain active even long after 
the program is closed by the user.

config.ini is as follows
--------------------------
eclipse.ignoreApp=false
osgi.noShutdown=false

osgi.bundles= \
 [EMAIL PROTECTED]:start, \
 [EMAIL PROTECTED], \
 [EMAIL PROTECTED]:start, \
 [EMAIL PROTECTED]:start, \
 [EMAIL PROTECTED]:start, \
 [EMAIL PROTECTED]:start, \
 [EMAIL PROTECTED]:start, \
 [EMAIL PROTECTED]:start, \
 [EMAIL PROTECTED]:start, \
 [EMAIL PROTECTED]:start, \
 [EMAIL PROTECTED]:start, \
 [EMAIL PROTECTED]:start, \
 [EMAIL PROTECTED]:start, \
 [EMAIL PROTECTED]:start, \
 [EMAIL PROTECTED]:start, \
 [EMAIL PROTECTED]:start, \
 [EMAIL PROTECTED]:start, \
 [EMAIL PROTECTED]:start, \
 org.eclipse.swt.win32.win32.x86, \
 [EMAIL PROTECTED]:start, \
 [EMAIL PROTECTED]:start, \
 [EMAIL PROTECTED]:start, \
 [EMAIL PROTECTED]:start, \
 [EMAIL PROTECTED]:start, \
 [EMAIL PROTECTED]:start, \
 [EMAIL PROTECTED]:start, \
 [EMAIL PROTECTED]:start, \
 [EMAIL PROTECTED]:start, \
[All of our bundles follow at run level 4]

eclipse.application=[our gui]
-------------------------


Our application class is as follows:
---------------------------------------------
public class Application implements IApplication {

        public Object start(IApplicationContext context) throws Exception {
                Display display = PlatformUI.createDisplay();
                try {
                        ApplicationWorkbenchAdvisor window = new 
ApplicationWorkbenchAdvisor();
                        
                        int returnCode = 
PlatformUI.createAndRunWorkbench(display, window);

                        if (returnCode == PlatformUI.RETURN_RESTART)
                                return IApplication.EXIT_RESTART;
                        else
                                return IApplication.EXIT_OK;
                } finally {
                        Thread.sleep(1000L);
                        display.dispose();
                }
        }

        public void stop() {
                final IWorkbench workbench = PlatformUI.getWorkbench();
                if (workbench == null)
                        return;
                final Display display = workbench.getDisplay();
                display.syncExec(new Runnable() {
                        public void run() {
                                if (!display.isDisposed())
                                        workbench.close();
                        }
                });
        }
}
---------------------------------------------

Any tips, or suggestions, or complete solutions are appreciated.
Thanks for doing the things that you do,

- Darren
_______________________________________________
equinox-dev mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/equinox-dev

Reply via email to