You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Tapdur <ta...@gmail.com> on 2009/05/01 15:32:05 UTC

get a Spring Bean from CXF, how to ?

Hi,

i implement a webservice based on CXF and i want to select the business bean
based on ws parameters.

So i just want to use a code like that on the server side


@webservice
public String GetLabel(String lang) {

     ILabel label = x.getBean(lang);

     return label.getLabel();
     
}

So my question is how to lookup Spring context from CXF and use the Spring
bean API at runtime ?
(how to lookup the Servlet Context too from CXF ?)


Thanks
Bruno

-- 
View this message in context: http://www.nabble.com/get-a-Spring-Bean-from-CXF%2C-how-to---tp23333153p23333153.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: get a Spring Bean from CXF, how to ?

Posted by bruno tapdur <ta...@gmail.com>.
thx , i use ApplicationContextAware and it works like a charm

Bruno

2009/5/1 Ian Roberts <i....@dcs.shef.ac.uk>

> Tapdur wrote:
> > So my question is how to lookup Spring context from CXF and use the
> Spring
> > bean API at runtime ?
> > (how to lookup the Servlet Context too from CXF ?)
>
> Configure your implementation object as a Spring bean itself, i.e.
> instead of <jaxws:endpoint implementor="my.pkg.ServiceImpl"/> do
>
> <bean id="myServiceImpl" class="my.pkg.ServiceImpl" />
> <jaxws:endpoint implementor="#myServiceImpl" ... />
>
> Now your service object is a Spring bean it can implement
> Spring-provided interfaces such as ApplicationContextAware or
> ServletContextAware in the usual way and the things you want will be
> injected automatically.
>
> Ian
>
> --
> Ian Roberts               | Department of Computer Science
> i.roberts@dcs.shef.ac.uk  | University of Sheffield, UK
>

Re: get a Spring Bean from CXF, how to ?

Posted by Ian Roberts <i....@dcs.shef.ac.uk>.
Tapdur wrote:
> So my question is how to lookup Spring context from CXF and use the Spring
> bean API at runtime ?
> (how to lookup the Servlet Context too from CXF ?)

Configure your implementation object as a Spring bean itself, i.e.
instead of <jaxws:endpoint implementor="my.pkg.ServiceImpl"/> do

<bean id="myServiceImpl" class="my.pkg.ServiceImpl" />
<jaxws:endpoint implementor="#myServiceImpl" ... />

Now your service object is a Spring bean it can implement
Spring-provided interfaces such as ApplicationContextAware or
ServletContextAware in the usual way and the things you want will be
injected automatically.

Ian

-- 
Ian Roberts               | Department of Computer Science
i.roberts@dcs.shef.ac.uk  | University of Sheffield, UK