cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Orban, Gyorgy \(IT\)" <Gyorgy.Or...@MorganStanley.com>
Subject cxf-spring integration questions
Date Thu, 09 Oct 2008 15:49:28 GMT
Hi,

I would like to ask for some guidance on using CXF together with Spring, more specifically
in terms of lifecycle management. There seems to be two ways how CXF can be integrated with
Spring:

1) It can be embedded in Spring as outlined in http://cwiki.apache.org/CXF20DOC/deploymentspring.html.
In this case, the user's application context imports the cxf spring configuration and the
CXF runtime will be in the same context as the application. For servlet environment, this
seems to be the only option.

2) CXF can start up a separate context (bus application context) for its runtime. Config example
for this can be found at  http://cwiki.apache.org/CXF20DOC/jax-ws-configuration.html (first
config, no imports).


CXF seems to have its own lifecycle manager component implemented in CXFBusLifeCycleManager,
which can control the spring context through org.apache.cxf.bus.spring.SpringBusFactory.BusApplicationContextLifeCycleListener
in case 2).

However, if a user chooses to embed cxf in the spring context (case 1) of his application
there seems to be no default mapping from some of the spring lifecycle events to the bus events.
For example, CXFBusImpl.shutdown() does not get called when spring closes the context because
it does not hook into Spring's destroy callback, which leaves servers running after the user
application context is shut down. Is there any reason why that is not done automatically?
For example, we need to do this now to get servers shut down properly:

public class CXFBusSpringLifecycleBridge implements InitializingBean, DisposableBean {
        @Resource(name = "org.apache.cxf.buslifecycle.BusLifeCycleManager")
        private org.apache.cxf.buslifecycle.BusLifeCycleManager busLifeCycleManager;

        @Resource(name = Bus.DEFAULT_BUS_ID)
        private Bus bus;
...
        @Override
        public void destroy() throws Exception {
                ((CXFBusImpl) bus).shutdown(true);
        }
}

Also, could you please advise on what would be the best way of delegating Spring's org.springframework.context.Lifecycle
start() and stop() events to cxf servers? org.apache.cxf.endpoint.Server.start() and stop()
seems to have the same semantics as Lifecycle.start() and stop(), so could CXF maybe implement
the spring Lifecycle interface directly?

Another problem around spring integration seems to be that it includes a Jsr250BeanPostProcessor
by default, which pollutes the user's config in case 1. Should that be maybe made optional
similarly to the extensions?

Thanks,
Gyorgy
--------------------------------------------------------

NOTICE: If received in error, please destroy and notify sender. Sender does not intend to
waive confidentiality or privilege. Use of this email is prohibited when received in error.

Mime
View raw message