<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Better Software and beyond... &#187; News</title>
	<atom:link href="http://www.thorsten-kamann.de/category/news/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thorsten-kamann.de</link>
	<description>About architecture, development, quality and more</description>
	<lastBuildDate>Tue, 25 Oct 2011 20:16:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Groovy-Eclipse 2.0.1 Released</title>
		<link>http://www.thorsten-kamann.de/2010/03/23/groovy-eclipse-2-0-1-released/</link>
		<comments>http://www.thorsten-kamann.de/2010/03/23/groovy-eclipse-2-0-1-released/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 10:06:44 +0000</pubDate>
		<dc:creator>thorque</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[groovy]]></category>

		<guid isPermaLink="false">http://blog.kamann.info/?p=306</guid>
		<description><![CDATA[<a href="http://www.thorsten-kamann.de/2010/03/23/groovy-eclipse-2-0-1-released/" title="Groovy-Eclipse 2.0.1 Released"></a>The newest release is available. This release is mainly a bugfix release. There are 2 new features: Filter internal stacktraces Importing GMaven projects You can read here the New and Noteworthy. If you like you are be able to update &#8230;<p class="read-more"><a href="http://www.thorsten-kamann.de/2010/03/23/groovy-eclipse-2-0-1-released/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://www.thorsten-kamann.de/2010/03/23/groovy-eclipse-2-0-1-released/" title="Groovy-Eclipse 2.0.1 Released"></a><p>The newest release is available. This release is mainly a bugfix release. There are 2 new features:</p>
<ul>
<li>Filter internal stacktraces</li>
<li>Importing GMaven projects</li>
</ul>
<p>You can read here the <a href="http://docs.codehaus.org/display/GROOVY/Groovy-Eclipse+2.0.1+New+and+Noteworthy" target="_blank">New and Noteworthy</a>. If you like you are be able to update your Eclipse installation with this update site: http://dist.springsource.org/release/GRECLIPSE/e3.5/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thorsten-kamann.de/2010/03/23/groovy-eclipse-2-0-1-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Groovy Eclipse Plugin wins award for Best Open Source Developer Tool</title>
		<link>http://www.thorsten-kamann.de/2010/03/23/groovy-eclipse-plugin-wins-award-for-best-open-source-developer-tool/</link>
		<comments>http://www.thorsten-kamann.de/2010/03/23/groovy-eclipse-plugin-wins-award-for-best-open-source-developer-tool/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 09:53:18 +0000</pubDate>
		<dc:creator>thorque</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[groovy]]></category>

		<guid isPermaLink="false">http://blog.kamann.info/?p=302</guid>
		<description><![CDATA[<a href="http://www.thorsten-kamann.de/2010/03/23/groovy-eclipse-plugin-wins-award-for-best-open-source-developer-tool/" title="Groovy Eclipse Plugin wins award for Best Open Source Developer Tool"></a>At EclipseCon 2010 the Groovy Eclipse Plugin wins the award for the Best Open Source Developer Tool. This is very nice since the version 2.0.1 offers much of the features you know from the Java Editor: Syntax Highlighting Code Completion &#8230;<p class="read-more"><a href="http://www.thorsten-kamann.de/2010/03/23/groovy-eclipse-plugin-wins-award-for-best-open-source-developer-tool/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://www.thorsten-kamann.de/2010/03/23/groovy-eclipse-plugin-wins-award-for-best-open-source-developer-tool/" title="Groovy Eclipse Plugin wins award for Best Open Source Developer Tool"></a><p>At <a href="http://eclipsecon.org/">EclipseCon 2010</a> the <a href="http://groovy.codehaus.org/Eclipse+Plugin" target="_blank">Groovy Eclipse Plugin</a> wins the award for the Best Open Source Developer Tool.</p>
<p>This is very nice since the version 2.0.1 offers much of the features you know from the Java Editor:</p>
<ul>
<li>Syntax Highlighting</li>
<li>Code Completion</li>
<li>Refactoring</li>
<li>Navigation</li>
<li>Compile as you type</li>
<li>and much more&#8230;</li>
</ul>
<p>If you are interested and understand the german language you can read my article about the <a href="http://it-republik.de/jaxenter/artikel/Nahtlose-Integration-von-Java-und-Groovy-2951.html" target="_blank">Groovy Eclipse Plugin published at Jaxenter</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thorsten-kamann.de/2010/03/23/groovy-eclipse-plugin-wins-award-for-best-open-source-developer-tool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Groovy&#039;s Elvis and Safe-Navigation Operator in Java 7</title>
		<link>http://www.thorsten-kamann.de/2009/08/31/elvis-and-safe-navigation-operator-in-java-7/</link>
		<comments>http://www.thorsten-kamann.de/2009/08/31/elvis-and-safe-navigation-operator-in-java-7/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 09:51:57 +0000</pubDate>
		<dc:creator>thorque</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[Java 7]]></category>

		<guid isPermaLink="false">http://www.thorsten-kamann.de/wordpress/?p=236</guid>
		<description><![CDATA[<a href="http://www.thorsten-kamann.de/2009/08/31/elvis-and-safe-navigation-operator-in-java-7/" title="Groovy&#039;s Elvis and Safe-Navigation Operator in Java 7"></a>Both operators are implemented in Groovy to shorten the code. The Elvis Operator shorten your if-conditions. You know the common ternary expression: def gender = user.male ? "male": "female" This you can shorten with the Elvis operator: def gender = &#8230;<p class="read-more"><a href="http://www.thorsten-kamann.de/2009/08/31/elvis-and-safe-navigation-operator-in-java-7/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://www.thorsten-kamann.de/2009/08/31/elvis-and-safe-navigation-operator-in-java-7/" title="Groovy&#039;s Elvis and Safe-Navigation Operator in Java 7"></a><p>Both operators are implemented in Groovy to shorten the code.<br />
The Elvis Operator shorten your if-conditions. You know the common <a href="http://java.sun.com/docs/books/tutorial/java/nutsandbolts/op2.html" target="_blank">ternary expression</a>:</p>
<pre escaped="erte" lang="groovy">def gender = user.male ? "male": "female"</pre>
<p>This you can shorten with the Elvis operator:</p>
<pre escaped="erte" lang="groovy">def gender = user.male ?: "female"</pre>
<p>Only if the expression evaluates to <em>false </em>or <em>null </em>the default value (here: <em>female</em>) will be used.</p>
<p>The other operator is the Safe-Navigation Operator. If you are working with Java Beans and their getter methods you have often a chain of calls:</p>
<pre escaped="erte" lang="java">customer.getAddress().getCity();</pre>
<p>This works fine until one of the getters return null. Then you get a NullPointerException. To avoid this you can surround this call with a try-catch block:</p>
<pre escaped="erte" lang="java">try{
   customer.getAddress().getCity();
}catch (NullPointerException npe){
   //what can I do here???
}</pre>
<p>This are at least 5 lines of code for catching the NullPointerException. But what can you do with this exception? Commonly you do nothing. You can log this or redirect this exception to the next tier. In Groovy there is the Safe-Navigation Operator:</p>
<pre escaped="erte" lang="groovy">customer?.address?.city</pre>
<p>At first in Groovy you can use the properties instead of accessing the getter methods. The ?. operator checks if the expression on the left hand is null. If true the complete expession evaluates to null.</p>
<p>For this both operators there is an <a href="http://mail.openjdk.java.net/pipermail/coin-dev/2009-March/000047.html" target="_blank">proposal</a> for a change in the Java Programming language. <a href="http://blogs.sun.com/darcy/entry/project_coin_final_five" target="_blank">For now this proposal is not accepted</a>&#8230;but we hope so <img src='http://www.thorsten-kamann.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.thorsten-kamann.de/2009/08/31/elvis-and-safe-navigation-operator-in-java-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GR8Conf Slides available on Slideshare</title>
		<link>http://www.thorsten-kamann.de/2009/06/25/gr8conf-slides-available-on-slideshare/</link>
		<comments>http://www.thorsten-kamann.de/2009/06/25/gr8conf-slides-available-on-slideshare/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 10:19:05 +0000</pubDate>
		<dc:creator>thorque</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[groovy]]></category>

		<guid isPermaLink="false">http://www.thorsten-kamann.de/wordpress/?p=234</guid>
		<description><![CDATA[<a href="http://www.thorsten-kamann.de/2009/06/25/gr8conf-slides-available-on-slideshare/" title="GR8Conf Slides available on Slideshare"></a>The slides from the Groovy and Grails conference in May 2009 are available on Slideshare: http://www.slideshare.net/gr8conf/presentations Enjoy]]></description>
			<content:encoded><![CDATA[<a href="http://www.thorsten-kamann.de/2009/06/25/gr8conf-slides-available-on-slideshare/" title="GR8Conf Slides available on Slideshare"></a><p>The slides from the Groovy and Grails conference in May 2009 are available on Slideshare:</p>
<p><a href="http://www.slideshare.net/gr8conf/presentations" target="_blank">http://www.slideshare.net/gr8conf/presentations</a></p>
<p>Enjoy <img src='http://www.thorsten-kamann.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.thorsten-kamann.de/2009/06/25/gr8conf-slides-available-on-slideshare/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring and Annotations</title>
		<link>http://www.thorsten-kamann.de/2008/03/29/spring-and-annotations/</link>
		<comments>http://www.thorsten-kamann.de/2008/03/29/spring-and-annotations/#comments</comments>
		<pubDate>Sat, 29 Mar 2008 22:16:32 +0000</pubDate>
		<dc:creator>thorque</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Posts]]></category>
		<category><![CDATA[Annotation]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://www.thorsten-kamann.de/wordpress/?p=15</guid>
		<description><![CDATA[<a href="http://www.thorsten-kamann.de/2008/03/29/spring-and-annotations/" title="Spring and Annotations"></a>The Spring-Framework is a non-invasive framework. This means you can develop pure POJOs without any dependencies to the framework. You don&#8217;t need implement any interface nor you need to extend any base classes. However there are a lot of useful &#8230;<p class="read-more"><a href="http://www.thorsten-kamann.de/2008/03/29/spring-and-annotations/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://www.thorsten-kamann.de/2008/03/29/spring-and-annotations/" title="Spring and Annotations"></a><p>The Spring-Framework is a non-invasive framework. This means you can develop pure POJOs without any dependencies to the framework. You don&#8217;t need implement any interface nor you need to extend any base classes. However there are a lot of useful classes and interfaces provided by Spring &#8211; do you know the HibernateTemplate? &#8211; so you can use them if you want but you aren&#8217;t forced to use them.</p>
<p>If you remember the Spring 1.x stream without use of these templates make it very difficult to implement DAOs. This is much better with Spring 2 and JPA. For now you need only to inject an EntityManager and use the methods of them. That&#8217;s very nice, because of the EntityManager is a class out of the JPA/EJB3 standard.</p>
<p>Since Spring 2 there are annotation support. Not only standardized annotations are supported. Spring provides his own annotations. This is not so nice, because the use of this annotations makes your PoJos depend on Spring.</p>
<p><span id="more-15"></span></p>
<h3>The Sample</h3>
<p>There are a sample project to this article. You can download it <a title="Download the sample" href="http://www.thorsten-kamann.de/files/samples/sping-annotations/spring-annotations.zip">here</a>. The sample is an Eclipse Project. You need at least 3 plugins to get the sample running:</p>
<ul>
<li>SpringIDE (<a title="SpringIDE" href="http://springide.org/updatesite" target="_blank">http://springide.org/updatesite</a>)</li>
<li>GroovyIDE (<a title="GroovyIDE" href="http://dist.codehaus.org/groovy/distributions/update/" target="_blank">http://dist.codehaus.org/groovy/distributions/update/</a>)</li>
<li>Maven Integration (<a title="Maven Integration" href="http://m2eclipse.sonatype.org/update/" target="_blank">http://m2eclipse.sonatype.org/update/</a>)</li>
</ul>
<p>Additional to these plugins it is recommend to install a native Maven from <a title="Apache Maven" href="http://maven.apache.org" target="_blank">http://maven.apache.org</a>. The embedded Maven of the Maven Integration sometimes have problems with Groovy-based tests. To enable another Maven Installation you can add it in the Preferences (<span style="font-family: courier new,courier;">Window -&gt; Preferences -&gt; Maven -&gt; Installations</span>). After you have prepared your Eclipse you can import the sample and run it with <span style="font-family: courier new,courier;">Run As -&gt; Maven install</span>.</p>
<h3>Spring and Annotations</h3>
<p>Spring supports a lot of annotations. Additional to the standard Java 6 annotations like (<span style="font-family: courier new,courier;">@Resource</span>, <span style="font-family: courier new,courier;">@PostConstruct</span>, <span style="font-family: courier new,courier;">@PreDestroy</span>,&#8230;) there are a number of Spring-Annotations:</p>
<ul>
<li>@Autowired &#8211; injets a resource byType or byName</li>
<li>@Required &#8211; marks a property as mandatory</li>
<li>@Component &#8211; marks a class as Component. This you need for <span style="font-family: courier new,courier;">@Resource</span>, <span style="font-family: courier new,courier;">@Autowired</span></li>
<li>@Service &#8211; similar to <span style="font-family: courier new,courier;">@Component</span></li>
<li>@Controller &#8211; marks a class as Controller for <a title="SpringMVC" href="http://static.springframework.org/spring/docs/2.0.x/reference/mvc.html" target="_blank">SpringMVC</a></li>
<li>&#8230;</li>
</ul>
<p>If you want to use dependency injection with annotations you can</p>
<pre lang="java">package testprojects.spring.annotations;

import javax.annotations.Resource;

public class Demo{
  @Resource(name="otherResource")
  private Other resource;
}</pre>
<p>In this case the Java field named with resource should get a reference to another bean with the symbolic name otherResource. To get this work you must define a bean with this symbolic name:</p>
<pre lang="java">import org.springframework.stereotype;

@Component("otherResource")
public class Other{}</pre>
<p>Now we have configured our classes with annotations. But Spring doesn&#8217;t know that he should scan our classes for annotations. This we can do with the element <span style="font-family: courier new,courier;">context:component-scan</span> in an <span style="font-family: courier new,courier;">applicationContext.xml</span>:</p>
<p>At the start of the ApplicationContext of Spring all classes in the package <span style="font-family: courier new,courier;">testprojects.spring.annotations</span> will be scanned for annotations. If Spring found any the context will be build &#8211; similar to the <span style="font-family: courier new,courier;">XmlApplicationContext</span></p>
<p>.</p>
<h3>The Problem</h3>
<p>If you take a closer look at the class <span style="font-family: courier new,courier;">Other </span>you will see the import of¬† <span style="font-family: courier new,courier;">org.springframework.stereotype</span>. This will make the class depend to the Spring Framework. Thats very bad, because we won&#8217;t have such a dependency. But what we can do?  The solution is quite simple. Let us define our own annotation for this case and re-configure Spring in that way that our annotation instead teh Spring one will be used to mark classes as <span style="font-family: courier new,courier;">Components</span>.  The definition of the annotation is simple and a one-to-one copy of the original annotation provided by Spring:</p>
<pre lang="java">package testprojects.spring.annotations;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.springframework.stereotype.Repository;

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Component {

  /**
  * The value may indicate a suggestion for a logical component name, to be
  * turned into a Spring bean in case of an autodetected component.
  *
  * @return the suggested component name, if any
  */
  String value() default "";
}</pre>
<p>The next step is to tell Spring that he doesn&#8217;t use its own <span style="font-family: courier new,courier;">@Component</span>-Annotation but our annotation. This can do with the <span style="font-family: courier new,courier;">context:component-scan</span> element, too:</p>
<p>The important changes are the attribute<span style="font-family: courier new,courier;"> use-default-filters</span>. If you set this to false, Spring ommit his own annotations. In this case you can define you own annotation classes with the c<span style="font-family: courier new,courier;">ontext:include-filter</span> element.</p>
<h3>And now&#8230; a sample</h3>
<p>Now we want it get together. To demonstrate the mechnism we want to create an own Annotation as replacement for the Spring @Service-Annotation. Then we mark a PoJo with this annotation and write a Unittest to verify that Spring use this class as Spring-Bean.</p>
<h4>1. Create the Service-Annotation</h4>
<pre lang="java">package testprojects.spring.annotations.Service;

@Target( { ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component
public @interface MyService {

  /**
  * The value may indicate a suggestion for a logical component name, to be
  * turned into a Spring bean in case of an autodetected component.
  *
  * @return the suggested component name, if any
  */
  String value() default "";
}</pre>
<h4>2. Add this annotation to our class</h4>
<pre lang="java">import testprojects.spring.annotations.Service;

@MyService
public class ServiceBean {

}</pre>
<h4>3. Re-configure Spring to use the @MyService-Annotation</h4>
<pre lang="xml">&lt;beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:p="http://www.springframework.org/schema/p"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
   http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"&gt;

   &lt;context:component-scan
     base-package="testprojects.spring.annotations" use-default-filters="false"&gt;
     &lt;context:include-filter
         expression="testprojects.spring.annotations.Service"
         type="annotation" /&gt;
    &lt;/context:component-scan&gt;
&lt;/beans&gt;</pre>
<h4>4. Write a Unittest to verify that Spring is using the annotated class as SpringBean</h4>
<pre lang="groovy">@RunWith(SpringJUnit4ClassRunner)
@ContextConfiguration
public class ServiceAnnotationTest{

  @Autowired
  ServiceBean serviceBean

  @Test
  final void testServiceAnnotation(){
    Assert.assertNotNull(serviceBean)
  }
}</pre>
<p>bcbcbc</p>
<p><img id="kosa-target-image" style="position: absolute; visibility: hidden; z-index: 2147483647; left: 44px; top: 2361px;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAUCAYAAACJfM0wAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAK8AAACvABQqw0mAAAAB90RVh0U29mdHdhcmUATWFjcm9tZWRpYSBGaXJld29ya3MgOLVo0ngAAAAWdEVYdENyZWF0aW9uIFRpbWUAMDQvMDQvMDhrK9wWAAACMElEQVQ4ja3SP2gTcRQH8O8vvUtIGmkqTY3SaMVFz6KDW2ywg4s4dGgXp3SyVLIIthCKQxCCuoZaXaSO/ilKd4sSdXRL0EWtIRYaSkXsJTH33utwSZM01xo0D353v+N+97l33/upQCAwFgwGfehiFYtFUxsYGPCmUqmv3YQTicSwBgCapnXTBQBoSinout5VVCnVDr/44B/OZH0xs6KMThCfR3LRs+aTycjvbwfCmawvduZkn7EwN4TBfheY90fXN6uYuffdyGQRu3apkmyDmzM2K8pYmBvC6kcLK+/KMEsWLCIQMSyLULUIFhH0HsGNycNYnDuO6PRno9lQSsFVh+tDQSEY6MHymzJKFQILgxkgYhALmBnMDLNsIf1sA8cG3VDYYzhFAWWfRBjCAiIbIxYQE1ga17+2GSICKLQYznCtiATEDK6BIrU5MUhgd0+NH+AIt+5jshdqgkpVwEwNkBgs9lyE4XY3nnLMWNf13QEAG1uE2JVe9PUC5JCvCMPrVpifOor1YnW34/pw7NjvVbmZ+3ljcTaMq5EjbRFJ07Gw8QfTd9fg96rc3o7bMh4f9SytvDenLl7/ZADAl5cjWF7dwmy60PaSeiPjo56lv2Ycnzi0Fp9AEgAu39x8+urtT9x5/GP74a2++LlTuumo76kDd4W9ALj9qIDIiOfBhdO+jtB9O279TFcuet77fD7Wn+sU7ajj1+kTSccb/wv/aymloEKh0Fg4HPZ2E87n86Udvs4FoWqwSHUAAAAASUVORK5CYII=" alt="" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thorsten-kamann.de/2008/03/29/spring-and-annotations/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

