Hi Infinity,

On Oct 5, 2009, at 9:58 AM, infinity wrote:

> Looking at the code in SpringRouter.setAttachments(), it looks like  
> the
> default implementation can not handle prototype spring beans.

SpringRouter can't directly handle spring-configured resource  
instances.  You want either SpringBeanRouter or SpringRouter +  
SpringBeanFinders.

Rhett

>
> if (value instanceof Restlet) {
>        router.attach(key, (Restlet) value);
> } else if (value instanceof Class) {
>            router.attach(key, (Class<?>) value);
> } else if (value instanceof String) {
>     resourceClass = Engine.loadClass((String) value);
>
>    if (org.restlet.resource.Resource.class
>           .isAssignableFrom(resourceClass)) {
>       router.attach(key, resourceClass);
>    } else if (org.restlet.resource.ServerResource.class
>           .isAssignableFrom(resourceClass)) {
>       router.attach(key, resourceClass);
>    } else {
>       router
>               .getLogger().warning("Unknown class found in the mappings. Only 
>  
> subclasses
> of
>         org.restlet.resource.Resource and ServerResource are  
> allowed.");
>    }
> }
>
> So, I get a warning since the "value" returned here is an instance of
> ServerResource.
>
> I think this should be a bug or clearly documented as not being able  
> to
> handle spring prototype beans for BaseServer Resources unless I'm  
> missing
> something here
>
>
>
>
>
>
>
> Pritam wrote:
>>
>> I'm using Restlet spring ext to configure routers
>>
>> <bean id="virtualHost" class="org.restlet.ext.spring.SpringHost">
>>        <constructor-arg ref="component" />
>>        <property name="attachments">
>>                <map>
>>                        <entry key="/ws" value-ref="wsRouter" />
>>                </map>
>>        </property>
>> </bean>
>>
>> <bean id="wsRouter" class="org.restlet.ext.spring.SpringRouter">
>>        <property name="attachments">
>>                <map>
>>                        <entry key="/contact/{operation}"
>> value-ref="contact" />
>>                </map>
>>        </property>
>> </bean>
>>
>> <bean id="contact" class="com.xxx.ContactData" scope="prototype" />
>>
>>
>> "contact" bean is not being injected in the SpringRouter if I use a
>> value-ref for some reason. Is this because the bean is a prototype?
>> Strangely, <value-ref> works for VirtualHost where wsRouter is  
>> injected,
>> but it's a singleton bean.
>>
>> Using <value> instead works too
>>
>> <entry key="/contact/{operation}" value="com.xxx.ContactData" />
>>
>> Any suggestions?
>>
>
> -- 
> View this message in context: 
> http://n2.nabble.com/Unable-to-inject-Protoype-beans-into-a-singleton-bean-via-value-ref-for-a-Spring-Router-tp3756435p3769372.html
> Sent from the Restlet Discuss mailing list archive at Nabble.com.
>
> ------------------------------------------------------
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2403696

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

Reply via email to