struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Gainty" <>
Subject Re: [S2] Spring: Interceptors, prototype or singleton?
Date Mon, 14 Apr 2008 15:51:27 GMT
I assume you're speaking of the capabilities of the spring-plugin?

A very good article on Spring BeanFactory scope parameters can be found
where Bean Factory scope is defined to be:
a.. Singleton: in this case, there's one shared instance of the object with
a particular name, which will be retrieved on lookup. This is the default,
and most often used, mode. It's ideal for stateless service objects.
a.. Prototype or non-singleton: in this case, each retrieval will result in
the creation of an independent object. For example, this could be used to
allow each caller to have a distinct object reference.
a.. Custom object "scopes", which typically interact with a store outside
the control of the container. Some of these come out of the box, such as
request and session (for web applications). Others come with third party
products, such as clustered caches. It is easy to define custom scopes in
the event that none of those provided out of the box is sufficient, through
implementing a simple interface.

Once you've committed to BeanFactory scope as either (shared) singleton or
(distinct object reference) prototype
there is no ability to change scope from then on

in /WEB-INF/web.xml you might have a way to determine the
applicationContext.xml file location such as what is displayed here


Simplest case for ./WEB-INF/applicationContext.xml configuration where bean
is declared as prototype (singleton="false")
<beans default-autowire="autodetect">
    <bean id="bar" class="" singleton="false"/>

The autowire property of struts.objectFactory.spring.autoWire is a bit
tricky as for Bean Dependency Injection you will
need an exact match on name, or class-type or constructor

----- Original Message -----
From: "GF" <>
To: "Struts Users ML" <>
Sent: Monday, April 14, 2008 8:51 AM
Subject: [S2] Spring: Interceptors, prototype or singleton?

> In a guide I found on the web, the interceptor was defined as singleton in
> the Spring's ApplicationContext.
> If I need to use "changeable" object properties, I need to have it as
> Prototype, otherwise different requests will result in a object property
> overwriting.
> Is there any issues about defining an interceptor as Prototype, or is it
> Thanks
> GF

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message