0 Replies Latest reply on Aug 10, 2005 8:49 AM by glyn_walters

    Service Locator pattern to recognise stale home reference

    glyn_walters

      Hi

      Just wondering if it's worth pursuing some refelection in a Service Locator to detect stale home references. Or will this code produce to much overhead on each cache lookup?

       if (cache.containsKey(jndiHomeName)) {
       home = (EJBHome) cache.get(jndiHomeName);
       // check the validity of the home reference
       try {
       Method method = home.getClass().getMethod("create", new Class[0]);
       method.invoke(home, new Object[0]);
       }
       catch (Exception ex) {
       // this failed so home reference is invalid; set the home reference to null
       home = null;
       }
       }
      


      Thanks for any advice.