One of the EJB programming restrictions is that EJB should not use Java Reflection API. Because of this, you got getEJBMetaData method in the remote home interface to interrogate the bean and know about it.
But in local home interface getEJBMetaData method does not exist. As per HFEJB on page 148, you can use java reflection to learn about the bean in case of local objects.
Whether it is a local or remote object, it is EJB only. Why can't the EJB programming restriction of "Reflection API should not be used" apply to the local objects?
It is impossible to use the Reflection API on an object that is 'remote'. To use reflection, we should be able to instantiate a class, using Class.forName(...), and only then we can query information about the class. An EJB that has remote interface may reside on a separate JVM or even physically different machine. It is not (yet) possible to instance an class in a different JVM using Java Reflection API.
It is not that Reflection should not be used on EJBs, but, Reflection cannot be used on remote EJBs/Objects. Its a limitation of the Reflection API.
With the Remote clients,you are actually working on the stub, not with the real object.If you use the reflection API for remote clients then you are interrogating the stub not the real object(EJB instance).So you need to use an EJBMetaData object to interrogate about the remote object.
With local clients both the client and EJB instance are in the same heap, so you will be actually working with EJBInstance not with 'remote object'. Hence the need of an EJBMetaData object is not required.Hope this clarifies you.Letme know if you need further clarification.Cheers...
Amateurs built google. Professionals built the titanic. We can't find the guy that built this tiny ad: