About Locator design pattern

Discussions

EJB design: About Locator design pattern

  1. About Locator design pattern (2 messages)

    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

    Threaded Messages (2)

  2. About Locator design pattern[ Go to top ]

    From Sun Java Center J2EE Patterns (link):
    <i>"The Service Locator abstracts the API lookup (naming) services, vendor dependencies, lookup complexities, and business object creation and provides a simple interface to clients. This reduces the client’s complexity. In addition, the same client or other clients can reuse the Service Locator."</i>
    <p>
    So, the amount of lookups is not the only dimension here. Using the Locator pattern, your client code is more independent of the location of the wanted resource/service/whatever.
  3. About Locator design pattern[ Go to top ]

    OOOOOh Yes!

    We can implement Locator as a Singleton, not EJB. So we needn't at least one lookup for locating Locator. It's great.

    Thanks,
    a13519