Java Reference
In-Depth Information
that does different things depending on the identity of the caller can call the
SecurityContextHolder
.
Security is one of the issues you must address when developing a
POJO
façade.
Another is remoting.
7.2.6
Supporting remote clients
In many applications, the business tier is invoked by a presentation tier that runs
within the same
JVM
. However, in some applications the business tier is invoked by
a client running on a different machine. For example, an application running on
a cell phone that enables a customer to order dinner on the way home would
invoke the
PlaceOrderFacade
remotely. Supporting remote clients with
EJB
s is easy
because remote invocation is built in. It even allows
EJB
s to participate in transac-
tions that are initiated by remote clients. If we want a
POJO
façade to support
remote clients, then we have to use a separate remoting technology.
Once again the Spring framework comes to the rescue. It supports several
methods of exposing a
POJO
façade to a remote client:
Standard Java
RMI
■
Hessian, an open source binary
HTTP
protocol that uses its own serializa-
tion mechanism for Java objects
■
Burlap, an open source
XML
over
HTTP
protocol that uses its own serializa-
tion mechanism for Java objects
■
Spring
HTTP
, an
HTTP
protocol provided by Spring that uses standard Java
serialization
■
Web services using the Java
API
for
XML
-based
RPC
(
JAX
-
RPC
) and Axis
■
Please note, however, that none of these technologies allows a
POJO
façade to par-
ticipate in a transaction initiated by a remote client. If that is one of your require-
ments, then you must use
EJB
s.
Spring makes it remarkably easy to expose a
POJO
façade to a remote client
using
RMI
, Hessian, Burlap, or the Spring
HTTP
invoker. You configure an
“exporter” Spring bean such as
RMIServiceExporter
, or
HessianServiceExporter
takes care of the infrastructure magic required to map requests from remote cli-
ents into calls to
POJO
façade methods. Exposing a
POJO
façade as a web service is
not quite as easy because you do need to write some code, but it is still very
straightforward. For more information on using these remoting technologies with
Spring, see the Spring documentation or
Spring in Action
[Walls 2005].
Search WWH ::
Custom Search