Service Locator Caching


EJB design: Service Locator Caching

  1. Service Locator Caching (7 messages)


    The service locator used to locate Entity Bean from Session Bean (Service Locator used in Business Logic Layer), is not supposed to cache the Home object reference, Why is it so ?


    Threaded Messages (7)

  2. Service Locator Caching[ Go to top ]

    The service locator is supposed to cache homes when used in a non clustered environment. In a clustered environment, depending on the vendor's implementation, homes might be bound to a specific server in the cluster or they might be not. Some of the distribution and failover policies might be implemented in the EJB homes. However, if your app. server and your envirnoment allows it, is a good thing to cache EJB homes.
    Best regards, Mircea
  3. Service Locator Caching[ Go to top ]

    I have my applications deployed in one container.
    The home objects accessed from Presentation tier are Cached,

    My doubt is regarding the caching of Entity Bean Homes accessed from Session Bean layer.

  4. Service Locator Caching[ Go to top ]

    In your case it seems like is ok to cache the entity beans home interfaces.
    Maybe I am missing something, could you please be more specific about your doubt ?
    Best regards, Mircea
  5. Service Locator Caching[ Go to top ]

    Hi,In your case it seems like is ok to cache the entity beans home interfaces.Maybe I am missing something, could you please be more specific about your doubt ?Best regards, Mircea

    Let me be more clear with the requirement.

    I have two Service Locators
    1) to look up and Cache Session facade/Session Bean home objects which are looked up from Presentation tier.

    2) to look up Entity bean homes from Session Bean layer

    My doubt is with the second Service locator, is it advisable to Cache home objects of Entity Beans ?
    If no, whats the reason ?

    Thanks to all
  6. Service Locator Caching[ Go to top ]

    Still it makes sense to cache the EJB Home. As Mircea said, if your application supposed to work in a clustered environment, please consult the application server documentation. For example weblogic supports cluster-aware home stubs.Check out the home-is-clusterable attribute in weblogic-ejb-jar.xml file.
  7. Need of not caching EJB Home.[ Go to top ]

    As per the J2EE 1.3 specification caching EJB home will create problem when there duplicate reference for two different objects. e.g. AccountsEJB JNDI name represented by two resources AccountEJBHome and AccountDetailsEJBHome. In this scenario AccountsEJB will refer first AccountEJBHome. This will cause runtime problems for application.
    Basically service locator is for locating Remote objects and not for caching them. But it is good idea to chache them, So prefer unique JNDI name, Or seperate Service locator per module or create the service instance as per need. Remote calls are now not expensive as per J2EE 1.3 specification.
    As well in case of BEA Weblogic server home object is set as clusterable too. You can do this by setting <home-is-clusterable>True</home-is-clusterable> in weblogic-jar.xml. Probably this is true by default - not sure. In this case the home object you are caching in the service locator is a cluster aware object - the usual routing logic and failover applies.
  8. Service Locator Caching[ Go to top ]

        I am not sure if you are talking of caching the EntityBean Home within the same Transaction. Event though if it is within the same Transaction the container Caches it and you could get the same LocalHome within the same Transaction by doing a findByprimaryKey Lookup.
        If not in the same Transaction, then Caching does not make sense.