Running Jetty as a Workbench service [message #105591] |
Thu, 28 February 2008 21:20  |
Eclipse User |
|
|
|
Originally posted by: csmith.adcaustin.com
I would like to use the embedded Jetty server to provide a http interface to
a running eclipse workbench. I created two action sets using the plug-in
wizards that start and stop Jetty using the JettyConfigurator.startServer()
and JettyConfigurator.stopServer() methods. Jetty starts up and a browser
pointed to them seems to confirm that Jetty is running. This is where I run
out of steam.
I created a servlet and context extension points and classes but I do not
know how I make this Jetty instance use them.
As you can see I'm pretty green so advise is welcome.
My goal is to have a program outside of a running eclipse workbench be able
to ask the the eclipse workbench to perform some actions and return a
response.
Thanks in advance.
|
|
|
|
|
|
Re: Running Jetty as a Workbench service [message #111789 is a reply to message #107474] |
Thu, 12 June 2008 04:57   |
Eclipse User |
|
|
|
I have written an Activator which starts Jetty and I want to register a
servlet which acts on the workspace.
Although I have registered my servlet throught the extension point,
<extension
point="org.eclipse.equinox.http.registry.servlets">
<servlet
alias="/MyServlet"
class="com.example.MyServlet">
</servlet>
</extension>
the servlet is not available.
Here is how I start Jetty:
Dictionary<String, Object> settings = new Hashtable<String, Object>();
settings.put("http.enabled", Boolean.TRUE);
settings.put("http.port", 8079);
settings.put("http.host", "0.0.0.0");
settings.put("https.enabled", Boolean.FALSE);
settings.put("context.path", "/");
settings.put("context.sessioninactiveinterval", 1800);
try
{
JettyConfigurator.startServer(PLUGIN_ID + ".server",
settings);
serverId = PLUGIN_ID + ".server";
}
catch (Exception e)
{
e.printStackTrace();
}
Any idea would be appreciated.
Loïc
Christopher Smith a écrit :
> Just to followup, I reviewed how Eclipse help uses the embeded Jetty. I
> mimiced it and it worked. My plugin explicitly starts and stops jetty
> from a singleton.
>
> The servlet then runs inside of my workbench and can interact with the
> workbench as it receives requests.
>
> Works great... and less filling too
>
> "Dennis O'Flynn" <dennis.oflynn@compuware.com> wrote in message
> news:fq8tci$o47$1@build.eclipse.org...
>> Assumptions:
>> * Your plugin has a dependency upon the
>> "org.eclipse.equinox.http.registry"
>> * Your plugin proves an extensions to the
>> "org.eclipse.equinox.http.registry.servlets" extension point.
>> The default startup configuration for the IDE does not launch the
>> equinox http service by default. This needs to be added to the
>> startup configuration in "configuration/config.ini".
>>
>> * Open "configuration/config.ini" in an editor
>> * Modify the property "osgi.bundles"
>> ** Append ", org.eclipse.equinox.http@3:start,
>> org.eclipse.equinox.http.registry@start"
>>
>> Optionally, you can change the port number (e.g. 3080) used by the
>> http service by define setting "org.osgi.service.http.port=3080".
>>
>> You may have to restart your IDE w/ the "clean" option (eclipse
>> -clean), for your changes to the "osgi.bundles" property to take affect.
>>
>>
>> "Christopher Smith" <csmith@adcaustin.com> wrote in message
>> news:fq7q68$37h$1@build.eclipse.org...
>>> I would like to use the embedded Jetty server to provide a http
>>> interface to a running eclipse workbench. I created two action sets
>>> using the plug-in wizards that start and stop Jetty using the
>>> JettyConfigurator.startServer() and JettyConfigurator.stopServer()
>>> methods. Jetty starts up and a browser pointed to them seems to
>>> confirm that Jetty is running. This is where I run out of steam.
>>>
>>> I created a servlet and context extension points and classes but I do
>>> not know how I make this Jetty instance use them.
>>>
>>> As you can see I'm pretty green so advise is welcome.
>>>
>>> My goal is to have a program outside of a running eclipse workbench
>>> be able to ask the the eclipse workbench to perform some actions and
>>> return a response.
>>>
>>> Thanks in advance.
>>
>>
>
|
|
|
Re: Running Jetty as a Workbench service [message #111810 is a reply to message #111789] |
Thu, 12 June 2008 10:08  |
Eclipse User |
|
|
|
Hi Loic,
The org.eclipse.equinox.http.registry bundle has to be started. Can you
confirm that it is.
If not Help/UA uses the following code that you might embelish:
---
Bundle bundle = Platform.getBundle("org.eclipse.equinox.http.registry");
if (bundle.getState() == Bundle.RESOLVED) {
bundle.start(Bundle.START_TRANSIENT);
}
---
This will work but a better practice here would be to use PackageAdmin
instead of Platform to get the bundle.
-Simon
"Lo
|
|
|
Powered by
FUDForum. Page generated in 0.04251 seconds