Archive for the ‘java’ Category

Inject Spring Beans into JSP Tags

Sunday, May 7th, 2006

Spring 2.0 supports injecting beans into an arbitrary POJO, which isn’t necessarily instantiated by a Spring bean factory. This powerful feature is mostly used in injecting into domain objects whose life cycle is usually managed by ORM tools such as Hibernate. But we don’t have to stop here, e.g., JSP tags can also be injected the same way. Here’s how: more…

The Not So Funny Daily WTF

Thursday, May 4th, 2006

Reading The Daily WTF has lately become my, well, daily entertainment. Most of the stories are like the IT version of Dude, Where’s My Car. But, today’s entry, Hungry, Hungry HIPAA, did not read funny to me at all. Here are two of the most insightful commentaries from the readers showing why it did not -

“This goes to show that no matter how secure your technology may be, it can be completely circumvented by the simplest (and dumbest) of human actions.” -RyanD

“When I see things like this I get a real urge to contact the responsible autority and get those idiots removed from the IT genepool. This is actually as scarey as it is funny. There could be muppets like this working at your bank!” -voyager

Chintan Zaveri’s Portlet Resources

Saturday, April 22nd, 2006

Chintan Zaveri did some research and posted a rather nice collection of portlets he found as a comment to this JBoss Portlet & Liferay review I wrote a while ago. I felt that it was informative enough to become an entry by itself. So here it goes, with a little cosmetic formatting. more…

bsh.jsp: a lightweight BeanShell “root kit”

Monday, April 17th, 2006

I hacked together a simple JSP page that allows remotely submitting and executing BeanShell commands in any servlet container. A primitive “allowed” list is built-in to control access to the page. By default only users from the localhost can access. more…

What’s Your Max Line Width?

Sunday, March 19th, 2006

I have recently been asked to review some development team’s Java coding convention. Just when I was about to flip over the page that says “the maximum line width is 80 characters,” I had this sudden realization that we were actually in the year 2006 now. This is the age in which we use GUI IDE’s that are capable of displaying and printing over 100 characters per line at normal font sizes, and the age in which we tend to use long names for variables, methods, and classes. Why are we still limiting ourselves to the 80-character limit which is basically a relic from when we had to telnet to a server, and vi our code?

A Small Gotcha in java.lang.Package

Sunday, February 19th, 2006

Class java.lang.Package provides a few methods that returns certain manifest attributes such as Specification-Version or Implementation-Vendor. These attributes are loaded from the jar file in which the package is located.

The gotcha comes when you have the same java package spreaded over more than one jar file. Since there is always only one Package instance for all the classes belonging to this package (within each classloader’s scope, of course), it’s pretty much up to a classloader implementation to choose which MANIFEST.MF from all those jar files should speak for the entire package. Usually, for the obvious caching reason, the first one wins.

The worst scenario happens when you have an exploded class directory at the beginning of the classpath, in which a single class from package foo.bar (say a patch class) would cause all the classes in foo.bar, albeit well contained in a jar themselves, to lose their manifest attributes.

The “phew” part in this story is this: the Sealed attribute is an exception to the above behavior - at least in the case of the Sun JRE. An exception is always thrown properly no matter when it’s a sealed jar loaded after an unsealed jar containing the same package or the other way around.

persist() vs. save()

Tuesday, February 14th, 2006

Hibernate 3 added a new persist() method to the Session interface. It came from the EJB3 Entity Manager spec. In case you are also wondering whether to migrate to it or just stick to the good old save() method to insert a new object, here’s what I found out:
A discussion on Hibernate Forum
A JIRA ticket

The Circular Bean Reference Problem in Spring 2.0’s Arbitrary Domain Object Wiring

Monday, February 6th, 2006

Spring 2.0 has an exciting new feature that, with AspectJ’s powerful AOP support, allows arbitrary domain objects to be injected with dependencies at the time of creation, even when the domain object is not created by Spring. This feature helps developers avoiding the “Anemic Domain Model” because now domain objects can have references to services or even DAO’s, instead of just some other domain objects. more…

I Don’t Get “I Don’t Get Spring”

Monday, January 30th, 2006

I was reading Bob Lee’s Spring bashing blog entry, and, while realizing how high the flaming index the article carries, being a long-time Spring advocate, felt that I had to respond. more…

My 2 Cents on The Future of Javadoc

Monday, January 30th, 2006

Other than the survey I just filled out, some more thoughts on Amy Fowler’s Invitation. more…