Open Source Consultant, Software Developer and System Administrator

If you are interrested in hiring a consultant for the effective use of open source software on an enterprise grade, take a look around in the About section to see, what I have to offer.

Blog and snippets

Various snippets or code parts I found useful, so I keep them here for reference.

German Date/Numbers on BeanWrapperFieldSetMapper in spring-batch

For parsing a CSV with german numbers and dates in a LineMapper using a BeanWrapperFieldSetMapper:

setFieldSetMapper(new BeanWrapperFieldSetMapper() {{
    setTargetType(PortfolioLine)
    setCustomEditors([
            (Date.class) : new CustomDateEditor(DateFormat.getDateInstance(DateFormat.SHORT, Locale.GERMAN), true),
            (BigDecimal.class) : new CustomNumberEditor(BigDecimal, NumberFormat.getInstance(Locale.GERMAN), true),
    ])
}})

Revised minimalistic grails wrapper

Finally switched to GVM but still wanted to have the trivial "version detection". Make sure to have the script in PATH before GVM or don't name it grails.

#!/bin/sh
version=current
if test -f "./application.properties"; then
        version=`cat ./application.properties | perl -ne 'print "$1" if (/app.grails.version=([0-9\.]+)$/)'`
fi
export GRAILS_HOME="$HOME/.gvm/grails/$version"
"$GRAILS_HOME/bin/grails" "$*"

SpringBoot, Gradle, Groovy

Create build.gradle:

buildscript {
    repositories {
        mavenCentral()
        maven { url 'http://repo.spring.io/libs-release' }
    }
    dependencies {
        classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.0.0.RC1'
    }
}

apply plugin: 'idea'
apply plugin: 'groovy'
apply plugin: 'spring-boot'

version = '1.0'

repositories {
    mavenCentral()
    maven { url "http://repo.spring.io/libs-release" }
}

dependencies {
    compile 'org.codehaus.groovy:groovy-all:2.2.1'
    compile 'org.springframework.boot:spring-boot-starter-batch:1.0.0.RC1'
}

task wrapper(type: Wrapper) {
    gradleVersion = '1.10'
}

Add some bootstrap for SpringBoot src/main/groovy/Application.groovy:

import org.springframework.boot.SpringApplication
import org.springframework.context.annotation.Configuration
import org.springframework.boot.autoconfigure.EnableAutoConfiguration

@Configuration
@EnableAutoConfiguration
class Application {

    public static void main(String[] args) {
        SpringApplication.run([Application].toArray(), args)
    }

}

Start and run with gradle bootRun