Announcement Announcement Module
Collapse
No announcement yet.
Service Object, Two Clients, Singleton Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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>

    Comment


    • #3
      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?

      Comment


      • #4
        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, 07:08 AM.

        Comment


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

          Comment

          Working...
          X