Results 1 to 4 of 4

Thread: Notion of "singleton" attribute with EJB access

  1. #1
    Join Date
    Aug 2004
    Posts
    218

    Default Notion of "singleton" attribute with EJB access

    I've been wondering what's the best practice around using the singleton attribute on DAOs defined in the applicationContext. These DAO's are being accessing by EJBs, so I have been setting them to false.

    I've been setting it as such on the interface DAO, but not sure if I should set on the implementation DAO bean that attaches my interceptors. Here's an example:

    Code:
       
    <bean id="clmClaimDaoTarget" singleton="false"    class="com.mitchell.services.technical.claim.dao.spring.ClmClaimHibernateDao">
          <property name="sessionFactory">
             <ref local="mySessionFactory"/>
          </property>
       </bean>
    <bean id="clmClaimDao"
          class="org.springframework.aop.framework.ProxyFactoryBean">
          <property name="proxyInterfaces">
             <value>com.mitchell.services.technical.claim.dao.ClmClaimDao</value>
          </property>
          <property name="interceptorNames">
             <list>
                <value>myHibernateInterceptor</value>
                <value>clmClaimDaoTarget</value>
             </list>
          </property>
       </bean>
    Thanks,
    Lou

  2. #2
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    DAOs can almost always be singletons, and whether they are being accessed by EJBs or another client should not really affect this in a significant way. I'm confused as to why you think you need to make them singleton.

    Regards,
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

  3. #3
    Join Date
    Aug 2004
    Posts
    218

    Default

    It's not that I want to make them singletons, it's more a question of which bean I should use "singleton=false" on; the interface (the target) or the implementation or both. Right now I'm just doing it on the target. Better question might be what's the default for singleton attribute (this might be moot)?

    My reason for not having them as singletons is because of the whole EJB/singleton issue being in a distributed environment with mutliple classloaders/JVM. I don't necessarily know what server I may be on one minute to the next if they're clustered.

    Best,
    Lou

  4. #4
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    Singleton="true" is default on beans in the beanfactory, as described in the manual and DTD.

    Even if the proxy is a singleton, you're still going through the AppServer's stub on each invocation, so you will be able to handle going out to another cluster member and the like. So you can leave everything as singleton...

    Regards,
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

Similar Threads

  1. Replies: 1
    Last Post: Jul 28th, 2005, 05:08 PM
  2. Access to model
    By maveganzones in forum Web
    Replies: 6
    Last Post: Jul 8th, 2005, 01:00 PM
  3. stale Oracle processes
    By compostellas in forum Data
    Replies: 7
    Last Post: Jun 27th, 2005, 12:14 PM
  4. MBeanClientInterceptor assumes lower-case Attribute names
    By Joris Kuipers in forum Container
    Replies: 10
    Last Post: Mar 31st, 2005, 09:18 AM
  5. Replies: 2
    Last Post: Sep 5th, 2004, 10:49 AM

Posting Permissions

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