5 Replies Latest reply on Oct 9, 2009 3:03 AM by vickyk

    datasource and singleton

    greiff

      simple question:

      to avoid expensive JNDI lookups to datasource is it possible to use the singleton pattern for datasources ?

      Torsten

        • 1. Re: datasource and singleton

          Yes, the DataSource is a factory. Singleton caching works with any factory that has
          been coded correctly (i.e. it is thread safe).

          In fact, the JBossCMP engine does this.

          • 2. Re: datasource and singleton
            greiff

            thanks for your quick reply adrion
            it's a helpful information

            Torsten

            • 3. Re: datasource and singleton
              henk53

               

              "greiff" wrote:

              to avoid expensive JNDI lookups to datasource is it possible to use the singleton pattern for datasources ?


              Just wondering, are JNDI lookups really that expensive? When looking up an EJB (either programmatic, or via injection), isn't there a JNDI lookup happening all the time?

              • 4. Re: datasource and singleton
                henk53

                Anyone?

                • 5. Re: datasource and singleton
                  vickyk

                   

                  "henk53" wrote:

                  Just wondering, are JNDI lookups really that expensive? When looking up an EJB (either programmatic, or via injection), isn't there a JNDI lookup happening all the time?

                  Yes, but you need to understand that there is a trade-off between the efficiency and flexibility(loosely coupling).
                  You should be talking at EJB forums for the EJB details, you can get more help there.