Java Reference
In-Depth Information
command interface, and a consistent place for the cache implementation in
the execute method. With this approach, we can automate cached command
generation with some careful thought and planning.
A cache between the facade and the controller
A second possibility is to design the facade to return atomic objects and collec-
tions that are easily cacheable, and then add appropriate hash and key fields to
the returned objects. This approach is manual, but it can result in clear, ele-
gant interfaces.
A distributed command
The Command pattern is very well suited to a distributed architecture. IBM
has some of the best practical guides and papers on this topic. One book that
has outstanding ideas for general architecture, although presented in a Web-
Sphere context, is called Design and Implement Servlets, JSP s, and EJB s for Web-
Sphere . Distributed commands give us a smaller, tighter footprint than a session
bean, less overhead per communication, and integrated keys and attachment
points for a cache. The downside is that this approach will probably mandate a
proprietary implementation, though some promising work—such as the action
objects of the Jakarta Struts framework—is moving the ball forward.
The key to success with EJB s is not to get lazy and expect the frameworks
to guess our intentions and optimize for us. We can choose a number of suc-
cessful approaches, and should not lose sight of the impact of a cache as a first
line of defense for a distributed interface.
8.7
Smoothing out the bitter beans
In this chapter, we've reviewed the basics of EJB s. They are implemented as
components that go into a container, which provides such important services
as support for transactions, persistence, and security. The EJB architecture is
distributed and uses the stub-based approach, similar to CORBA . You learned
that there are two major classifications: session beans and entity beans. Session
beans come in stateless and stateful varieties, and entity beans have persistence
that is managed either by the container or the bean itself.
Of the antipatterns that we examined, the worst was Round-tripping. We
looked at an example that showed how complex object relationships can have
a multiplier effect that can bring system performance to its knees. We did
reveal a silver bullet that can kill this beast: the facade. We can wrap a chatty
Search WWH ::




Custom Search