Architecture of the Smart Client Container

Author: Holger Engels

Overview

The Smart Client Container (SmartCC in short) is framework, that fills the gap between J2EE development on the server and application development on the client. It consists of a client container in the sense of the ejb spec and an ejb-ref abstraction, called Smart Refs. As shown in figure 1, an application can be seen as a directed, mostly noncyclic graph of components. The edges between the components are ejb-refs or ejb-local refs. Some components reside on the server, others on the client.

At this point, the SmartCC goes a little beyound the ejb spec. Local Session Beans can also be used on the client, albeit with some restrictions. For client side components, there's no need for authentication and authorization. Also transaction management is less usefull. However, aspects like configurability, pluggability and reuseability do still apply and make local session beans a valuable construct. The run-as identity could be used to call different remote components with different identities / credentials.

Smart References

Smart references enhance conventional ejb-refs with aspects like a pluggable transport, retrying, reconnecting, caching, tracing, profiling, etc. Even invocation bundeling, asynchronous invocation, invocation recording and replaying are possible.

A smart reference is a proxy to the target ejb. It is realized as a dynamic proxy with a generic invocation handler. The handler marshalls the invocation and forwards it to a configurable interceptor chain. Every interceptor interrogates the invocation and adds operational aspects. The last interceptor in the chain is called Transport. Its job is the delivery of the invocation to the target. A RMI transport will use reflection to invoke the methods of the remote stubs. An HTTP transport forwards the invocation to a generic connector servlet, that does the invocation on the ejb. The target returns void or an object or throws an exception. In any way, the result travels back the same way: through the transport, the interceptors, the invocation handler of the dynamic proxy and finally reaches the caller.

Smart Local References

Smart local references are the counterpart to ejb-local-refs. The transport of a local ref is plain reflection and not pluggable. However, some aspects like profiling and tracing are usefull for local references as well. Thus, there is also a dynamic proxy, a handler, that marshalles the invocation and hands it down the interceptor chain. The local transport uses reflection to call the methods on the remote and home implementation.

Local Session Beans

A local session bean consists of an implementation (the actual bean), a local- and a local home interface. The interfaces are implemented by a dynamic proxy. Calls to the local home interface lead to instantiations of new session beans. The life cycle methods are called in a manner, that gives the bean the feeling of a j2ee conform container. Calls to the local interface are forwarded to the session bean implementation. Transactions and security are not handled at all. The session bean has a local jndi context (ENC), that is populated with env-entries.

Application Client

The central component on the client is the application client. From the perspective of the container, an application client is a jar with a main-class (manifest) and a deployment descriptor that defines env-entries and references to local and remote session beans. Smart references of course ;-)

The j2ee spec 1.3 introduces a callback handler for JAAS based authentication. The configuration of the login context is read from a file auth-conf. Two startup procedures are possible:

Related Technologies and Perspectives

Some of the concepts of the SmartCC are are already planned to be included in future version of J2EE. Method interceptors for instance are already mentioned in the current Spec. JBoss is using them quite sucessfully on the serverside since the very beginning. A few month ago, we discussed about using them also on the client on the jboss development list. If you were reading the mailing list in the past, you will have noticed, that they put much effort in making the jboss core as light weight as can get. In fact, JBoss has already become an option as a container for component based clients. A few weeks ago, I implemented a rudimentary application client deployer for jboss but dropped it in favour of the SmartCC.

As mentioned above, the transport can also use the SOAP protocol. Accessing SOAP services from the client like remote session beans sounds promising to me. The SmartCC also supports you with accessing beans on different application servers in a transparent manner.