Archive for February, 2009

Hibernate Performance-Tuning

Thursday, February 26th, 2009

Today, I spent some time to dive deeply into the heart of the Semtinel Core to fix a performance leak that occured since I did some experiments with rather large annotation sets. I ran into several difficulties that might be interesting to other developers as well, so this post covers the following topics:

  • Tracing of SQL statements for performance tuning of the H2 database.
  • Generating statistics for H2 in order to see, where the time is lost.
  • How to configure a single-value property in Hibernate for lazy fetching using annotations.
  • Extending the Netbeans build.xml, so that the necessary bytecode instrumentation is done automatically at build time.

(more…)

How to configure SVN for group access

Thursday, February 26th, 2009

In order to seperate the access permissions among different user groups and for different directories, you have to extend the configuration of svnserve a little bit. For example, you could have a group of users with read-only access and another group with write-access. Or you want to assign write-permissions on a per-directory basis. The setup described here is valid for the access via svnserve (svn://-style URLs).

(more…)

Determine current method in Java

Friday, February 13th, 2009

A rather strange way to determine the method, where you currently are, but it works:

1
2
3
4
5
6
7
8
9
private String getCurrentMethodName() {
   List stackTraceList = Arrays.asList((new Throwable()).getStackTrace());
   for (Iterator it=stackTraceList.iterator();it.hasNext();) {
      StackTraceElement ste = (StackTraceElement) it.next();
      if (!ste.getClassName().equals(this.getClass().getName())) 
         return ste.getClassName().concat(".").concat(ste.getMethodName());
   }
   return null;
}

I implemented it the way that the first method from the stacktrace is returned that does not belong to the class, where this code resides. So it is possible to use this code for example in an own logging class to augment the logging messages with the method name.

You can find another example here: http://dev.kanngard.net/

Basic Auth Webservice Client with .NET

Wednesday, February 11th, 2009

If a webservice requires basic http authentication (like the ones from wortschatz.uni-leipzig.de) and it doesn’t respond to a request without authentication with the proper 401 response (for example with a 500), you cannot use this service with the standard .NET client, because this client doesn’t send the header with the first request. Only after a 401 response, the header is sent. (more…)