Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Opening ServerSocket from plugin
Opening ServerSocket from plugin [message #448364] Sun, 23 April 2006 19:10 Go to next message
Davor Cengija is currently offline Davor CengijaFriend
Messages: 6
Registered: July 2009
Junior Member
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 #448425 is a reply to message #448364] Mon, 24 April 2006 13:25 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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.

Later,
PW


Re: Opening ServerSocket from plugin [message #448429 is a reply to message #448364] Mon, 24 April 2006 14:29 Go to previous messageGo to next message
Thomas Darimont is currently offline Thomas DarimontFriend
Messages: 10
Registered: July 2009
Junior Member
Hello,

yes that's possible. Simply provide an extension to the
org.eclipse.ui.startup extension-point and declare a startup class
(which has to implement the org.eclipse.ui.IStartup interface).

Kind regards,
Thomas
Re: Opening ServerSocket from plugin [message #448433 is a reply to message #448425] Mon, 24 April 2006 17:14 Go to previous message
Davor Cengija is currently offline Davor CengijaFriend
Messages: 4
Registered: July 2009
Junior Member
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
Previous Topic:NLS problem
Next Topic:Jobs API: Overhead scheduling > 100 Jobs?
Goto Forum:
  


Current Time: Tue Nov 12 13:13:22 GMT 2024

Powered by FUDForum. Page generated in 0.04587 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top