From: Geyer, R. <Ran...@in...> - 2011-07-12 16:27:00
|
Set the spring bean scope to request or prototype depending on your deployment model. - rg -----Original Message----- From: Bill Burke [mailto:bb...@re...] Sent: Tuesday, July 12, 2011 10:46 AM To: res...@li... Subject: Re: [Resteasy-developers] Auto scan resources /providers when combining resteasy with spring Isn't there some way for Spring to make per-request instances? On 7/12/11 11:29 AM, jan...@no... wrote: > Hey cool, > > that worked. It has only one side effect: > I had a path param on class level like and referenced this via a member with the PathParam annotation > > @Path("/{version}") > public class My Resource{ > > @PathParam("version") > int version; > } > > I could use this perfectly in my called functions. This is not working anymore. I now have to define the the parameter in each function :( > But the rest is working, so this is something I can live with! > > Thanks a lot > > Jan > -----Original Message----- > From: ext Hempel, Robert [mailto:Robert.Hempel@INTER-FORUM.DE] > Sent: Dienstag, 12. Juli 2011 16:11 > To: res...@li... > Subject: Re: [Resteasy-developers] Auto scan resources /providers when combining resteasy with spring > > Hello Jan, > > whats working for me.. > > 1. Spring-Configuration: > > <context:component-scan base-package="< "/> > > (xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util") > > 2. > Annotatate the JAX-RS classes with @Component or what ever .. so they will be recognized from Spring as beans. > > According to documentation - Chapter 40. Spring Integration the BeanPostProcessor is running around an scans for JAX-RS Annotations and @Provider-Annotations. > > There is no need to set the "resteasy.scan"-Property in web.xml. > I can't see this config in your mail, but I received similar error messages from spring while trying to combine RESTEasy and Spring. > > Example: > > JAX-RS-Interface > > @Consumes( { "application/xhtml+xml", "application/json" } ) @Path( "/1.0/" ) @Produces( { "application/xhtml+xml", "application/json" } ) public interface IService { > > @GET > @Path( "/single" ) > WSLevelOneDTO getSingle(); > } > > Implementation > > @Component > public class Service implements IService { ... } > > Spring-Config: > > <?xml version="1.0" encoding="UTF-8"?> > <beans > ... > xmlns="http://www.springframework.org/schema/beans" > ... > http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd > default-autowire="byName"> > > <context:component-scan base-package="de.interforum.rest"/> > > </beans> > > Web.xml: > > <?xml version="1.0" encoding="UTF-8"?> > <web-app > xmlns="http://java.sun.com/xml/ns/j2ee" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > version="2.4" > xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> > > <display-name>${project.name}</display-name> > > <!-- Spring Context Config --> > <context-param> > <param-name>contextConfigLocation</param-name> > <param-value>classpath*:spring-config.xml</param-value> > </context-param> > > > <!-- RESTeasy --> > <context-param> > <param-name>resteasy.servlet.mapping.prefix</param-name> > <param-value>/rest</param-value> > </context-param> > > <context-param> > <param-name>resteasy.server.cache.maxsize</param-name> > <param-value>1000</param-value> > </context-param> > > <context-param> > <param-name>resteasy.server.cache.eviction.wakeup.interval</param-name> > <param-value>5000</param-value> > </context-param> > > <!-- URL Content negotiation --> > <context-param> > <param-name>resteasy.media.type.mappings</param-name> > <param-value>json : application/json, xml : application/xhtml+xml, html : application/xhtml+xml</param-value> > </context-param> > > <!-- Listener --> > <!-- RESTEasy initialisieren --> > <listener> > <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class> > </listener> > > <!-- Spring Integration --> > <listener> > <listener-class>org.jboss.resteasy.plugins.spring.SpringContextLoaderListener</listener-class> > </listener> > > <!-- REST-Servlet --> > <servlet> > <display-name>exampleServletJSR311</display-name> > <servlet-name>exampleServletJSR311</servlet-name> > <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class> > > > <load-on-startup>1</load-on-startup> > </servlet> > > <servlet-mapping> > <servlet-name>exampleServletJSR311</servlet-name> > <url-pattern>/rest/*</url-pattern> > </servlet-mapping> > </web-app> > > > > Hopefully this can help you > > Robert > > > > > > > -----Ursprüngliche Nachricht----- > Von: jan...@no... [mailto:jan...@no...] > Gesendet: Dienstag, 12. Juli 2011 15:24 > An: res...@li... > Betreff: Re: [Resteasy-developers] Auto scan resources / providerswhen combining resteasy with spring > > I'm not at the spring resources yet. It is not loading any RESTEasy Resource or Provider. > > -----Original Message----- > From: ext Bill Burke [mailto:bb...@re...] > Sent: Dienstag, 12. Juli 2011 15:22 > To: res...@li... > Subject: Re: [Resteasy-developers] Auto scan resources / providers when combining resteasy with spring > > Unfortunately, I really don't know much about Spring and its scanning facilities. Are the classes being found by spring, but just not registered into resteasy? > > On 7/12/11 5:24 AM, jan...@no... wrote: >> Hi, >> >> I'm trying to combine RESTEasy and spring resources. I followed the >> description in the RESTEasy documentation to the following web.xml: >> >> <?xml version="1.0" encoding="UTF-8"?> >> >> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" >> >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >> >> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee >> http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> >> >> <display-name>Resteasy example</display-name> >> >> <listener> >> >> <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBoot >> strap</listener-class> >> >> </listener> >> >> <listener> >> >> <listener-class>org.jboss.resteasy.plugins.spring.SpringContextLoaderL >> istener</listener-class> >> >> </listener> >> >> <servlet> >> >> <servlet-name>appServlet</servlet-name> >> >> <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDi >> spatcher</servlet-class> >> >> <load-on-startup>1</load-on-startup> >> >> </servlet> >> >> <context-param> >> >> <param-name>resteasy.servlet.mapping.prefix</param-name> >> >> <param-value>/rest</param-value> >> >> </context-param> >> >> <servlet-mapping> >> >> <servlet-name>appServlet</servlet-name> >> >> <url-pattern>/rest/*</url-pattern> >> >> </servlet-mapping> >> >> </web-app> >> >> With a minimalistic applicationContext.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:jee="http://www.springframework.org/schema/jee" >> >> xmlns:context="http://www.springframework.org/schema/context" >> >> xmlns:security="http://www.springframework.org/schema/security" >> >> xmlns:util="http://www.springframework.org/schema/util" >> >> xsi:schemaLocation=" >> >> http://www.springframework.org/schema/beans >> http://www.springframework.org/schema/beans/spring-beans-3.0.xsd >> >> http://www.springframework.org/schema/util >> http://www.springframework.org/schema/util/spring-util-3.0.xsd >> >> http://www.springframework.org/schema/jee >> http://www.springframework.org/schema/jee/spring-jee-3.0.xsd >> >> http://www.springframework.org/schema/context >> http://www.springframework.org/schema/context/spring-context-3.0.xsd >> >> http://www.springframework.org/schema/security >> >> http://www.springframework.org/schema/security/spring-security-3.0.xsd >> "> >> >> <context:annotation-config /> >> >> <context:component-scan base-package="com.nokia.journeys" /> >> >> </beans> >> >> Unfortunately neither the ResteasyBootstrap nor the >> SpringContextLoaderListener are scanning for any resource, but the >> SpringContextLoaderListener is complaining at Runtime about auto scan >> properties. >> >> How can I make my Providers and Resources make known to the resteasy? >> >> If the answer is, with instance of Application, is there any way to >> combine spring and resteasy with autoscanning - I try to avoid the >> explicit resource linking as it is resolved via library selection. >> >> Jan >> >> >> >> ---------------------------------------------------------------------- >> -------- All of the data generated in your IT infrastructure is >> seriously valuable. >> Why? It contains a definitive record of application performance, >> security threats, fraudulent activity, and more. Splunk takes this >> data and makes sense of it. IT sense. And common sense. >> http://p.sf.net/sfu/splunk-d2d-c2 >> >> >> >> _______________________________________________ >> Resteasy-developers mailing list >> Res...@li... >> https://lists.sourceforge.net/lists/listinfo/resteasy-developers > > -- > Bill Burke > JBoss, a division of Red Hat > http://bill.burkecentral.com > > > ------------------------------------------------------------------------------ > All of the data generated in your IT infrastructure is seriously valuable. > Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. > http://p.sf.net/sfu/splunk-d2d-c2 > _______________________________________________ > Resteasy-developers mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/resteasy-developers > > ------------------------------------------------------------------------------ > All of the data generated in your IT infrastructure is seriously valuable. > Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. > http://p.sf.net/sfu/splunk-d2d-c2 > _______________________________________________ > Resteasy-developers mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/resteasy-developers > > ------------------------------------------------------------------------------ > All of the data generated in your IT infrastructure is seriously valuable. > Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. > http://p.sf.net/sfu/splunk-d2d-c2 > _______________________________________________ > Resteasy-developers mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/resteasy-developers > > ------------------------------------------------------------------------------ > All of the data generated in your IT infrastructure is seriously valuable. > Why? It contains a definitive record of application performance, security > threats, fraudulent activity, and more. Splunk takes this data and makes > sense of it. IT sense. And common sense. > http://p.sf.net/sfu/splunk-d2d-c2 > _______________________________________________ > Resteasy-developers mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/resteasy-developers -- Bill Burke JBoss, a division of Red Hat http://bill.burkecentral.com ------------------------------------------------------------------------------ All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2d-c2 _______________________________________________ Resteasy-developers mailing list Res...@li... https://lists.sourceforge.net/lists/listinfo/resteasy-developers |