users@jersey.java.net

[Jersey] Injecting a Spring bean into a Jersey resource

From: cgswtsu78 <cgray_at_proofpoint.com>
Date: Sat, 9 Jan 2010 18:17:24 -0800 (PST)

Hello,

I'm trying to inject a Spring bean into a jersey resource. Is this
possible? If so, can someone provide a simple example? Below is an old cxf
example implementation...I want to have my jersey resource be able to call a
java method to retrieve some application wide objects and use those in some
resource logic. Any help would be greatly appreciated!


web.xml (add below context parm and listener)
<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>

beans.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
        xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd">
        
        <bean id="testBean" class="com.proofpoint.webauth.pres.TestBean">
        </bean>

</beans>


-- 
View this message in context: http://n2.nabble.com/Injecting-a-Spring-bean-into-a-Jersey-resource-tp4279895p4279895.html
Sent from the Jersey mailing list archive at Nabble.com.