Ebichu

I discovered Ebichu anime last night.  Ebichu is a cute housekeeping (?) hamster who is fiercely loyal to her undeserving master.  Ebichu is simply hillarious.  Here are some screenshots to make up for all the boring technical posts:

Ebichu cleaning

Ebichu dusting

Ebichu telling her master's boyfriend to
be fair to both of her master's breasts.

Ebichu telling her master's coworkers
what a nice girl her master is.

Ebichu underappreciated
 

Jury Duty

My wife wasted 5 hours today waiting for jury selection process.  She doesn't understand English very well but the jokers administrating the jury duty doesn't care.  Apparently they also don't care about wasting people's time because she told me she had to wait all that time just to be told to come back tommorrow.

Jury duty is a serious responsibility for every American citizen but bureaucrats are turning it into a joke.  What is the point of dragging in a busy housewife who understants little English to warm up a chair all day?  With such idiocy and glaring disregard for people's time, it is no wonder everyone tries to avoid the jury duty.  While everyone complains about the slowness of DMV and US Post Office, they are speedy when compared to the American court system.

Persimmons

On Sunday, my wife and I harvested some ripe persimmons off our two persimmon trees and took some photos while at it.

My wife doing her sexy persimmon hunter pose
in front of a persimmon tree.  Long stick she is holding is
what we use to cut the persimmons down.

A closer look at the persimmon tree.
Persimmons are riper at the top for some reason.

What we managed to harvest before I threw in the towel.

Eating too much persimmons can cause constipation.  Since I enjoy being an easy going fella, I don't eat persimmon.  Half of the harvest are for my wife and son.  The rest goes to our friends and neighbors.  The best way to eat persimmons is to ripe them until they turn red (called hong-shil in Korean) and then freeze them.  This way you can eat them like ice cream any time.

JSTL, EL, and DBXML

I changed my DBXML taglib last night so it will work with JSTL tags.  I left out EL support because I didn't need it yet.

As to the kind of changes needed for a taglib to be integrated with JSTL, classes need to support the JavaBeans method naming design pattern and implement common interfaces like Iterator or Collection.  For example JSTL Core forEach tag requires a variable set with an array of primitive data types or an object or its member implementing Iterator or Collection interface.

Unfortunately, DBXML's Java binding classes looks like they were written by a C programmer with little understanding common Java practices nor common performance pitfalls.  XmlResults class, for example, doesn't follow the JavaBeans method naming design pattern and doesn't provide an Iterator interface.  Not surprising since it doesn't even override the toString method.  It also instantiates a new XmlValue for each result item.

To get around these problems, I made these changes to DBXML Java binding:

  1. added XmlValue.setCPtr method so XmlValue can be reused.
  2. added XmlValue.nextValue method with an XmlValue out parameter.
  3. added XmlValue.toString()
  4. added getXXX versions of asXXX methods.
  5. added XmlResults.getItems() that resets and returns an Iterator implementation.

With above changes, I was able to use my DBXML taglib with JSTL tags like this:

<%@ taglib prefix="dbxml"
uri="/WEB-INF/dbxml.tld" %>
<%@ taglib prefix="c"
uri="http://java.sun.com/jstl/core" %>
<html><head><title>DBXML Test</title></head><body>
<h2>My Posts about Flash</h2>
<dbxml:setDataSource dataSource="dbxml/blog"/>
<dbxml:query var="titles"
  xpath=
"/donpark/post/item/title[contains(.,'Flash')]/text()"
  resultType="values" />
<c:forEach var="item" items="${titles.items}">
  <h4><c:out value="${item.string}"/></h4>
</c:forEach>

</body></html>

Which returns:

<h4>Funniest Comment about Flash Mobs</h4>
<h4>Flash Mob Discount?</h4>
<h4>Flash Mobs in the Bay Area?</h4>
<h4>Flashing XML</h4>

Note that EL expression ${titles.items} invokes XmlResults.getItems method and ${item.string} invokes XmlResults.getString method according to JavaBeans design pattern.  Adding EL support to a taglib involves passing attribute values and body content through the EL parser so users can use EL expressions when using your tags.

Tomcat Inner City

I spent a couple of hours this morning to write a JNDI ObjectFactory for DBXML so access to XML databases can be located and shared across web applications via JNDI similar to the way JDBC DataSources are handled automatically by Tomcat.  Unfortunately, ObjectFactory doesn't handle object lifecycle meaning it just ships objects out the door and not worry about them afterward.

To close down those databases gracefully, I need to receive notification of the container shutting down.  Tomcat provides varioius kinds of Listener support but there are two problems:

  1. Tomcat-specific interfaces must be used.
  2. Listeners are specified by class name.

I think a JCA (J2EE Connector Architecture) connector version would be more portable but I am not sure if Tomcat supports this.  Looks like I'll have to wander around the inner city a little longer.

After dinner, I am going to tinker with DBXML TagLib to make it look more like JSTL's SQL tags and support EL as well.  I don't usually get to play around at this level, so it's fun in a way.

DBXML TagLib

Not much to blog about except I now have a simple taglib for DBXML.  It has only two tags for now, <dbxml:query> for querying DBXML with XPath and <dbxml:value> for retrieving query result value.  Writing taglib is rather tedious so I might just build some more blog, wiki, and RSS related taglibs while I am at it.

IBDNetworking Event Tonight

I just cancelled my registration for the IBDNetwork event tonight because I got up at 4AM today and expect to be sleepy by early evening.  So don't look for my face there.  I'll miss Joi's dinner also.  I hate getting up early in the morning.  My house office faces south east and, in the morning, the sun is too bright for the computer screens.  What I like to do is get up around noon and work til 4AM or so.  But I have little control over my internal clock meaning I am consistently inconsistent.