Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Server instance creation programmatically(Create one or more instance server (if not exist) in a startup Eclipse plugin)
Server instance creation programmatically [message #901096] Thu, 09 August 2012 18:50 Go to next message
Alix Lourme is currently offline Alix LourmeFriend
Messages: 5
Registered: April 2012
Junior Member

I'm in charge of Eclipse distribution in my company. For rationalise repetitive items configuration, I link a preferences file at startup (-pluginCustomization runtime option) and provide a startup plugin (with some class 'implements IStartup').

One of this task is to configure runtime server and instances server.

Runtimes servers could be configured in preferences file with 'org.eclipse.wst.server.core/runtimes=...'.

But I have no great solution to create servers instances if not exist :
- I didn't found item in preferences file to do that
- Update "manually" (with a xml parser) the file '[workspace]/.metadata/.plugins/org.eclipse.wst.server.core/server.xml' is not secure ...

=> With a link on 'org.eclipse.wst.server.core' bundle/dependency in a Eclipse plugin, I could access to 'org.eclipse.wst.server.core.ServerCore' and have all information about runtimes/instances servers (configured or available) ... but I didn't found the code to use for create items Sad

Someone would have an idea of the API part to use ? (The code called when we click on "Finish" in the "Define a new Server" window Smile ).

Thanks in advance.
Re: Server instance creation programmatically [message #1203271 is a reply to message #901096] Fri, 22 November 2013 15:19 Go to previous message
Jochen Schmich is currently offline Jochen SchmichFriend
Messages: 29
Registered: July 2009
Junior Member
Wow, you might have solved this problem by yourself in the meanwhile Smile. If not, you might try to start out with the following snippet:

IRuntimeType runtimeType = ServerCore.findRuntimeType("org.eclipse.jst.server.tomcat.runtime.70");
IServerType serverType = ServerCore.findServerType("org.eclipse.jst.server.tomcat.70");
try {
	NullProgressMonitor progressMonitor = new NullProgressMonitor();
	IRuntimeWorkingCopy runtime = runtimeType.createRuntime("my_tomcat_runtime", progressMonitor);
	runtime.setName("Tomcat Runtime");
	IServerWorkingCopy server = serverType.createServer("my_tomcat_server", null, runtime, progressMonitor);
	server.setName("Tomcat Server");
	server.saveAll(false, progressMonitor);
} catch (CoreException e) {

Have fun!
Previous Topic:Remote Debug Weblogic 10.3.3 on Linux from Windows machine
Next Topic:Can't install WTP in Eclipse 4.2 Classic
Goto Forum:

Current Time: Thu Apr 27 05:45:29 GMT 2017

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

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