Hi, More easy way to start your ServerLifeCycleListener is using META-INF/cxf/bus-extensions.txt. Here is example: https://github.com/apache/cxf/blob/master/rt/ws/security/src/main/resources/META-INF/cxf/bus-extensions.txt https://github.com/apache/cxf/blob/master/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/CacheCleanupListener.java
Regards, Andrei. > -----Original Message----- > From: Frizz [mailto:[email protected]] > Sent: Montag, 8. Juni 2015 15:30 > To: [email protected]; [email protected] > Subject: Re: How to install a CXF ServerLifeCycleListener when app is running > in > Apache Tomcat? > > How do I access the WebApplicationContext? > > I did this in my code: > > @Resource > private WebServiceContext wsContext; > > The code gets executed when I deploy the WAR, but wsContext is null. > > > > On Sun, Jun 7, 2015 at 6:31 PM, André Costa Lima <[email protected]> > wrote: > > > Hi, > > > > You can set publish=false in jaws:endpoint. Then, through > > WebApplicationContext you can get the bean and start the endpoint yourself. > > You probably can get the Bus through the bean casting. > > > > There is probably a cleaner way of doing this. Maybe supplying the Bus > > to the endpoint in Spring xml configuration? > > > > Regards, > > > > André Costa Lima > > > > > > 2015-06-07 15:40 GMT+01:00 Frizz <[email protected]>: > > > > > I have published a Web-Service in Tomcat with cxf-servlet.xml > > > > > > <jaxws:endpoint id="myService" > > > implementor="#MyServiceImpl" address="/MyService"> > > > </jaxws:endpoint> > > > > > > So far, so god. > > > > > > Now I wanted to add a CXF ServerLifeCycleListener, but it seems this > > > has > > to > > > be done BEFORE the service is published in order to have an effect. > > > > > > How can I do this with Tomcat / Spring? > > > > > > > > > When I run my app in pure Java I do it this way: > > > > > > Bus cxfBus = BusFactory.getDefaultBus(); > > > ServerLifeCycleManager mgr = > > > cxfBus.getExtension(ServerLifeCycleManager.class); > > > mgr.registerListener(new MyListener()); > > > > > > MyServiceImpl fri = new MyServiceImpl(); > > > Endpoint ep = Endpoint.publish(" > > > http://localhost:8080/apps/MyService", > > > service); > > > > > > This works. > > > > > > - But how do I get access to the *correct* bus when deployed in Tomcat? > > > - And how can I set my ServerLicefycleListener *before* services get > > > published by the cxf-servlet.xml? > > > > >
