Skip to Content »

Tech Life of Recht » archive for May, 2009

 Hudson Plugin for Eclipse 1.0.7

  • May 20th, 2009
  • 5:49 pm

It seems there were a couple of regressions in the 1.0.6 version of the Hudson plugin for Eclipse. The new version checked for valid build status values, but apparently, I didn’t quite get all the values right, which resulted in a NPE when starting the plugin.

A couple of other small fixes were also applied, so I’ve released version 1.0.7. Download at Google Code or use the update site.

 Hudson Plugin for Eclipse 1.0.6

  • May 17th, 2009
  • 2:48 am

I just spent the evening implementing 3 new features in the Hudson Eclipse plugin. All three were requested in the issue tracker, and the requests even had patches attached, so it wasn’t too much work. Thanks very much to all the contributors.
The new features are:

  • Display build health along with build status
  • Make it possible to set parameters when launching a parameterized build. Unfortunately, it’s not possible to read the necessary parameters from the xml interface, but I’ve created a feature request, so hopefully it will be added to Hudson soon.
  • It’s now possible to detect any running Hudson instances using network broadcasting. This only works for local network. So see in action, go to the preferences page and click “Discover”.

As usual, the new version can be downloaded from the project site, or using the Eclipse update manager.

 Agile Hitler

  • May 16th, 2009
  • 3:48 pm

I usually don’t use much time on YouTube and other sites like that, because it simply takes up too much time. However, yesterday I was introduced to Agil Hitler, and if you haven’t met him, then now is the time. Once again, you have to wonder who makes this stuff, and where do they get the ideas? I don’t know, but apparently it’s pretty popular to create this sort of video, just check out the related videos section. Politically incorrect? Check. Funny? Check. Waste of time? Check.

 Modeling Objects

  • May 14th, 2009
  • 11:07 pm

I’ve spent the last two days giving a course on basic programming and modeling techniques such as UML, design patterns, refactoring, and other related subjects. I think it’s the sixth time I do this, so it’s getting a little trivial. One of the more fun parts, however, is that I also spend a couple of hours on Color Modeling, most of the time on an exercise where the participants use colored post-it-notes to create a model of a business. They’ve more or less tried the same using just plain UML without using any particular methodology, and the difference is always striking: With Color Modeling, the result is quite consistent and contains more or less the same terms and classes. Without it, the models tend to be much more random, and they don’t really capture the essence of the business domain.
While pretty much everybody at the course can see that it can be a good idea to use Color Modeling, almost nobody actually does it afterwards. Personally, I feel that designs based on Color Modeling are much more consistent with the actual problem domain, so it’s somewhat hard to understand why it’s not more widely known (it’s extremely rare that I run into developers who know about the technique).

I know that Color Modeling is not the answer to everything, and that it has its downsides too. However, it strikes me as very strange that just about no developers I know actually know any reusable modeling technique which results in consistent models. Why is this? Modeling is hard, so why is there not any focus on this? It might be an educational issue – when I was at university, I was taught the only other technique I know: Find all the things in the system – these become classes. Find all the actions these things perform – these become the methods on the classes. And that’s more or less it. And isn’t that just a little saddening?

 Spring iBatis integration with TypeHandlers

  • May 7th, 2009
  • 8:24 am

I recently had to do some iBatis SqlMap integration in a Spring project. It turned out not to be relevant after all, but I thought I'd share it in case anybody else could use it.
Basically, the problem was that I had to do some type conversion in code. For this, iBatis has the TypeHandler concept, where a handler can be registered on a specific Java type, and when this type is encountered in a SqlMap, the handler is called. Usually, the handlers are configured in the main SqlMap config file by referring to the class name in XML. However, in my case, the handlers had to be Spring-managed beans (they needed some beans to be injected), so the static configuration didn't work. The solution was to extend the SqlMapClientFactoryBean class to do some extra wiring:

CODE:
  1. public class SqlMapTemplateFactoryBean extends SqlMapClientFactoryBean {
  2.  
  3.   private Map<String,TypeHandlerCallback> handlers;
  4.  
  5.   @SuppressWarnings("deprecation")
  6.   @Override
  7.   public Object getObject() {
  8.     ExtendedSqlMapClient client = (ExtendedSqlMapClient) super.getObject();
  9.     if (handlers != null) {
  10.       for (Iterator<?> i = client.getDelegate().getResultMapNames(); i.hasNext(); ) {
  11.         String name = (String) i.next();
  12.         ResultMap map = client.getDelegate().getResultMap(name);
  13.        
  14.         for (ResultMapping rm : map.getResultMappings()) {
  15.           if (rm.getJavaType() != null &&
  16.             handlers.containsKey(rm.getJavaType().getName())) {
  17.             rm.setTypeHandler(new CustomTypeHandler(handlers.get(rm.getJavaType().getName())));
  18.           }
  19.         }
  20.       }
  21.     }
  22.     return client;
  23.   }
  24.  
  25.   @Override
  26.   public Class<SqlMapClientTemplate> getObjectType() {
  27.     return SqlMapClientTemplate.class;
  28.   }
  29.  
  30.   public void setTypeHandlers(Map<String, TypeHandlerCallback> handlers) {
  31.     this.handlers = handlers;
  32.   }
  33. }

This FactoryBean can then be used as a replacement for the regular SqlMapClientFactoryBean, and by setting the typeHandlers property, TypeHander instances can be injected:

CODE:
  1. <bean id="sqlmap" class="dk.test.SqlMapTemplateFactoryBean">
  2.     <property name="dataSource" ref="dataSource" />
  3.     <property name="configLocation" value="classpath:sqlmap.xml" />
  4.     <property name="typeHandlers">
  5.       <map>
  6.         <entry>
  7.           <key><value>dk.test.SomeVO</value></key>
  8.           <bean class="dk.test.SomeTypeHandler">
  9.             <property name="dao" ref="someDAO" />
  10.           </bean>
  11.         </entry>
  12.       </map>
  13.     </property> 
  14.   </bean>

 xmonad upgrade

  • May 1st, 2009
  • 9:10 am

Yesterday, I decided to upgrade my xmonad installation to the latest from the Darcs repository. There were no problems compiling the new version, but when I restarted X, xmonad wouldn't start. After digging in the log files, I found this error:

xmonad-i386-linux: getProcessStatus: does not exist

Very strange, and not much help on Google either. After fiddling around a little, I remembered that xmonad compiles the ~/.xmonad/xmonad.hs config file into a new executable, which is called xmonad-i386-linux, and is placed in ~/.xmonad. Remove the file and everything will work again.

The problem seems to be that a new patch in the repository changes the way xmonad launches child processes, but xmonad does not automatically detect that the configuration should also be recompiled.