On Tue, Dec 16, 2008 at 7:52 AM, Paul French <paul.fre...@kirona.com> wrote: > Hello All, > > There is support to supply a Spring managed bean as a service using the > ServiceObjectSupplier parameter in the services.xml. However is there > similar support for modules? > > For example I want to log all Soap messages into a database from a module. I > would like to obtain a fully configured module handler from Spring. Is this > possible? > > Thanks > Paul
Getting spring setup sort of "anyplace, anytime" like axis2 does is pretty simple, and you could use this ApplicationContextHolder class that comes with the distro. The only thing I'm not sure about with concerning modules is getting a handle to a Classloader reference, since you need either a servlet container or the Classloader from Axis2Service when used to integrate Axis2 services. A module though is totally different and you may not really need to integrate with axis2, just run spring inside of it. In that case, I'd try something like(not tested): public class MyModule implements Module { // initialize the module public void init(ConfigurationContext configContext, AxisModule module) throws AxisFault { ClassLoader classLoader = getClass().getClassLoader(); ClassPathXmlApplicationContext appCtx = new ClassPathXmlApplicationContext(new String[] {"applicationContext.xml"}, false); appCtx.setClassLoader(classLoader); appCtx.refresh(); } define this bean as shown in the docs: <!-- Configure spring to give a hook to axis2 without a ServletContext --> <bean id="applicationContext" class="org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder" /> Then every time you need a bean reference: ApplicationContext aCtx = ApplicationContextHolder.getContext(); MyObject = (MyObject) aCtx.getBean("myBean"); HTH, Robert