<?xml version="1.0" encoding="utf-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">
<title>Pierre Delisle&apos;s Blog</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/pierre/" />
<modified>2006-01-10T01:27:23Z</modified>
<tagline></tagline>
<id>tag:weblogs.java.net,2008:/blog/pierre/164</id>
<generator url="http://www.movabletype.org/" version="3.01D">Movable Type</generator>
<copyright>Copyright (c) 2006, pierre</copyright>
<entry>
<title>Resource Injection and the Java Persistence API in web applications</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/pierre/archive/2006/01/resource_inject_1.html" />
<modified>2006-01-10T01:27:23Z</modified>
<issued>2006-01-10T01:16:26Z</issued>
<id>tag:weblogs.java.net,2006:/blog/pierre/164.3907</id>
<created>2006-01-10T01:16:26Z</created>
<summary type="text/plain">Some thoughts on the experience of migrating the Duke&apos;s Bookstore
sample web application (in the J2EE 1.4 tutorial) from JNDI and JDBC to the
new Resource-Injection and Java-Persistence-API combo.</summary>
<author>
<name>pierre</name>

<email>Pierre.Delisle@Sun.COM</email>
</author>
<dc:subject>Community: Java Enterprise</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/pierre/">
<![CDATA[<p>
The <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html">Java EE tutorial</a> constitutes a great resource to help
developers better understand what the Java EE platform is all
about. It covers the technologies you will be interested in if you
write enterprise applications using EJBs as well as simpler web
applications. See the <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/doc/About.html#wp68936">tutorial roadmap diagram</a> to get an
idea of the key topics that are addressed by the tutorial.
</p>
<p>
Lately, I've been helping Jennifer (one of the tutorial writers)
update the "Duke's Bookstore" sample application of the tutorial so it
leverages some of the new Java EE 5 features. 
Here is the tutorial's description of the Duke's Bookstore sample app:
<blockquote>
   In Chapters 11 through 22 a common example--Duke's Bookstore--is
   used to illustrate the elements of Java Servlet technology,
   JavaServer Pages technology, the JSP Standard Tag Library, and
   JavaServer Faces technology. The example emulates a simple online
   shopping application. It provides a book catalog from which users
   can select books and add them to a shopping cart. Users can view
   and modify the shopping cart. When users are finished shopping,
   they can purchase the books in the cart.
</blockquote>
More specifically, we've been looking at migrating the 'database
access' portion of the app from JNDI and JDBC to the new Java EE 5
Resource Injection and Java Persistence API (from the EJB 3.0
specification).
<p><p>
I must admit we've struggled a little bit with some of the concepts
that one must master to properly use this new combo. Even if Resource
Injection and the Java Persistence API can be used independently of
EJBs, it appeared to us that familiarity with EJB usage patterns makes
it easier to understand how to properly use these new features in the
context of webtier applications.
<p>
Here are therefore a few thoughts on the topic.

<h4>Basic concepts, the EJB way</h4>

In the EJB world, an entity bean represents a business object in a
persistent storage mechanism. In Duke's bookstore, 'Book' is the typical
business object. In the Application Server, the persistent storage
mechanism is a relational database. Each entity bean has an
underlying table in a relational database, and each instance of the
bean corresponds to a row in that table.
<p><p>
A session bean, be it stateless or stateful, is an entry point into
the business logic of the enterprise application. So when a user wants
to add a book to the shopping cart, the ShoppingCart session bean is
invoked and it takes care of properly handling the operation.
<p><p>
Finally, all of the resources exposed by an enterprise application
need to to be accessible. Getting a handle to these resources is
typically handled through JNDI.
<p><p>
Most will agree that the above concepts are simple and
straightforward. Unfortunately, the complexity associated with the
implementation of EJBs have scared more than one developer in the
past. Luckily, much of this is changing with the Ease of Development
focus of Java EE 5. Not only is it easier to work with EJBs, but
benefits associated with traditional EJBs can be now be leveraged
without even using them, as is the case with web applications.

<h4>The new order: Java Persistence API and Resource Injection</h4>

As stated in the EJB 3.0 specification, the Java Persistence API is
"the Java API for the management of persistence and object/relational
mapping with Java EE and Java SE". Entity beans are therefore no
longer an exclusive feature of the Enterprise platform. The Java
Persistence API is totally independent of EJBs and provides the
Object-Relational Mapping layer that is so convenient to persist
business objects.
<p><p>
As can be seen in the tech tip <a href="http://java.sun.com/developer/EJTechTips/2005/tt1122.html#2">Converting a POJO to a Persistent
Entity</a>, taking advantage of Java Persistence is quite easy.
<p><p>
The only issue though is that using Java Persistence is much easier if
you can rely on a container that supports "Resource Injection", a new
feature also introduced in Java EE 5.
<p><p>
Note though that Resource Injection is limited to components that are
managed by a Java EE compliant container. Session beans therefore fit
the model perfectly.
<p><p>
But web applications live in a world that is EJB-free. While there are
no session beans in a webapp, the need to implement business logic
that is accessible over the web still exists. To fill that need, web
app developers can choose from a variety of technologies.
<p><p>
This choice is clearly showcased with the Dukes Bookstore web
application. The webapp is implemented using three different technologies:
pure Servlets, JSP, and finally JSF (and one could easily think of a
Struts-based implementation to complement the offering).
<p><p>
The challenge for a webapp developer that uses the Java Persistence API
is therefore to design the application such that Resource Injection can
be used (go with the flow young man, don't fight it!).
<p><p>
As mentioned above, Resource Injection can only be used by classes that
are managed by a Java EE compliant container. This is for two
reasons. First, for performance considerations, a container can
restrict its search of annotations only to the components it manages,
which are defined in a deployment descriptor or accessible in specific
locations of the classpath. Second, the container must have control
over the creation of the component to be able to transparently perform
the injection into the component.
<p><p>
While it is true that Resource Injection would be most useful in the
webtier if it were applicable to any POJO (Plain Old Java Objects),
this will have to wait for a future release. In Java EE 5, the
support for resource injection in the webtier is limited to the 
following webtier-managed components:
<ul>
  <li>Servlet Specification: Servlets, Servlet Filters, Event Listeners
  <li>JSP Specification: Taglib listeners, Taglib Tag Handlers
  <li>JSP Specification: Managed Beans
</ul>
What's important to note though is that this limitation is quite
acceptable if one follows a pattern similar to the one employed by
session beans. A <a href="https://bpcatalog.dev.java.net/nonav/soa/ws-servicelocator/frames.html">Service Locator pattern</a> to get access to
resources is no longer required because a controller can be
transparently injected with the resources it needs to carry on
database operations.
<p><p>
If the entry point into the business logic of a web application
is a webtier-managed component, then all resources required to 
support the Java Persistence API can be injected transparently.
<p><p>
This therefore works very well in a Servlet environment because
servlets act as controllers into the business logic. The same holds in
a JSF environment where managed beans associated with a page also act
as controllers into the business logic of the application.
<p><p>
The situation is unfortunately not as straightforward with JSPs.
JSP pages cannot be the target of resource injection 
because all the information represented by these injection annotations 
needs to be known at deployment time.  If an annotation is included 
in a JSP page, it won't be seen at deployment time. 
[actually, it would if the page had been precompiled, but one cannot
assume that all pages are precompiled].
<p><p>
A possible solution is to use a tag library since tag handlers can
be the target of resource injections. See <a href="http://weblogs.java.net/blog/ss141213/archive/2006/01/custom_tags_to.html">Sahoo's blog</a> for an example.
The problem though is that this promotes the use of scriptlets in 
a JSP page, which should ideally be avoided.
<p><p>
Ideally, we'd want a bean that is declared in a JSP page via
&lt;jsp:useBean&gt; to act as a controller and be "injectable", just as is
the case with managed beans in JSF. Since this is not possible,
a solution is to allow this controller bean to access resources
that have been injected elsewhere. 
<p><p>
That's what we're planning to do in Duke's bookstore; simply use a 
ServletContextListener to save global instances of the injected
resources. These resources can then be accessed from the controller
bean.
<hr>
Confused? In a forthcoming blog I'll describe how JNDI and
JDBC are used in the J2EE 1.4 version of Duke's bookstore, and how we're
planning to modify the different implementations of the webapp (servlets, JSP, and JSF) to take advantage of Resource Injection and the Java
Persistence API introduced in Java EE 5. And if you have comments on
the topic, please share them with us all...
<p><p>
<em>
Thanks to Jennifer, Sahoo, and Marina for their contributions in
helping clarify the migration path to Resource Injection and the
Java Persistence API.</em>]]>

</content>
</entry>
<entry>
<title>Java EE WebTier Expression Language: simplicity and feature-set tradeoff</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/pierre/archive/2005/06/java_ee_webtier_1.html" />
<modified>2008-01-02T17:42:16Z</modified>
<issued>2005-06-27T15:43:35Z</issued>
<id>tag:weblogs.java.net,2005:/blog/pierre/164.2655</id>
<created>2005-06-27T15:43:35Z</created>
<summary type="text/plain">When some developers complain that essential features are missing, while others argue that preserving simplicity is paramount, tough decisions are to be made...</summary>
<author>
<name>pierre</name>

<email>Pierre.Delisle@Sun.COM</email>
</author>
<dc:subject>Community: Java Enterprise</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/pierre/">
<![CDATA[There have been a couple blogs recently regarding "bloating" (<a href="http://weblogs.java.net/blog/kirillcool/archive/2005/06/you_say_eclipse.html">Eclipse</a>, <a href="http://weblogs.java.net/blog/opinali/archive/2005/06/bloated_mustang_1.html">Mustang</a>). Whoever has been on a design team that has to decide <em>which feature goes in and which one stays out</em> will probably feel the pain. As a spec lead (JSP, JSTL), I sure do. We all wish we could please everyone, but that's unrealistic. One has to accept that some developers will be unhappy with the decisions made. However, these days, it is often the case that a developer's voice can be heard before these decisions are made, and it can make a difference. Anyone with a strong opinion should make sure to take advantage of this...
<p><p>

In Java EE webtier land, we've worked hard over the last few releases to simplify the life of page authors (those that code the JSP pages). There's been many improvements to JSP, as well as the introduction of both the JSP Standard Tag Library and JavaServer Faces. One key element of our simplification effort has been the <strong>Expression Language</strong> (EL), which simplifies access to application data for the presentation layer. The EL (which by the way was first known as SPEL, the Simplest Possible Expression Language) started with JSTL 1.0, and was later picked up in parallel by JSP 2.0 and JSF 1.0. JSF's version of the EL diverged slightly from the JSP version because of its unique requirements (mostly defferred evaluation and support for method expressions). With the upcoming releases of JSP 2.1 and JSF 1.2, the two expert groups (EGs) have worked together to merge these differences into a common Unified EL, with an API that makes the EL much more flexible so it better adapts to the diverse needs of Java EE webtier technologies.
<p>
From its inception, the key design goal of the EL has been <strong>simplicity</strong>. It is commonly acknowledged these days that complex code should be written and maintained outside of view pages, and the expert groups have evolved the specs to better support this model. There have been some discussions recently on <a href="http://www.theserverside.com/news/thread.tss?thread_id=33990">The Server Side</a> comparing the EL with OGNL, with some complaining about shortcomings in the EL. I won't get into the details here, but it is clear that the expert group will have some tough calls to make regarding the evolution of the EL. While we don't want to lose sight of our base requirement for simplicity, we also do not want to alienate a large number of developers who strongly believe that a few important new features should be added to ensure improved usability of the EL. But the key point here is that the EG does not want to make any decision out of thin air. We do care about the community's input. Which finally brings me to the point I'd like to make in this blog.
<p>
There were some excellent comments made in that TSS discussion thread. Luckily, someone notified me and I will make sure that the EG follows up on them. There's obviously much more we can learn from the community, and I want to make sure it gets to our EGs. As I <a href="http://weblogs.java.net/blog/pierre/archive/2004/06/index.html">blogged last year</a>, the new JCP 2.6 creates more transparency into the specification work performed by the Expert Groups. Many specifications (e.g. <a href="http://jsp-spec-public.dev.java.net">JSP</a>, <a href="http://jstl-spec-public.dev.java.net">JSTL</a>, <a href="http://javaserverfaces.dev.java.net">Faces</a>) have a project at java.net to help developers stay abreast of the work done on on these JSRs. Use the mailing list to voice your opinion on any aspect of the spec, and browse/submit issues related to a spec through the issue tracker. The likelihood of an issue being tackled by the expert group is much higher if a comment is submitted through these official channels. And it will make our tough calls much easier to make if we do have lots of data points to work with. We know we won't be able to please everyone, but we'll definitely listen to all. 
<p>
And by the way, as you probably all know by now, <strong><a href="http://glassfish.dev.java.net">GlassFish is out, and it is open source</a></strong>. It's got most (if not all) the new JSP 2.1/JSF 1.2 features implemented. Take it for a spin and experiment with the improved JSP/JSF integration, as well as the unified EL. And don't forget to send us comments...]]>

</content>
</entry>
<entry>
<title>No submission? Got suggestions?</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/pierre/archive/2005/01/no_submission_g_1.html" />
<modified>2008-01-02T17:42:16Z</modified>
<issued>2005-01-08T01:05:58Z</issued>
<id>tag:weblogs.java.net,2005:/blog/pierre/164.1910</id>
<created>2005-01-08T01:05:58Z</created>
<summary type="text/plain">I&apos;ll have the privilege to serve on the selection committee for the
web-tier related submissions for the upcoming 
JavaOne conference. Got any advice I should bring to the committee?</summary>
<author>
<name>pierre</name>

<email>Pierre.Delisle@Sun.COM</email>
</author>
<dc:subject>Community: Java Enterprise</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/pierre/">
<![CDATA[<p>
There is always a great deal of interesting proposals submitted for the
JavaOne conference, and this
makes it really challenging for the various selection committees.
</p>
<p>
In his <a href="http://blogs.sun.com/roller/page/caseyc/20050103#how_not_to_have_your">blog</a> last Monday, Casey Cameron provided good advice for
submitters. In my case, I'd like to turn this around and ask
potential conference goers for any advice they would like to give
regarding the selection of the <strong>web-tier sessions and BOFs</strong>.
</p>
<p>
So... what web-tier related topics/speakers/events would make it
worthwhile to you at the 2005 conference?
</p>
<p>
Please let me know (comments below, or <a href="mailto:pierre.delisle@sun.com">email me</a> directly) and I'll make sure these opinions are heard.
As a reference, the 2004 web-tier selections are included below.</em> -- Thanks!
</p>
<p>
<strong>JavaOne 2004 web-tier technical sessions</strong><br>
3166  Internationalization and Localization of Web Applications<br>
2702  Web-Tier State of the Union<br>
1580  Advanced Real-World JavaServer Faces technology-Based Application Development<br>
2866  Blueprints for Interactive Web Applications: Designing applications for J2EE<br>
1341  Browser Tree Framework using Java and JavaScript technologies<br>
2471  Building Advanced J2EE 1.4 Web-Tier Applications<br>
2218  Building real-world ready UI Components for the web using JavaServer Faces Technology<br>
1925  Code Reuse Techniques in JavaServer Pages Technology: A Comparative Analysis<br>
1103  Creating a Component Community for JavaServer Faces Technology<br>
1936  Developing Advanced Graphics Components Using JavaServer Faces Technology<br>
2987  eXtreme JavaServer Faces Technology<br>
2553  Scripting in the Java Platform<br>
2168  Performance Considerations for Developing Portal Applications - Based on JSR 168<br>
1062  Portlet Specification: What is Real and What Comes Next?<br>
2100  Putting Faces on Your Portlets: Exploiting JavaServer Faces Technology in Portlet Applications<br>
1265  Scalable Java Technology Application Environment Infrastructure for the Web Tier<br>
2610  Using JSF with JDO: Developing Scalable Web Applications Easily<br>
2615  Using User Interface Modeling for Automatic Generation of Large-Scale J2EE Web Applications<br>
1286  Why you should use the JSP 2.0 Expression Language<br>
</p>
<p>
<strong>JavaOne 2004 web-tier BOFs</strong><br>
2240  Boosting Java Technology-Based Web Applications Development Productivity: A Generative Approach<br>
3080  Dynamic VoiceXML and CCXML Applications in Java Technology<br>
2101  JSP 2.0 Tag Libraries<br>
1966  Unraveling WSRP and its Alignment with JSR 168<br>
3154  Web Frameworks to Go: Productivity and Web MVC<br>
2091  Coexistence of JSF and Struts for Web Applications Development<br>
2693  Community Input on the Java Servlet and JavaServer Pages Technologies<br>
2938  Designing Secure Web Applications<br>
2180  Effective WebTier Clustering<br>
2937  J2EE Platform Blueprints for Web Services and Web Applications<br>
2780  JSR 168 In Depth<br>
3069  Portals, Portlets, and Web Services, Oh My! Lessons from the Trenches<br>
2056  Testing Strategies for Java Technology Based Web Applications<br>
2220  The Faces Behind the JavaServer Faces Technology: Developer to Developer with the JavaServer Faces Technology Team and Expert Group<br>]]>

</content>
</entry>
<entry>
<title>More transparency into the JSTL Expert Group spec work</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/pierre/archive/2004/06/more_transparen.html" />
<modified>2008-01-02T17:42:16Z</modified>
<issued>2004-06-10T21:43:32Z</issued>
<id>tag:weblogs.java.net,2004:/blog/pierre/164.1573</id>
<created>2004-06-10T21:43:32Z</created>
<summary type="text/plain">The jstl-spec-public project has just been launched to increase
transparency into the JavaServer Pages Standard Tag Library (JSTL)
specification work.</summary>
<author>
<name>pierre</name>

<email>Pierre.Delisle@Sun.COM</email>
</author>
<dc:subject>Community: Java Enterprise</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/pierre/">
<![CDATA[<p>
One key goal of the new <a href="http://jcp.org/files/whitepaper.JCP26Whitepaper.pdf">JCP 2.6</a> (Java Community Process)
introduced earlier this year is to create more transparency into the
specification work performed by the Expert Groups. To promote
this goal of increased transparency,
the JavaServer Pages Standard Tag Library (JSTL) expert group
(JSR-052) is launching project <a
href="http://jstl-spec-public.dev.java.net">
jstl-spec-public</a>.
</p>
<p>
While the source code for the JSTL Reference Implementation is already
open-sourced as the <a href="http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html">Standard Taglib</a> within the jakarta-taglibs project at Apache, two
key tools will be used in our new java.net project to make the work on
the spec as transparent as possible and to help bring an even greater
sense of community around our technology.
</p>
<ol>
<li><a href="http://jstl-spec-public.dev.java.net/servlets/ProjectMailingListList">Mailing lists</a></li>

The <i>users</i> mailing list for jstl-spec-public is now available to the
community to post comments and bring up issues related to the JSTL
spec that can then be discussed by the community at large.  There is
also the <i>announce</i> list, which is low traffic and will be used for
major announcements related to JSTL.<br><br>

<li><a href="http://jstl-spec-public.dev.java.net/servlets/ProjectIssues">Issue Tracker</a></li>

All issues related to the spec will now be kept in this public
repository. We have started populating it with issues we will be
considering for the next JSTL Maintenance Review, as well as with
enhancement requests we've received for a future revision
JSR. Relevant issues brought up on the users mailing list will be fed
into the issue tracker. One can also subscribe to the <i>issues</i> mailing
list to be automatically notified of all changes made to these issues.
</ol>

<p>
So, if you want to keep abreast of the work done on JSTL, check out
the new <a
href="http://jstl-spec-public.dev.java.net">jstl-spec-public
project</a>.  Justyna, Dhiru, and myself, along with the Expert Group,
will be happy to meet you there...
</p>
]]>

</content>
</entry>

</feed>