Các lớp con AbstractLocalStatelessSessionServiceLocator thực hiện các phương pháp mẫu đặt () để kiểm tra rằng đối tượng thực sự là một nhà EJB địa phương, và gọi một setEjbHome trừu tượng () phương pháp phải được thực hiện bởi các lớp con biết loại ứng dụng cụ thể của các nhà EJB,tạo điều kiện cho họ | public final void afterPropertiesSet throws Exception if null II throw new Exception Property jndiName must be set on getciass .getName Object o lookup jndiName I located o protected abstract void located Object o private Object lookup String jndiName throws NamingException Looking up object with jndlName jndlName This helper will close JNDI context Object o new JndiServices .lookup jndiName I Looked up objet with jndiName jndiName OK o I return o The AbstractLocalStatelessSessionServiceLocator subclass implements the located template method to check that that the object is actually an EJB local home and to invoke an abstract setEjbHome method that must be implemented by subclasses that know the application-specific type of the EJB home enabling them to obtain EJB references from it package import import import public abstract class AbstractLocalStatelessSessionServiceLocator extends AbstractJndiLocator public AbstractLocalStatelessSessionServiceLocator public AbstractLocalStatelessSessionServiceLocator String jndiName super j ndiName protected abstract void setEjbHome EJBLocalHome home protected final void located Object o if o instanceof EJBLocalHome throw new FatalBeanException Located object with JNDI name getJndiName must be an EJBLocalHome object null setEjbHome EJBLocalHome o 420 Brought to you by ownSky Infrastructure and Application Implementation It s always safe to cache a reference to a local EJB home interface. Although the EJB specification implies that it s safe to cache a remote home there is a slight chance that a cached remote home reference may become stale in some servers for example if the remote server hosting the EJB was restarted during the client s lifetime . The following UML class diagram illustrates the superclasses for both local and remote .