Re: Auto-Attachment of Resources to Router
Hi, You need to override Resource#init: http://www.restlet.org/documentation/1.1/api/org/restlet/resource/Resource.html#init(org.restlet.Context,%20org.restlet.data.Request,%20org.restlet.data.Response) The Finder will invoke method that after acquiring the resource instance (i.e., after retrieving the prototype bean from the spring application context). As the javadoc mentions, you need to be sure to call super.init() when you override init, otherwise the basic features of the Resource class (including getRequest()) won't work. Rhett On Jan 27, 2009, at 1:21 PM, Jean-Philippe Steinmetz wrote: > I was wondering if anyone had an answer to this question yet? I > created my own init function that is called once my Dao object is > set. Unfortunately in trying to perform a getRequest() within that > function I get a nullpointer exception thrown. There must be some > way to execute a function once the bean is fully set up? > > On Fri, Jan 23, 2009 at 12:07 PM, Jean-Philippe Steinmetz > > wrote: > Excellent that works. > > One more quick question. I noticed that I had to remove all the > original constructors for Resources that took parameters. I perform > my data look up in the constructor but since Spring hasn't injected > everything yet i'm getting null pointer exceptions. Is there an init > function or some standard method that gets called after all Spring > is finished setting things up? > > Jean-Philippe > > > On Fri, Jan 23, 2009 at 8:27 AM, Rhett Sutphin > wrote: > Hi Jean-Philippe, > > Your Application bean isn't connected to the router. Since you are > not using a custom Application, you could just remove the Application > bean and make the router the root (either by naming it "root" or by > setting the targetRestletBeanName parameter for > RestletFrameworkServlet to "router"). RestletFrameworkServlet will > automatically instantiate a default Application. > > If you do want to create your own application instance (e.g., because > you decide later that you want a custom version), you need to attach > the router as the root of the Application: > > > > > > Rhett > > On Jan 22, 2009, at 5:18 PM, Jean-Philippe Steinmetz wrote: > > > Oh I like the idea of that... i've tried setting it up but now i'm > > getting the following error: > > > > Jan 22, 2009 3:16:58 PM org.restlet.Filter doHandle > > WARNING: A filter was executed without a next Restlet attached to > it. > > > > Here is my web.xml: > > > > Web Service > > > > > > > > webservices > >> class>com.noelios.restlet.ext.spring.RestletFrameworkServlet > servlet-class> > > 1 > > > > > > > > > > webservices > > /* > > > > > > > > And here is my applicationContext > > > > http://www.springframework.org/schema/beans"; > >xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; > >xmlns:util="http://www.springframework.org/schema/util"; > >xsi:schemaLocation=" > > http://www.springframework.org/schema/beans > > http://www.springframework.org/schema/beans/spring-beans-2.5.xsd > > http://www.springframework.org/schema/util > > http://www.springframework.org/schema/util/spring-util-2.5.xsd > > "> > > > > > > > > > class="org.restlet.ext.spring.SpringBeanRouter"/> > > > > > > > scope="prototype" > > > class="com.trilogy.engine.webservice.restlets.AssetsResource"> > > > > > > > scope="prototype" > > > class="com.trilogy.engine.webservice.restlets.AssetResource"> > > > > > > > > > scope="prototype" > > > > class="com.trilogy.engine.webservice.restlets.BodyPartsResource"> > > > > > > > autowire="byName" scope="prototype" > > > > class="com.trilogy.engine.webservice.restlets.BodyPartsResource"> > > > > > > > > > > Any ideas what could be wrong? > > > > Jean-Philippe > > > > On Wed, Jan 21, 2009 at 11:13 PM, Rhett Sutphin > > wrote: > > Hi Jean-Philippe, > > > > On Jan 21, 2009, at 1:07 PM, Jean-Philippe Steinmetz wrote: > > > > > Quick question about attaching URI patterns and resource classes > to > > > the router. Is there a way to make this happen more automagically > > > with annotations or some other mechanism? Adding each one by hand > > > will get unwieldy and requires touching the main Application class > > > every time I want to add a new resource. I see there is some work > > > with this with JAX-RS but I wasn't sure if this was included in > > > restlet or not. > > > > Since you are already using Spring, you might consider using > > SpringBeanRouter: > > > > http://www.restlet.org:8080/documentation/1.1/ext/org/restlet/ext/spring/SpringBeanRouter.html > > > > It allows you to define URI templates in your application > context. It > > also allows you to do Spring DI on the resource instances. > > > > Rhett > > > > -- > > http://restlet.tigris.org/ds/viewMessage.do?
Re: Auto-Attachment of Resources to Router
I was wondering if anyone had an answer to this question yet? I created my own init function that is called once my Dao object is set. Unfortunately in trying to perform a getRequest() within that function I get a nullpointer exception thrown. There must be some way to execute a function once the bean is fully set up? On Fri, Jan 23, 2009 at 12:07 PM, Jean-Philippe Steinmetz < caskate...@gmail.com> wrote: > Excellent that works. > > One more quick question. I noticed that I had to remove all the original > constructors for Resources that took parameters. I perform my data look up > in the constructor but since Spring hasn't injected everything yet i'm > getting null pointer exceptions. Is there an init function or some standard > method that gets called after all Spring is finished setting things up? > > Jean-Philippe > > > On Fri, Jan 23, 2009 at 8:27 AM, Rhett Sutphin > wrote: > >> Hi Jean-Philippe, >> >> Your Application bean isn't connected to the router. Since you are >> not using a custom Application, you could just remove the Application >> bean and make the router the root (either by naming it "root" or by >> setting the targetRestletBeanName parameter for >> RestletFrameworkServlet to "router"). RestletFrameworkServlet will >> automatically instantiate a default Application. >> >> If you do want to create your own application instance (e.g., because >> you decide later that you want a custom version), you need to attach >> the router as the root of the Application: >> >> >> >> >> >> Rhett >> >> On Jan 22, 2009, at 5:18 PM, Jean-Philippe Steinmetz wrote: >> >> > Oh I like the idea of that... i've tried setting it up but now i'm >> > getting the following error: >> > >> > Jan 22, 2009 3:16:58 PM org.restlet.Filter doHandle >> > WARNING: A filter was executed without a next Restlet attached to it. >> > >> > Here is my web.xml: >> > >> > Web Service >> > >> > >> > >> > webservices >> > > > class>com.noelios.restlet.ext.spring.RestletFrameworkServlet> > servlet-class> >> > 1 >> > >> > >> > >> > >> > webservices >> > /* >> > >> > >> > >> > And here is my applicationContext >> > >> > http://www.springframework.org/schema/beans"; >> >xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; >> >xmlns:util="http://www.springframework.org/schema/util"; >> >xsi:schemaLocation=" >> > http://www.springframework.org/schema/beans >> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd >> > http://www.springframework.org/schema/util >> http://www.springframework.org/schema/util/spring-util-2.5.xsd >> > "> >> > >> > >> > >> > > > class="org.restlet.ext.spring.SpringBeanRouter"/> >> > >> > >> > > > scope="prototype" >> > class="com.trilogy.engine.webservice.restlets.AssetsResource"> >> > >> > >> > > > scope="prototype" >> > class="com.trilogy.engine.webservice.restlets.AssetResource"> >> > >> > >> > >> > > > scope="prototype" >> > >> > class="com.trilogy.engine.webservice.restlets.BodyPartsResource"> >> > >> > >> > > > autowire="byName" scope="prototype" >> > >> > class="com.trilogy.engine.webservice.restlets.BodyPartsResource"> >> > >> > >> > >> > >> > Any ideas what could be wrong? >> > >> > Jean-Philippe >> > >> > On Wed, Jan 21, 2009 at 11:13 PM, Rhett Sutphin < >> rh...@detailedbalance.net >> > > wrote: >> > Hi Jean-Philippe, >> > >> > On Jan 21, 2009, at 1:07 PM, Jean-Philippe Steinmetz wrote: >> > >> > > Quick question about attaching URI patterns and resource classes to >> > > the router. Is there a way to make this happen more automagically >> > > with annotations or some other mechanism? Adding each one by hand >> > > will get unwieldy and requires touching the main Application class >> > > every time I want to add a new resource. I see there is some work >> > > with this with JAX-RS but I wasn't sure if this was included in >> > > restlet or not. >> > >> > Since you are already using Spring, you might consider using >> > SpringBeanRouter: >> > >> > >> http://www.restlet.org:8080/documentation/1.1/ext/org/restlet/ext/spring/SpringBeanRouter.html >> > >> > It allows you to define URI templates in your application context. It >> > also allows you to do Spring DI on the resource instances. >> > >> > Rhett >> > >> > -- >> > >> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1042895 >> > >> >> -- >> >> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1045059 >> > > -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1059974
Re: Auto-Attachment of Resources to Router
Excellent that works. One more quick question. I noticed that I had to remove all the original constructors for Resources that took parameters. I perform my data look up in the constructor but since Spring hasn't injected everything yet i'm getting null pointer exceptions. Is there an init function or some standard method that gets called after all Spring is finished setting things up? Jean-Philippe On Fri, Jan 23, 2009 at 8:27 AM, Rhett Sutphin wrote: > Hi Jean-Philippe, > > Your Application bean isn't connected to the router. Since you are > not using a custom Application, you could just remove the Application > bean and make the router the root (either by naming it "root" or by > setting the targetRestletBeanName parameter for > RestletFrameworkServlet to "router"). RestletFrameworkServlet will > automatically instantiate a default Application. > > If you do want to create your own application instance (e.g., because > you decide later that you want a custom version), you need to attach > the router as the root of the Application: > > > > > > Rhett > > On Jan 22, 2009, at 5:18 PM, Jean-Philippe Steinmetz wrote: > > > Oh I like the idea of that... i've tried setting it up but now i'm > > getting the following error: > > > > Jan 22, 2009 3:16:58 PM org.restlet.Filter doHandle > > WARNING: A filter was executed without a next Restlet attached to it. > > > > Here is my web.xml: > > > > Web Service > > > > > > > > webservices > >> class>com.noelios.restlet.ext.spring.RestletFrameworkServlet > servlet-class> > > 1 > > > > > > > > > > webservices > > /* > > > > > > > > And here is my applicationContext > > > > http://www.springframework.org/schema/beans"; > >xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; > >xmlns:util="http://www.springframework.org/schema/util"; > >xsi:schemaLocation=" > > http://www.springframework.org/schema/beans > http://www.springframework.org/schema/beans/spring-beans-2.5.xsd > > http://www.springframework.org/schema/util > http://www.springframework.org/schema/util/spring-util-2.5.xsd > > "> > > > > > > > > > class="org.restlet.ext.spring.SpringBeanRouter"/> > > > > > > > scope="prototype" > > class="com.trilogy.engine.webservice.restlets.AssetsResource"> > > > > > > > scope="prototype" > > class="com.trilogy.engine.webservice.restlets.AssetResource"> > > > > > > > > > scope="prototype" > > > > class="com.trilogy.engine.webservice.restlets.BodyPartsResource"> > > > > > > > autowire="byName" scope="prototype" > > > > class="com.trilogy.engine.webservice.restlets.BodyPartsResource"> > > > > > > > > > > Any ideas what could be wrong? > > > > Jean-Philippe > > > > On Wed, Jan 21, 2009 at 11:13 PM, Rhett Sutphin < > rh...@detailedbalance.net > > > wrote: > > Hi Jean-Philippe, > > > > On Jan 21, 2009, at 1:07 PM, Jean-Philippe Steinmetz wrote: > > > > > Quick question about attaching URI patterns and resource classes to > > > the router. Is there a way to make this happen more automagically > > > with annotations or some other mechanism? Adding each one by hand > > > will get unwieldy and requires touching the main Application class > > > every time I want to add a new resource. I see there is some work > > > with this with JAX-RS but I wasn't sure if this was included in > > > restlet or not. > > > > Since you are already using Spring, you might consider using > > SpringBeanRouter: > > > > > http://www.restlet.org:8080/documentation/1.1/ext/org/restlet/ext/spring/SpringBeanRouter.html > > > > It allows you to define URI templates in your application context. It > > also allows you to do Spring DI on the resource instances. > > > > Rhett > > > > -- > > > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1042895 > > > > -- > > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1045059 > -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1045323
Re: Auto-Attachment of Resources to Router
Hi Jean-Philippe, Your Application bean isn't connected to the router. Since you are not using a custom Application, you could just remove the Application bean and make the router the root (either by naming it "root" or by setting the targetRestletBeanName parameter for RestletFrameworkServlet to "router"). RestletFrameworkServlet will automatically instantiate a default Application. If you do want to create your own application instance (e.g., because you decide later that you want a custom version), you need to attach the router as the root of the Application: Rhett On Jan 22, 2009, at 5:18 PM, Jean-Philippe Steinmetz wrote: > Oh I like the idea of that... i've tried setting it up but now i'm > getting the following error: > > Jan 22, 2009 3:16:58 PM org.restlet.Filter doHandle > WARNING: A filter was executed without a next Restlet attached to it. > > Here is my web.xml: > > Web Service > > > > webservices >class>com.noelios.restlet.ext.spring.RestletFrameworkServlet servlet-class> > 1 > > > > > webservices > /* > > > > And here is my applicationContext > > http://www.springframework.org/schema/beans"; >xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; >xmlns:util="http://www.springframework.org/schema/util"; >xsi:schemaLocation=" > http://www.springframework.org/schema/beans > http://www.springframework.org/schema/beans/spring-beans-2.5.xsd > http://www.springframework.org/schema/util > http://www.springframework.org/schema/util/spring-util-2.5.xsd > "> > > > > class="org.restlet.ext.spring.SpringBeanRouter"/> > > > scope="prototype" > class="com.trilogy.engine.webservice.restlets.AssetsResource"> > > > scope="prototype" > class="com.trilogy.engine.webservice.restlets.AssetResource"> > > > > scope="prototype" > > class="com.trilogy.engine.webservice.restlets.BodyPartsResource"> > > > autowire="byName" scope="prototype" > > class="com.trilogy.engine.webservice.restlets.BodyPartsResource"> > > > > > Any ideas what could be wrong? > > Jean-Philippe > > On Wed, Jan 21, 2009 at 11:13 PM, Rhett Sutphin > wrote: > Hi Jean-Philippe, > > On Jan 21, 2009, at 1:07 PM, Jean-Philippe Steinmetz wrote: > > > Quick question about attaching URI patterns and resource classes to > > the router. Is there a way to make this happen more automagically > > with annotations or some other mechanism? Adding each one by hand > > will get unwieldy and requires touching the main Application class > > every time I want to add a new resource. I see there is some work > > with this with JAX-RS but I wasn't sure if this was included in > > restlet or not. > > Since you are already using Spring, you might consider using > SpringBeanRouter: > > http://www.restlet.org:8080/documentation/1.1/ext/org/restlet/ext/spring/SpringBeanRouter.html > > It allows you to define URI templates in your application context. It > also allows you to do Spring DI on the resource instances. > > Rhett > > -- > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1042895 > -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1045059
Re: Auto-Attachment of Resources to Router
Oh I like the idea of that... i've tried setting it up but now i'm getting the following error: Jan 22, 2009 3:16:58 PM org.restlet.Filter doHandle WARNING: A filter was executed without a next Restlet attached to it. Here is my web.xml: Web Service webservices com.noelios.restlet.ext.spring.RestletFrameworkServlet 1 webservices /* And here is my applicationContext http://www.springframework.org/schema/beans"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:util="http://www.springframework.org/schema/util"; xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd";> Any ideas what could be wrong? Jean-Philippe On Wed, Jan 21, 2009 at 11:13 PM, Rhett Sutphin wrote: > Hi Jean-Philippe, > > On Jan 21, 2009, at 1:07 PM, Jean-Philippe Steinmetz wrote: > > > Quick question about attaching URI patterns and resource classes to > > the router. Is there a way to make this happen more automagically > > with annotations or some other mechanism? Adding each one by hand > > will get unwieldy and requires touching the main Application class > > every time I want to add a new resource. I see there is some work > > with this with JAX-RS but I wasn't sure if this was included in > > restlet or not. > > Since you are already using Spring, you might consider using > SpringBeanRouter: > > > http://www.restlet.org:8080/documentation/1.1/ext/org/restlet/ext/spring/SpringBeanRouter.html > > It allows you to define URI templates in your application context. It > also allows you to do Spring DI on the resource instances. > > Rhett > > -- > > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1042895 > -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1043753
Re: Auto-Attachment of Resources to Router
Hi Jean-Philippe, On Jan 21, 2009, at 1:07 PM, Jean-Philippe Steinmetz wrote: > Quick question about attaching URI patterns and resource classes to > the router. Is there a way to make this happen more automagically > with annotations or some other mechanism? Adding each one by hand > will get unwieldy and requires touching the main Application class > every time I want to add a new resource. I see there is some work > with this with JAX-RS but I wasn't sure if this was included in > restlet or not. Since you are already using Spring, you might consider using SpringBeanRouter: http://www.restlet.org:8080/documentation/1.1/ext/org/restlet/ext/spring/SpringBeanRouter.html It allows you to define URI templates in your application context. It also allows you to do Spring DI on the resource instances. Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1042895
Auto-Attachment of Resources to Router
Hello again, Quick question about attaching URI patterns and resource classes to the router. Is there a way to make this happen more automagically with annotations or some other mechanism? Adding each one by hand will get unwieldy and requires touching the main Application class every time I want to add a new resource. I see there is some work with this with JAX-RS but I wasn't sure if this was included in restlet or not. Thanks much, Jean-Philippe -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1041869