Hello,
I have a Spring 3.1/Restlet 2.0 web application. I see that the beans for
my resources are instantiated twice per request. I suspect that this is
because an instance is created for both the root and servlet contexts, but
I can't figure out how to either merge the contexts or only instantiate the
beans only in the servlet's context.
Any help would be appreciate. I have include what I believe are the
relevant snippets below.
Thanks,
Gavin
My web.xml contains the following:
<servlet>
<servlet-name>integrationApi</servlet-name>
<servlet-class>org.restlet.ext.spring.RestletFrameworkServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>integrationApi</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
integrationApi-servlet.xml contains the following:
<!-- Scan the package for classes to inject -->
<context:component-scan base-package="com.company.api" />
<!-- Setup the main component -->
<bean id="integrationApiComponent"
class="org.restlet.ext.spring.SpringComponent">
<property name="defaultTarget" ref="integrationApiAppliction" />
</bean>
<!-- Setup the router -->
<bean id="integrationApiAppliction" name="root"
class="com.company.api.application.IntegrationApiApplication">
<property name="root" ref="router" />
</bean>
<!-- Define the router -->
<bean name="router" class="org.restlet.ext.spring.SpringBeanRouter" />
<!-- Routes and resources -->
<bean name="/v1/foo/{val}"
class="com.company.api.resource.FooResource"
scope="prototype" autowire="byName" />
<bean name="/v1/status"
class="com.company.api.resource.StatusResource"
scope="prototype" autowire="byName" />
<!-- Load the properties -->
....
<!-- Camel Endpoints -->
....
<!-- Configure the ActiveMQ component -->
....
<!-- Services -->
....
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3073613