Opening ServerSocket from plugin [message #448364] |
Sun, 23 April 2006 15:10  |
Eclipse User |
|
|
|
Hi,
Is it possible to activate a (non-gui) plugin at the platform startup,
without having it opening views or editors? Actually, the plugin in
question shouldn't have views nor editors at all.
My situation:
I'm looking for the possibility for plugins to load at startup, without
opening views or editors. Actually, my plugin should open a ServerSocket
and listen for connections as soon as RCP application is started. Once the
connection is received and a 'command' is issued by the client, plugin
should open some view or editor from other plugins (e.g. open specified
file for editing).
I'm having troubles activating a plugin if it doesn't have a view or
editor opened. I'm not quite sure if it's possible to initialize plugin at
platform startup if it doesn't contribute to GUI.
If not possible, where would be the right place to put ServerSocket,
having in mind that other views and editors must be visible and ready to
open.
Code related to opening a server socket is plain simple:
// class extends thread, this is in run()
ServerSocket serverSocket = new ServerSocket(PORT);
while (true) {
Socket clientSocket = serverSocket.accept();
BufferedReader in = new BufferedReader(new InputStreamReader(
clientSocket.getInputStream()));
String inputLine, outputLine;
while ((inputLine = in.readLine()) != null) {
if (inputLine.equals("some command")) {
// parse command, activate view in the window
// which is in focus
}
// close connection
clientSocket.close();
break;
}
}
}
Any advices, thought or ideas are greatly welcome.
Thanks in advance
Davor
|
|
|
|
|
Re: Opening ServerSocket from plugin [message #448433 is a reply to message #448425] |
Mon, 24 April 2006 13:14  |
Eclipse User |
|
|
|
Paul Webster wrote:
> There is an org.eclipse.ui.startup extension. It will start the class
> specified in the extension once the workbench is up (but in a non-UI
> thread).
>
> Don't make the startup class the plugin activator class.
>
> If you want to kick off your server, or use asyncExec(*) to put a "Job"
> onto the UI display queue, you can do it from there.
Thanks Paul (and Thomas) for the insight.
For Proof of Concept we placed socket init procedure in
ApplicationWorkbenchWindowAdvisor.preWindowOpen() and used something like
Display.getDefault().asyncExec( new Runnable() {
public void run() {
FileView.instance().setFile(received); // internal method
}
});
It works, but plugin based solution is much better.
Thanks again.
Cheers,
Davor
|
|
|
Powered by
FUDForum. Page generated in 0.03485 seconds