Results 1 to 8 of 8

Thread: Scoped Beans

  1. #1
    Join Date
    Jun 2008
    Location
    Berlin, Germany
    Posts
    46

    Default Scoped Beans

    Hi together,

    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,
    Thomas

  2. #2
    Join Date
    Jun 2009
    Posts
    190

    Default Request scope

    You can use the request scope

  3. #3
    Join Date
    Jun 2008
    Location
    Berlin, Germany
    Posts
    46

    Default

    Hi,

    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.

    ~Thomas

  4. #4
    Join Date
    Jun 2009
    Posts
    190

    Default

    So you need a single bean for various request /sessions? Which means you need a singleton scoped bean?

    -Hetal

  5. #5
    Join Date
    Jun 2008
    Location
    Berlin, Germany
    Posts
    46

    Default

    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.

    ~Thomas

  6. #6
    Join Date
    Jun 2009
    Posts
    190

    Default

    Hi,

    May be you can check the secttion 3.7.3 in ref doc http://static.springsource.org/sprin...nce/beans.html

    -Hetal

  7. #7
    Join Date
    May 2007
    Location
    Netherlands
    Posts
    614

    Default

    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.

  8. #8
    Join Date
    Jun 2008
    Location
    Berlin, Germany
    Posts
    46

    Default

    Hi Iwein,

    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.

    ~Thomas

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •