I understand your frustration with having to create the application outside of 
Spring. One potential solution I've thought might work is to have a version of 
restlet's ServerServlet that extends Springs HttpServletBean. In the meantime, 
we've been able to get everything except the application managed by Spring by 
doing something like this:

Within your class that extends Application:

    Map<String, Finder> resourceMap = (Map<String, Finder>) springContext       
.getBean(RESOURCE_MAP);
    for (String key : resourceMap.keySet()) {
         router.attach(key, resourceMap.get(key));
    }

And in you ApplicatonContext.xml:

     <bean id="resourceMap" class="java.util.HashMap">
       <constructor-arg>
         <map>
              <entry key="/foos/{foo}"><ref bean="fooFinder"/></entry>
              <entry key="/bars/{bar}"><ref bean="barFinder"/></entry>
         </map>
        </constructor-arg>
     </bean>
 
    <bean id="fooFinder" class="org.restlet.ext.spring.SpringFinder">
        <lookup-method name="createResource" bean="fooResource"/>
    </bean>

    <bean id="barFinder" class="org.restlet.ext.spring.SpringFinder">
        <lookup-method name="createResource" bean="barResource"/>
    </bean>

    <bean id="fooResource" class="com.example.resource.FooResource" 
scope="prototype" parent="baseResourceBean" />

    <bean id="barResource" class="com.example.resource.BarResource" 
scope="prototype" parent="baseResourceBean" />


Hope that helps...

-Michael

________________________________________
From: Ryan Daum [mailto:[EMAIL PROTECTED] 
Sent: 09 March 2007 16:22
To: [email protected]
Subject: Using SpringFinder

I'm trying to use the new SpringFinder class, but I'm unsure about one thing.

I see from the example in the Javadoc for configuring the resource using 
SpringFinder, but I do not see an example about how to register the 
SpringFinder from the application.  In particular, how can the application 
"know" about my SpringFinder instance given that the RESTlet framework insists 
on creating the application; it is not injectable, since there doesn't appear 
to be a way to have Spring manage the application instance. 

Keep in mind that I cannot use the SpringContext stuff included in the 
extension package since I am using Restlet in an existing Spring application 
invoked from a WAR, and it uses the traditional WebApplicationContext stuff 
from Spring which is initialized from a servlet. 

Unfortunately it seems (hope I'm wrong) that Restlet is still vaguely competing 
with Spring and other IOC systems rather than cooperating with them.

Ryan

-- 
Ryan Daum
[EMAIL PROTECTED]
Senior Developer, Toronto
647.724.5232 x 2073 

Reply via email to