CB:
OK, now I have some Best Practices questions for you. To
start, when is it appropriate to use entity beans and when would you go for
straight JDBC?
SS:
You can get yourself into trouble if you use [entity beans]
in the wrong way. One company [was] apparently just generating these massive
reports for web pages, and bitching about the CMP2 performance... going through a
layer that [they] were probably not going to reuse. If I'm not actually using
those business objects in another context – I'm just going to the database, to
an object and to a web page and the object is never accessed except for this
web page -- then there's a question: Why am I going there? Why did I go
through the trouble of doing that [CB: programming a bean]?.. As soon as I start talking to
the object in any other context., now I'm writing an EJB... Call it what you
want. Call it a Data Value Object Layer.... You're in an EJB container.
CB:
I haven't come across any good material on how to use J2EE
to handle the Lost Update problem. You know,
this is where there are two people, say Marc and I, looking at the same record
in a database – say it's a customer information database -- I change the phone number field and save,
then Marc changes the email field and he overwrites my change of the phone
number with the previous value. This
seems to involve both locking and transaction related issues. Is there a
preferred design method to handle this?
SS:
No, because it depends on how granular you can make the
transactions. Now if you can go very coarse...just putting in a very heavyweight
distributed transaction... well, problem solved. But now you have zero
scalability. You have big problems with integration, with XA drivers... So in general you'd have to come up with
some optimistic locking policy, or something like that. It's a pure application level thing.
That's one thing we'll try to look at in the future. You
know, under what scenarios can we at the container [level] handle optimistic
locking failures. With sophisticated caching...
CB:
And maybe a timestamping mechanism to check when stuff gets
out of date?
SS:
Absolutely...
CB:
Yeah, I think... as someone who has done stuff on the
application side, this [lost update issue] is something you see time and time
again. I've been looking for J2EE to solve that for me, and...
SS:
...That's the problem... You have all these issues and J2EE's
completely mute on them
The fundamental, difficult stuff, J2EE says nothing about...
Security's the same way. They'll never state anything meaningful on security –
other than, you know, X can do Y –
cause... once you get down in there you're basically in a cross between security
administration, ACL descriptors and application policies. They'll never get in
that space....
J2EE is nothing more than enterprise RMI...just a set of API's that you can [use]
to gain some portability... But all the details... I mean, if you read the specs
everything relevant is "this is left to a deployment detail". And that's my big criticism of J2EE. And generally of people who build up J2EE
as this cross... this cross to bear. And people do that. People come to our list and say "look, I've put together this package that
works on Weblogic. And when I deploy on your application server I get a class
cast exception."... and we're saying [it's] because we don't put a lot of crap
in. You don't have to go through preprocessing steps to do deployment. Because
we have a very lightweight layer. You
have to know what you're doing, ‘cause we'll give you the flexibility to do
whatever you want... As opposed to "J2EE is the only way."
BS:
We go beyond J2EE.
And Off They Go....
A few hours after I spoke with Marc and his colleagues, I
attended a presentation
Marc prepared for members of the Silicon Valley Software Development Forum. He
went in to more depth about JBOSS's internal architecture and the JBOSS Group's
goal of offering a platform that goes beyond J2EE by serving as a generalized
WebOS – one that can even run in memory constrained, embedded environments.
Should You Go Along For the Ride?
Overall, I've been really impressed with JBOSS's forward
thinking and elegant design. Still, there are some warts. From my experience,
JBOSS's main problem is that its documentation has a long way to go before it
can compete with the richness of BEA's.
When you are new to J2EE and are attempting to get the "lay of the land" it's
mighty helpful to have well-integrated and accurate documentation. Of course, Scott might say, "You have to know
what you're doing" with JBOSS. OK. I
admit that I don't, yet. Nevertheless, I still found it annoying that the code examples
in JBOSS's fee-based online documentation didn't work with the latest release
available on their download site.
After I got over the documentation humps, I wrote up and
deployed a couple of trivial applications. It wasn't an in-depth test, but the
experience left me very impressed with the speed with which I could compile,
jar and deploy my beans. Similar
trivial applications that I toyed with on a Weblogic-configured machine took
two to three times as long to deploy. Again, these tests were not what you'd
call scientific, so your mileage may vary.
So is JBOSS right for your organization? My recommendation
in selecting an app server is that you follow a defined and agreed-upon process
that's driven by the anticipated requirements of your application. Chapter 2 of
Rod Johnson's book (mentioned above) and Chapter 16 of Mastering
Enterprise Java Beans II (Roman,
et.al.) both contain good recommendations for what to consider in your
evaluation. I hope you find these resources useful, and that you code well,
deploy fast, and enjoy your holidays.
Last Modified
November 27, 2002
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.