EJB Fundamentals 47 When you write a local (Free web hosting music)
Wednesday, October 31st, 2007EJB Fundamentals 47 When you write a local interface, you extend javax.ejb.EJBLocalObject, and when you write a local home interface, you extend javax.ejb.EJBLocalHome. Those interfaces are previewed in the following code, and are fully explained in Appendix E. public interface javax.ejb.EJBLocalObject { public javax.ejb.EJBLocalHome getEJBLocalHome() throws javax.ejb.EJBException; public Object getPrimaryKey() throws javax.ejb.EJBException; public boolean isIdentical(javax.ejb.EJBLocalObject) throws javax.ejb.EJBException; public void remove() throws javax.ejb.RemoveException, javax.ejb.EJBException; } public interface javax.ejb.EJBLocalHome { public void remove(java.lang.Object) throws javax.ejb.RemoveException, javax.ejb.EJBException; } Local interfaces have two important side effects: They only work when you re calling beans in the same process for example, if you have a bank teller session bean that calls a bank account entity bean in the same application server. But there lies the rub. You cannot call a bean remotely if your code relies on the local interface. If you decide to switch between a local or remote call, you must change your code from using the local interface to using the remote interface. This is an inherent drawback to local interfaces. They marshal parameters by reference rather than by value. While this may speed up your application because parameters are not copied, it also changes the semantics of your application. Be sure that you re aware of this when coding your clients and beans. For a while, the primary author of this book (Ed Roman) has been pushing for Sun to adopt some kind of flag that enables you to switch between local and remote access to beans without changing code. The idea is that this flag would determine whether the container-generated interceptor object would behave as a local object or remote object. We think this is the best approach because (in reality) many developers will misjudge whether to use remote or local interfaces when designing their object models, and will have to rewrite parts of their code later in their projects.
We provide special commissions and earns up to $125 us per referral for all website hosting directories. With such big commissions you should immediately sign up for our affiliate program for website hosting directory sites.