Sonntag, 25. Dezember 2011

Goovy & Unix: How to find a program?

How to find out in Groovy whether a program is installed?

I've tried this:

// Check for availability of "formail", which should be included in packages for "procmail"
def formailPath = 'which formail'.execute().text.trim()
assert formailPath > '', 'Programm "formail" is needed. Please install package procmail'

and it worked quite well, since the expression 'which formail'.execute().text.trim() returns either the empty string or the path to the executable.

Sonntag, 19. Juli 2009

Netbeans Module for Hibernates-Entitymanager

Trying to develop a little application with the Netbeans-Platform I encountered a little problem with Netbeans module structure. Since I don't want to have the database module (Derby) included in the JPA-Provider module (Hibernate-Entitymanger) I tried to simply let the derby-module export the token "java.sql.Driver" and let the JPA-mdodule require that token. But this led to runtime exception, since the DriverManager inside of the JPA-module couldn't see the driver included in the derby-module.
Finally I wrote my own LookupConnectionProvider (implementing org.hibernate.connection.ConnectionProvider), which uses Netbeans Lookup mechanism to find the required driver. With this new connection provider no "hard" reference to the derby module is needed to let the JPA-module find the driver.