Results 1 to 5 of 5

Thread: Service Object, Two Clients, Singleton

  1. #1
    Join Date
    May 2006
    Posts
    3

    Default Service Object, Two Clients, Singleton

    Hello,

    I am trying to find the best way to instantiate a service object once as a singleton and have it used by two consumers - a web app and a web services soapbindingimpl class.

    Any recommendations?

    Thanks,

    Jim M.

  2. #2
    Join Date
    Nov 2004
    Location
    Hilversum - The Netherlands
    Posts
    1,054

    Default

    In Spring beans a singleton by default, so in your case the following would do the trick:

    Code:
    <bean id="someService" class="SomeService"/>
    
    <bean id="someController" class="SomeController">
       <property name="someService" ref="someService"/>
    </bean>
    
    <bean id="someSoapThingy" class="SomeSoapThingy">
       <property name="someService" ref="someService"/>
    </bean>

  3. #3
    Join Date
    May 2006
    Posts
    3

    Default

    I understand that. However, In this case, I would need to load the BeanFactory in two places because of the two consumers call my transactional boundary. If I load the BeanFactory in two places would there not be two instances?

  4. #4
    Join Date
    Nov 2004
    Location
    Hilversum - The Netherlands
    Posts
    1,054

    Default

    Quote Originally Posted by jimmatts
    I understand that. However, In this case, I would need to load the BeanFactory in two places because of the two consumers call my transactional boundary.
    Aha ok. I don't think you should load the container twice. If you load the container with the ContextLoaderListener you can access it from the ServletContext.

    And you should not worry about concurrent access to that service: that is what the I from ACID stands for: Isolation
    Last edited by Alarmnummer; May 26th, 2006 at 06:08 AM.

  5. #5
    Join Date
    May 2006
    Posts
    3

    Default

    I don't think the generated Axis code for SoapBindingImpl class has access to the servletContext does it?

Posting Permissions

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