Hi Ryan,

I thought about this but didn't want to put such a specific class into the
Restlet API itself. For now, Spring is the only IOC that we explicitly
support. If this changes in the future, we could always create a new
"org.restlet.ext.ioc" extension. For now, it's a bit overkill IMO. But I see
you point. Let's keep this in mind for 1.1 or 2.0

Best regards,
Jerome  

> -----Message d'origine-----
> De : Ryan Daum [mailto:[EMAIL PROTECTED] 
> Envoyé : lundi 26 février 2007 15:09
> À : [email protected]
> Objet : Re: Spring context and Resource
> 
> Just a suggestion, there should be no reason for the solution 
> 2 to be Spring-specific and packaged as such; it could easily 
> sit in the base package and be called 'IOCFinder' or 
> 'ExternallyConfigurableFinder' (or whatever) and be used by 
> any number of dependency injection systems, not just Spring. 
> 
> Ryan
> 
> 
> On 2/26/07, Jerome Louvel < [EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]> > wrote:
> 
> 
>       Hi all,
>       
>       Thanks for the discussion. I've added a SpringFinder 
> class into the Spring
>       extension package with the
>       Javadocs based on solution 2.
>       
>       Best regards,
>       Jerome
>       
>       > -----Message d'origine----- 
>       > De : Jonathan Hall [mailto:[EMAIL PROTECTED]
>       > Envoyé : samedi 24 février 2007 16:10
>       > À : [email protected] 
>       > Objet : Re: Spring context and Resource
>       >
>       > Thankyou Valdis, I went with option 2 which works great.
>       >
>       > Jonathan
>       >
>       >
>       > Valdis Rigdon wrote:
>       > > I've found 2 approaches that work, and there are 
> possibly more. 
>       > >
>       > > 1.  Use @Configurable on your Resource classes, and use
>       > Spring AOP to
>       > > inject dependencies.  Search the message archives for more
>       > details on
>       > > this.
>       > > 
>       > > 2.  If you don't like having the dependency on AspectJ, you
>       > can extend
>       > > org.restlet.Finder and override createResource(Request,
>       > Response) to
>       > > delegate to a no-arg createResource() method (but 
> be sure to call 
>       > > init() on it after it's created).  Then create a singleton
>       > Spring bean
>       > > based on that Finder,  and configure it using 
> "lookup-method" to
>       > > return instances of a "prototype" bean for 
>       > createResource().  Finally,
>       > > attach the Finder to your Router.  When the
>       > createResource() method is
>       > > invoked, a new instance of your prototype bean will 
> be created and
>       > > returned. 
>       > >
>       > >
>       > > A sample xml for "lookup-method":
>       > >
>       > > <bean id="myRestlet" 
> class="com.mycompany.rest.SpringFinder">
>       > >        <lookup-method name="createResource" 
> bean="myResource"/> 
>       > > </bean>
>       > > <bean id="myResource"
>       > class="com.mycompany.rest.resource.MyResource"
>       > > scope="prototype">
>       > >    <property name="aProperty" value="anotherOne"/> 
>       > >    <property name="oneMore" value="true"/>
>       > > </bean>
>       > >
>       > >
>       > > Perhaps org.restlet.Finder could be reworked so this worked
>       > out of the 
>       > > box, instead of having to have a custom Finder object.
>       > >
>       > >
>       > > Valdis
>       > >
>       > >
>       > > Jonathan Hall wrote:
>       > >> Hi,
>       > >>
>       > >> Following the wiki examples, I integrated Spring and 
>       > Restlet by using an
>       > >> extended Restlet bean and handle(Request request, Response
>       > response).
>       > >> However, it seems I would want to extend Resource instead,
>       > as it has all 
>       > >> the gubbins for get/post/put/etc. The problem is the
>       > router accepts a
>       > >> class and not an object; so I can't use Spring to inject
>       > other beans
>       > >> into my extended class. 
>       > >>
>       > >> The following options occur to me:
>       > >> modify Router to accept instances,
>       > >> recreate the spring context on every call in the Resource,
>       > >> stash the springcontext in the restlet context. 
>       > >>
>       > >> Have I missed something that would solve this problem, or
>       > misunderstood
>       > >> the framework? If not, then would it be possible to add
>       > something to
>       > >> help with this in future releases? 
>       > >>
>       > >> Thanks for all the great work, I'm enjoying learning this
>       > framework.
>       > >>
>       > >> Best Regards,
>       > >> Jonathan
>       > >>
>       > >> 
>       > >
>       
> 
> 
> 

Reply via email to