Blogging Roller

Dave Johnson on open web technologies, social software and software development


Struts Validator and java.math.BigDecimal.

I've been working feverishly against a Friday deadline, having lots of fun, and learning more than I ever wanted to know about Struts, Hibernate, XDoclet, etc. I'm the closest thing that we have on the project to a Struts expert, so I've had to come up to speed fast on Struts Tiles, Struts Validator, and XDoclet's Struts support. So far, so good, but now I've hit a snag. I've run up against what appears to be a serious Struts Validator limitation: no support for java.math.BigDecimal.

I tried using the double validator, but when I apply the XDoclet tag for the double validator to a field that is a BigDecimal, XDoclet does not generate an entry for the field in validation.xml. Maybe, if I can fix this I can get away with using the double validator. Hmmm...

To resolve this problem the right way, it seems that I'll need to write my own validator. No problem right? I think this involves four steps:

  • Provide a class with a validateBigDecimal() method for server-side validation.
  • Write the JavaScript for client-side validation.
  • Write the XML for my validator and put it in validator-rules.xml.
  • Fetch XDoclet from CVS and hack the Struts Validator support to handle my new validator.

That last step is a doozy. There's got to be an easier way, but googling turns up nothing. I guess I have figured out how I will spend my evening.

Tags: Java

Redhat to bundle JOnAS.

InfoWorld: Red Hat to ship JOnAS J2EE software - The key question now is whether or not the JOnAS software will become the first open source application server to receive J2EE certification, an expensive process whose price tag has thus far helped prevent the JBoss application server from being certified by Sun.
Wow. First Apache with Geronimo, now Redhat with JOnAS. Whatever happened to The End of Free? I wonder why Redhat chose JOnAS. Did the Fleury vs. Sun antics scare them away from JBoss or was it the LGPL?
Tags: Java

Code generation rules.

Norman Richard:
  • Never check generated files into the repository
  • Never generate code using a tool that can't be automated
Words to live by. I like to generate code right into the build directory, somewhere like ./build/src.gen, to ensure it gets blown away by a build clean and to ensure that everybody knows it.

Tags: General

Geronimo!

Geronimo proposal: There are two main aspects to this Apache project:
  • a complete J2EE certified server which is fully ASF/BSD licensed and backed by a healthy open source community.
  • to create a fully modular J2EE stack so that the Apache community can use whichever parts of the J2EE stack they require separate from the J2EE server project.
Very cool.
Tags: Java

I'm in InfoWorld!

John Udell, InfoWorld: Programmer and author Dave Johnson shared an anecdote on his Weblog last year about what happened when his 5-year-old son walked up behind him while he was coding. "He saw the JUnit green bar on the screen," Johnson reports, "and said 'Dad, you did good.'" There's more to this touching father-and-son moment than meets the eye.
Tags: family humor java

Usability reading.

I've started to enjoy the java.net blogs and I'm not ashamed to admit that I read them almost daily. I'll be visiting more often as Simon Brown and Alan Williamson have taken up residence there.

Today, I was happy to see Jonathan Simon's list of usability books and websites. My new title is Senior GUI Developer, so I'm getting my re-aquainted with UI design and usability. In fact, my copy of Don't Make Me Think: A Common Sense Approach to Web Usability just arrived today. For some odd reason Jonathan did not make the links clickable. That is not very usable now is it? I've taken Jonathan's list and make it clickable for your easy reference:

Jonathon Simon: Here is a list of books that I have found useful. And some good links:
Tags: General

HAHT news.

Congratulations to Michael Kelley, who is leaving his position as VP of Development for HAHT Commerce, Inc. and moving to Redmond to join Microsoft. Before joining HAHT in 1996, Michael directed the development of DG/UX Unix at Data General. Rumor has it that he is back in the OS game and will be working on Windows Server. What a catch for Microsoft!

Michael is certainly not the first former HAHT employee to join Microsoft. Many of the original HAHT developers now work for Microsoft, but most are working on webapp testing, next-generation source code control (look out SourceGear), and bug tracking products here in Microsoft's new RTP development center.

Tags: General

Congrats

Congratulations to Matt Raible, who has been blogging for over a year now, and to Simon Brown, who has been asked to blog for java.net.

Tags: Blogging

