I have a rest web service. In that at webservice start i have to start few
other services. I decided to extend the
org.apache.cxf.transport.servlet.CXFServlet class and in that initiate those
services. So far i have extended the class and it's working now.

How can i inject spring bean to this extended class

my servlet

public class RestUIServlet extends CXFServlet {

   @Autowired
   private Util util; // Problem is to inject this.

   public RestUIServlet() {
        super();
       //TODO : Initialize service here
   }
}

My web.xml

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>WEB-INF/beans.xml</param-value>
</context-param>
<listener>
    <listener-class>
        org.springframework.web.context.ContextLoaderListener
    </listener-class>
</listener>
<servlet>
    <servlet-name>CXFServlet</servlet-name>
    <servlet-class>
        test.RestUIServlet
    </servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>CXFServlet</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

My beans.xml
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:spring/springContext.xml"/>
<context:property-placeholder/>
<context:annotation-config/>
<bean
class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer"/>
<bean
class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer"/>

<jaxrs:server id="services" address="/">
    <jaxrs:serviceBeans>
        <ref bean="uiServiceImpl"/>
    </jaxrs:serviceBeans>
    <jaxrs:providers>
        <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>
    </jaxrs:providers>
</jaxrs:server>

<bean id="uiServiceImpl" class="test.UIServiceImpl"/>

I'm using cxf 3.0.0



--
View this message in context: 
http://cxf.547215.n5.nabble.com/How-to-inject-spring-bean-to-CXFServlet-extented-class-tp5752665.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to