If I remember correctly (been a while since I looked at this), the engine will shut itself down when the Bus is shutdown AND all the endpoints are stopped. Thus, you may be able to just do:
endpoint.stop(); //for each endpoint bus.shutdown(); and it should shut the engine down completely. Dan On Nov 3, 2012, at 9:21 PM, [email protected] wrote: > And here is the code if not wanting to reply on spring: > > Bus bus = BusFactory.getDefaultBus(); > JettyHTTPServerEngineFactory engineFactory = > bus.getExtension(JettyHTTPServerEngineFactory.class); > JettyHTTPServerEngine engine = > engineFactory.retrieveJettyHTTPServerEngine(9448); > engine.shutdown(); > > > > On Sun, Nov 4, 2012 at 12:11 PM, <[email protected]> wrote: >> I checked into this a little more and the following code is considerably >> safer: >> >> JettyHTTPServerEngineFactory engineFactory = >> context.getBean(JettyHTTPServerEngineFactory.class); >> JettyHTTPServerEngine engine = >> engineFactory.retrieveJettyHTTPServerEngine(9448); >> engine.shutdown(); >> >> It will not shutdown the server if any Endpoints are still deployed. >> Hopefully someone much more familiar with the jetty stuff can >> advise us both if my approach is appropriate. >> >> Cheers >> Jason >> >> On Sun, Nov 4, 2012 at 11:55 AM, <[email protected]> wrote: >>> to explain a little more. When you use JaxWsServerFactoryBean.create >>> or use a jaxws:endpoint in spring (which I would recommend over >>> programmatic creation anyway), it will start the Jetty instance if it >>> has not already been started. However it does not stop the instance >>> for you again automatically that I know of. I guess that might be an >>> enhancement you could request / or contribute. >>> >>> If you do use jaxws:endpoint, you can get access to the Server to stop >>> your endpoint via the code: >>> >>> org.apache.cxf.jaxws.EndpointImpl endpoint = >>> (org.apache.cxf.jaxws.EndpointImpl) >>> context.getBean("MySpringBeanIdForJaxWsEndpoint", >>> javax.xml.ws.Endpoint.class); >>> org.apache.cxf.endpoint.Server server = endpoint.getServer(); >>> server.stop(); >>> >>> And then you can shut down the jetty instance if you also need to with: >>> >>> JettyHTTPServerEngineFactory.destroyForPort(9448); >>> >>> An enhancement to automatically shutdown the jetty endpoint when the >>> last server is stopped would be interesting to look at, but has all >>> sorts of interesting issues with it. For instance in our case at >>> work, we often stop an endpoint only to redeploy a replacement service >>> to the same endpoint so we would not want to automatically shut it >>> down. >>> >>> its safer to leave that to the individual application to decide, which >>> I guess is why the method above has been provided. >>> >>> On Sun, Nov 4, 2012 at 11:49 AM, <[email protected]> wrote: >>>> Stopping the Server will only remove the endpoint from the started Jetty >>>> Engine. However you can stop jetty itself >>>> >>>> programmtically with something like: >>>> >>>> JettyHTTPServerEngineFactory.destroyForPort(9448); >>>> >>>> >>>> Where 9448 is the port number your jetty engine is running on. >>>> >>>> >>>> I don't know what the official recommendation is for this but that will >>>> certainly do the trick. Although cxf javadoc might not be all up to >>>> scratch this mailing rocks so its a pretty good alternative. >>>> >>>> >>>> Cheers >>>> >>>> Jason >>>> >>>> >>>> Sent from my Galaxy S2 >>>> >>>> On Nov 1, 2012 3:01 AM, "selvakumar netaji" <[email protected]> wrote: >>>>> >>>>> Hi All, >>>>> >>>>> I'm new to apache cxf. I have tried out the hello world example. The >>>>> service is exposed using the JaxWsServerFactoryBean. After starting the >>>>> server I tested the services. It was working fine and tired to stop the >>>>> server using the destroy method. It didn't work out. So I tried to see the >>>>> javadoc but nothing was mentioned in those javadoc except the method >>>>> summary. The server is stopped only on stopping the vm. Can you please >>>>> help on this to find out the javadocs. -- Daniel Kulp [email protected] - http://dankulp.com/blog Talend Community Coder - http://coders.talend.com
