5 Replies Latest reply on Feb 1, 2007 12:36 PM by alrubinger

    ServiceLocator pattern - delegates in the context of EJB3.0

      Hi, I am building a new J2ee app, using Jboss 4, EJb3 , JPA in general using most of the stuff of J2EE5. I am @ the stage which I want to glue efficiently my web layer (name it struts) with all this infrustructure.

      I am aware of the ServiceLocator Patterns (EJB2.0) era, though now I am having problems of mapping the service locator semantics with EJb3. The usual interfaces are not there anymore etc etc.

      Has anyone any idea (apart from an article @ the serverside ) which talks about servicelocators and a mechanism for SLSB

      the article is http://www.javalobby.org/java/forums/t61662.html

      I have also found a very relevant topic / talk on the Design EJb3 sub forum

      http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3999064

      It would be musch appreciated if anyone could point me any resource or link towards the implementations (if any) of a ServiceLocator for EJb3 SLSB

      At the moment I am just doing JNDI calls from my web layer...and its a bit lame..

      Thanks in advace


      (i am sorry if it is in the wrong topic / maybe the JNDI one? )

        • 1. Re: ServiceLocator pattern - delegates in the context of EJB
          alesj

           

          "javaneze" wrote:

          At the moment I am just doing JNDI calls from my web layer...and its a bit lame..


          Lame in what way?
          Why the need for ServiceLocator, what do you gain?

          EJB3 simplified things so much that a simple JNDI look-up of wanted EJB session bean (interface) is all you need.


          • 2. Re: ServiceLocator pattern - delegates in the context of EJB
            jc7442

            Sometime I have to use a service locator like because I am in a class that is not a EJB3.

            A small example:
            Some of my entities have a @EntityListener. Implementation of the entity listener needs to use a service provided by an EJB3 session. In the source code of the entity listener, I can not use @EJB annotations (not supported). Consequently I use a ServiceLocator to get my session bean.

            I'm not very happy with that but I have not found a better solution. In there something simpler in EJB3 ?

            • 3. Re: ServiceLocator pattern - delegates in the context of EJB

              Thank you for your replies!
              The need of service locator was to hide the multiple JNDI calles and in EJB2.x to cache the interfaces so that you would not have to 'ask' it every time you need a common used EJB reference.

              I am bit confused how we can achieve this kind of caching! or maybe is this caching necessary in EJB3 or the container now does greater magic..trying to optimize the whole thing!

              I know service locator is not rocket science my app now runs perfect with plain JNDI calls..though I come from a EJb2.x background and it used to be a heavily used pattern..

              • 4. Re: ServiceLocator pattern - delegates in the context of EJB
                jc7442
                • 5. Re: ServiceLocator pattern - delegates in the context of EJB
                  alrubinger

                   

                  "alesj" wrote:
                  Lame in what way?
                  Why the need for ServiceLocator, what do you gain?


                  Lame in the way that the EJB3 Spec allowed intracontainer injection of dependencies; why not provide the same utility to client applications? And in the process...abstract the inner plumbing of JNDI Lookups, naming exceptions, etc.

                  The JEE5 Application Clients spec doesn't quite fill these needs; doesn't provide for more than one Service Provider, no caching of SLSB and JMX Stubs, etc.

                  I'm really hoping to have some time to invest in this when things at my day job cool a bit. I'd love for a public Service Locator integrated w/ the new injection framework.

                  So will post back when I'm able to commit something of worth.

                  S,
                  ALR