OSCache 2.0 is quite an improvement.



I just tried the new OSCache 2.0-beta2 release and it is quite an improvement over the 1.7.5 release. Wow. Look at these numbers:

Testing Roller 0.9.7.5 with the old OSCache and the new:

Test Cache-TO Threads Loops Max-Delay Avg Med Dev T-Put
OSCache175 5/5 20 10 1000ms 4684 1382 8012 138.7/min.
OSCache200 5/5 20 10 1000ms 2237 821 6624 201.4/min.
OSCache175 60/120 20 10 1000ms 2601 1382 3136 186.9/min.
OSCache200 60/120 20 10 1000ms 1680 731 2113 242.9/min.
OSCache200 60/120 20 1000 1000ms 2248 1603 2079 271.5/min.

See Roller0975Throughput for more information on the tests.

Tags: Java

Software success.

Joel Spolsky: no software company can succeed unless there is a programmer at the helm

...and free M&M's on Wednesdays ;-)

Tags: General

Roller 0.9.7.5 progress.



I've been working on improving the performance of the Roller persistence tier. I've been doing this work in the old Roller 0.9.7 branch to make it easy for FreeRoller to deploy the improvements. Here are some details on the improvements.

Roller uses an O/R mapping framework persist objects in a relational database. Before the improvements, every call into the Roller persistence layer would open, use, and close a persistence session (either a Hibernate Session or a Castor Database). Roller often makes multiple persistence layer calls to process a web request and, so, Roller would often open, use, and close multiple persistence sessions per web request. A number of people pointed out that this is a bad thing.

To fix this problem, I changed Roller to ensure that each incoming web request gets it's very own persistence session and all persistence layer calls made on behalf of that request use that same persistence session. That means that there is, at most, one persistence session per incoming request. Persistence sessions don't hang around, each one lasts for the duration of one web request only.

These change improved Roller's performance, but not by much. Here are the JMeter test results. As always, comments, suggestions, and criticisms welcome. I think it is interesting that Resin performed better than Tomcat on the baseline test, but not the Roller test (a sign that I screwed something up?).

Update: FreeRoller is deploying these changes now. Even though the performance gains are minimal, I'm hoping the load and the number of MySQL threads will be reduced. I'll be playing with Hibernate caching and the new OSCache beta release tonight to see if they can offer any additional improvements.

Tags: Roller

Erik Hatcher on XDoclet and the Struts Validator.

It's a nice coincidence that the very week that I have to dig into the Struts Validator, two articles appear by Erik Hatcher on XDoclet and Struts. After reading these articles and browsing Matt Raible's AppFuse project code, I was able to fit the pieces together and get XDoclet to generate the right struts-config.xml and validation.xml entries for my form beans. Below are links to Erik's articles and some other resources I found useful in investigating Struts Validation:

Seems like everytime I try to use XDoclet, I have to tweak one of the XDoclet template files to work around a bug. This time was no exception. I found that XDoclet would only generate the right entries in struts-config.xml if my form beans extend ActionForm, but to use the Struts Validator, I need my form beans to extend ValidatorForm. The only way I found to get around this problem was to copy struts_config_xml.xdt out of the XDoclet xdoclet-apache-module-1.2b4.jar file and to change the first forAllClasses like so (my change in bold):

  <!-- ========== Form Bean Definitions ============== -->
  <form-beans>
<XDtClass:forAllClasses type="org.apache.struts.validator.ValidatorForm"> <XDtClass:forAllClassTags tagName="struts:form" superclasses="false"> <form-bean name="<XDtClass:classTagValue tagName="struts:form" paramName="name"/>" type="<XDtClass:fullClassName/>" /> </XDtClass:forAllClassTags> </XDtClass:forAllClasses>

I believe there needs to be one of those forAllClassses loops for each type of form: ActionForm, ValidatorForm, and ValidatorActionForm. This does not appear in the current XDoclet CVS for <a href= "http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/xdoclet/xdoclet/modules/apache/src/xdoclet/modules/apache/struts/resources/struts_config_xml.xdt?rev=1.11&content-type=text/vnd.viewcvs-markup"> struts_config_xml.xdt. My chance to get a patch in?

Tags: Java

« Previous page of month (Aug 2003) | Main | Next month (Sep 2003) »