Freitag, 19. Dezember 2008

it-rockstars became appfuse consulting provider

IT-Rockstars, the experts for project skeleton, project kick start and agile development became appfuse consulting provider.

http://appfuse.org/display/APF/Consulting+Providers

Peter and Josip send greetings to Matt Raible :-) See you next Oktoberfest.

Mittwoch, 3. Dezember 2008

Annotation-driven transactions

Instead of programmatically implementing code or configuring Spring applicaton context xml files to manage transactions, it can simply be done by using Spring's transaction annotations. There's really not much to it. All you need to do is add the following to your Spring context:

<tx:annotation-driven />

Additionally ensure that the tx namespace is defined as per the xsi:schemaLocation

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.1.xsd"
default-lazy-init="true" />


And now to the fun part! Add annotations to your code. I prefer to apply annotations to interfaces. That way all implementations of the interface are transactional.



...and Bob's your uncle!

New IT-Rockstars Website online

The IT-Rockstars Website has been redesigned and is now reachable at: http://www.it-rockstars.com
Check it out if you are interested in consulting services around agile, test-driven development in JAVA or .NET!

Dienstag, 25. November 2008

Spring: Get Classpath Resources with Wildcards

With Spring's Resource abstraction it is easy to load resources from the classpath, but what if you need to load many files that follow a certain naming pattern? The following code accomplishes that with the org.springframework.core.io.support.PathMatchingResourcePatternResolver, it supports the same wildcards in the URL like the ApplicationContextLoader:

PathMatchingResourcePatternResolver patternResolver = new PathMatchingResourcePatternResolver();
Resource[] resources = patternResolver.getResources("classpath:/conf/aggregations/*_agg.xml");

Follower