Re: Axis2 module + Spring
On Tue, Dec 16, 2008 at 1:08 PM, Paul French wrote: > Thanks for the reply. > > Its not what I am after though. We have AXIS2 as part of our web > application. We have web services which are defined as beans in the Spring > application context loaded as part of the web application. > > We also want our modules defined as beans from the same application context. > For example our logging module requires a datasource. This datasource is > already defined in Spring for the web application. I suppose I am trying to > avoid having to setup things twice in 2 different places. > Well that's why I mentioned the Classloader reference issue, in case you needed it, and you do. IIRC both Modules and AAR's have their own classloader. Axis2Service is used to supply the Classloader reference in the AAR case. I'm not sure how to get the equivalent in Module.init() as I see no examples in the source, or even if you did it'd work correctly with the Classloader stuff in AbstractMessageReceiver. Maybe someone like Deepal can comment further. - R
RE: Axis2 module + Spring
Thanks for the reply. Its not what I am after though. We have AXIS2 as part of our web application. We have web services which are defined as beans in the Spring application context loaded as part of the web application. We also want our modules defined as beans from the same application context. For example our logging module requires a datasource. This datasource is already defined in Spring for the web application. I suppose I am trying to avoid having to setup things twice in 2 different places. Thanks Paul -Original Message- From: robert lazarski [mailto:robertlazar...@gmail.com] Sent: 16 December 2008 13:37 To: axis-user@ws.apache.org Subject: Re: Axis2 module + Spring On Tue, Dec 16, 2008 at 7:52 AM, Paul French 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: Then every time you need a bean reference: ApplicationContext aCtx = ApplicationContextHolder.getContext(); MyObject = (MyObject) aCtx.getBean("myBean"); HTH, Robert __ NOD32 3695 (20081216) Information __ This message was checked by NOD32 antivirus system. http://www.eset.com
Re: Axis2 module + Spring
On Tue, Dec 16, 2008 at 7:52 AM, Paul French 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: Then every time you need a bean reference: ApplicationContext aCtx = ApplicationContextHolder.getContext(); MyObject = (MyObject) aCtx.getBean("myBean"); HTH, Robert
Axis2 module + Spring
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