View Full Version : Scoped Beans
Mar 11th, 2010, 03:08 AM
I'm using SI and need some help concerning scoped beans.
In my application I have beans which should be created and destroyed through a specific HTTP request. Each request that contains a unique conversation id should have access to these beans.
I can't use the session scope because there are several HTTP requests in different HTTP sessions.
How can I solve this?
Thanks in advance,
Mar 11th, 2010, 03:16 AM
You can use the request scope
Mar 11th, 2010, 03:30 AM
As I undestand the request scope, the container will create a new bean for each HTTP request.
That is not what I want. I will use one bean across multiple HTTP requests from different HTTP sessions.
Mar 11th, 2010, 03:37 AM
So you need a single bean for various request /sessions? Which means you need a singleton scoped bean?
Mar 11th, 2010, 03:44 AM
I need a bean instance for each HTTP request with a specific conversation id.
So the container should create a new instance if a HTTP request contains a new conversation id.
Mar 11th, 2010, 04:08 AM
May be you can check the secttion 3.7.3 in ref doc http://static.springsource.org/spring/docs/2.5.x/reference/beans.html
Mar 16th, 2010, 01:24 AM
You could define a custom scope, but my first advice would be not to go there. Not that the api is not clean, but if you can avoid thinking about scopes you'll save yourself (and the maintenance programmers after you) a headache.
Mar 16th, 2010, 02:26 AM
the reason why I'm thinking about scopes is, that my service holds a state. The additional requirement is, that the service must handle multiple sessions (no HTTP sessions). Several HTTP clients can send requests to the service. The conversation id is part of the HTTP request. So I have to decide which request is connected with which service instance.
If I define a custom scope I don't know how to signal the end of the scope.
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.