<?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>Developers, Developers, Developers! &#187; example</title>
	<atom:link href="http://maksim.sorokin.dk/it/tag/example/feed/" rel="self" type="application/rss+xml" />
	<link>http://maksim.sorokin.dk/it</link>
	<description>Maksim Sorokin IT Blog</description>
	<lastBuildDate>Sun, 05 Feb 2012 19:37:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>Maven + Apache Felix + CXF + DOSGi: An Example of DOSGi Service</title>
		<link>http://maksim.sorokin.dk/it/2011/09/18/maven-apache-felix-cxf-dosgi-an-example-of-dosgi-service/</link>
		<comments>http://maksim.sorokin.dk/it/2011/09/18/maven-apache-felix-cxf-dosgi-an-example-of-dosgi-service/#comments</comments>
		<pubDate>Sun, 18 Sep 2011 22:04:29 +0000</pubDate>
		<dc:creator>Maksim Sorokin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Apache Felix]]></category>
		<category><![CDATA[DOSGi]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[web services]]></category>

		<guid isPermaLink="false">http://maksim.sorokin.dk/it/?p=827</guid>
		<description><![CDATA[Link in series Link to two Felix instances Here is yet another post in Maven + Apache Felix + CXF + DOSGi series. Here I will show how to use Apache CXF DOSGi for cosuming remote services. You may see the sources on my GitHub account. We will have three projects dosgiRemote.service, dosgiRemote.service.api and dosgiRemote.consumer. [...]]]></description>
			<content:encoded><![CDATA[<p>Link in series</p>
<p>Link to two Felix instances</p>
<p>Here is yet another post in <a href="http://maksim.sorokin.dk/it/2011/07/19/maven-apache-felix-cxf-dosgi-series/">Maven + Apache Felix + CXF + DOSGi series</a>.</p>
<p>Here I will show how to use <a href="http://cxf.apache.org/dosgi-releases.html">Apache CXF DOSGi</a> for cosuming remote services. You may see the sources on <a href="https://github.com/mah01/examples/tree/master/dosgiRemote">my GitHub account</a>.</p>
<p>We will have <span id="more-827"></span> three projects <code>dosgiRemote.service</code>, <code>dosgiRemote.service.api</code> and <code>dosgiRemote.consumer</code>. <code>dosgiRemote.service.api</code> provides an interface for a service. <code>dosgiRemote.service</code> provides implementation for the service. <code>dosgiRemote.consume</code> will consume the service.<br />
<code>dosgiRemote.service.api</code> has to be shared between <code>dosgiRemote.service</code> and <code>dosgiRemote.consumer</code> as both has to know which service they are publishing and consuming. <code>dosgiRemote.service.api</code> and <code>dosgiRemote.service</code> will run in one OSGi container. <code>dosgiRemote.service.api</code> and <code>dosgiRemote.consumer</code> will run in another OSGi container. You may see how to do that in Eclipse in the <a href="http://maksim.sorokin.dk/it/2011/08/11/apache-felix-running-two-instances-of-felix-launcher-in-the-eclipse/">previous post</a>.</p>
<p><code>dosgiRemote.service.api</code> contains the following interface to a service:</p>
<pre class="brush: java; title: ;">
package dk.sorokin.maksim.dosgiRemote.service.api;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path(&quot;greeter&quot;)
public interface Greeter {

  @GET
  @Path(&quot;sayHello/{name}&quot;)
  @Produces(MediaType.TEXT_PLAIN)
  String sayHello(@PathParam(&quot;name&quot;) String name);
}
</pre>
<p><code>dosgiRemote.service</code> provides the following implementation:</p>
<pre class="brush: java; title: ;">
package dk.sorokin.maksim.dosgiRemote.internal.service;

import dk.sorokin.maksim.dosgiRemote.service.api.Greeter;

public class GreeterImpl implements Greeter {

  public String sayHello(String name) {
    return &quot;Hello, &quot; + name;
  }
}
</pre>
<p>Also, <code>dosgiRemote.service</code> registers a service in the following way:</p>
<pre class="brush: java; title: ;">
package dk.sorokin.maksim.dosgiRemote.internal;

import java.util.Dictionary;
import java.util.Hashtable;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

import dk.sorokin.maksim.dosgiRemote.internal.service.GreeterImpl;
import dk.sorokin.maksim.dosgiRemote.service.api.Greeter;

public class Activator implements BundleActivator {

  public void start(BundleContext context) throws Exception {
    Dictionary&lt;String, String&gt; restProps = new Hashtable&lt;String, String&gt;();

    restProps.put(&quot;service.exported.interfaces&quot;, &quot;*&quot;);
    restProps.put(&quot;service.exported.configs&quot;, &quot;org.apache.cxf.rs&quot;);
    restProps.put(&quot;service.exported.intents&quot;, &quot;HTTP&quot;);
    restProps.put(&quot;org.apache.cxf.rs.address&quot;, &quot;http://localhost:8080/&quot;);
    context.registerService(Greeter.class.getName(), new GreeterImpl(), restProps);
  }

  public void stop(BundleContext context) throws Exception {
    //
  }
}
</pre>
<p><code>dosgiRemote.consumer</code> will have <code>OSGI-INF\remote-service\remote-services.xml</code>, according to <a href="http://cxf.apache.org/distributed-osgi-reference.html#DistributedOSGiReference-%7B%7Bremoteservices.xml%7D%7Dfiles">DOSGi documentation</a>:</p>
<pre class="brush: xml; title: ;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;service-descriptions xmlns=&quot;http://www.osgi.org/xmlns/sd/v1.0.0&quot;&gt;
  &lt;service-description&gt;
    &lt;provide interface=&quot;dk.sorokin.maksim.dosgiRemote.service.api.Greeter&quot; /&gt;
    &lt;property name=&quot;service.exported.interfaces&quot;&gt;*&lt;/property&gt;
    &lt;property name=&quot;service.exported.configs&quot;&gt;org.apache.cxf.rs&lt;/property&gt;
    &lt;property name=&quot;service.exported.intents&quot;&gt;HTTP&lt;/property&gt;
    &lt;property name=&quot;org.apache.cxf.rs.address&quot;&gt;http://localhost:8080&lt;/property&gt;
  &lt;/service-description&gt;
&lt;/service-descriptions&gt;
</pre>
<p>And the Activator class for <code>dosgiRemote.consumer</code> will be:</p>
<pre class="brush: java; title: ;">
package dk.sorokin.maksim.dosgiRemote.consumer.internal;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;

import dk.sorokin.maksim.dosgiRemote.service.api.Greeter;

public class Activator implements BundleActivator {

  @Override
  public void start(BundleContext context) throws Exception {
    ServiceTracker serviceTracker = new ServiceTracker(context, Greeter.class.getName(), null) {
      @Override
      public Object addingService(ServiceReference reference) {
        Object result = super.addingService(reference);

        Object svc = context.getService(reference);
        if (svc instanceof Greeter) {
          final Greeter greeter = (Greeter) svc;
          System.out.println(greeter.sayHello(&quot;Max&quot;));
        }

        return result;
      }
    };
    serviceTracker.open();
  }

  public void stop(BundleContext context) throws Exception {
    //
  }
}
</pre>
<p>We will have two startup configuration for Apache Felix, as described above. The first one:</p>
<pre class="brush: plain; title: ;">
felix.auto.deploy.action=install,start
felix.log.level=1

org.osgi.framework.storage.clean=onFirstInit

felix.auto.start.1 = \
 assembly:/C:/projects/dosgiRemote/dosgiRemote.service.api/target/classes \
 assembly:/C:/projects/dosgiRemote/dosgiRemote.service/target/classes
</pre>
<p>And the second one:</p>
<pre class="brush: plain; title: ;">
felix.auto.deploy.action=install,start
felix.log.level=1

org.osgi.framework.storage.clean=onFirstInit

felix.auto.start.1 = \
 assembly:/C:/projects/dosgiRemote/dosgiRemote.service.api/target/classes \
 assembly:/C:/projects/dosgiRemote/dosgiRemote.service/target/classes
</pre>
<p>Launch the first configuration and then the second. You should see the following message in the console:</p>
<pre class="brush: plain; title: ;">
Hello, Max
</pre>
<p>You could also see the same message in the browser on <a href="http://localhost:8080/greeter/sayHello/Max">http://localhost:8080/greeter/sayHello/Max</a>.</p>
<p>You may pass objects as well. Refer to <a href="http://maksim.sorokin.dk/it/2011/07/24/maven-apache-felix-cxf-creating-a-restful-webservice-with-cxf-returning-and-object/">previous</a> <a href="http://maksim.sorokin.dk/it/2011/07/26/maven-apache-felix-cxf-creating-a-restful-webservice-with-cxf-consuming-an-object/">posts</a> to do that.</p>
<p>You can take the sources from may <a href="https://github.com/mah01/examples/tree/master/dosgiRemote">GitHub account</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://maksim.sorokin.dk/it/2011/09/18/maven-apache-felix-cxf-dosgi-an-example-of-dosgi-service/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mule ESB: Building a Self-Contained Standalone Web App with Maven</title>
		<link>http://maksim.sorokin.dk/it/2011/07/29/mule-esb-building-a-self-contained-standalone-web-app-with-maven/</link>
		<comments>http://maksim.sorokin.dk/it/2011/07/29/mule-esb-building-a-self-contained-standalone-web-app-with-maven/#comments</comments>
		<pubDate>Fri, 29 Jul 2011 10:44:19 +0000</pubDate>
		<dc:creator>Maksim Sorokin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[esb]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[mule]]></category>
		<category><![CDATA[mule esb]]></category>

		<guid isPermaLink="false">http://maksim.sorokin.dk/it/?p=802</guid>
		<description><![CDATA[This example demonstrates how to build standalone self-contained Mule ESB web application, which can be deployed to a Java web container, e.g. Tomcat. The sources used are taken from Mule ESB "hello" example, which is distributed together with Mule. You can obtain the sources from this post on my github: https://github.com/mah01/examples/tree/master/muleHelloStandalone I will just show [...]]]></description>
			<content:encoded><![CDATA[<p>This example demonstrates how to build standalone self-contained Mule ESB web application, which can be deployed to a Java web container, e.g. Tomcat. The sources used are taken from Mule ESB "hello" example, which is distributed together with Mule.</p>
<p>You can obtain the sources from this post on my github:<br />
<a href="https://github.com/mah01/examples/tree/master/muleHelloStandalone">https://github.com/mah01/examples/tree/master/muleHelloStandalone</a></p>
<p>I will just show the keypoints of the application and changes, that were different from "hello" application in Mule distributable.</p>
<p>First of all, the <span id="more-802"></span> <code>pom.xml</code> file. We download all required Mule dependencies in order to run the example. Note, that we use <a href="http://dist.codehaus.org/mule/dependencies/maven2">Mule Maven repository</a>, because for some reason Mule artifacts has transitive dependencies on OSGified versions of certain libraries, which are not contained in <a href="http://repo1.maven.org/maven2/">Maven Central</a>:</p>
<pre class="brush: xml; title: ;">
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
  xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;

  &lt;groupId&gt;dk.sorokin.maksim&lt;/groupId&gt;
  &lt;artifactId&gt;muleHelloStandalone&lt;/artifactId&gt;
  &lt;version&gt;1.0.0-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;

  &lt;name&gt;Self-Contained Standalone Mule Hello World&lt;/name&gt;
  &lt;description&gt;The sources for this application were copied from Mule distributable&lt;/description&gt;

  &lt;properties&gt;
    &lt;mule.version&gt;3.1.2&lt;/mule.version&gt;
  &lt;/properties&gt;

  &lt;build&gt;
    &lt;resources&gt;
      &lt;resource&gt;
        &lt;directory&gt;src/main/app&lt;/directory&gt;
      &lt;/resource&gt;
      &lt;resource&gt;
        &lt;directory&gt;src/main/resources&lt;/directory&gt;
      &lt;/resource&gt;
    &lt;/resources&gt;
  &lt;/build&gt;

  &lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.codehaus.groovy&lt;/groupId&gt;
      &lt;artifactId&gt;groovy-all&lt;/artifactId&gt;
      &lt;version&gt;1.8.1&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;org.mule&lt;/groupId&gt;
      &lt;artifactId&gt;mule-core&lt;/artifactId&gt;
      &lt;version&gt;${mule.version}&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;org.mule&lt;/groupId&gt;
      &lt;artifactId&gt;mule-core&lt;/artifactId&gt;
      &lt;version&gt;${mule.version}&lt;/version&gt;
      &lt;scope&gt;test&lt;/scope&gt;
      &lt;type&gt;test-jar&lt;/type&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;org.mule.modules&lt;/groupId&gt;
      &lt;artifactId&gt;mule-module-builders&lt;/artifactId&gt;
      &lt;version&gt;${mule.version}&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;org.mule.modules&lt;/groupId&gt;
      &lt;artifactId&gt;mule-module-scripting&lt;/artifactId&gt;
      &lt;version&gt;${mule.version}&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;org.mule.transports&lt;/groupId&gt;
      &lt;artifactId&gt;mule-transport-vm&lt;/artifactId&gt;
      &lt;version&gt;${mule.version}&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;org.mule.transports&lt;/groupId&gt;
      &lt;artifactId&gt;mule-transport-servlet&lt;/artifactId&gt;
      &lt;version&gt;${mule.version}&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;org.mule.transports&lt;/groupId&gt;
      &lt;artifactId&gt;mule-transport-stdio&lt;/artifactId&gt;
      &lt;version&gt;${mule.version}&lt;/version&gt;
    &lt;/dependency&gt;
  &lt;/dependencies&gt;

  &lt;repositories&gt;
    &lt;repository&gt;
      &lt;id&gt;mule-deps&lt;/id&gt;
      &lt;name&gt;Mule Dependencies&lt;/name&gt;
      &lt;url&gt;http://dist.codehaus.org/mule/dependencies/maven2&lt;/url&gt;
    &lt;/repository&gt;
  &lt;/repositories&gt;
&lt;/project&gt;
</pre>
<p>And then we also add <code>log4j.properties</code> to <code>src/main/java</code>:</p>
<pre class="brush: plain; title: ;">
log4j.rootLogger=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %-5p %x - %m\n
</pre>
<p>And our <code>web.xml</code> looks like:</p>
<pre class="brush: xml; title: ;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;web-app xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
  xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd&quot;
  version=&quot;3.0&quot;&gt;
  &lt;display-name&gt;mule.esb&lt;/display-name&gt;

  &lt;context-param&gt;
    &lt;param-name&gt;org.mule.config&lt;/param-name&gt;
    &lt;param-value&gt;mule-config.xml&lt;/param-value&gt;
  &lt;/context-param&gt;

  &lt;listener&gt;
    &lt;listener-class&gt;org.mule.config.builders.MuleXmlBuilderContextListener&lt;/listener-class&gt;
  &lt;/listener&gt;
&lt;/web-app&gt;
</pre>
<p>All other sources are copied directly from Mule "hello" example (the whole <code>src</code> folder).</p>
<p>Build the application with maven with <code>mvn clean install</code> and deploy the war to Tomcat (or other container).<br />
Then go to <a href="http://localhost:8888/?name=Max">http://localhost:8888/?name=Max</a>. You should see the following message:</p>
<pre class="brush: plain; title: ;">
Hello Max, how are you?
</pre>
]]></content:encoded>
			<wfw:commentRss>http://maksim.sorokin.dk/it/2011/07/29/mule-esb-building-a-self-contained-standalone-web-app-with-maven/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IzPack with Maven</title>
		<link>http://maksim.sorokin.dk/it/2010/06/10/izpack-with-maven/</link>
		<comments>http://maksim.sorokin.dk/it/2010/06/10/izpack-with-maven/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 07:19:58 +0000</pubDate>
		<dc:creator>Maksim Sorokin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[IzPack]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://maksim.sorokin.dk/it/?p=231</guid>
		<description><![CDATA[What does Maven? Maven builds a project. What does IzPack? IzPack builds an installer. Naturally, one would like to use Maven to control IzPack. Here is an example of a simple application which uses Maven and IzPack to create an installer for an application. We start by creating a pom.xml: &#60;project xmlns=&#34;http://maven.apache.org/POM/4.0.0&#34; xmlns:xsi=&#34;http://www.w3.org/2001/XMLSchema-instance&#34; xsi:schemaLocation=&#34;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&#34;&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>What does <a href="http://maven.apache.org/">Maven</a>? Maven builds a project. What does <a href="http://izpack.org/">IzPack</a>? IzPack builds an installer. Naturally, one would like to use Maven to control IzPack. Here is an example of a simple application which uses Maven and IzPack to create an installer for an application.</p>
<p>We start by creating a <code>pom.xml</code>:<span id="more-231"></span></p>
<pre class="brush: xml; title: ;">
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
  xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;

  &lt;groupId&gt;test&lt;/groupId&gt;
  &lt;artifactId&gt;test18&lt;/artifactId&gt;
  &lt;name&gt;Test IzPack and maven&lt;/name&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;pom&lt;/packaging&gt;

  &lt;properties&gt;
    &lt;staging.dir&gt;${project.build.directory}\staging&lt;/staging.dir&gt;
    &lt;izpack.standalone.compiler.version&gt;4.3.2&lt;/izpack.standalone.compiler.version&gt;
  &lt;/properties&gt;

  &lt;build&gt;
    &lt;plugins&gt;
      &lt;!-- Used to configure IzPack installer --&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;org.codehaus.izpack&lt;/groupId&gt;
        &lt;artifactId&gt;izpack-maven-plugin&lt;/artifactId&gt;
        &lt;version&gt;1.0-alpha-5&lt;/version&gt;
        &lt;executions&gt;
          &lt;execution&gt;
            &lt;phase&gt;package&lt;/phase&gt;
            &lt;goals&gt;
              &lt;goal&gt;izpack&lt;/goal&gt;
            &lt;/goals&gt;
            &lt;configuration&gt;
              &lt;izpackBasedir&gt;${staging.dir}&lt;/izpackBasedir&gt;
            &lt;/configuration&gt;
          &lt;/execution&gt;
        &lt;/executions&gt;
        &lt;dependencies&gt;
          &lt;dependency&gt;
            &lt;groupId&gt;org.codehaus.izpack&lt;/groupId&gt;
            &lt;artifactId&gt;izpack-standalone-compiler&lt;/artifactId&gt;
            &lt;version&gt;${izpack.standalone.compiler.version}&lt;/version&gt;
          &lt;/dependency&gt;
        &lt;/dependencies&gt;
      &lt;/plugin&gt;

      &lt;plugin&gt;
        &lt;artifactId&gt;maven-resources-plugin&lt;/artifactId&gt;
        &lt;version&gt;2.4.2&lt;/version&gt;
        &lt;executions&gt;
          &lt;execution&gt;
            &lt;id&gt;copy-resources&lt;/id&gt;
            &lt;phase&gt;validate&lt;/phase&gt;
            &lt;goals&gt;
              &lt;goal&gt;copy-resources&lt;/goal&gt;
            &lt;/goals&gt;
            &lt;configuration&gt;
              &lt;encoding&gt;UTF-8&lt;/encoding&gt;
              &lt;outputDirectory&gt;${staging.dir}&lt;/outputDirectory&gt;
              &lt;resources&gt;
                &lt;resource&gt;
                  &lt;directory&gt;src/main/resources&lt;/directory&gt;
                &lt;/resource&gt;
              &lt;/resources&gt;
            &lt;/configuration&gt;
          &lt;/execution&gt;
        &lt;/executions&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;
  &lt;/build&gt;
&lt;/project&gt;
</pre>
<p>Provided Maven packaging is <code>pom</code> since we don't want to produce any application jars. IzPack will create a executable jar file by itself.<br />
And we are using two plugings. One is <a href="http://izpack.codehaus.org/izpack-maven-plugin/">Maven IzPack</a> plugin. And another one is used to copy installation files to the "staging" directory. Staging directory it is where all needed resources are copied. Executable jar will be created from it afterwards.</p>
<p>And then in the <code>src/main/resources</code> we create a <code>install.xml</code> configuration file which configures our installation:</p>
<pre class="brush: xml; title: ;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;

&lt;installation version=&quot;1.0&quot;&gt;

  &lt;info&gt;
    &lt;appname&gt;Test Installer&lt;/appname&gt;
    &lt;appversion&gt;1&lt;/appversion&gt;
    &lt;uninstaller write=&quot;no&quot; /&gt;
    &lt;javaversion&gt;1.6&lt;/javaversion&gt;

    &lt;pack200 /&gt;
  &lt;/info&gt;

  &lt;guiprefs resizable=&quot;no&quot; width=&quot;480&quot; height=&quot;360&quot;&gt;
    &lt;laf name=&quot;looks&quot;&gt;
      &lt;param name=&quot;variant&quot; value=&quot;windows&quot; /&gt;
      &lt;os family=&quot;windows&quot; /&gt;
    &lt;/laf&gt;
  &lt;/guiprefs&gt;

  &lt;locale&gt;
    &lt;langpack iso3=&quot;eng&quot; /&gt;
  &lt;/locale&gt;

  &lt;panels&gt;
    &lt;panel classname=&quot;HelloPanel&quot; /&gt;
    &lt;panel classname=&quot;SimpleFinishPanel&quot; /&gt;
  &lt;/panels&gt;

  &lt;packs&gt;
    &lt;pack name=&quot;main&quot; required=&quot;yes&quot;&gt;
      &lt;description&gt;Test Installation&lt;/description&gt;
    &lt;/pack&gt;
  &lt;/packs&gt;

&lt;/installation&gt;
</pre>
<p>All the detailed about this <code>install.xml</code> configuration file can be found on <a href="http://izpack.org/documentation/">IzPack documentation page</a>.</p>
<p>And now we are ready to go. Run <code>mvn install</code> and in <code>target</code> folder you will find an installer! It will consist of two panels -- Hello Panel and Finish Panel. Nothing fancy. But you have to start somewhere!</p>
]]></content:encoded>
			<wfw:commentRss>http://maksim.sorokin.dk/it/2010/06/10/izpack-with-maven/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Multirow and Multicolumn Spanning in Latex</title>
		<link>http://maksim.sorokin.dk/it/2010/05/22/multirow-and-multicolumn-spanning-in-latex/</link>
		<comments>http://maksim.sorokin.dk/it/2010/05/22/multirow-and-multicolumn-spanning-in-latex/#comments</comments>
		<pubDate>Sat, 22 May 2010 08:55:33 +0000</pubDate>
		<dc:creator>Maksim Sorokin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[LaTeX]]></category>

		<guid isPermaLink="false">http://maksim.sorokin.dk/it/?p=161</guid>
		<description><![CDATA[Miltirow and multicolumn table spanning now with colors! or more complex example: And here how we do that for simple variant: \documentclass[12pt]{article} \usepackage{multirow} \usepackage{colortbl} \definecolor{kugray5}{RGB}{224,224,224} \begin{document} \begin{figure} \centering \begin{tabular}{&#124;c&#124;c&#124;c&#124;c&#124;c&#124;c&#124;c&#124;c&#124;c&#124;} \hline \multicolumn{1}{&#124;&#62;{\columncolor{kugray5}}c&#124;}{}&#38;\multicolumn{4}{c&#124;}{Rank}&#38;\multirow{2}{*}{Total}\\ \arrayrulecolor{kugray5} \arrayrulecolor{black} \cline{2-5} \multicolumn{1}{&#124;&#62;{\columncolor{kugray5}}c&#124;}{}&#38;A&#38;B&#38;C&#38;Other&#38;\\ \hline type 2&#38;8&#38;14&#38;5&#38;2&#38;29\\ \hline \end{tabular} \caption{Distribution of the types by rank} \label{fig:typeDistribution} \end{figure} \end{document} And for more complex one: \documentclass[12pt]{article} [...]]]></description>
			<content:encoded><![CDATA[<p>Miltirow and multicolumn table spanning now with colors!</p>
<p><img class="alignnone size-full wp-image-168" src="http://maksim.sorokin.dk/it/wp-content/uploads/2010/04/latex_table_simple1.png" alt="" width="457" height="150" /></p>
<p>or more complex example:</p>
<p><img class="alignnone size-full wp-image-162" src="http://maksim.sorokin.dk/it/wp-content/uploads/2010/04/latex_table.png" alt="" width="489" height="205" /></p>
<p>And here how we do that for simple variant:<span id="more-161"></span></p>
<pre class="brush: plain; title: ;">
\documentclass[12pt]{article}
\usepackage{multirow}
\usepackage{colortbl}
\definecolor{kugray5}{RGB}{224,224,224}

\begin{document}

\begin{figure}
  \centering
  \begin{tabular}{|c|c|c|c|c|c|c|c|c|}
    \hline
    \multicolumn{1}{|&gt;{\columncolor{kugray5}}c|}{}&amp;\multicolumn{4}{c|}{Rank}&amp;\multirow{2}{*}{Total}\\
    \arrayrulecolor{kugray5}
    \arrayrulecolor{black}
    \cline{2-5}
    \multicolumn{1}{|&gt;{\columncolor{kugray5}}c|}{}&amp;A&amp;B&amp;C&amp;Other&amp;\\
    \hline
    type 2&amp;8&amp;14&amp;5&amp;2&amp;29\\
    \hline
  \end{tabular}
  \caption{Distribution of the types by rank}
  \label{fig:typeDistribution}
\end{figure}

\end{document}
</pre>
<p>And for more complex one:</p>
<pre class="brush: plain; title: ;">
\documentclass[12pt]{article}
\usepackage{multirow}
\usepackage{colortbl}
\definecolor{kugray5}{RGB}{224,224,224}

\begin{document}

\begin{figure}
  \centering
  \begin{tabular}{|c|c|c|c|c|c|c|c|c|}
    \hline
    \multicolumn{2}{|&gt;{\columncolor{kugray5}}c|}{}&amp;\multicolumn{4}{c|}{Rank}&amp;\multirow{2}{*}{Total}\\
    \arrayrulecolor{kugray5}
    \arrayrulecolor{black}
    \cline{3-6}
    \multicolumn{2}{|&gt;{\columncolor{kugray5}}c|}{}&amp;A&amp;B&amp;C&amp;Other&amp;\\
    \hline
    \multirow{2}{*}{Type}&amp;type 1&amp;10&amp;21&amp;6&amp;3&amp;40\\
    \cline{2-7}
                         &amp;type 2&amp;8&amp;14&amp;5&amp;2&amp;29\\
    \hline
    \multicolumn{2}{|c|}{Total}&amp;18&amp;35&amp;11&amp;5&amp;69\\
    \hline
  \end{tabular}
  \caption{Distribution of the types by rank}
  \label{fig:typeDistribution}
\end{figure}

\end{document}</pre>
]]></content:encoded>
			<wfw:commentRss>http://maksim.sorokin.dk/it/2010/05/22/multirow-and-multicolumn-spanning-in-latex/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Config Files in Haskell</title>
		<link>http://maksim.sorokin.dk/it/2010/05/09/config-files-in-haskell/</link>
		<comments>http://maksim.sorokin.dk/it/2010/05/09/config-files-in-haskell/#comments</comments>
		<pubDate>Sun, 09 May 2010 08:09:41 +0000</pubDate>
		<dc:creator>Maksim Sorokin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[functional programming]]></category>
		<category><![CDATA[Haskell]]></category>

		<guid isPermaLink="false">http://maksim.sorokin.dk/it/?p=170</guid>
		<description><![CDATA[Here is an easy and simple way to read configuration files in Haskell using ConfigFile package. Here is a simple configuration file test.cfg example: key: value And here is the program which reads the configuration file: import Data.ConfigFile import Data.Either.Utils main = do val &#60;- readfile emptyCP &#34;test.cfg&#34; let cp = forceEither val putStrLn $ [...]]]></description>
			<content:encoded><![CDATA[<p>Here is an easy and simple way to read configuration files in Haskell using <a href="http://hackage.haskell.org/package/ConfigFile">ConfigFile</a> package.<br />
<span id="more-170"></span></p>
<p>Here is a simple configuration file <code>test.cfg</code> example:</p>
<pre class="brush: plain; title: ;">
key: value
</pre>
<p>And here is the program which reads the configuration file:</p>
<pre class="brush: plain; title: ;">
import Data.ConfigFile
import Data.Either.Utils

main =
 do val &lt;- readfile emptyCP &quot;test.cfg&quot;
    let cp = forceEither val
    putStrLn $ forceEither $ get cp &quot;&quot; &quot;key&quot;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://maksim.sorokin.dk/it/2010/05/09/config-files-in-haskell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Haskell and MySQL</title>
		<link>http://maksim.sorokin.dk/it/2010/04/24/haskell-and-mysql/</link>
		<comments>http://maksim.sorokin.dk/it/2010/04/24/haskell-and-mysql/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 09:38:48 +0000</pubDate>
		<dc:creator>Maksim Sorokin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[functional programming]]></category>
		<category><![CDATA[Haskell]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://maksim.sorokin.dk/it/?p=154</guid>
		<description><![CDATA[In this post I will describe how to connect and use MySQL with Haskell. In this example we will use Ubuntu machine. We will use MySQL driver for HDBC from HackageDB. First, we need to install MySQL server: sudo apt-get install mysql-server Then we need MySQL client library: sudo apt-get install libmysqlclient-dev Then, we install [...]]]></description>
			<content:encoded><![CDATA[<p>In this post I will describe how to connect and use MySQL with Haskell.<span id="more-154"></span></p>
<p>In this example we will use Ubuntu machine. We will use <a href="http://hackage.haskell.org/package/HDBC-mysql">MySQL driver for HDBC</a> from HackageDB.</p>
<p>First, we need to install MySQL server:</p>
<pre class="brush: plain; title: ;">sudo apt-get install mysql-server</pre>
<p>Then we need MySQL client library:</p>
<pre class="brush: plain; title: ;">sudo apt-get install libmysqlclient-dev</pre>
<p>Then, we install <a href="http://hackage.haskell.org/package/HDBC-mysql">HDBC MySQL driver</a> using <a href="http://www.haskell.org/cabal/">Cabal</a>:</p>
<pre class="brush: plain; title: ;">http://hackage.haskell.org/package/HDBC-mysql</pre>
<p>And you are ready to write some code!</p>
<pre class="brush: plain; title: ;">
module DatabaseTest where

import Database.HDBC
import Database.HDBC.MySQL

main =
   do conn &lt;- connectMySQL defaultMySQLConnectInfo {
                  mysqlHost = &quot;localhost&quot;,
                  mysqlDatabase = &quot;db&quot;,
                  mysqlUser = &quot;user&quot;,
                  mysqlPassword = &quot;pass&quot;,
                  mysqlUnixSocket = &quot;/var/run/mysqld/mysqld.sock&quot; }
      quickQuery conn &quot;INSERT INTO test VALUES (1)&quot; []
</pre>
]]></content:encoded>
			<wfw:commentRss>http://maksim.sorokin.dk/it/2010/04/24/haskell-and-mysql/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JPA Persistence With GlassFish</title>
		<link>http://maksim.sorokin.dk/it/2010/02/26/jpa-persistence-with-glassfish/</link>
		<comments>http://maksim.sorokin.dk/it/2010/02/26/jpa-persistence-with-glassfish/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 22:20:32 +0000</pubDate>
		<dc:creator>Maksim Sorokin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[GlassFish]]></category>
		<category><![CDATA[injection]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[persistence]]></category>

		<guid isPermaLink="false">http://maksim.sorokin.dk/it/?p=75</guid>
		<description><![CDATA[So you want to use javax.persistence. Here is how you can configure it and run with GlassFish. In this example we will use MySQL database. First, we will need to configure GlassFish JDBC resources. In GlassFish administration portal go to "Resources-&#62;JDBC-&#62;Connection Pools". Create new Connection Pool with name examplePool. Set Resource Type to java.sql.Driver; Database [...]]]></description>
			<content:encoded><![CDATA[<p>So you want to use <code>javax.persistence</code>. Here is how you can configure it and run with GlassFish.<span id="more-75"></span></p>
<p>In this example we will use MySQL database.<br />
First, we will need to configure GlassFish JDBC resources. In GlassFish administration portal go to "Resources-&gt;JDBC-&gt;Connection Pools". Create new Connection Pool with name <code>examplePool</code>. Set Resource Type to <code>java.sql.Driver</code>; Database Vendor to <code>MySql</code>, <code>com.mysql.jdbc.Driver</code>.<br />
Then go to "Resources-&gt;JDBC-&gt;JDBC Resources". Add new resource with JNDI Name <code>jdbc/example</code>. Set Pool Name to <code>examplePool</code>.</p>
<p>In the application under <code>src/main/resource</code> <code>META-INF</code> folder should be created. And inside <code>META-INF</code> folder <code>persistence.xml</code> file added with following content:</p>
<pre class="brush: xml; title: ;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
    &lt;persistence xmlns=&quot;http://java.sun.com/xml/ns/persistence&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
    xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd&quot;
    version=&quot;1.0&quot;&gt;
  &lt;persistence-unit name=&quot;default&quot; transaction-type=&quot;JTA&quot;&gt;
    &lt;jta-data-source&gt;&lt;strong&gt;${jtaDataSource}&lt;/strong&gt;&lt;/jta-data-source&gt;
  &lt;/persistence-unit&gt;
&lt;/persistence&gt;
</pre>
<p>Where <code>${jtaDataSource}</code> should be <code>jdbc/example</code>. Or you can enable filtering in Maven <code>pom.xml</code> file and specify <code>jdbc/example</code> there So afterwards it would be easier to change and maintain it:</p>
<pre class="brush: xml; title: ;">
&lt;build&gt;
  ...
  &lt;resources&gt;
    &lt;resource&gt;
      &lt;directory&gt;src/main/resources&lt;/directory&gt;
      &lt;filtering&gt;true&lt;/filtering&gt;
    &lt;/resource&gt;
  &lt;/resources&gt;
  ...
&lt;/build&gt;
...
&lt;properties&gt;
  &lt;jtaDataSource&gt;jdbc/example&lt;/jtaDataSource&gt;
&lt;/properties&gt;
</pre>
<p>You are ready to go! Create Entity:</p>
<pre class="brush: java; title: ;">@Entity
@Table(name = &quot;pencils&quot;)
public class Pencil {
  @Id
  private int id;

  @Column
  private String color;

  public int getId() {
    return id;
  }

  public String getColor() {
    return color;
  }
}
</pre>
<p>Inject <code>javax.persistence.PersistenceContext</code>:</p>
<pre class="brush: java; title: ;">@PersistenceContext
private EntityManager em;</pre>
<p>And you can create queries:</p>
<pre class="brush: java; title: ;">Query q = em.createQuery(&quot;select p from Pencil p where p.color=:color&quot;);
q.setParameter(&quot;color&quot;, &quot;blue&quot;);</pre>
]]></content:encoded>
			<wfw:commentRss>http://maksim.sorokin.dk/it/2010/02/26/jpa-persistence-with-glassfish/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java EE 6 Injection With Dynamic Parameter</title>
		<link>http://maksim.sorokin.dk/it/2010/02/19/java-ee-6-injection-with-dynamic-parameter/</link>
		<comments>http://maksim.sorokin.dk/it/2010/02/19/java-ee-6-injection-with-dynamic-parameter/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 18:08:40 +0000</pubDate>
		<dc:creator>Maksim Sorokin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[injection]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE 6]]></category>

		<guid isPermaLink="false">http://maksim.sorokin.dk/it/?p=66</guid>
		<description><![CDATA[Say, you want to inject an object using @javax.inject.Inject. And you would like to pass additional dynamic parameter upon initialization. You can do the following trick. For instance you want to inject and object which depends on some input. In current case let it be Pencil object, which needs to be initialized with color. public [...]]]></description>
			<content:encoded><![CDATA[<p>Say, you want to inject an object using <code>@javax.inject.Inject</code>. And you would like to pass additional dynamic parameter upon initialization. You can do the following trick. <span id="more-66"></span></p>
<p>For instance you want to inject and object which depends on some input. In current case let it be <code>Pencil</code> object, which needs to be initialized with color.</p>
<pre class="brush: java; title: ;">
public class Pencil {
  private Color color;

  void init(Color color) {
    this.color = color;
  }

  public void draw() {
    //
  }
}
</pre>
<p>In this case when you inject the Pencil, you have to call <code>init(Color)</code> explicitly, which is kind off error-prone. What you can do is create a <code>PencilProducer</code> which would create <code>Pencil</code> objects with desired color.</p>
<pre class="brush: java; title: ;">
public class PencilProducer {
  @Inject private Instance pencilInstance;

  public Pencil produce(Colour color) {
    Pencil pencil = pencilInstance.get();
    pencil.init(color);
    return pencil;
  }
}
</pre>
<p>In this case <code>PencilProducer</code> will create new <code>Pencil</code> object every time it is called. And in the application you simply inject <code>PencilProducer</code> and call <code>produce</code> method when needed.</p>
<p>This may seem to be too straight and dirty, but hey -- no <code>new</code> keyword!</p>
]]></content:encoded>
			<wfw:commentRss>http://maksim.sorokin.dk/it/2010/02/19/java-ee-6-injection-with-dynamic-parameter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Servlet 3.0 Without Configuration Hell</title>
		<link>http://maksim.sorokin.dk/it/2010/02/07/servlet-3-0-without-configuration-hell/</link>
		<comments>http://maksim.sorokin.dk/it/2010/02/07/servlet-3-0-without-configuration-hell/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 16:41:23 +0000</pubDate>
		<dc:creator>Maksim Sorokin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[servlet 3.0]]></category>

		<guid isPermaLink="false">http://maksim.sorokin.dk/it/?p=42</guid>
		<description><![CDATA[Servlets 3.0 become easier. Lets try simple InfoServlet example. Our web.xml will look like: &#60;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&#62; &#60;web-app xmlns=&#34;http://java.sun.com/xml/ns/javaee&#34; xmlns:web=&#34;http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&#34;&#62; &#60;display-name&#62;info&#60;/display-name&#62; &#60;/web-app&#62; And our InfoServlet.java would look like: package example; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet(urlPatterns = { &#34;/info&#34; }) public class InfoServlet extends HttpServlet { [...]]]></description>
			<content:encoded><![CDATA[<p>Servlets 3.0 become easier.</p>
<p>Lets try simple InfoServlet example.<br />
<span id="more-42"></span><br />
Our <code>web.xml</code> will look like:</p>
<pre class="brush: xml; title: ;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;web-app xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot; xmlns:web=&quot;http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot;&gt;
  &lt;display-name&gt;info&lt;/display-name&gt;
&lt;/web-app&gt;
</pre>
<p>And our <code>InfoServlet.java</code> would look like:</p>
<pre class="brush: java; title: ;">
package example; 

import java.io.IOException;
import java.io.PrintWriter; 

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; 

@WebServlet(urlPatterns = { &quot;/info&quot; })
public class InfoServlet extends HttpServlet { 

  private static final long serialVersionUID = 5585664118773284494L; 

  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,
      IOException {
    doPost(request, response);
  } 

  @Override
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
      IOException {
    PrintWriter out = response.getWriter();
    out.println(&quot;Info Servlet!&quot;);
    out.close();
  }
}
</pre>
<p>And that is it.</p>
<p>Why "InfoServlet"? Because it can be easily combined with earlier post about Maven versioning. In InfoServlet you can read a file with a version and show on a web page.</p>
]]></content:encoded>
			<wfw:commentRss>http://maksim.sorokin.dk/it/2010/02/07/servlet-3-0-without-configuration-hell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

