Nov 3rd, 2005, 02:25 AM
Automatic remoting of POJOs as EJB Beans & implicit context passing
I am looking for some feedback for a spring remoting extension published on sourceforge.
It can in addition generate EJB session bean fašades to delegate work to POJOs (Spring recommends this pattern but requires to do this by hand). We generate a XDoclet-annotated EJB bean and generate the other EJB artefacts with XDoclet. In case the interface is not RMI compliant (RemoteExceptions), we adapt it accordingly. The user can keep working with his interface of the POJO.
A second feature we added is that we can (optionally) provide implicit context passing when making remote calls: this allows adding additional technical information with each remote invocation.
What is the interest of this? One could e.g. add the security principal with all requests, add an ID to indicate on behalf of what company one executes a transaction, or add other client-context with the call.
And contrary to many other approaches for this, you still keep a clean Java interface: no need to tunnel your request through a
It's easy to implement implicit context passing if the used communication protocol supports it: one can simply add the implicit context to the remote
invocations. However, in the Java context, many protocols do not directly support implicit context passing (RMI, EJB or RMI-IIOP do not support it).
Our solution is to add the implicit context in the form of a Map as the
last argument of each method. Behind the existing interface, we add transparently a shadow interface that has the additional parameter added.
(We do this in a generic way, the generation of the shadow interface could also be used differently.) The adding of this interface is normally hidden during runtime. It uses a mechanism similar to what is done in CGLIB and it could even be made during build time to avoid concerns with interfaces generated during runtime.
More documentation can be found in the reference documentation under http://el4j.sourceforge.net/documentation.htm .
How does that sound for you?