instanceof on Class objects

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

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

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.