Skip to main content


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: 6
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 15:19 Go to previous messageGo to next 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");
	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!
Re: Server instance creation programmatically [message #1764065 is a reply to message #1203271] Wed, 24 May 2017 14:07 Go to previous message
Alix Lourme is currently offline Alix LourmeFriend
Messages: 6
Registered: April 2012
Junior Member
Many thanks ! very useful ! (though a "double time" myself meanwhile^^)
Previous Topic:Can't setup JSP debugging in Neon.3 with tomcat8
Next Topic:Link inside proposals?
Goto Forum:
  


Current Time: Fri Apr 26 01:02:26 GMT 2024

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

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

Back to the top