Introducing Barracuda:
A Presentation Framework
for XMLC and EAS
By David H. Young, Lutris Technologies
Despite its appearance as a "point release," Lutris EAS 4.1
is introducing some exciting new technology, including the Web Services
command "ws" and, of particuar note to presentation developers,
Barracuda, the open source presentation framework from enhydra.org. There
are two Barracuda applications incorporated with EAS. Be sure to deploy
them for a comprehensive explanation of how Barracuda works. The documentation
and example applications incorporated in barracudaTutor.war is impresssive,
and a real testament to Barracuda creator and former Lutris employee,
Christian Cryder.
lutris-eas4.1/earlyAccess/barracuda/barracudaTutor.war
lutris-eas4.1/components/webApps/discRackBarracuda.war
As demonstrated by its incorporation into EAS 4.1, Lutris is very much
behind Barracuda and its basis in the XMLC focus of delivering dynamic
content by DOM manipulation. This article attempts to explain what Barracuda
is, what role it assumes in Web application development, how it relates
to XMLC and how it relates to its direct competitor, Struts.
Presentation Technologies: JSP and XMLC
Enhydra XMLC is a presentation technology. So is JSP. Both
are supported by Lutris EAS 4.1. Both employ different strategies for
generating HTML dynamically, such as a table of rows with customer addresses.
JSP: A "Pull" Strategy
JSP uses a "pull" strategy. Java scriplets and JSP taglibs are introduced
into an HTML file ("page"). The file is compiled into a Java class.
The "pull" refers to the fact that Java code inside the page "pulls" new
content into the page by, for example, accessing a java bean representing
some business logic.
XMLC: A "Push" Strategy
XMLC uses a "push" strategy. An HTML document is compiled into a java
class by the XMLC compiler. It is captured as a Java class representing
a hierarchical tree that can be accessed according to a W3C specification
known as the Document Object Model (DOM). The"push" refers to the fact
that Java code in servlets "pushes" new content into the DOM, which is
later converted by XMLC methods back to HTML, then streamed back to the
client.
The Debate
There are plenty of reasons why we believe xmlc and the push strategy
is way better than the JSP strategy. They include:
- No matter what, java code and html never meet. The implication
is:
- it's easier for HTML designers to restructure or update presentations
- java developer's can't become control freaks and start shoving
java inside the html
- it's much easier to maintain and rework web presentations using
xmlc
- It's easier to build language-independent presentations (e.g., french,
english...)
- XMLC guarantees that the updated dom will generate well-formed html
or xml. jsp cannot guarantee the same.
- to approximate the value above of xmlc, a software architect must
make heavy use of additional capabilities that have been added to JSP
(to stop the bleeding), such as JSP taglibs. BUT, the fact is
that they can never enforce the use of these capabilities because engineers
will often take shortcuts to get their jobs done. And even if
they do follow these guidelines, it's still not a pure separation of
Java and mark-up.
And now about Barracuda
Barracuda is a presentation framework. So is something called
"Struts" from Apache.org. Both are submissions to the Sun JSR-127,
"Java Faces." Barracuda does for XMLC what Struts does for JSP
Presentation Frameworks
A presentation framework standardizes the standard needs of Web presentation
development.
- Client type detection ("what kind of device is making this request?
NS, IE, Nokia, J2ME? What is the client's perferred spoken language?)
- Localization - mechanism for displaying page in preferred language.
- Form Valiation - process of ensuring the client filled out the form
according to some set of rules
- Event Handling - mechanism for routing the push of a particular button
to any server-side code that wants to deal with that event.
Presentation technologies, such as XMLC and JSP, punt on these topics.
They instead focus on the original question of "how do you glue markup
and logic together?"
Barracuda versus Struts
There are two major reasons, albeit they are somewhat prejudice ;) why
Barracuda is better than Struts.
Barracuda is mimicked after the JFC/Swing MVC model - Ignore MVC for
now. Just know that the Swing model is very popular and critically
acclaimed. It does a very, very good job of describing how an application
should handle a request and generate a presentaton response.
Barracuda is built on an XMLC foundation. - The result: Barracuda
inherits all the goodness of XMLC (versus JSP) as described above.
Struts is based on JSP. As a result, it's must first insulate
the developer/designer from the weaknesses and inconstitent capabilities
of JSP development in order to present a standard environment that compose
a presentation framework.
There are a number of other reasons including the comprehensive state
of Barracuda development compared to Struts. One of them is the
"tacklebox" analogy used by Christian Cryder in defining the Barracuda
architecture. Tacklebox refers to the fact that if you are developing
with xmlc and all you want to use is Barracuda's localization capabilities,
then just use it and do everything else your own way. This is a
very nice feature for those who don't want a heavy handed, policy rich
presentation framework or for those who simply want to get their toes
wet until they become more comfortable with the rest of Barracuda.
A Final Observation
Clearly, there are a lot of perspectives and personal preferences when
it comes to the hot topic of standardizing presentation development. There
are at least two, clearly different strategies: push versus pull. There
is no reason why only one must emerge as the developer/project manager/designer's
only option.
One last thought. XMLC means that Barracuda will also support the push
model where Java and mark-up (HTML, XML) never meet. Architects recognize
the immediate value: that the natural tendancy to shove Java inside mark-up
can never occur. Despite taglibs, despite Struts, can you say the same
thing about using JSP?
Resources
Be sure to check out past articles written about Barracuda by Christian
Cryder
http://www.lutris.com/journal/July2001/articles/Barracuda/localization.html
http://www.lutris.com/journal/March2001/articles/barracude.html
|