2 Replies Latest reply on Aug 6, 2002 2:17 PM by dsundstrom

    Locator Design Pattern

    a13519

      From book 'J2ee Design Pattern' published by Sun, there is a Locator pattern. This mechanism can be implemented by a Ejb, it cache EJBHome objects in their pool. The first time client locate a home, it lookup this home, before return it add it to its pool for later using. But, I suspect that can this improve the performance? If I don't use it, the most I using JNDI to locate EJBHome is only once, oppositely; If I use it, first I have to lookup this locator by JNDI one time, if it is exist, that's fine I return. If not, Locator have to second lookup for the one I need, there are two 'lookup'. So by this way, the system maybe perform 2 'lookup'. Anyone has same feeling?

      Regards,
      a13519

        • 1. Re: Locator Design Pattern

          If you're speaking of Service Locator pattern (and I think you are), and if I remember right, the idea was that the Service Locator would be a singleton (so at most a few copies scattered among the various classloaders), and retrieved using static methods, not JNDI. So there would be one call to JNDI per home per ServiceLocator per server start, as the Home interface stubs would be cached thereafter, potentially saving considerable time. Another option might be to do the same using purely static methods, but I haven't thought that option through to comment on it.

          • 2. Re: Locator Design Pattern
            dsundstrom

            I'd use XDoclet if I were you as it includes a locator method in the generated code.