Never mind.  Like an idiot I had two beans named "metadataResource".  I 
thought Spring would whine about that, but apparently not.  :-(

(There may still be an issue with SpringFinder, but not from my flawed 
analysis.)

Thanks,
Sean

On 13-11-15 01:31 PM, Sean Hogan wrote:
> Hi,
>
> I believe I may have found a bug with the way SpringFinder works in 
> Restlet 2.1.4.
>
> I have two Application subclasses, each with one Router.  Call them 
> app1 and app2, mapped in my servlet-based web app to "/app1" and 
> "/app2".  Both apps define a template "/metadata" mapped to their own 
> private Resource subclasses (Metadata1Resource and 
> Metadata2Resource).  app2 happens to be initialized after app1.
>
> I find that invoking /app_1_/metadata instantiates a 
> Metadata_2_Resource. Looking into how this happens, I believe the 
> problem is that SpringFinder is a singleton, and therefore gets 
> attached to both Routers in order of initialization.  Since app2 was 
> initialized later, it wins, and the /metadata is looked up relative to 
> that Router.
>
> The bit of Spring context for app1 looks like this:
>
>     <bean id="router1" class="org.restlet.ext.spring.SpringRouter">
>         <property name="attachments">
>             <map>
>                 <entry key="/metadata">     <!-- GET -->
>                      <bean class="org.restlet.ext.spring.SpringFinder">
>                          <lookup-method name="create" 
> bean="metadataResource" />
>                      </bean>
>                  </entry>
>                 ...
>     </bean>
>
>     <bean id="metadataResource" class="...Metadata1Resource" 
> scope="prototype" />
>
> and similarly for app2.  Both apps are loaded into the same Spring 
> context.
>
> If I'm understanding things correctly, this is a fundamental issue in 
> using SpringFinder with multiple Routers.  Can anyone give me 
> workaround?  I absolutely need my Resource instances to be created by 
> Spring so they get autowired.
>
> Thanks,
> Sean

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3068571

Reply via email to