Commit 30b0516f authored by Andrea Aime's avatar Andrea Aime
Browse files

[GEOS-4179] Importer and monitoring REST resources are not thread-safe

parent 8d3fd5ff
......@@ -6,49 +6,49 @@
<!--
rest bindings
-->
<bean id="importResource" class="org.geoserver.importer.rest.ImportResource">
<bean id="importResource" class="org.geoserver.importer.rest.ImportResource" singleton="false">
<constructor-arg ref="importer"/>
</bean>
<bean id="importContextFinder" class="org.geoserver.rest.BeanResourceFinder">
<constructor-arg value="importResource"/>
</bean>
<bean id="importTaskResource" class="org.geoserver.importer.rest.TaskResource">
<bean id="importTaskResource" class="org.geoserver.importer.rest.TaskResource" singleton="false">
<constructor-arg ref="importer"/>
</bean>
<bean id="importTaskFinder" class="org.geoserver.rest.BeanResourceFinder">
<constructor-arg value="importTaskResource"/>
</bean>
<bean id="taskTargetResource" class="org.geoserver.importer.rest.TaskTargetResource">
<bean id="taskTargetResource" class="org.geoserver.importer.rest.TaskTargetResource" singleton="false">
<constructor-arg ref="importer"/>
</bean>
<bean id="taskTargetFinder" class="org.geoserver.rest.BeanResourceFinder">
<constructor-arg value="taskTargetResource"/>
</bean>
<bean id="layerResource" class="org.geoserver.importer.rest.LayerResource">
<bean id="layerResource" class="org.geoserver.importer.rest.LayerResource" singleton="false">
<constructor-arg ref="importer"/>
</bean>
<bean id="layerFinder" class="org.geoserver.rest.BeanResourceFinder">
<constructor-arg value="layerResource"/>
</bean>
<bean id="importDataResource" class="org.geoserver.importer.rest.DataResource">
<bean id="importDataResource" class="org.geoserver.importer.rest.DataResource" singleton="false">
<constructor-arg ref="importer"/>
</bean>
<bean id="importDataFinder" class="org.geoserver.rest.BeanResourceFinder">
<constructor-arg value="importDataResource"/>
</bean>
<bean id="dirResource" class="org.geoserver.importer.rest.DirectoryResource">
<bean id="dirResource" class="org.geoserver.importer.rest.DirectoryResource" singleton="false">
<constructor-arg ref="importer"/>
</bean>
<bean id="dirFinder" class="org.geoserver.rest.BeanResourceFinder">
<constructor-arg value="dirResource"/>
</bean>
<bean id="txResource" class="org.geoserver.importer.rest.TransformResource">
<bean id="txResource" class="org.geoserver.importer.rest.TransformResource" singleton="false">
<constructor-arg ref="importer"/>
</bean>
<bean id="txFinder" class="org.geoserver.rest.BeanResourceFinder">
......
......@@ -34,14 +34,14 @@
</bean>
<!-- rest bindings -->
<bean id="requestResource" class="org.geoserver.monitor.rest.RequestResource">
<bean id="requestResource" class="org.geoserver.monitor.rest.RequestResource" scope="prototype">
<constructor-arg ref="monitor"/>
</bean>
<bean id="requestResourceFinder" class="org.geoserver.rest.BeanResourceFinder">
<constructor-arg value="requestResource"/>
</bean>
<bean id="owsRequestResource" class="org.geoserver.monitor.rest.OwsRequestResource">
<bean id="owsRequestResource" class="org.geoserver.monitor.rest.OwsRequestResource" scope="prototype">
<constructor-arg ref="monitor"/>
</bean>
<bean id="owsRequestResourceFinder" class="org.geoserver.rest.BeanResourceFinder">
......
/* (c) 2014 Open Source Geospatial Foundation - all rights reserved
/* (c) 2014 - 2015 Open Source Geospatial Foundation - all rights reserved
* (c) 2001 - 2013 OpenPlans
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
......@@ -18,13 +18,18 @@ import org.springframework.context.ApplicationContextAware;
* <p>
* The following shows an example of using this class in a spring context:
* <pre>
* <bean id="myResource" class="org.acme.MyResource"/>
* <bean id="myResource" class="org.acme.MyResource" scope="prototype" />
*
* <bean id="myBeanResourceFinder" class="org.geoserver.rest.BeanResourceFinder">
* <constructor-arg ref="myResource"/>
* </bean>
* </pre>
* </p>
* <p>The creation scope of the bean must be "prototype", at each lookup the resource
* will be provided the request and response via its {@link Resource#init(org.restlet.Context, Request, Response)}
* method, making it hold those values in the object fields: a singleton won't thus
* be thread safe
* </p>
*
* @author David Winslow, OpenGEO
* @author Justin Deoliveira, OpenGEO
......@@ -69,7 +74,7 @@ public class BeanResourceFinder extends Finder implements ApplicationContextAwar
public String getBeanToFind(){
return beanName;
}
public Resource findTarget(Request request, Response response){
Resource res = (Resource) applicationContext.getBean(getBeanToFind());
res.init(getContext(), request, response);
......
......@@ -8,8 +8,8 @@
<beans>
<bean id="exceptionThrowingResource" class="org.geoserver.rest.ExceptionThrowingResource"/>
<bean id="gsUserResource" class="org.geoserver.rest.GsUserResource"/>
<bean id="exceptionThrowingResource" class="org.geoserver.rest.ExceptionThrowingResource" singleton="false"/>
<bean id="gsUserResource" class="org.geoserver.rest.GsUserResource" singleton="false"/>
<bean id="testMapping" class="org.geoserver.rest.RESTMapping">
<property name="routes">
<map>
......
......@@ -545,7 +545,7 @@
<constructor-arg index="1" value="true"/> <!-- force reset instead of reload -->
</bean>
<bean id="fontFinder" class="org.geoserver.rest.FontListResource"/>
<bean id="fontFinder" class="org.geoserver.rest.FontListResource" singleton="false"/>
<bean id="catalogLocker" class="org.geoserver.rest.RestConfigurationLockCallback">
<constructor-arg index="0" ref="configurationLock"/>
......
......@@ -48,13 +48,13 @@
</property>
</bean>
<bean id="masterPasswordResource" class="org.geoserver.security.rest.MasterPasswordResource">
<bean id="masterPasswordResource" class="org.geoserver.security.rest.MasterPasswordResource" singleton="false">
</bean>
<bean id="dataAccessControlResource" class="org.geoserver.security.rest.DataAccessControlResource"/>
<bean id="restAccessControlResource" class="org.geoserver.security.rest.RESTAccessControlResource"/>
<bean id="serviceAccessControlResource" class="org.geoserver.security.rest.ServiceAccessControlResource"/>
<bean id="catalogModeResource" class="org.geoserver.security.rest.CatalogModeResource"/>
<bean id="dataAccessControlResource" class="org.geoserver.security.rest.DataAccessControlResource" singleton="false"/>
<bean id="restAccessControlResource" class="org.geoserver.security.rest.RESTAccessControlResource" singleton="false"/>
<bean id="serviceAccessControlResource" class="org.geoserver.security.rest.ServiceAccessControlResource" singleton="false"/>
<bean id="catalogModeResource" class="org.geoserver.security.rest.CatalogModeResource" singleton="false"/>
</beans>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment