Author Archives: nydi

Mahout Clustering Example

With Version 0.9 of the Mahout library the Hello World example of the Mahout in Action book is mostly deprecated. I searched for an updated version but not any of the results satisfied me. Following you will find a version of the ‘Hello World clustering example’ without deprecated code, compiler warnings and a bit manner of clean code. It clusters a small amount of points in two clusters using the K-means Algorithm.


Spring – Composite interceptor to create dynamic interceptor/advice chain

In my projects I reuse approved intercepter implementations. In in some cases I combine several interceptors to one interceptor or dynamicaly chains interceptors. In view of the method invocation the interceptors appears as one interceptor, or in other word as composition of interceptors. To support chaining of interceptors I implemented a CompositeInterceptor and a Interceptors utility class.


Spring – Usage of @Primary annotation or attribut for inject default bean instances

For using dependency injection with Spring 3.0, several ways exists. You can use the annotation based way with the annotations @Service, @Repository, @Component or the JSR 330 @Named annotation or define the beans in xml with autowiring attributes or last but not least define the beans in a Java configuration. To wire up the injection targets you can use the @Autowired or the JSR 330 @Inject annotation or wire up the target in the XML bean definition.

Well the sense of this post isn’t to explain Spring dependency injection in deep. I will rather discuss what happens if Spring found multiple beans qualified for injection, and how you can help Spring to make the decision which is the right one bean. I use the JSR 330 annotations, The examples also works with the Spring annotations @Service and @Autowire.


Spring – load multiple property based on utils properties code

With the utils namespace in Spring 3.0 you can load a property file and use the values in Spring EL expressions. Unlike the valued flexibilty of other Spring components, utils:properties lacks possibilty to add multiple property file locations. But there is no problem to support multiple property locations by usage of PropertiesFactoryBean, the source of util:properties


Lucene Spatial Example

As you know deal with lucene spatial search is sometimes hard. To understand the basic functionality I searched for a simple example. Mike Haller explained in his post Spatial search with Lucene a good example of how lucene spatial works and he gives some example code based on Lucene 3.0.2. In this post I deal with lucene 2.9.3 and lucene spatial.