Currently the system is not designed to allow you to shutdown the framework
from an adaptor hook as the framework is being launched.  Anything you do
will likely be a hack and likely will not do exactly what you want.  With
the current Eclipse Platform, I think the simplest approach is to put both
the client and server directly in your application (implementation of
IApplication).

- The default application that is launched has complete control over when
the running instance shuts down.  This happens when you exit the
IApplication.start method.
- Your IApplication.start method can check for a server and communicate
with it to process the request and then exit the start method to shutdown
the instance of Eclipse.
- If no server is found you can start your server and process the request
directly in the current instance.

The disadvantage of this approach is the overhead of getting to your
IApplication.start(), but that should be quite low since you should do it
very early in your application before any extensions have been loaded and
any UI has been displayed.

Tom




                                                                       
  From:       Jens Goldhammer <[email protected]>           
                                                                       
  To:         [email protected]                                  
                                                                       
  Date:       02/03/2009 11:21 AM                                      
                                                                       
  Subject:    Re: [equinox-dev] Using Equinox Hooks for handling application    
starting?
                                                                       






Thanks for answering, Thomas!

Yes, my idea was to put the client and server into the application. The
server starts as a separate thread in the background and the hook contains
the client which tries to connect to the server. If no server is found, I
want to leave the current running instance starting, so in my case I have
nothing to do in the hook. In the other case, to connect to another
instance, I want to stop the current instance. You say that it I cannot
stop
the osgi platform in my hook? Is there really no oppurtunity for doing
that?
What about system.exit()?? :-) I think, that should be the last solution...
I have seen the class OSGi and the method close(). Can I reference it
somehow? Maybe I can use AspectJ for get an reference to an instance of
OSGi?

Thanks,
Jens



Thomas Watson wrote:
>
>
> See https://bugs.eclipse.org/bugs/show_bug.cgi?id=178927 for an
> enhancement
> request that is similar to what you require.
>
> The Equinox Hook (AdaptorHook.startFramework method) will not be
> sufficient
> for implementing this.  You can get the command line by using the
> EnvironmentInfo service in you hook.  You are passed a BundleContext
which
> you could use to get the EnvironmentInfo service.  This service has the
> methods you need to get the command line arguments.  But there is no way
> from the startFramework method to tell the platform not to start the
> application.  When Eclipse RCP is launched it is configured with an
> application to launch.  You still want this application to be configured
> to
> launch in case there is no running instance of your application yet.  So
> even though you processed the command line in your adaptor hook and
> communicated with another running instance the platform will continue to
> boot and attempt to start your application.  At that point your
> application
> could determine that a command line was used to communicate with another
> instance and return immediately.  If you already have to enter your
> application each time then you might as well just put all the TCP
> client/server logic directly in your application and have it determine
> whether it should pass the information off to another running instance of
> your application and return immediately or process the request directly
> because it is the first running instance of the application.
>
> Tom
>
>
>
>
>
>   From:       Jens Goldhammer <[email protected]>
>
>   To:         [email protected]
>
>   Date:       02/03/2009 05:46 AM
>
>   Subject:    [equinox-dev] Using Equinox Hooks for handling application
> starting?
>
>
>
>
>
>
>
> Hello,
>
> We implemented a rcp application which can be started either by clicking
> the
> application file (.exe) or by doubleclicking a file (with a certain
> fileextension) on the filesystem. The problem is that we want to handle a
> doubleclick on this file by extracting its information and show a dialog
> in
> our application. There are two possibilites: There is already an running
> instance or we have to start a new one.
>
> It seems to me that the Equinox Hook can be a friend in this case. Read
> the
> proposed solution under
> http://www.ibm.com/developerworks/library/os-eclipse-rcpurl/index.html, I
> have the idea to put the uri client into an Equinox hook. Either I can
> call
> the other instance via TCP (and close the new one) or run the current
> instance if there is no other instance open.
>
> The problem is now that I have to parse the commandline to get out the
> filepath of the file which was used to start our application. Is there a
> way
> to do that in the hook frameworkstart method? How can I close the osgi
> platform if there is another instance which can handle the file?
>
> Thanks,
> Jens
> --
> View this message in context:
>
http://www.nabble.com/Using-Equinox-Hooks-for-handling-application-starting--tp21808278p21808278.html

>
> Sent from the Equinox - Dev mailing list archive at Nabble.com.
>
> _______________________________________________
> equinox-dev mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/equinox-dev
>
>
>
>
> _______________________________________________
> equinox-dev mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/equinox-dev
>
>

--
View this message in context:
http://www.nabble.com/Using-Equinox-Hooks-for-handling-application-starting--tp21808278p21814525.html

Sent from the Equinox - Dev mailing list archive at Nabble.com.

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

<<inline: graycol.gif>>

<<inline: ecblank.gif>>

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

Reply via email to