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 <[email protected]> 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

Reply via email to