Issue Details (XML | Word | Printable)

Key: INT-852
Type: Bug Bug
Status: Open Open
Priority: Blocker Blocker
Assignee: Mark Fisher
Reporter: shanti sharma
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Spring Integration

Prototype Bean with Spring integration

Created: 19/Oct/09 01:41 AM   Updated: 29/Dec/09 04:10 PM
Component/s: Core
Affects Version/s: 1.0.3
Fix Version/s: None

Time Tracking:
Not Specified

Environment: Spring 2.5 , Spring Integration 1.0.3.RELEASE , WebSphere


 Description  « Hide

Spring Integration is not respecting scope="prototype" setting when specified in annotation/XML configuration.

We have a requirement to initialize Prototype bean , when the flow is triggered by SI. SI is always creating a singleton bean.

Please provide us solution/workarounds for this.



Grzegorz Grzybek added a comment - 04/Nov/09 01:18 AM

Hello

Can you please describe what is the kind of bean you want to be a prototype? Is this some Spring-Integration specific bean (channel, transformer, selector) or some business component (e.g. ServiceActivator)?

Your scenario may be implemented using some FactoryBean, which produces new objects in it's getObject() method.

Regards
Grzegorz Grzybek


Grzegorz Grzybek added a comment - 29/Dec/09 12:54 AM

Hello! Anyone still interested in this issue? If so, please give some more information!


shanti sharma added a comment - 29/Dec/09 02:42 PM

Here is some detail -

We have a channel, which receives a request from JMS queue and transfers control to a Business service (NOT SI component).
Our requirement was to have the Business service as "prototype" bean, Which is not honored by Spring Integration, everything in spring integration is initialized as singleton ( as far as we observed).
(We can use a lookup method to resolve this issue, but with lookup method required CGI-lib whereas we are using javaassit)


Mark Fisher added a comment - 29/Dec/09 04:10 PM

Can you provide a configuration excerpt?

When you use a "ref" from a Spring Integration component (e.g. service-activator), that reference may be to a prototype bean. It's just like any other bean reference. However, as with any other bean reference the injection happens only once. This is the way "prototype" scope works in Spring generally. What it does mean is that any other "ref" would hold a distinct instance.

When you say that you want to instantiate the bean "when the flow is triggered", I believe you might be looking for something more like a custom scope? i.e. a "flow" scope that would act similar to a "request" scope in a web application. Is that the case?

If so, then the next question would be why do you need that scope? I assume that you have something stateful, whereas the main idea in Spring Integration is to keep all state in the Message (payload and headers) while using stateless services.

Can you please provide some information about the stateful requirements of your services?

Thanks,
Mark