You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Dennis Sosnoski <dm...@sosnoski.com> on 2011/08/24 01:43:23 UTC
Shut down JAX-RS embedded Jetty from code?
When I create a JAX-RS server and run it in process with the following code:
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setServiceClass(LibraryRestImpl.class);
sf.setBindingId(JAXRSBindingFactory.JAXRS_BINDING_ID);
sf.setAddress("http://localhost:8081/cxf-library-rest");
Server server = sf.create();
synchronized (LibraryRestImpl.class) {
try {
LibraryRestImpl.class.wait(60000);
} catch (InterruptedException e) {
// ignore
}
}
server.stop();
server.destroy();
the Jetty threads keep running even after the service has been shutdown.
How can I terminate the Jetty server?
Thanks,
- Dennis
--
Dennis M. Sosnoski
Java SOA and Web Services Consulting <http://www.sosnoski.com/consult.html>
Axis2/CXF/Metro SOA and Web Services Training
<http://www.sosnoski.com/training.html>
Web Services Jump-Start <http://www.sosnoski.com/jumpstart.html>
Re: Shut down JAX-RS embedded Jetty from code?
Posted by Willem Jiang <wi...@gmail.com>.
You can also call the bus.shutdown() to shutdown the Jetty server.
On 8/24/11 7:43 AM, Dennis Sosnoski wrote:
> When I create a JAX-RS server and run it in process with the following code:
>
> JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
> sf.setServiceClass(LibraryRestImpl.class);
> sf.setBindingId(JAXRSBindingFactory.JAXRS_BINDING_ID);
> sf.setAddress("http://localhost:8081/cxf-library-rest");
> Server server = sf.create();
> synchronized (LibraryRestImpl.class) {
> try {
> LibraryRestImpl.class.wait(60000);
> } catch (InterruptedException e) {
> // ignore
> }
> }
> server.stop();
> server.destroy();
>
> the Jetty threads keep running even after the service has been shutdown.
> How can I terminate the Jetty server?
>
> Thanks,
>
> - Dennis
>
--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang
Re: Shut down JAX-RS embedded Jetty from code?
Posted by Dennis Sosnoski <dm...@sosnoski.com>.
Thanks, Arul - that works!
- Dennis
On 08/24/2011 01:23 PM, Arul Dhesiaseelan wrote:
> Here is how I use the APIs and it cleanly destroys the server:
>
> JettyHTTPServerEngineFactory factory = new
> JettyHTTPServerEngineFactory();//add this
> JettyHTTPServerEngine engine = factory.createJettyHTTPServerEngine(port,
> "http");//add this
> JAXRSServerFactoryBean restFactory = new JAXRSServerFactoryBean();
> restFactory.setResourceClasses(FlowChartListener.class);
> FlowChartListenerImpl flowChartListener = new
> FlowChartListenerImpl(flowContext, engineUsername, enginePassword);
> restFactory.setResourceProvider(FlowChartListener.class, new
> SingletonResourceProvider(flowChartListener));
> restFactory.setAddress(restEndpoint);
> Server restServer = restFactory.create();
> restServer.destroy();
> engine.shutdown();//add this
>
> -Arul
>
> On Tue, Aug 23, 2011 at 5:43 PM, Dennis Sosnoski <dm...@sosnoski.com> wrote:
>
>> When I create a JAX-RS server and run it in process with the following
>> code:
>>
>> JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
>> sf.setServiceClass(LibraryRestImpl.class);
>> sf.setBindingId(JAXRSBindingFactory.JAXRS_BINDING_ID);
>> sf.setAddress("http://localhost:8081/cxf-library-rest");
>> Server server = sf.create();
>> synchronized (LibraryRestImpl.class) {
>> try {
>> LibraryRestImpl.class.wait(60000);
>> } catch (InterruptedException e) {
>> // ignore
>> }
>> }
>> server.stop();
>> server.destroy();
>>
>> the Jetty threads keep running even after the service has been shutdown.
>> How can I terminate the Jetty server?
>>
>> Thanks,
>>
>> - Dennis
>>
>> --
>>
>> Dennis M. Sosnoski
>> Java SOA and Web Services Consulting <http://www.sosnoski.com/consult.html
>> Axis2/CXF/Metro SOA and Web Services Training
>> <http://www.sosnoski.com/training.html>
>> Web Services Jump-Start <http://www.sosnoski.com/jumpstart.html>
>>
>>
>
Re: Shut down JAX-RS embedded Jetty from code?
Posted by Arul Dhesiaseelan <ar...@acm.org>.
Here is how I use the APIs and it cleanly destroys the server:
JettyHTTPServerEngineFactory factory = new
JettyHTTPServerEngineFactory();//add this
JettyHTTPServerEngine engine = factory.createJettyHTTPServerEngine(port,
"http");//add this
JAXRSServerFactoryBean restFactory = new JAXRSServerFactoryBean();
restFactory.setResourceClasses(FlowChartListener.class);
FlowChartListenerImpl flowChartListener = new
FlowChartListenerImpl(flowContext, engineUsername, enginePassword);
restFactory.setResourceProvider(FlowChartListener.class, new
SingletonResourceProvider(flowChartListener));
restFactory.setAddress(restEndpoint);
Server restServer = restFactory.create();
restServer.destroy();
engine.shutdown();//add this
-Arul
On Tue, Aug 23, 2011 at 5:43 PM, Dennis Sosnoski <dm...@sosnoski.com> wrote:
> When I create a JAX-RS server and run it in process with the following
> code:
>
> JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
> sf.setServiceClass(LibraryRestImpl.class);
> sf.setBindingId(JAXRSBindingFactory.JAXRS_BINDING_ID);
> sf.setAddress("http://localhost:8081/cxf-library-rest");
> Server server = sf.create();
> synchronized (LibraryRestImpl.class) {
> try {
> LibraryRestImpl.class.wait(60000);
> } catch (InterruptedException e) {
> // ignore
> }
> }
> server.stop();
> server.destroy();
>
> the Jetty threads keep running even after the service has been shutdown.
> How can I terminate the Jetty server?
>
> Thanks,
>
> - Dennis
>
> --
>
> Dennis M. Sosnoski
> Java SOA and Web Services Consulting <http://www.sosnoski.com/consult.html
> >
> Axis2/CXF/Metro SOA and Web Services Training
> <http://www.sosnoski.com/training.html>
> Web Services Jump-Start <http://www.sosnoski.com/jumpstart.html>
>
>
--
http://aruld.info
http://twitter.com/aruld