If you need to access the metadata of a class or be a bit less type safe than Java is by itself, you will have to get involved with the Java Reflection API. At that the question may arise, how to check whether one class object is the super class of another. If you are working with objects, you may use the java keyword instanceof
. But this won’t work as expected for class objects, since all class objects are instances of Class<?>
. So Class<?>
owns the method cls1.isAssignableFrom(cls2)
, checking whether cls1
is a super class/interface or the same as cls2
. So it works just like instanceof
on objects, but the order of the parameters is switched.
Access javadoc programmatically
This tar ball (export-doclet-0.1.tar.gz) contains two maven project artifacts. It shows how to access the javadoc information of a project during the maven lifecycle phase ‘generate-sources’, traverse it, fill a Java object structure (export-doclet-api), marshal it to XML and include it into the jar of the artifact. Later on, you will be able to unmarshal the javadoc information. The export-doclet-api is oriented towards the doclet-api and the reflection-api and may therefore be familiar to you.
Read More
Problem using SQL keywords as field names in entities
If you’re using an JPA implementation in your application like hibernate you might try to name a field of an entity just as SQL keywords (e.g. ‘order’ or ‘key’). But beware of the nasty persistence provider.
Read More
Using External LDAP Naming service in JBoss-5.1.0.GA
Often you’re using ldap for authentication. But what if you’d like to store more information to your ldap and access it from your enterprise application? You can add an external context to your JNDI tree.
Read More
Bug in JDK Javadoc for class java.util.regex.Pattern
The Javadoc for class java.util.regex.Pattern contains a bug. It says that a back reference (Pattern (Java Platform SE 6)) to a capturing group is depicted by \n
whereas n denotes the number of the capturing group. Unfortunately this won’t work. Use $n
instead.
Read More
Script for comparing working copies
svn diff
compares repository URLs only. So, if you reintegrated a branch to the working copy of your trunk or synchronized the trunk to the working copy of your branch, you will have a problem. This little script helps you to compare two working copies.
Read More
Transaction Propagation for Remote calls
I didn’t find a clear statement whether transactions are propagated for remote calls in Java EE 5. So I tested it by creating two enterprise applications being deployed in different ears to the same JBoss-5.1.0-GA. In short: YES, the transaction is propagated and a rollback on a calling method initiates a rollback on the remote transaction, too. The willing reader might read on in order to get to know the test setup. Read More
Track Login and Logout of Users with Tapestry 5
Often it is necessary to be notified, whenever a user logs in or out. This tutorial shows, how this can be achieved with tapestry 5 using form based authentication supported by a web container like tomcat. A really nice design decision of tapestry 5 is not to use XML for configuration, but pure Java. Beside avoiding most of the configuration overhead by following the paradigm Convention over Configuration, there are service classes being responsible for the configuration as defining filters or customized dependency injection and much more. Read More
Problem deleting mailboxes in cyrus with cyradm
The cyrus imap server in version 2.2 has a weired behavior: By default an admin user is not allowed to delete mailboxes he created. The good news is, he is allowed to give himself the right to do so. Read More
Virtualization for VPN on Shared Systems
If you are using a machine being shared between several persons it is not advisable to open a VPN connection, because the tunnel would be accessible for all users of the computer. This is often the case in environments with thin clients. Instead of using a notebook or some other dedicated system, there is another possibility. Stephan Windmüller pointed me at the following solution. Simply install a virtualizer like VirtualBox with an operating system emulating its own network hardware. You can use a VPN tunnel from inside the virtualized OS without sharing the connection with other users on the host machine.