Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (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 14:50 Go to next message
Alix Lourme is currently offline Alix Lourme
Messages: 5
Registered: April 2012
Junior Member
Hi,

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 10:19 Go to previous message
Jochen Schmich is currently offline Jochen Schmich
Messages: 21
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");
	runtime.setLocation(...........);
	IServerWorkingCopy server = serverType.createServer("my_tomcat_server", null, runtime, progressMonitor);
	server.setName("Tomcat Server");
	server.saveAll(false, progressMonitor);
} catch (CoreException e) {
	e.printStackTrace();
}


Have fun!
Previous Topic:NullPointerException when adding Axis2 facet
Next Topic:source code for org.mozilla.javascript_1.7.2.v201005080400
Goto Forum:
  


Current Time: Thu Jul 24 09:11:28 EDT 2014

Powered by FUDForum. Page generated in 0.03592 seconds