<?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>Martin Ahrer - Together we&#039;ll make IT</title>
	<atom:link href="http://www.martinahrer.at/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.martinahrer.at</link>
	<description>Java Enterprise Softwareentwicklung und Consulting</description>
	<lastBuildDate>Sun, 11 Dec 2011 16:19:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<meta name="generator" content="deSignum 0.8.1" />
		<item>
		<title>Migrate from Hades to Spring Data JPA</title>
		<link>http://www.martinahrer.at/2011/09/13/migrate-from-hades-to-spring-data-jpa/</link>
		<comments>http://www.martinahrer.at/2011/09/13/migrate-from-hades-to-spring-data-jpa/#comments</comments>
		<pubDate>Tue, 13 Sep 2011 19:27:44 +0000</pubDate>
		<dc:creator>Martin Ahrer</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[hades]]></category>
		<category><![CDATA[spring-data-jpa]]></category>

		<guid isPermaLink="false">http://www.martinahrer.at/?p=818</guid>
		<description><![CDATA[For the past 18 months I have been utilizing hades for implementing JPA based repositories/DAOs. Hades has now been moved into the Spring Data JPA project. Starting with their 1.0.1 release I tried migrating one of my projects to this release. Following I document the steps that were necessary to achieve this. Their project page [...]]]></description>
			<content:encoded><![CDATA[<p>For the past 18 months I have been utilizing <a href="http://redmine.synyx.org/projects/hades">hades</a> for implementing JPA based repositories/DAOs. Hades has now been moved into the <a href="http://www.springsource.org/spring-data/jpa">Spring Data JPA</a> project. Starting with their 1.0.1 release I tried migrating one of my projects to this release. Following I document the steps that were necessary to achieve this.</p>
<p>Their project page starts off with showing the Maven repositories and dependency descriptors (in case you are using Maven). Obviously the first thing is to replace the hades artifact by the spring-data-jpa artifact.</p>
<h2>Domain classes, JPA entities</h2>
<p>The project&#8217;s domain classes implement the <code>org.synyx.hades.domain.Persistable</code> interface which has to be replaced by <code>org.springframework.data.domain.Persistable</code> (takes a single generics parameter for the id type).</p>
<h2>CRUD repositories</h2>
<p>DAO interfaces extending <code>org.synyx.hades.dao.GenericDao</code> have to be modified to extend <code>org.springframework.data.repository.CrudRepository</code>. With this modification you will face a couple of compile problems. <code>read*</code>-methods have been renamed to <code>find*</code>-methods. Also you are loosing the paging and sorting capable <code>find*</code> &#8211; methods (which I didn&#8217;t use). If those are required then extend the <code>org.springframework.data.repository.PagingAndSortingRepository</code> interface.</p>
<p><code>find*</code> &#8211; methods now return iterables rather than list types requiring minor adjustments to existing codebase. To get around this, the interface can also extend from <code>JpaRepository</code>. Using this base interface hands you a pretty powerful DAO that goes far beyond a simple CRUD repository.</p>
<h2>CRUD repository instantiation</h2>
<p>When I started off with hades many month ago I used an explicit XML-based configuration of DAO components.</p>
<pre class="brush:xml">
&lt;bean id="addressDao" class="org.synyx.hades.dao.orm.GenericDaoFactoryBean" p:daoInterface="at.martinahrer.training.spring.jpa.dao.hades.AddressDao" /&gt;
</pre>
<p>For migration the factory bean class has to be changed:</p>
<pre class="brush:xml">
&lt;bean id="addressDao" class="org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean" p:daoInterface="at.martinahrer.training.spring.jpa.dao.hades.AddressDao" /&gt;</pre>
<p>With these changes in place all tests were showing the green bar again. However, today I would recommend using repository namespace http://www.springframework.org/schema/data/jpa which significantly reduces the amount of configuration needed by utilizing class path scanning to detect repository components.</p>
<pre class="brush:xml">
&lt;repository:repositories base-package="at.martinahrer.training.spring.jpa.dao" /&gt;
</pre>
<p>Certainly you might encounter more steps during migration depending on the features you have used from the old hades code base. In my case I only had used named JPA queries which just continued to work like before.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinahrer.at/2011/09/13/migrate-from-hades-to-spring-data-jpa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Analyzing class metadata with the Springframework</title>
		<link>http://www.martinahrer.at/2011/08/16/analyzing-class-metadata-with-the-springframework/</link>
		<comments>http://www.martinahrer.at/2011/08/16/analyzing-class-metadata-with-the-springframework/#comments</comments>
		<pubDate>Tue, 16 Aug 2011 20:11:45 +0000</pubDate>
		<dc:creator>Martin Ahrer</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Bytecode]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Springframework]]></category>

		<guid isPermaLink="false">http://www.martinahrer.at/?p=805</guid>
		<description><![CDATA[What a shame I haven&#8217;t published anything for a long time. To make up for this long pause, I&#8217;m going to discuss how Spring can support with analyzing class metadata. These days everybody is crazy about using annotations in their frameworks. Occasionally you need to know what classes/methods are annotated. A good example might be [...]]]></description>
			<content:encoded><![CDATA[<p>What a shame I haven&#8217;t published anything for a long time. To make up for this long pause, I&#8217;m going to discuss how Spring can support with analyzing class metadata. These days everybody is crazy about using annotations in their frameworks. Occasionally you need to know what classes/methods are annotated. A good example might be to build a list of class names for all JPA entities (those classes annotated with javax.persistence.Entity and the like).</p>
<p><strong>A simple use-case showing how to detect classes annotated as components</strong></p>
<p>This use-case is using a few Spring APIs and some home grown code that controls resource matching (ClassResourceResolver and AnnotationMetadataMatcher).</p>
<pre class="brush:java">
import java.io.IOException;

import org.junit.Assert;
import org.junit.Test;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import org.springframework.util.ClassUtils;

public class ClassResourceResolverTest {
	@Test
	public void testSelect() throws IOException {
		// given
		ClassResourceResolver scanner = new ClassResourceResolver(
				ClassUtils.convertClassNameToResourcePath(AComponent.class.getPackage().getName()));
		final MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(
				new PathMatchingResourcePatternResolver());

		// when
		String[] classNames = scanner.select(new AnnotationMetadataMatcher(metadataReaderFactory, false,
				Component.class));
		// then
		Assert.assertArrayEquals(new String[] { AComponent.class.getName() }, classNames);
		Assert.assertTrue(metadataReaderFactory.getMetadataReader(classNames[0]).getAnnotationMetadata()
				.isAnnotated(Component.class.getName()));
	}
}

@Component
class AComponent {
}

@Repository
class ARepository {
}
</pre>
<p><strong>ClassResourceResolver is doing the resource matching all from a set of resource paths</strong></p>
<pre class="brush:java">
	public String[] select(ClassResourceMetadataMatcher matcher) throws IOException {
		List&lt;String&gt; result = new ArrayList&lt;String&gt;();

		for (String path : resourcePath) {
			String resourcePattern = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + path + "/**/*.class";
			Resource[] resources = this.resourcePatternResolver.getResources(resourcePattern);
			for (Resource resource : resources) {
				if (resource.isReadable()) {
					MetadataReader reader = matcher.match(resource, resourcePatternResolver);
					if (reader != null) {
						result.add(reader.getClassMetadata().getClassName());
					}
				}
			}
		}
		return result.toArray(new String[result.size()]);
	}
</pre>
<p><strong>A ClassResourceMetadataMatcher is looking at the annotations present on a class resource</strong></p>
<pre class="brush:java">
	@Override
	public MetadataReader match(Resource resource, ResourceLoader resolver) throws IOException {
		for (Class&lt;? extends Annotation&gt; annotationType : annotationTypes) {
			MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
			if (new AnnotationTypeFilter(annotationType, considerMetaAnnotations).match(metadataReader,
					metadataReaderFactory)) {
				return metadataReader;
			}
		}
		return null;
	}
</pre>
<p>Under the hood Spring is using the <a href="http://asm.ow2.org/">ASM</a> bytecode library for looking into the class files. Not that no class examined by the code above is actually loading any of the class objects so it is fairly lightweight and not filling up your perm gen space. Still you need to make up useful search paths so you don&#8217;t end up scanning through you full classpath.</p>
<p>The full code just is available as a gist
<pre class="brush:bash">git clone git@gist.github.com:73f21e68d24032ad7672.git</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.martinahrer.at/2011/08/16/analyzing-class-metadata-with-the-springframework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Git Workshop mit Matthew McCullough (Github Trainer)</title>
		<link>http://www.martinahrer.at/2011/03/23/git-workshop-mit-matthew-mccullough/</link>
		<comments>http://www.martinahrer.at/2011/03/23/git-workshop-mit-matthew-mccullough/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 20:02:32 +0000</pubDate>
		<dc:creator>Martin Ahrer</dc:creator>
				<category><![CDATA[Workshop]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[GitHub]]></category>

		<guid isPermaLink="false">http://www.martinahrer.at/?p=707</guid>
		<description><![CDATA[Subversion, das wohl immer noch am weitesten verbreitete SCM im Java-Bereich, muss sich in letzter Zeit einige Kritik gefallen lassen. Tatsächlich häufen sich die Anzeichen, dass die Konkurrenten aus dem Lager der verteilten Systeme immer mehr an Popularität gewinnen. So wechseln immer mehr Projekte auf das verteilte Versionsmanagementsystem (DVCS) Git.Ist das nur ein temporärer Hype [...]]]></description>
			<content:encoded><![CDATA[<p>Subversion, das wohl immer noch am weitesten verbreitete SCM im Java-Bereich, muss sich in letzter Zeit einige Kritik gefallen lassen.<br />
Tatsächlich häufen sich die Anzeichen, dass die Konkurrenten aus dem Lager der verteilten Systeme immer mehr an Popularität gewinnen. So wechseln immer mehr Projekte auf das verteilte Versionsmanagementsystem (DVCS) Git.Ist das nur ein temporärer Hype oder eine technologische (R)Evolution?</p>
<p>Am 4.Mai 2011 gibt es erstmals in Österreich einen Git Workshop mit Matthew McCullough (offizieller GitHub Trainer) und somit eine einmalige Gelegenheit zu erfahren was denn hinter dem Erfolg von Git steckt.</p>
<ul>
<li>mit <strong>Matthew McCullough</strong></li>
<li>am <strong>4. Mai 2011, von 9:00-16:30</strong></li>
<li><strong>Spitz Hotel</strong> &#8211; Raum “Round Table 2”<br />
Fiedlerstrasse 6,  4040 Linz<br />
<a href="http://www.spitzhotel.at/">http:// www.spitzhotel.at</a></li>
<li><a href="http://www.martinahrer.at/wp-content/uploads/2011/03/Git-Workshop.pdf" target="_blank" >Trainingsprogramm (Broschüre)</a></li>
<li>€330,00 (zuzüglich Mwst.)</li>
</ul>
<p>Anmeldung per EMail (mit Name und Adresse des anzumeldenden Teilnehmers) an <a href="mailto:office@martinahrer.at?subject=Anmeldung zum Git Workshop mit Matthew McCullough">office@martinahrer.at</a>.  Zum Workshop in Englisch werden maximal 20 Teilnehmer zugelassen, ein eigener Laptop ist mitzunehmen. </p>
<p><strong>Anmeldung von Gruppen ab 3 Personen zu ermäßigtem Preis</strong> auf Anfrage. Im Preis enthalten sind Getränke sowie ein Brötchenbuffet zu Mittag! Ermäßigtes Parken in der Hoteltiefgarage ist möglich.</p>
<p><p><a href="mailto:office@martinahrer.at?subject=Anmeldung zum Git Workshop mit Matthew McCullough" class="btn btn-small" >Zur Anmeldung</a></p>
 <span id="more-707"></span><br />
<br/><br />
<strong>Matthew McCullough’s Bio</strong><br />
<img alt="Matthew McCullough" src="https://d3nwyuy0nl342s.cloudfront.net/images/modules/training/McCullough.jpg" title="Matthew McCullough" class="alignleft" width="130" height="170" />Matthew McCullough is an energetic 15 year veteran of enterprise software development, world-traveling open source educator, and co-founder of Ambient Ideas, LLC, a US consultancy. Matthew currently is a trainer for GitHub.com, author of the Git Master Class series for O&#8217;Reilly, speaker on the No Fluff Just Stuff tour, author of three of the top 10 DZone RefCards, including the Git RefCard, and President of the Denver Open Source Users Group.<br />
His current topics of research center around project automation: build tools (Maven, Leiningen, Gradle), distributed version control (Git), Continuous Integration (Hudson) and Quality Metrics (Sonar).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinahrer.at/2011/03/23/git-workshop-mit-matthew-mccullough/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing static methods…</title>
		<link>http://www.martinahrer.at/2011/01/19/testing-static-methods/</link>
		<comments>http://www.martinahrer.at/2011/01/19/testing-static-methods/#comments</comments>
		<pubDate>Wed, 19 Jan 2011 11:46:42 +0000</pubDate>
		<dc:creator>Martin Ahrer</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Test]]></category>

		<guid isPermaLink="false">http://www.martinahrer.at/?p=685</guid>
		<description><![CDATA[We all have learned that it is not wise to overuse static methods as these are kind of hard to test and deal with. So in general I strive to get out of their way. Sometimes I&#8217;m facing the situation that the use of a framework or that some technical infrastructure requires me to implement [...]]]></description>
			<content:encoded><![CDATA[<p>We all have learned that it is not wise to overuse static methods as these are kind of hard to test and deal with. So in general I strive to get out of their way. Sometimes I&#8217;m facing the situation that the use of a framework or that some technical infrastructure requires me to implement static methods.<br />
So for testing I found <a href="https://code.google.com/p/powermock/">PowerMock</a> which nicely integrates with <a href="https://code.google.com/p/powermock/wiki/EasyMock">EasyMock</a> and Mockito.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinahrer.at/2011/01/19/testing-static-methods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActiveMQ in embedded mode</title>
		<link>http://www.martinahrer.at/2010/10/19/activemq-in-embedded-mode/</link>
		<comments>http://www.martinahrer.at/2010/10/19/activemq-in-embedded-mode/#comments</comments>
		<pubDate>Tue, 19 Oct 2010 20:41:38 +0000</pubDate>
		<dc:creator>Martin Ahrer</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[ActiveMQ]]></category>
		<category><![CDATA[Springframework]]></category>

		<guid isPermaLink="false">http://www.martinahrer.at/?p=665</guid>
		<description><![CDATA[I&#8217;m using Apache ActiveMQ for testing JMS based code. With their Springframework support it&#8217;s pretty simple to embed it into a test suite. Today I encountered a strange problem. After I had broken my test and fixed the bug later I was not able to restart the embedded ActiveMQ container. Obviously java.io.EOFException: Chunk stream does [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m using Apache ActiveMQ for testing JMS based code. With their Springframework support it&#8217;s pretty simple to embed it into a test suite.<br />
Today I encountered a strange problem. After I had broken my test and fixed the bug later I was not able to restart the embedded ActiveMQ container.</p>
<p>Obviously <strong>java.io.EOFException: Chunk stream does not exist at page: 0</strong> sounds like some temporary file data was corrupt. <code>JobSchedulerStore</code> creates a directory <code>activemq-data/localhost/scheduler</code> for storing scheduler data. Clean/delete that and it should be startable again. If you don&#8217;t need that then you are better off with completely deactivating that feature.<br />
<span id="more-665"></span></p>
<pre class="brush:xml">
	&lt;amq:broker useJmx="true" persistent="false" start="false" schedulerSupport="true"&gt;
		&lt;amq:transportConnectors&gt;
			&lt;amq:transportConnector uri="${amq.brokerURL}" /&gt;
		&lt;/amq:transportConnectors&gt;
	&lt;/amq:broker&gt;
</pre>
<p>Also its helpful to disable automatic start of the queue container so the test can fully control it.</p>
<pre class="brush:java">
public class ServiceOperationsJmsProducerTest extends AbstractJUnit4SpringContextTests implements BrokerServiceAware {
	private BrokerService brokerService;

	@Test
	public void testProducer() throws Exception {
		try {
			brokerService.start();
			// do the testing
		} finally {
			brokerService.stop();
			brokerService.waitUntilStopped();
		}
	}

	@Override
	@Resource
	public void setBrokerService(BrokerService brokerService) {
		this.brokerService = brokerService;
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.martinahrer.at/2010/10/19/activemq-in-embedded-mode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AspectJ runtime weaving within a Maven build</title>
		<link>http://www.martinahrer.at/2010/10/16/aspectj-runtime-weaving-within-a-maven-build/</link>
		<comments>http://www.martinahrer.at/2010/10/16/aspectj-runtime-weaving-within-a-maven-build/#comments</comments>
		<pubDate>Sat, 16 Oct 2010 16:11:06 +0000</pubDate>
		<dc:creator>Martin Ahrer</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[AspectJ]]></category>
		<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://www.martinahrer.at/?p=654</guid>
		<description><![CDATA[In order to perform AspectJ runtime weaving, an agent is required. Here we are using the agent (spring-instrument-3.0.3.RELEASE) provided by the Springframework. So for surefire we have to use a command line argument -javaagent: that specifies the JAR file containing the agent. To keep the build portable we copy that artifact to the build directory [...]]]></description>
			<content:encoded><![CDATA[<p>In order to perform AspectJ runtime weaving, an agent is required. Here we are using the agent (spring-instrument-3.0.3.RELEASE) provided by the Springframework. So for surefire we have to use a command line argument -javaagent: that specifies the JAR file containing the agent. To keep the build portable we copy that artifact to the build directory first using the maven-dependency-plugin.<br />
<span id="more-654"></span></p>
<pre class="brush:xml">
&lt;plugin&gt;
	&lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
	&lt;executions&gt;
		&lt;execution&gt;
			&lt;id&gt;copy&lt;/id&gt;
			&lt;phase&gt;process-sources&lt;/phase&gt;
			&lt;goals&gt;
				&lt;goal&gt;copy&lt;/goal&gt;
			&lt;/goals&gt;
			&lt;configuration&gt;
				&lt;artifactItems&gt;
					&lt;artifactItem&gt;
						&lt;groupId&gt;org.springframework&lt;/groupId&gt;
						&lt;artifactId&gt;spring-instrument&lt;/artifactId&gt;
						&lt;version&gt;3.0.3.RELEASE&lt;/version&gt;
					&lt;/artifactItem&gt;
				&lt;/artifactItems&gt;
			&lt;/configuration&gt;
		&lt;/execution&gt;
	&lt;/executions&gt;
&lt;/plugin&gt;
</pre>
<p>We have to pass in the weaving agent to surefire.</p>
<pre class="brush:xml">
&lt;plugin&gt;
	&lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
	&lt;configuration&gt;
		&lt;argLine&gt;-javaagent:${project.build.directory}/dependency/spring-instrument-3.0.3.RELEASE.jar&lt;/argLine&gt;
	&lt;/configuration&gt;
&lt;/plugin&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.martinahrer.at/2010/10/16/aspectj-runtime-weaving-within-a-maven-build/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using a blackberry device as a modem on your Mac</title>
		<link>http://www.martinahrer.at/2010/10/11/using-a-blackberry-device-as-a-modem-on-your-mac/</link>
		<comments>http://www.martinahrer.at/2010/10/11/using-a-blackberry-device-as-a-modem-on-your-mac/#comments</comments>
		<pubDate>Mon, 11 Oct 2010 15:08:25 +0000</pubDate>
		<dc:creator>Martin Ahrer</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Blackberry]]></category>
		<category><![CDATA[macosx]]></category>

		<guid isPermaLink="false">http://www.martinahrer.at/?p=650</guid>
		<description><![CDATA[While on the windows platform it was sufficient to only provide the username and password for the providers APN, with Mac OSX a generic modem phone number is required. This phone number is &#8220;*99***1#&#8220;. For a username and password for the providers APN you have to consult your provider. The user name for A1 (Austria) [...]]]></description>
			<content:encoded><![CDATA[<p>While on the windows platform it was sufficient to only provide the username and password for the providers APN, with Mac OSX a generic modem phone number is required. This phone number is &#8220;<strong>*99***1#</strong>&#8220;.<br />
For a username and password for the providers APN you have to consult your provider.<br />
The user name for A1 (Austria) is <strong>ppp@A1plus.at</strong> with the password <strong>ppp</strong>.</p>
<p>In the &#8220;Advanced&#8221; settings choose &#8220;Research in Motion&#8221; as vendor, &#8220;BlackBerry IP Modem (GSM)&#8221; as model, &#8220;a1.net&#8221; as APN!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinahrer.at/2010/10/11/using-a-blackberry-device-as-a-modem-on-your-mac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Register ActiveMQ Spring namespace with eclipse 3.6</title>
		<link>http://www.martinahrer.at/2010/10/06/register-activemq-spring-namespace-with-eclipse-3-6/</link>
		<comments>http://www.martinahrer.at/2010/10/06/register-activemq-spring-namespace-with-eclipse-3-6/#comments</comments>
		<pubDate>Wed, 06 Oct 2010 19:45:33 +0000</pubDate>
		<dc:creator>Martin Ahrer</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[ActiveMQ]]></category>
		<category><![CDATA[eclipse]]></category>

		<guid isPermaLink="false">http://www.martinahrer.at/?p=633</guid>
		<description><![CDATA[In a earlier post I described how to setup the eclipse XML editor to validate a Spring context file containing the AMQ namespace. Looks like with eclipse 3.6 that does not work anymore, I was not able to actually use a JAR file as location like I used to set this up with eclipse 3.4. [...]]]></description>
			<content:encoded><![CDATA[<p>In a earlier <a href="http://www.martinahrer.at/2009/03/13/register-xml-schema-in-eclipse-xml-catalog/">post</a> I described how to setup the eclipse XML editor to validate a Spring context file containing the AMQ namespace.</p>
<p>Looks like with eclipse 3.6 that does not work anymore, I was not able to actually use a JAR file as location like I used to set this up with eclipse 3.4.<br />
So I&#8217;m directly associating the AMQ namespace with the <a href="http://activemq.apache.org/xml-reference.html">XML schema</a> available from the AMQ project.<br />
<span id="more-633"></span></p>
<pre class="brush:xml; wrap-lines=false">
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&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:jms="http://www.springframework.org/schema/jms"
	xmlns:p="http://www.springframework.org/schema/p"
	xmlns:amq="http://activemq.apache.org/schema/core"

	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
		http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd
		http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"&gt;

	&lt;bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
		p:locations="classpath:jms.properties"&gt;
	&lt;/bean&gt;
	&lt;amq:broker useJmx="true" persistent="false"&gt;
		&lt;amq:transportConnectors&gt;
			&lt;amq:transportConnector uri="${amq.brokerURL}" /&gt;
		&lt;/amq:transportConnectors&gt;
	&lt;/amq:broker&gt;
&lt;/beans&gt;
</pre>
<p>Go to the eclipse XML catalog editor and add a custom entry:</p>
<pre>
Location: http://activemq.apache.org/schema/core/activemq-core-5.4.1.xsd
Key type: Schema location
Key: http://activemq.apache.org/schema/core/activemq-core.xsd
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.martinahrer.at/2010/10/06/register-activemq-spring-namespace-with-eclipse-3-6/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tapestry 5 Workshop</title>
		<link>http://www.martinahrer.at/2010/09/02/tapestry-5-workshop-mit-igor-drobiazko/</link>
		<comments>http://www.martinahrer.at/2010/09/02/tapestry-5-workshop-mit-igor-drobiazko/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 19:58:29 +0000</pubDate>
		<dc:creator>Martin Ahrer</dc:creator>
				<category><![CDATA[Workshop]]></category>

		<guid isPermaLink="false">http://www.martinahrer.at/?p=479</guid>
		<description><![CDATA[Am 2.11.2010 hält Igor Drobiazko (Committer und PMC von Apache Tapestry) in Linz einen Hands-On (Laptop mitbringen) Tagesworkshop zum Thema Tapestry. Die Teilnahme am Workshop kostet €390,00 (exkl. Mwst.). Apache Tapestry ist ein komponentenorientiertes Web-Framework zur Entwicklung von skalierbaren Web-Anwendungen in Java. In dieser Session wird Tapestry vorgestellt und ein innovativer Ansatz zur Entwicklung von [...]]]></description>
			<content:encoded><![CDATA[<p>Am 2.11.2010 hält Igor Drobiazko (Committer und PMC von Apache Tapestry) in Linz einen Hands-On (Laptop mitbringen) Tagesworkshop zum Thema Tapestry. Die Teilnahme am Workshop kostet €390,00 (exkl. Mwst.).</p>
<p><a href="https://www.xing.com/events/tapestry-workshop-igor-drobiazko-committer-pmc-apache-tapestry-556179" class="btn btn-small" target="_blank">Anmeldung</a></p>

<p><span id="more-479"></span><br />
<strong>Apache Tapestry</strong> ist ein komponentenorientiertes Web-Framework zur Entwicklung von skalierbaren Web-Anwendungen in Java. In dieser Session wird Tapestry vorgestellt und ein innovativer Ansatz zur Entwicklung von Web 2.0 &#8211; Anwendungen diskutiert. Es wird demonstriert, wie Tapestry 5 die Mächtigkeit von Java mit der Einfachheit und der Produktivität von Scripting-Lösungen wie Ruby on Rails oder Django kombiniert. Mit Tapestry bekommt man das Beste aus den beiden Welten. Tapestry stellt eine Menge von Features zur Steigerung der Produktivität bereit, die ich in einigen Demos zeigen werde. Weiterhin wird der Vorteil eines komponentenorientierten Frameworks wie Tapestry erläutert.</p>
<p>Dipl.-Informatiker <strong>Igor Drobiazko</strong> ist Committer und PMC von Apache Tapestry. Igor verfügt über extensive Erfahrung in Web-Entwicklung, OSGi, Test-Frameworks und JEE-Architekturen. Er hat das erste deutschsprachige Buch über Tapestry 5 geschrieben und arbeitet gerade an einer Übersetzung seines Buches für Manning Publications. Igor hält Vorträge über das Framework und bloggt auf http://tapestry5.de/.</p>
<h3>Agenda</h3>
<h4>Tapestry-Schnelleinstieg</h4>
<p>- Überblick über Tapestry<br />
- Aufsetzen einer Entwicklungsumgebung<br />
- Erstellen der ersten Tapestry-Anwendung</p>
<h4>Tapestry für Einsteiger</h4>
<p>- Produktivität mit Tapestry während der Entwicklung: Live Class Realoding und Fehlerberichte<br />
- Navigation zwischen Seiten<br />
- Entwicklung von zustandsbehafteten Anwedungen<br />
- Lokalisierung und Internationalisierung<br />
- Entwicklung von Formularen, Validierung von Benutzereingaben<br />
- Behandeln von Anfragen und Actions (Feuern und Behandeln von Ereignissen)</p>
<h4>Tapestry für Fortgeschrittene</h4>
<p>- Entwicklung von wiederverwendbaren Komponenten<br />
- Ajax<br />
- Integration von Hibernate, Java Persistenz API und Spring<br />
- Entwicklung von Benutzerschnittstellen für JavaBeans</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinahrer.at/2010/09/02/tapestry-5-workshop-mit-igor-drobiazko/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Nexus and the Nexus REST API for implementing a software update tool</title>
		<link>http://www.martinahrer.at/2010/05/25/using-nexus-and-the-nexus-rest-api-for-implementing-a-software-update-tool/</link>
		<comments>http://www.martinahrer.at/2010/05/25/using-nexus-and-the-nexus-rest-api-for-implementing-a-software-update-tool/#comments</comments>
		<pubDate>Tue, 25 May 2010 20:03:42 +0000</pubDate>
		<dc:creator>Martin Ahrer</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://www.martinahrer.at/?p=456</guid>
		<description><![CDATA[Nexus is using a pretty well documented REST API which is usable externally as well. For one of my customers I implemented a kind of automatic software update tool that can be embedded into any product. It is based on the Sonatype NEXUS repository manager. That tool performs the following steps Detect the current software [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://nexus.sonatype.org/">Nexus </a> is using a pretty well documented REST API which is usable externally as well.<br />
For one of my customers I implemented a kind of automatic software update tool that can be embedded into any product. It is based on the Sonatype NEXUS repository manager.</p>
<p><span id="more-456"></span></p>
<p>That tool performs the following steps</p>
<ol>
<li>Detect the current software version from the artifact metadata that is embedded into any Maven-built artifact</li>
<li>Query Nexus for available artifacts for the installed software (identified by Maven groupId and artifactId).</li>
<li>Test if any of the available artfacts has a version number higher than the installed one</li>
<li>If a newer version is available then download it</li>
<li>Move the new version to the target directory (e.g. the deployment folder of the application server)</li>
</ol>
<p>The Nexus REST url for a simple query for some artifact looks like <code>http://localhost/nexus/service/local/data_index/repositories/releases/content?q=commons-lang</code>. This query asks for the <em>commons-lang</em> artifact from the <em>releases repository</em>.</p>
<p>More URL schemes are documented <a href="https://docs.sonatype.com/display/NX/Nexus+Rest+API">here</a> and <a href="https://grid.sonatype.org/ci/view/Nexus/job/Nexus/label=ubuntu/ws/trunk/nexus/nexus-rest-api/target/classes/docs/index.html">there</a>.</p>
<p>The result from this query is like (only the latest versions are included for brevity):</p>
<pre class="brush:xml">
&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;search-results&gt;
	&lt;totalCount&gt;5&lt;/totalCount&gt;
	&lt;from&gt;-1&lt;/from&gt;
	&lt;count&gt;-1&lt;/count&gt;
	&lt;tooManyResults&gt;false&lt;/tooManyResults&gt;
	&lt;data&gt;
		&lt;artifact&gt;

			&lt;resourceURI&gt;http://localhost/nexus/service/local/repositories/central/content/commons-lang/commons-lang/2.4/commons-lang-2.4.jar&lt;/resourceURI&gt;
			&lt;groupId&gt;commons-lang&lt;/groupId&gt;
			&lt;artifactId&gt;commons-lang&lt;/artifactId&gt;
			&lt;version&gt;2.4&lt;/version&gt;
			&lt;packaging&gt;jar&lt;/packaging&gt;
			&lt;extension&gt;jar&lt;/extension&gt;

			&lt;repoId&gt;central&lt;/repoId&gt;
			&lt;contextId&gt;Maven Central (Cache)&lt;/contextId&gt;
			&lt;pomLink&gt;http://localhost/nexus/service/local/artifact/maven/redirect?r=central&amp;g=commons-lang&amp;a=commons-lang&amp;v=2.4&amp;e=pom&lt;/pomLink&gt;
			&lt;artifactLink&gt;http://localhost/nexus/service/local/artifact/maven/redirect?r=central&amp;g=commons-lang&amp;a=commons-lang&amp;v=2.4&amp;e=jar&lt;/artifactLink&gt;

		&lt;/artifact&gt;
		&lt;artifact&gt;
			&lt;resourceURI&gt;http://localhost/nexus/service/local/repositories/central/content/commons-lang/commons-lang/2.4/commons-lang-2.4-sources.jar&lt;/resourceURI&gt;
			&lt;groupId&gt;commons-lang&lt;/groupId&gt;
			&lt;artifactId&gt;commons-lang&lt;/artifactId&gt;
			&lt;version&gt;2.4&lt;/version&gt;
			&lt;classifier&gt;sources&lt;/classifier&gt;

			&lt;packaging&gt;jar&lt;/packaging&gt;
			&lt;extension&gt;jar&lt;/extension&gt;
			&lt;repoId&gt;central&lt;/repoId&gt;
			&lt;contextId&gt;Maven Central (Cache)&lt;/contextId&gt;
			&lt;pomLink&gt;&lt;/pomLink&gt;
			&lt;artifactLink&gt;http://localhost/nexus/service/local/artifact/maven/redirect?r=central&amp;g=commons-lang&amp;a=commons-lang&amp;v=2.4&amp;e=jar&amp;c=sources&lt;/artifactLink&gt;

		&lt;/artifact&gt;

	&lt;/data&gt;
&lt;/search-results&gt;
</pre>
<p>That only needs to be parsed using a SAX parser for extracting the most important elements. This is the Maven GAV, packaging, classifier, and  the download url which are stored in a POJO. This POJO implements the algorithm for selecting the latest version by its compareTo method.</p>
<pre class="brush:java">
public class MavenArtifactMetadata implements Comparable&lt;MavenArtifactMetadata&gt; {
	private String groupId;
	private String artifactId;
	private String version;
	private String resourceURI;
	private String packaging;
	private String classifier;

	@Override
	public int compareTo(MavenArtifactMetadata o) {
		if (!this.groupId.equals(o.groupId) || !this.artifactId.equals(o.artifactId)) {
			return -1;
		}
		return versionCompareTo(o.version);
	}

	int versionCompareTo(String version) {
		Integer[] thatVersion = versionComponents(version);
		Integer[] thisVersion = versionComponents(this.version);
		int length = Math.min(thatVersion.length, thisVersion.length);
		for (int i = 0; i < length; i++) {
			if (thatVersion[i].equals(thisVersion[i])) {
				continue;
			}
			return thisVersion[i].compareTo(thatVersion[i]);
		}
		return thisVersion.length - thatVersion.length;
	}

	Integer[] versionComponents(String version) {
		String[] splitted = StringUtils.delimitedListToStringArray(version, ".");
		if (splitted.length>0 &#038;&#038; splitted[splitted.length-1].endsWith("-SNAPSHOT")) {
			splitted[splitted.length-1]=splitted[splitted.length-1].replaceAll("-SNAPSHOT", "");
		}
		Integer[] components = new Integer[splitted.length];
		for (int i = 0; i < splitted.length; i++) {
			components[i] = (Integer.valueOf(splitted[i]));
		}
		return components;
	}
}
</pre>
<p>While implementing the download part I had learned an important lesson. For downloading and moving large files it is much more efficient to use the Java NIO API.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinahrer.at/2010/05/25/using-nexus-and-the-nexus-rest-api-for-implementing-a-software-update-tool/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

