<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0' gd:etag='W/&quot;D0QAQHc5fCp7ImA9WhBUEkk.&quot;'><id>tag:blogger.com,1999:blog-3088683402556685885</id><updated>2013-04-29T07:22:21.924-07:00</updated><category term='interface'/><category term='Java Web Services'/><category term='software design principle'/><category term='JAX-RPC'/><category term='Maven'/><category term='JSR 181'/><category term='Program'/><category term='Dependency Injection'/><category term='JAXB'/><category term='Spring-Core'/><category term='Web Services'/><category term='JAX-WS'/><category term='code'/><category term='Spring'/><category term='JWS'/><category term='J2EE'/><title>Pragmatic Java</title><subtitle type='html'>All about Java, Enterprise Architectures, Spring, Web Services, Design Patterns, Refactoring Strategies, Algorithms and in general good programming practices.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://pragmaticjava.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default?redirect=false&amp;v=2'/><link rel='alternate' type='text/html' href='http://pragmaticjava.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>pragmaticjava</name><uri>http://www.blogger.com/profile/04234725971961576090</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>14</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry gd:etag='W/&quot;AkIBSXw6fSp7ImA9WhBXGE8.&quot;'><id>tag:blogger.com,1999:blog-3088683402556685885.post-5704632342630419048</id><published>2011-09-23T09:51:00.000-07:00</published><updated>2013-04-01T08:02:38.215-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2013-04-01T08:02:38.215-07:00</app:edited><title>JAXB and Java 5 Enums</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
In my previous post about Java 5 Enums, I wrote about how Java 5 provides capabilities to add behavior (via member fields and methods) within the enum class. This can be leveraged to provide the switching-like on the enumeration constants. So instead of the following code fragment:
&lt;br /&gt;
&lt;script src="https://gist.github.com/anonymous/53d64d0e0fd6e11bc019.js"&gt;&lt;/script&gt;

We can define an abstract method in the Enum specification, and override that method in each of the Enum definitions as shown &lt;a href="http://pragmaticjava.blogspot.com/2011/06/java-5-enums.html"&gt;here&lt;/a&gt;.
However there can be cases where it is not possible to change the Enum class in order to define an abstract method, if the Enum class has been generated, such as via JAXB compiler. In that case, the only way we can provide any custom behavior is by programming a switch construct as above in a class that leverages the enum.
&lt;br /&gt;
Digressing a little bit from the main point, I would also like to point out how JAXB treats different XSD enum definitions. See the examples below from a file, example.xsd which contains the 2 schema definitions, viz. CountryCurrencyEnum and CountryEnum.

&lt;br /&gt;
&lt;pre class="xml" name="code"&gt;&lt;xsd:complextype name="CountryCurrencyEnum"&gt;
    &lt;xsd:sequence&gt;
        &lt;xsd:element name="currency"&gt;
           &lt;xsd:simpletype&gt;
               &lt;xsd:restriction base="xsd:string"&gt;
                   &lt;xsd:enumeration value="USD"&gt;&lt;/xsd:enumeration&gt;
                   &lt;xsd:enumeration value="EUR"&gt;&lt;/xsd:enumeration&gt;
                   &lt;xsd:enumeration value="GBP"&gt;&lt;/xsd:enumeration&gt;
                   &lt;xsd:enumeration value="YEN"&gt;&lt;/xsd:enumeration&gt;
               &lt;/xsd:restriction&gt;
           &lt;/xsd:simpletype&gt;
        &lt;/xsd:element&gt;
        &lt;xsd:element name="country" type="tns:CountryEnum"&gt;&lt;/xsd:element&gt;
    &lt;/xsd:sequence&gt;
&lt;/xsd:complextype&gt;
&lt;/pre&gt;
&lt;pre class="xml" name="code"&gt;&lt;xsd:simpletype name="CountryEnum"&gt;
    &lt;xsd:restriction base="xsd:string"&gt;
        &lt;xsd:enumeration value="UnitedStates"&gt;&lt;/xsd:enumeration&gt;
        &lt;xsd:enumeration value="France"&gt;&lt;/xsd:enumeration&gt;
        &lt;xsd:enumeration value="UnitedKingdom"&gt;&lt;/xsd:enumeration&gt;
        &lt;xsd:enumeration value="Japan"&gt;&lt;/xsd:enumeration&gt;
    &lt;/xsd:restriction&gt;
&lt;/xsd:simpletype&gt;
&lt;/pre&gt;
The above example demonstrates 2 Enum examples. The currency Enum is an example of inline definition of the Enum, while the Country enum is an example of a external Enum definition. When you run the latter explicit enum definition through the XJC compiler, it produces a separate Enum class as below:

&lt;br /&gt;
&lt;pre class="java" name="code"&gt;package com.examples;

import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlType;

@XmlType(name = "CountryEnum")
@XmlEnum
public enum CountryEnum {

    @XmlEnumValue("UnitedStates")
    UNITED_STATES("UnitedStates"),
    @XmlEnumValue("France")
    FRANCE("France"),
    @XmlEnumValue("UnitedKingdom")
    UNITED_KINGDOM("UnitedKingdom"),
    @XmlEnumValue("Japan")
    JAPAN("Japan");
    private final String value;

    CountryEnum(String v) {
        value = v;
    }

    public String value() {
        return value;
    }

    public static CountryEnum fromValue(String v) {
        for (CountryEnum c: CountryEnum.values()) {
            if (c.value.equals(v)) {
                return c;
            }
        }
        throw new IllegalArgumentException(v);
    }
}
&lt;/pre&gt;
However the XJC compiler will produce the following file when it sees the inline Enum definition.

&lt;br /&gt;
&lt;pre class="java" name="code"&gt;package com.examples;

import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CountryCurrencyEnum", propOrder = {
    "currency",
    "country"
})
public class CountryCurrencyEnum
    implements Serializable
{

    private final static long serialVersionUID = 2010L;
    @XmlElement(required = true)
    protected String currency;
    @XmlElement(required = true)
    protected CountryEnum country;

    public String getCurrency() {
        return currency;
    }

    public void setCurrency(String value) {
        this.currency = value;
    }

    public CountryEnum getCountry() {
        return country;
    }

    public void setCountry(CountryEnum value) {
        this.country = value;
    }
}
&lt;/pre&gt;
So if we are interested in generating Java 5 style enums via JAXB, we are better off creating a separate definition in the xsd file.
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pragmaticjava.blogspot.com/feeds/5704632342630419048/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3088683402556685885&amp;postID=5704632342630419048' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/5704632342630419048?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/5704632342630419048?v=2'/><link rel='alternate' type='text/html' href='http://pragmaticjava.blogspot.com/2011/09/in-my-previous-post-about-java-5-enums.html' title='JAXB and Java 5 Enums'/><author><name>pragmaticjava</name><uri>http://www.blogger.com/profile/04234725971961576090</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;C0UFSHkycCp7ImA9WhdXEkk.&quot;'><id>tag:blogger.com,1999:blog-3088683402556685885.post-7523821676206865917</id><published>2011-08-20T14:55:00.000-07:00</published><updated>2011-08-24T20:00:19.798-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-08-24T20:00:19.798-07:00</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='Maven'/><title>Customizing Maven's lifecycle</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Every project has a lifecycle from project initiation all the way through regular production releases. A typical lifecycle involves at least the basic steps of getting all the resources together, compilation of source-code, unit-tests, integration-tests, packaging to create the custom-format. Maven formalizes this concept into a “default” lifecycle that every project is expected to have.&lt;br /&gt;
&lt;br /&gt;
According to Maven, a lifecycle is made up of a sequence of phases. Each phase has zero or more plugin goals bound to it. Some of the core plugin goals are bound to the core phase steps by default, e.g the &lt;a href="http://maven.apache.org/plugins/maven-compiler-plugin/"&gt;compiler plugin’s&lt;/a&gt; compile goal is bound to the compile phase. A more clear second example would be the &lt;a href="http://maven.apache.org/plugins/maven-surefire-plugin/"&gt;Surefire plugin’s&lt;/a&gt; test goal is bound to the unit test phase. However, some phases are free-form and not necessary part of the core of the default lifecycle, they will be activated only when a corresponding plugin goal bound to that phase by default is configured. At the same time, some plugins and their goals are free-form and it is upto the developer to bind them to a particular phase. &lt;br /&gt;
&lt;br /&gt;
Maven site lists all the following goals as part of the default lifecycle for any project regardless of the packaging type. Here are a few examples on what aspects of the project build we can customize by leveraging what plugins. &lt;br /&gt;
&lt;br /&gt;
1.&lt;b&gt;validate &lt;/b&gt;- Validates the project is correct and all necessary information is available. The &lt;a href="http://maven.apache.org/plugins/maven-enforcer-plugin/"&gt;enforcer plugin&lt;/a&gt; can be used here to enforce a few environment-specific constraints on the project.&lt;br /&gt;
Eg.&lt;br /&gt;
&lt;pre class="xml" name="code"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;plugin&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;groupid&gt;org.apache.maven.plugins&lt;/groupid&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;artifactid&gt;maven-enforcer-plugin&lt;/artifactid&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;executions&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;execution&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;id&gt;enforce-versions&lt;/id&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;goals&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;goal&gt;enforce&lt;/goal&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/goals&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;configuration&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;rules&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;requiremavenversion&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;version&gt;2.0.10&lt;/version&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/requiremavenversion&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;requirejavaversion&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;version&gt;1.6&lt;/version&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/requirejavaversion&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/rules&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/configuration&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/execution&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/executions&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/plugin&gt;&lt;/pre&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
2. &lt;b&gt;initialize &lt;/b&gt;- Initialize build state, e.g. set properties or create directories. An example would be to use some programmatic plugins like &lt;a href="http://maven.apache.org/plugins/maven-antrun-plugin/"&gt;antrun &lt;/a&gt;or &lt;a href="http://groovy.codehaus.org/GMaven"&gt;groovy &lt;/a&gt;to generate custom properties. In the example below, the property ‘buildtime’ was created during build-time and it will be used inside the manifest file to mark the time the jar/war/ear was created. &lt;br /&gt;
&lt;pre class="xml" name="code"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;plugin&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;groupid&gt;org.codehaus.mojo&lt;/groupid&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;artifactid&gt;groovy-maven-plugin&lt;/artifactid&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;version&gt;1.3&lt;/version&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;executions&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;execution&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;phase&gt;generate-resources&lt;/phase&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;goals&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;goal&gt;execute&lt;/goal&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/goals&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;configuration&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;source&gt;&lt;/source&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;import java.util.Date
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;import java.text.MessageFormat
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;def buildtime = MessageFormat.format("{yyyy-MM-dd HH:mm:sss}", new Date())
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;project.properties['buildtime'] = buildtime
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;
&lt;/configuration&gt;&lt;/execution&gt;&lt;/executions&gt;&lt;/plugin&gt;&lt;/pre&gt;3.&lt;b&gt;generate-sources&lt;/b&gt; - Generate any source code for inclusion in compilation. Projects that use webservices or any of the Java-XML bindings, like &lt;a href="http://mojo.codehaus.org/jaxb2-maven-plugin/"&gt;JAXB2&lt;/a&gt;, &lt;a href="http://mojo.codehaus.org/xmlbeans-maven-plugin/"&gt;XMLBeans&lt;/a&gt;, &lt;a href="http://mojo.codehaus.org/castor-maven-plugin/"&gt;Castor &lt;/a&gt;can make use of the corresponding plugins (e.g. &lt;b&gt;axistools:wsdl2java, jaxb2:xjc, xmlbeans:xmlbeans, castor:castor&lt;/b&gt;) to generate any source code in this phase. These plugin goals bind by default to this lifecycle phase so that you do not have to explicitly mention it.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&lt;pre class="xml" name="code"&gt;&lt;plugins&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;plugin&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;groupid&gt;org.codehaus.mojo&lt;/groupid&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;artifactid&gt;jaxb2-maven-plugin&lt;/artifactid&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;version&gt;1.3.1&lt;/version&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;executions&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;execution&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;id&gt;xjc&lt;/id&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;goals&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;goal&gt;xjc&lt;/goal&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/goals&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/execution&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/executions&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;configuration&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;packagename&gt;com.example.myschema&lt;/packagename&gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/configuration&gt;&amp;nbsp;&lt;/plugin&gt;&lt;/plugins&gt;&lt;/pre&gt;4. &lt;b&gt;process-sources&lt;/b&gt; - Process the source code, for example to filter any values from within the source code. More on filtering in a later blog.&lt;br /&gt;
5. &lt;b&gt;generate-resources&lt;/b&gt; - Generate resources for inclusion in the package like WSDLs in a web-services project (e.g&amp;nbsp;&lt;a href="http://mojo.codehaus.org/axistools-maven-plugin/"&gt; axistools:java2wsdl&lt;/a&gt;), or Hibernate Configuration XML or hbm.xmls (&lt;a href="http://mojo.codehaus.org/maven-hibernate3/hibernate3-maven-plugin/"&gt;hibernate3:hbm2cfgxml&lt;/a&gt;)&lt;br /&gt;
6. &lt;b&gt;process-resources&lt;/b&gt; - Copy and process the resources into the destination directory, ready for packaging. This is also a great place to filter any values from within the resources file. More on filtering in a later blog.&lt;br /&gt;
7. &lt;b&gt;compile&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/b&gt;- This is the most obvious phase. Although the compiler plugin is part of the core lifecycle and need not be defined explicitly to be attached to any phase, there is often a need to customize the JDK version to use. Eg&lt;br /&gt;
&lt;pre class="xml" name="code"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;plugin&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;groupid&gt;org.apache.maven.plugins&lt;/groupid&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;artifactid&gt;maven-compiler-plugin&lt;/artifactid&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;configuration&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;source&gt;1.6&lt;/source&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;target&gt;1.6&lt;/target&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;verbose&gt;true&lt;/verbose&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/configuration&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/plugin&gt;&lt;/pre&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
8. &lt;b&gt;process-classes&lt;/b&gt;- This phase is used to post-process the generated class files from compilation, for example to do bytecode enhancement on Java classes. &lt;br /&gt;
9. &lt;b&gt;generate-test-sources&lt;/b&gt; - This is conceptually same as generate-sources phase as above, except that we are generating test source code here.&lt;br /&gt;
10. &lt;b&gt;process-test-sources&lt;/b&gt; - This phase is used to process test source files, e.g to filter any values, make program variables point to a test DB location instead of production DB location etc.&lt;br /&gt;
&lt;pre class="xml" name="code"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;plugin&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;groupid&gt;org.apache.maven.plugins&lt;/groupid&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;artifactid&gt;maven-antrun-plugin&lt;/artifactid&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;executions&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;execution&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;id&gt;update-test-sources&lt;/id&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;phase&gt;process-test-sources&lt;/phase&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;goals&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;goal&gt;run&lt;/goal&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/goals&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;configuration&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;tasks&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;replace file="${build.directory}/classes/dao/DBConnection.java"&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;replacetoken&gt;[test-DB-path-placeholder]&lt;/replacetoken&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;replacevalue&gt;${testDB.path}&lt;/replacevalue&gt; // testDB.path is a locally defined property.
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/replace&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/tasks&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/configuration&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/execution&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/executions&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/plugin&gt;&lt;/pre&gt;&lt;br /&gt;
11. &lt;b&gt;generate-test-resources&lt;/b&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;- This phase is used to create resources for testing. E.g. Let's say your project's tests are off some companydata.dat file which is a part of the companycore.jar. Since your project is interested only in this data file for the purposes of testing, you could use &lt;a href="http://maven.apache.org/plugins/maven-dependency-plugin/"&gt;maven-dependency-plugin&lt;/a&gt; to unpack the companycore.jar, extracting only that file into your test-resources directory.&lt;br /&gt;
&lt;pre class="xml" name="code"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;plugin&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;groupid&gt;org.apache.maven.plugins&lt;/groupid&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;artifactid&gt;maven-dependency-plugin&lt;/artifactid&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;executions&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;execution&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;id&gt;unpack-test-resources&lt;/id&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;phase&gt;generate-test-resources&lt;/phase&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;goals&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;goal&gt;unpack&lt;/goal&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/goals&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;configuration&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;artifactitems&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;artifactitem&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;groupid&gt;com.company.core&lt;/groupid&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;artifactid&gt;core-artifacts&lt;/artifactid&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;version&gt;1.0&lt;/version&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;type&gt;test-jar&lt;/type&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;overwrite&gt;true&lt;/overwrite&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;includes&gt;companydata.dat&lt;/includes&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/artifactitem&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/artifactitems&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;outputdirectory&gt;${build.testResourcesDir}&lt;/outputdirectory&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/configuration&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/execution&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/executions&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/plugin&gt;&lt;/pre&gt;&lt;br /&gt;
12. &lt;b&gt;process-test-resources&lt;/b&gt; - This phase is used to copy and process the resources into the test destination directory.&lt;br /&gt;
13. &lt;b&gt;test-compile&lt;/b&gt; - The &lt;a href="http://maven.apache.org/plugins/maven-compiler-plugin/"&gt;compiler plugin&lt;/a&gt; compiles the test source code into the test destination directory.&lt;br /&gt;
14. &lt;b&gt;process-test-classes&lt;/b&gt; - Conceptually same as process-classes to do any byte code enhancement. &lt;br /&gt;
15. &lt;b&gt;test &lt;/b&gt;- The &lt;a href="http://maven.apache.org/plugins/maven-surefire-plugin/"&gt;Surefire plugin&lt;/a&gt; runs tests using a suitable unit testing framework. You may need to configure the plugin to skipTests or exclude any particular test class that are causing the build to fail. This may be useful during active development phase.&lt;br /&gt;
&lt;pre class="xml" name="code"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;plugin&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;groupid&gt;org.apache.maven.plugins&lt;/groupid&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;artifactid&gt;maven-surefire-plugin&lt;/artifactid&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;configuration&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;excludes&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;exclude&gt;**/TestFeatureX.java&lt;/exclude&gt;
&amp;nbsp;&lt;/excludes&gt;&lt;/configuration&gt;&lt;/plugin&gt;&lt;/pre&gt;&lt;br /&gt;
16. &lt;b&gt;package&amp;nbsp;&amp;nbsp; &lt;/b&gt;- Take the compiled code and package it in its distributable format, such as a JAR. You can request Maven to package source files and test source files into respective jars via &lt;a href="http://maven.apache.org/plugins/maven-jar-plugin/"&gt;maven-jar-plugin&lt;/a&gt; and &lt;a href="http://maven.apache.org/plugins/maven-source-plugin/"&gt;maven-source-plugin &lt;/a&gt;in addition to the distributable class file jar that it creates.&lt;br /&gt;
&lt;pre class="xml" name="code"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;plugin&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;groupid&gt;org.apache.maven.plugins&lt;/groupid&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;artifactid&gt;maven-jar-plugin&lt;/artifactid&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;executions&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;execution&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;goals&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;goal&gt;test-jar&lt;/goal&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/goals&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/execution&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/executions&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/plugin&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;plugin&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;groupid&gt;org.apache.maven.plugins&lt;/groupid&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;artifactid&gt;maven-source-plugin&lt;/artifactid&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;executions&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;execution&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;id&gt;attach-sources&lt;/id&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;phase&gt;package&lt;/phase&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;goals&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;goal&gt;jar&lt;/goal&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/goals&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/execution&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/executions&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/plugin&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;plugin&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;groupid&gt;org.apache.maven.plugins&lt;/groupid&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;artifactid&gt;maven-war-plugin&lt;/artifactid&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;configuration&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;archive&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;addmavendescriptor&gt;false&lt;/addmavendescriptor&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;manifest&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;adddefaultimplementationentries&gt;true&lt;/adddefaultimplementationentries&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/manifest&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;manifestentries&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;build-time&gt;${timestamp}&lt;/build-time&gt;
&lt;/manifestentries&gt;&lt;/archive&gt;&lt;/configuration&gt;&lt;/plugin&gt;&lt;/pre&gt;&lt;br /&gt;
17. &lt;b&gt;verify&lt;/b&gt;- This phase can be used to run any checks to verify the package is valid and meets quality criteria. It is a great place to enforce any source code formatting styles. &lt;br /&gt;
&lt;pre class="xml" name="code"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;plugin&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;groupid&gt;org.apache.maven.plugins&lt;/groupid&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;artifactid&gt;maven-checkstyle-plugin&lt;/artifactid&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;executions&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;execution&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;phase&gt;verify&lt;/phase&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;goals&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;goal&gt;checkstyle&lt;/goal&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/goals&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/execution&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/executions&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;configuration&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;configlocation&gt;path_to/checkstyle_rules.xml&lt;/configlocation&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;consoleoutput&gt;true&lt;/consoleoutput&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;failsonerror&gt;true&lt;/failsonerror&gt;
&amp;nbsp;&lt;/configuration&gt;&lt;/plugin&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
So the above list gives a fair idea on how you can leverage Maven plugins to customize your build lifecycle. The above are just brief samples. Any ideas beyond the above usage of plugins in various build phases is more than welcome.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pragmaticjava.blogspot.com/feeds/7523821676206865917/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3088683402556685885&amp;postID=7523821676206865917' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/7523821676206865917?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/7523821676206865917?v=2'/><link rel='alternate' type='text/html' href='http://pragmaticjava.blogspot.com/2011/08/customizing-mavens-lifecycle.html' title='Customizing Maven&apos;s lifecycle'/><author><name>pragmaticjava</name><uri>http://www.blogger.com/profile/04234725971961576090</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry gd:etag='W/&quot;A0QDQnY4fCp7ImA9WhdREEU.&quot;'><id>tag:blogger.com,1999:blog-3088683402556685885.post-2674394232244297816</id><published>2011-07-30T22:16:00.000-07:00</published><updated>2011-07-30T22:16:13.834-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-07-30T22:16:13.834-07:00</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='Maven'/><title>Maven's assumptions</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Maven does both - 'makes assumptions' as well as 'enforces' a lot of standards and good practices for project programming and management at an enterprise-level. It also provides some good features such as resource filtering, though not enabled by default, suggest good programming practice. I wish to list down all of them as they come to my mind from the very obvious to the subtle ones below:&lt;br /&gt;
&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;&lt;li&gt;Projects would have a standard directory layout relative to project's home directory to place source code, target binaries, test source code, test binaries, resources etc as described in the Introduction to &lt;a href="http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html"&gt;Standard Directory Layout&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Projects would adopt unit-testing as a standard practice by including the test-compile and test phases as part of the build lifecycle. Maven even goes a step further by failing a build if the test source does not compile or the unit tests fail in its default build lifecycle.&lt;/li&gt;
&lt;li&gt;Projects provide a clean directory/folder separation between application source code and the resources required (such as Spring applicationContext files, Hibernate configuration files, log4j properties file etc) and not put everything together in project home folder.&lt;/li&gt;
&lt;li&gt;Projects need not hardcode application properties inside the configuration resources or source code and instead make use of resource filtering - i.e. a property like jdbc.driverName could be externalized in the &lt;project-home&gt;/src/main/filters and its value will be substituted wherever it is referenced. Thus any changes to it are localized to one file under &lt;project-home&gt;/src/main/filters although it can be referenced in several places in configuration and code.&lt;/project-home&gt;&lt;/project-home&gt;&lt;/li&gt;
&lt;li&gt;Modern-day applications (represented by an aggregate project model / POM in Maven) will be divided into separate modules - app-domain-model, app-DAO, app-business-logic, app-web-modules, app-webservices-modules, app-utils etc - instead of old-school monolithic applications. Maven multi-module projects and the &lt;a href="http://maven.apache.org/plugins/maven-reactor-plugin/"&gt;Reactor plugin&lt;/a&gt; help achieve this.&lt;/li&gt;
&lt;li&gt;Projects would need to be built for various platforms (Windows, Unix, Linux etc) and deployment environments (dev, staging, test, production) and builds do differ based on the platform and enviroment needed. Eg. different database servers required for each enviroment thereby a different jdbc.url, jdbc.username, jdbc.password for each environment. Maven Profiles are a great feature that if leveraged well can make the build process seamless across environments.&lt;/li&gt;
&lt;/ol&gt;&lt;div style="text-align: left;"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden" /&gt;&lt;!--Session data--&gt;&lt;input id="jsProxy" onclick="jsCall();" type="hidden" /&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pragmaticjava.blogspot.com/feeds/2674394232244297816/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3088683402556685885&amp;postID=2674394232244297816' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/2674394232244297816?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/2674394232244297816?v=2'/><link rel='alternate' type='text/html' href='http://pragmaticjava.blogspot.com/2011/07/mavens-assumptions.html' title='Maven&apos;s assumptions'/><author><name>pragmaticjava</name><uri>http://www.blogger.com/profile/04234725971961576090</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;Dk4MQng6fCp7ImA9WhdREEU.&quot;'><id>tag:blogger.com,1999:blog-3088683402556685885.post-2753693436737209861</id><published>2011-07-30T21:03:00.000-07:00</published><updated>2011-07-30T21:03:03.614-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-07-30T21:03:03.614-07:00</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='Maven'/><title>Maven references</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Recently I have been learning Maven as it is widely deployed and used at an organizational level in a very clever and effective manner. However, the Maven documentation, although quite extensive for an open-source project does not flow logically to educate a newbie. After scouring through most of the available online information in a not so logical progression and then trying to connect the pieces together, I came to a conclusion that the following would be the ideal order to comprehend Maven.&lt;br /&gt;
&lt;br /&gt;
Online reference books made available by Sonatype.&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;&lt;li&gt;&lt;a href="http://www.sonatype.com/index.php/Support/Books/Maven-By-Example"&gt;Maven By Example&lt;/a&gt;&amp;nbsp; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.sonatype.com/index.php/Support/Books/Maven-The-Complete-Reference"&gt;Maven : The Complete Reference&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;
All about Maven settings.&lt;/div&gt;&lt;ul style="text-align: left;"&gt;&lt;li&gt;The settings.xml file in your Maven installation directory/conf&lt;/li&gt;
&lt;li&gt;&lt;a href="http://maven.apache.org/guides/mini/guide-configuring-maven.html"&gt;How to configure Maven settings&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://goog_43191815/"&gt;Maven settings reference&lt;/a&gt;&amp;nbsp; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://maven.apache.org/ref/2.2.1/maven-settings/settings.html"&gt;Settings model reference &lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;
Core of Maven - Project Object Model and all its intricacies - multi-module builds, profiles, reactors etc&lt;/div&gt;&lt;ul style="text-align: left;"&gt;&lt;li&gt;&lt;a href="http://maven.apache.org/guides/index.html"&gt;Index to all tutorial articles&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://maven.apache.org/pom.html"&gt;POM reference&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://maven.apache.org/ref/3.0.3/maven-model/maven.html"&gt;POM model reference&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="text-align: left;"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden" /&gt;&lt;!--Session data--&gt;&lt;input id="jsProxy" onclick="jsCall();" type="hidden" /&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pragmaticjava.blogspot.com/feeds/2753693436737209861/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3088683402556685885&amp;postID=2753693436737209861' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/2753693436737209861?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/2753693436737209861?v=2'/><link rel='alternate' type='text/html' href='http://pragmaticjava.blogspot.com/2011/07/maven-references.html' title='Maven references'/><author><name>pragmaticjava</name><uri>http://www.blogger.com/profile/04234725971961576090</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;DkQNQX09fSp7ImA9WhdTFU0.&quot;'><id>tag:blogger.com,1999:blog-3088683402556685885.post-6694752618469373055</id><published>2011-07-12T13:57:00.000-07:00</published><updated>2011-07-12T13:59:50.365-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-07-12T13:59:50.365-07:00</app:edited><title>CVS and (no) Atomic Commits</title><content type='html'>&lt;span style="font-size: large;"&gt;&lt;b&gt;E&lt;/b&gt;&lt;/span&gt;very project that I have worked so far has used a different version control system. My history of using version control systems has been thus - Rational ClearCase in my very first job/project, then Visual Sourcesafe, then Subversion for a very brief period of time (about 3 months) and then Perforce for the longest time as yet(for a little over 4 years) and now I am currently using CVS.&lt;br /&gt;
&lt;br /&gt;
Using Perforce was a pleasant experience and its atomic commits combined with its changelist/changeset feature is something that I am missing while using CVS currently. In CVS, each file committed to the repository has its own, independent version number and history which sure is a limitation. I do not remember enough about Rational ClearCase except that its config-specs pretty much allowed a much efficient branching and merging in a manner that could emulate atomic commits. So this blog entry is about atomic commits and changesets and how they reduce the frequency of build breaks which seem to happen every once in a while in a high-traffic team workload.&lt;br /&gt;
&lt;br /&gt;
A typical reason why a build could break is that developers fail to commit all of the files that go in as part of the task or a bug fix. As a consequence when one or more of the checked-in files try to access constructs(classes, methods, constants etc) newly introduced in the file that was forgotten to be checked-in. And thats the build breaking right in your face! &lt;br /&gt;
&lt;br /&gt;
In my opinion, the kind of SCM being used as the source code repository(read CVS, Visual SourceSafe) can also be a contributing factor towards this. Ideally, when a developer commits files to the repository, it is great if the files are grouped together as a single atomic change towards the bug fix, new feature development or new task. So even mentally developers start to group all files together, thereby reducing the probability of a build break. Also in the event of a networking failure, atomic commits save the build by ensuring all or none of the files are submitted to the repository. &lt;br /&gt;
&lt;br /&gt;
Perforce takes one more step beyond these atomic commits - if a developer modifies any of the local files that are mapped to the repository, it automatically puts them in a pool called 'changelist'. That way there is no chance that a developer could have forgotten to check-in any file.&lt;br /&gt;
Changelists serve two purposes:&lt;br /&gt;
- to organize your work into logical units by grouping related changes to files together&lt;br /&gt;
- to guarantee the integrity of your work by ensuring that related changes to files are checked in together.&lt;br /&gt;
&lt;br /&gt;
Now different version control systems record this atomic commit differently in their history. For Subversion, a changeset/changelist is just a collection of changes with a unique name. The commit will create a new revision number which can forever be used as a "name" for the change. As per Subversion documentation:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; "&lt;i&gt;In Subversion, a global revision number N names a tree in the repository: it's the way the repository looked after the Nth commit. It's also the name of an implicit changeset: if you compare tree N with tree N-1, you can derive the exact patch that was committed. For this reason, it's easy to think of “revision N” as not just a tree, but a changeset as well. If you use an issue tracker to manage bugs, you can use the revision numbers to refer to particular patches that fix bugs—for example, “this issue was fixed by revision 9238”. Somebody can then run svn log -r9238 to read about the exact changeset which fixed the bug, and run svn diff -r9237:9238 to see the patch itself&lt;/i&gt;."&lt;br /&gt;
&lt;br /&gt;
Perforce keeps track of each file's independent revision history as well as changelist numbers. Again you can associate changelist numbers with a bug/task tracking database and we can go back and forth between the SCM and the bug/task tracking database.&lt;br /&gt;
&lt;br /&gt;
As I searched through the web, I did find some solutions and forums that discussed ways to get around this limitation which will be the next task on my agenda.&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;StackOverflow: &lt;a href="http://stackoverflow.com/questions/1065919/list-all-the-files-checked-in-in-a-single-cvs-commit"&gt;List all the files checked in in a single cvs commit. &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;StackOverflow: &lt;a href="http://stackoverflow.com/questions/86515/does-anyone-know-the-cvs-command-line-options-to-get-the-details-of-the-last-chec"&gt;Does-anyone-know-the-cvs-command-line-options-to-get-the-details-of-the-last-check-in? &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.cvstrac.org/"&gt;CVSTrac &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.cobite.com/cvsps/"&gt;CVSps &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://ant.apache.org/manual/Tasks/changelog.html"&gt;ANT CVS Changelog task &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.pragmaticautomation.com/cgi-bin/pragauto.cgi/Monitor/LettingCVSPullTheTrigger.rdoc/style/print"&gt;CVS Hooks &lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://pragmaticjava.blogspot.com/feeds/6694752618469373055/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3088683402556685885&amp;postID=6694752618469373055' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/6694752618469373055?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/6694752618469373055?v=2'/><link rel='alternate' type='text/html' href='http://pragmaticjava.blogspot.com/2011/07/e-very-project-that-i-have-worked-so.html' title='CVS and (no) Atomic Commits'/><author><name>pragmaticjava</name><uri>http://www.blogger.com/profile/04234725971961576090</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;D0QCRn04fCp7ImA9WhZaFEk.&quot;'><id>tag:blogger.com,1999:blog-3088683402556685885.post-5351132809138934672</id><published>2011-06-29T20:22:00.000-07:00</published><updated>2011-06-30T07:49:27.334-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-06-30T07:49:27.334-07:00</app:edited><title>Java 5 Enums</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Enums or enumerated types basically means a type that can be defined to have a certain set of fixed values as per the problem domain. Historically, enums (via enum keyword and any associated semantics) were missing from the featureset provided by versions upto Java 1.4. &lt;br /&gt;
However developers tried to achieve the "same enum effect" via something like this:&lt;br /&gt;
Example 1:&lt;br /&gt;
&lt;pre class="java" name="code"&gt;public class Currency {
  public static final int USD = 1;
  public static final int EUR = 2;
  public static final int GBP = 3;
  public static final int YEN = 4;
}

public class CurrencyConverter {
  public void convertCurrency(int fromCurrency, int toCurrency) { ... }

  public static void main(String[] args) {
    CurrencyConverter cc = new CurrencyConverter();
    cc.convertCurrency(Currency.USD, Currency.YEN);
  }
}
&lt;/pre&gt;Additional currencies could be added to the Currency class by defining new constants. However, the convertCurrency (int, int) method lacks typesafety since the method signature indicates it can accept any int. However, the only acceptabe range of ints is 1 through 4. If we call the method outside of the range of agreed upon constants , e.g. convertCurrency(8, 10), the program fails. &lt;br /&gt;
&lt;br /&gt;
The above can be avoided if we accept that Enumerations should be treated as a separate type. Implementing them as a sequence of integers is not helpful. To define enumerations as their own type, you do the following:&lt;br /&gt;
&lt;br /&gt;
1. Replace the primitive ints above with 'static final' object references to the same class defining the enumerated constants. &lt;br /&gt;
2. Disallow any object creation of the class via a private constructor.&lt;br /&gt;
&lt;br /&gt;
Example 2:&lt;br /&gt;
&lt;pre class="java" name="code"&gt;public final class Currency {
  public static final Currency USD = new Currency(1);
  public static final Currency EUR = new Currency(2);
  public static final Currency GBP = new Currency(3);
  public static final Currency YEN = new Currency(4);

  int value;

  private Currency(int value){
    this.value = value;
  }
}

public class CurrencyConverter {
   public void convertCurrency(Currency fromCurrency, Currency toCurrency) { ... }

   public static void main(String[] args) {
     CurrencyConverter cc = new CurrencyConverter();
     cc.convertCurrency(Currency.USD, Currency.YEN);
   }
}
&lt;/pre&gt;The convertCurrency(Currency, Currency) now takes the Currency type instead of an int.&lt;br /&gt;
&lt;br /&gt;
Secondly the acceptable values of Currency can only be defined inside the class due to the private constructor.This along with the fact that Currency is a final class ensures that Currency.USD, Currency.EUR, Currency.GBP and Currency.YEN are the only instances of the Currency class.&lt;br /&gt;
&lt;br /&gt;
It also means that we can use the identity comparison (==) operator instead of the equals() method when comparing enum values. Identity comparison (==) is always faster than equals since we are only comparing object references in the former as opposed to object values in the latter.&lt;br /&gt;
&lt;br /&gt;
However the above typesafety approach comes with the following disadvantages:&lt;br /&gt;
1. The above implementation is not Serializable and Comparable by default. It means we can have issues using them in the context of RMI and EJBs. In case, if we make them Serializable, constructing the object again creates a new instance of the same Currency by ignoring its private constructor completely and does not retrieve the same instance that was serialized. This means == comparison fails to identify the equality of a serialized and a non-serialized Currency. Also it means we no longer have a unique single instance of the currency type. We have to implement more boiler-plate code like implementing the readResolve method as suggested in &lt;a href="http://www.javaworld.com/javaworld/javatips/jw-javatip122.html?page=2."&gt;http://www.javaworld.com/javaworld/javatips/jw-javatip122.html?page=2.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
2. We cannot switch over the above enum values (remember it is easier to switch over ints) to get any business logic done. If we need to switch, it can be facilitated by providing a getValue() method that returns the int value. &lt;br /&gt;
&lt;br /&gt;
Example 3:&lt;br /&gt;
Inside Currency class,&lt;br /&gt;
&lt;pre class="java" name="code"&gt;public class Currency {
      ....

      public int getValue() {
        return value;
      }
   }

   public class CurrencyConverter {
     public void convertCurrency(Currency fromCurrency, Currency toCurrency) { ... }
   }
&lt;/pre&gt;Java 5 enums are a typesafe feature and overcome all the above problems listed with the Enumerated pattern. In addition to facilitating a way to list a set of constant values, they also provide features such as :&lt;br /&gt;
&lt;br /&gt;
1. All defined enums implicitly extend from java.lang.Enum&lt;provide link=""&gt; just as all objects implicitly extend from java.lang.Object.&lt;br /&gt;
&lt;br /&gt;
2. The above feature taks care of default implementation for toString(), equals(), hashCode() methods.&lt;br /&gt;
&lt;br /&gt;
3. They are Serializable and Comparable by default without generating duplicate instances during deserialization&lt;br /&gt;
&lt;br /&gt;
4. They can be used in switch-case statements.&lt;br /&gt;
&lt;br /&gt;
5. They can have behavior ( via member variables , methods , constructors, interface implementations etc) in addition to just specifying the constants.&lt;br /&gt;
&lt;br /&gt;
Simplest example of Java 5 enum class with no additional behavior.&lt;br /&gt;
&lt;br /&gt;
Example 4:&lt;br /&gt;
&lt;/provide&gt;&lt;br /&gt;
&lt;pre class="java" name="code"&gt;public enum Currency { USD,GBP,EUR,YEN }

public class CurrencyConverter
{
   public void printCurrencies() {
     for (Currency currency : Currency.values()) {
        System.out.println(currency);
        System.out.println(currency.ordinal());
   }
} 

}
&lt;/pre&gt;Currency is an enum type, and all the above enum values, viz USD, GBP, EUR, YEN are of type Currency.&lt;br /&gt;
&lt;br /&gt;
We can iterate through all the instances of Currency via the static values() method and take advantage of the toString() method in the print statement.&lt;br /&gt;
&lt;br /&gt;
Example 5:&lt;br /&gt;
We can also add behavior via member fields and methods.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="java" name="code"&gt;public enum Currency 
  {
    USD("United States"),
    GBP("United Kingdom"),
    EUR("Europe"),
    YEN("Japan")

    String country;

   public Currency(String country){
     this.country = country;
   }

   public Currency getCurrencyForCountry(String country) {
     return Currency.valueOf(country);
   }
 }
&lt;/pre&gt;&lt;br /&gt;
When you need to provide custom behavior based on the enum values, there are 2 ways of doing it. Either you switch case based on the enum values in the application code or a yet better way is to move the custom logic inside the enum class as follows:&lt;br /&gt;
&lt;br /&gt;
Example 6:&lt;br /&gt;
&lt;pre class="java" name="code"&gt;public class Client 
   {
     enum HttpStatusCode
     {
        HTTP200("HTTP 200") {
         @Override
         void printMessage() {
            System.out.println("Successful Transaction ");
         }
     },
     HTTP401("HTTP 401 Error") {
        @Override
        void printMessage() {
          System.out.println("Authentication Failure");
        }
     },
     HTTP404("HTTP 404 Error") {
          @Override
          void printMessage() {
             System.out.println("Requested resource not found at specified location");
           }
     },
     HTTP500("HTTP 500 Error") {
       @Override
       void printMessage() {
          System.out.println("An error occured on server-side, please have   patience.");
      }
    };

    String statusString;

    HttpStatusCode(String statusString) {
       this.statusString = statusString;
    }

    abstract void printMessage();
 }

   public static void main(String[] args)
   {
     HttpStatusCode status = connectToServer();
     status.printMessage();
   }
 }
&lt;/pre&gt;&lt;br /&gt;
Switching over case statements could be used if you have no option of modifying the enum class code. This can happen in cases where the enum class is generated - e.g. using JAXB -  from an XSD. More on this in a later blog.&lt;br /&gt;
&lt;br /&gt;
So this covers the basics of Java 5 Enums. Java 5 also provides 2 data structures - java.util.EnumSet and java.util.EnumMap. More on this again will be in yet another blog. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pragmaticjava.blogspot.com/feeds/5351132809138934672/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3088683402556685885&amp;postID=5351132809138934672' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/5351132809138934672?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/5351132809138934672?v=2'/><link rel='alternate' type='text/html' href='http://pragmaticjava.blogspot.com/2011/06/java-5-enums.html' title='Java 5 Enums'/><author><name>pragmaticjava</name><uri>http://www.blogger.com/profile/04234725971961576090</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry gd:etag='W/&quot;DUIMRnY_fyp7ImA9WhZaEkU.&quot;'><id>tag:blogger.com,1999:blog-3088683402556685885.post-5713049545154772503</id><published>2009-01-05T08:32:00.000-08:00</published><updated>2011-06-28T11:59:47.847-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-06-28T11:59:47.847-07:00</app:edited><title>Tomcat 6 and class loading</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;In continuation with the &lt;a href="http://pragmaticjava.blogspot.com/2009/01/java-and-class-loading-delegation-model.html"&gt;previous blog entry&lt;/a&gt;, I would also like to write about Tomcat 6 (in particular) and class loading pattern that it adopts. Java allows the creation of custom class loaders by implementing the java.lang.ClassLoader.  Now Tomcat 6 creates the following class loaders on startup. They share a parent-child relationship too, but NOTE that the delegation pattern is a bit different as will be explained&lt;br /&gt;
&lt;a href="http://3.bp.blogspot.com/_mKzdYE6Bmi0/SWJg5qagj2I/AAAAAAAADpI/0gwZT4XNLhQ/s1600-h/classloader.JPG" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5287895456240668514" src="http://3.bp.blogspot.com/_mKzdYE6Bmi0/SWJg5qagj2I/AAAAAAAADpI/0gwZT4XNLhQ/s320/classloader.JPG" style="height: 168px; width: 215px;" /&gt;&lt;/a&gt;&lt;br /&gt;
Although invisible in default installation of Tomcat 6, there are additional shared and server class loaders also available and they fall below the Common class loader in the hierarchy.  Each of the class loaders has a responsibility to load classes from certain specific areas, noted below:  &lt;span style="font-weight: bold;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;1. Bootstrap + Extension class loader&lt;/span&gt; - It loads the Java run-time classes in the JDK as well as any classes from the jars in the Extensions folder.  &lt;span style="font-weight: bold;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;2. System class loader&lt;/span&gt; - As noted in the previous blog, the System class loader is responsible for loading the classes and the Jar classes present in the CLASSPATH.  &lt;span style="font-weight: bold;"&gt;But an important NOTE here&lt;/span&gt;:  Tomcat clears the user-set CLASSPATH entry in its startup.bat or startup.sh file. Instead it sets the CLASSPATH to be following:          $CATALINA_HOME/bin/bootstrap.jar           $CATALINA_HOME/bin/tomcat-juli.jar  &lt;span style="font-weight: bold;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;3. Common class loader&lt;/span&gt; - This is a Tomcat 6 provided class loader. It loads the classes present in the following folder - $CATALINA_HOME/lib. These classes are available to Tomcat as well as all the web applications that will be hosted on this instance of Tomcat.  Although developers can reference the APIs from the jars inside the $CATALINA_HOME/lib directory, they shouldn't be placing their own custom classes and/or jars in there. If developers need certain custom classes and/or jars to be shared by all web applications, then they should be placed where the shared class loader can see them.  Note that Tomcat 6.0.14 the $CATALINA_HOME/shared/lib directory does not exist. So this can be done in Tomcat 6 as foll: &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Create your own $CATALINA_HOME/shared/lib directory.&lt;/li&gt;
&lt;li&gt;Modify $CATALINA_HOME/conf/catalina.properties by changing the line: shared.loader = ${catalina.home}/shared/lib&lt;/li&gt;
&lt;/ul&gt;However the above does not apply to certain 3rd party libraries such as database drivers etc where Tomcat itself would need to set up data sources. Such jars have to be placed in the $CATALINA_HOME/lib folder for the common class loader to see.  One can also add more jars for the common class loader without placing them under the $CATALINA_HOME/lib folder. This can be done by modifying $CATALINA_HOME/conf/catalina.properties by changing the property common.loader as above.  &lt;span style="font-weight: bold;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;4. WebappX class loaders&lt;/span&gt; - Tomcat creates a class loader for every webapp that is deployed in its instance. This class loader loads classes under WEB-INF/classes and WEB-INF/lib folder.  It is for these class loaders where the delegation model deviates, thanks to the Servlet Specification which states as follows: "&lt;span style="font-style: italic;"&gt;It is recommended also that the [web] application class loader be implemented so&lt;/span&gt; &lt;span style="font-style: italic;"&gt;that classes and resources packaged within the WAR are loaded in preference to&lt;/span&gt; &lt;span style="font-style: italic;"&gt;classes and resources residing in container-wide library JARs.&lt;/span&gt;"&lt;br /&gt;
However the above specification cannot override the Java standard delegation model of delegating to Bootstrap and System class loaders. It only is used to override the parent-child relationships that are introduced by Tomcat - ie. Common, Shared and WebappX class loaders.  So when an application requests a class, the class loading hierarchy is as follows: &lt;br /&gt;
&lt;ol&gt;&lt;li&gt;The &lt;span style="font-weight: bold;"&gt;bootstrap &lt;/span&gt;class loader looks in the core Java classes folders.&lt;/li&gt;
&lt;li&gt;The &lt;span style="font-weight: bold;"&gt;system &lt;/span&gt;class loader looks in the $CATALINA_HOME/bin/bootstrap.jar and&lt;/li&gt;
&lt;li&gt; $CATALINA_HOME/bin/tomcat-juli.jar&lt;/li&gt;
&lt;li&gt;The &lt;span style="font-weight: bold;"&gt;WebAppX &lt;/span&gt;class loader looks in WEB-INF/classes and then WEB-INF/lib&lt;/li&gt;
&lt;li&gt;The &lt;span style="font-weight: bold;"&gt;common &lt;/span&gt;class loader looks in $CATALINA_HOME/lib folder.&lt;/li&gt;
&lt;li&gt;The &lt;span style="font-weight: bold;"&gt;shared &lt;/span&gt;class loader looks in $CATALINA_HOME/shared/classes and $CATALINA_HOME/shared/lib if the shared.loader property is set in conf/catalina.properties file. &lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pragmaticjava.blogspot.com/feeds/5713049545154772503/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3088683402556685885&amp;postID=5713049545154772503' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/5713049545154772503?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/5713049545154772503?v=2'/><link rel='alternate' type='text/html' href='http://pragmaticjava.blogspot.com/2009/01/tomcat-6-and-class-loading.html' title='Tomcat 6 and class loading'/><author><name>pragmaticjava</name><uri>http://www.blogger.com/profile/04234725971961576090</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_mKzdYE6Bmi0/SWJg5qagj2I/AAAAAAAADpI/0gwZT4XNLhQ/s72-c/classloader.JPG' height='72' width='72'/><thr:total>2</thr:total></entry><entry gd:etag='W/&quot;AkcCQXY4fip7ImA9WhZaEkU.&quot;'><id>tag:blogger.com,1999:blog-3088683402556685885.post-2180088465131689384</id><published>2009-01-04T18:25:00.000-08:00</published><updated>2011-06-28T12:07:40.836-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-06-28T12:07:40.836-07:00</app:edited><title>Java and Class loading delegation model</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;The role of a &lt;span style="font-weight: bold;"&gt;class loader&lt;/span&gt; in Java is to hide the details of loading classes - like  searching the file system (local as well as network) for the class file, loading the class file, returning it to JVM as a Class class so that JVM can use the Class class to instantiate the requested object in the application.  Since J2SE, the JVM is provided 3 distinct primary classloaders - &lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Bootstrap class loader&lt;/span&gt; - This class loader is written in native language and comes as part of the JVM implementation. It loads all the core Java classes. (e.g java.lang.* etc). The location of these jars depends on the implementation of JVM. Sun's JVM looks in the &lt;span style="font-family: courier new;"&gt;jdk/jre/lib&lt;/span&gt; directory.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Extension class loader&lt;/span&gt; - Usually, developers make use of the CLASSPATH environment variable to load application classes, 3rd party jars etc. However, the CLASSPATH can become too unwieldy to handle and prone to errors using this approach. So since Java 1.2 , we can drop the 3rd party jars into a standard extension directory - &lt;span style="font-family: courier new;"&gt;jdk/jre/lib/ext&lt;/span&gt; - and JVM will find them. The extension class loader loads all the classes found in one or more of these extension directories. &lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight: bold;"&gt; System class loader&lt;/span&gt; - This class loader locates and loads the classes in the directories and jar files specified on the CLASSPATH variable. It also loads the application's main class (the one containing the main() method). &lt;/li&gt;
&lt;/ol&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_mKzdYE6Bmi0/SWF-98ssqDI/AAAAAAAADpA/gQTB6FAHRq0/s1600-h/classloader.JPG" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5287647040240396338" src="http://3.bp.blogspot.com/_mKzdYE6Bmi0/SWF-98ssqDI/AAAAAAAADpA/gQTB6FAHRq0/s320/classloader.JPG" style="height: 219px; width: 206px;" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&amp;nbsp;The above 3 exist in a &lt;span style="font-weight: bold;"&gt;parent-child relationship&lt;/span&gt; as follows: &lt;br /&gt;
&lt;br /&gt;
A &lt;span style="font-weight: bold;"&gt;delegation model &lt;/span&gt;is utilized by the JVM in order to determine which class loader amongst the above 3 to use to load a particular class. The model works in a "&lt;span style="font-weight: bold;"&gt;Delegate to Parent-Before-Looking&lt;/span&gt;" as follows:  When an application requests a Class (e.g String str = "Hello World"; or MyClass myobj = new MyClass()) : &lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Each class loader delegates the request to its parent. &lt;/li&gt;
&lt;li&gt;Once the topmost class loader is reached, the bootstrap class loader, it tries to load the class. If it is unable, its child will try.&lt;/li&gt;
&lt;li&gt;If one of the class loaders finds the class, it is returned as a Class object.  Following the delgation pattern , if the lowermost  class loader in the hierarchy (System class loader) does not find the class, a ClassNotFoundException is thrown.&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pragmaticjava.blogspot.com/feeds/2180088465131689384/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3088683402556685885&amp;postID=2180088465131689384' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/2180088465131689384?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/2180088465131689384?v=2'/><link rel='alternate' type='text/html' href='http://pragmaticjava.blogspot.com/2009/01/java-and-class-loading-delegation-model.html' title='Java and Class loading delegation model'/><author><name>pragmaticjava</name><uri>http://www.blogger.com/profile/04234725971961576090</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_mKzdYE6Bmi0/SWF-98ssqDI/AAAAAAAADpA/gQTB6FAHRq0/s72-c/classloader.JPG' height='72' width='72'/><thr:total>2</thr:total></entry><entry gd:etag='W/&quot;AkUBQXk-eCp7ImA9WhZaEkU.&quot;'><id>tag:blogger.com,1999:blog-3088683402556685885.post-815576976131223239</id><published>2008-12-07T19:42:00.000-08:00</published><updated>2011-06-28T12:10:50.750-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-06-28T12:10:50.750-07:00</app:edited><title>Java 5 Concurrency: The Executor framework</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;The Java platform has always provided support for multi-threaded/concurrent programming. However, prior to Java 5, the support was in the form of primitive constructs in the programming language itself. Java 5 steps up and provides concurrency utility frameworks and data structures in the &lt;span style="font-family: courier new;"&gt;java.util.concurrent&lt;/span&gt; package. One of the utilities provided is the task scheduling framework better known as the &lt;span style="font-weight: bold;"&gt;Executor framework&lt;/span&gt;.  The JVM runs as a process and our application is one of the threads in the JVM. There are various other "system" threads running to do tasks like garbage collection, memory management etc. But from the application's perspective, there is the single "main" thread to begin with.  The application, in itself, can spawn a number of threads to perform various helper tasks for various reasons like performance etc. Prior to Java 5 , spawning a new thread to perform a task was most commonly done as follows, although you could also do by extending the &lt;span style="font-family: courier new;"&gt;Thread &lt;/span&gt;class, but it is not highly recommended:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="java" name="code"&gt;public void mainMethod() {
 HelperTask task = new HelperTask(); // Step 1: Create an object representing the task
 Thread t = new HelperThread(task);  // Step 2: Create a new thread for executing the task
 t.start();                        //  Step 3: Start the new thread
}

public class HelperTask implements Runnable {
public void run() {
      doHelperTask();
}
}
&lt;/pre&gt;We have the following issues: &lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Most of the code related to thread creation and task delegation to the thread is a part of the application itself. We need a way to abstract the above steps away from the application. &lt;/li&gt;
&lt;li&gt;Also what if we have multiple helper tasks or a scenario where every single user action requires a new Thread to be spawned to process? Creating a lot many threads with no bounds to the maximum threshold can cause out application to run out of memory. &lt;/li&gt;
&lt;li&gt;Secondly although threads are light-weight (but only as compared to the process) , creating them utilizes a lot of resources. In such a situation, having a ThreadPool is a better solution so that only fixed number of Threads are created and re-used later.&lt;/li&gt;
&lt;li&gt;Another short-coming of the &lt;span style="font-family: courier new;"&gt;Runnable &lt;/span&gt;interface's &lt;span style="font-family: courier new;"&gt;void run() &lt;/span&gt;method is that the task executed within run() has no way of returning any result back to the main thread. So work-arounds designed around that would be that the asynchronous task either updates certain database table(s) or some file(s) or some such external data structure(s) to communicate the result to the main thread.&lt;/li&gt;
&lt;/ol&gt;The &lt;span style="font-weight: bold;"&gt;Executor framework&lt;/span&gt; addresses all the above issues and in addition also provides additional  life-cycle management features for the threads. The Executor framework consists of the following important interfaces:&lt;br /&gt;
&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;&lt;li&gt;&amp;nbsp;&lt;a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Callable.html"&gt;Callable&lt;/a&gt;: This interface is similar in concept to Runnable interface, ie it represents the asynchronous task to be executed. The only difference is that its call() method returns a value, ie the asynchronous task will be able to return  a value once it is done executing.&amp;nbsp; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Executor.html"&gt;Executor&lt;/a&gt;, &lt;a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ExecutorService.html"&gt;ExecutorService &lt;/a&gt;and &lt;a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ScheduledExecutorService.html"&gt;ScheduledExecutorService&lt;/a&gt; - Each of these interfaces adds more functionality to the previous one in thread and their life-cycle management. The &lt;span style="font-weight: bold;"&gt;Executor &lt;/span&gt;abstracts the Thread creation (as seen in Step 1 above) and executes all &lt;span style="font-style: italic;"&gt;Runnable &lt;/span&gt;tasks. The &lt;span style="font-weight: bold;"&gt;ExecutorService &lt;/span&gt;extends the Executor and is able to execute &lt;span style="font-style: italic;"&gt;Callable &lt;/span&gt;tasks in addition to Runnable tasks. It also contains life cycle management methods. The &lt;span style="font-weight: bold;"&gt;ScheduledExecutorService &lt;/span&gt;allows us to schedule the asynchronous tasks thereby adding support for delayed and periodic task execution.&amp;nbsp; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Future.html"&gt;Future&lt;/a&gt;: This interface represents the result of the asynchronous task which itself could be represented as Callable. The ExecutorService which can execute Callable tasks returns a Future object to return the result of the Callable task.&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pragmaticjava.blogspot.com/feeds/815576976131223239/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3088683402556685885&amp;postID=815576976131223239' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/815576976131223239?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/815576976131223239?v=2'/><link rel='alternate' type='text/html' href='http://pragmaticjava.blogspot.com/2008/12/java-5-concurrency-executor-framework.html' title='Java 5 Concurrency: The Executor framework'/><author><name>pragmaticjava</name><uri>http://www.blogger.com/profile/04234725971961576090</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry gd:etag='W/&quot;D04AQXs4eyp7ImA9WxRVFUQ.&quot;'><id>tag:blogger.com,1999:blog-3088683402556685885.post-2246713227003189981</id><published>2008-11-13T09:04:00.001-08:00</published><updated>2008-11-13T09:05:40.533-08:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2008-11-13T09:05:40.533-08:00</app:edited><title>Essentials of a Software Engineer</title><content type='html'>Sites like &lt;a href="http://www.digg.com"&gt;Digg &lt;/a&gt;usually have highest number of "diggs" on stuff like "Top 5/10/n" things on varied topics. Recently a co-worker sent me one such popular article about "Top 10 concepts that every software engineer should know". This was just in time as I was preparing to start this blog about the various techniques that would enable a Java engineer to be more pragmatic regardless of the kind of applications being developed and the myriad of technologies/frameworks being used .
In my opinion, it is more essential to know these principles thoroughly and put them in practice before jumping to learning any new frameworks. Most of the frameworks - open source or otherwise - are usually the usage of the design principles in practice to solve commonly encountered problems.

Good Object-Oriented(OO) design is the key principle here. As Rod Johnson points out here,

"&lt;span style="font-style: italic;"&gt;It's possible to design a [J2EE] application so badly that, even if it contains beautifully written Java code at an individual object level, it will still be deemed a failure. A [J2EE] application with an excellent overall design but poor implementation code will be an equally miserable failure.&lt;/span&gt;
&lt;span style="font-style: italic;"&gt;... adherence to good OO principles brings real benefits. OO design is more important than any particular implementation technology (such as [J2EE], or even Java). Good programming practices and sound OO design underpin good [Java/J2EE] applications. Bad Java code is bad J2EE code.&lt;/span&gt;"</content><link rel='replies' type='application/atom+xml' href='http://pragmaticjava.blogspot.com/feeds/2246713227003189981/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3088683402556685885&amp;postID=2246713227003189981' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/2246713227003189981?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/2246713227003189981?v=2'/><link rel='alternate' type='text/html' href='http://pragmaticjava.blogspot.com/2008/11/essentials-of-software-engineer.html' title='Essentials of a Software Engineer'/><author><name>pragmaticjava</name><uri>http://www.blogger.com/profile/04234725971961576090</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;AkMGQ3k9eip7ImA9WhZaEkU.&quot;'><id>tag:blogger.com,1999:blog-3088683402556685885.post-845576239251306897</id><published>2008-09-28T19:49:00.000-07:00</published><updated>2011-06-28T12:13:42.762-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-06-28T12:13:42.762-07:00</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='Web Services'/><title>Overview of Web Service Stacks</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;There are currently the following open-source Java Web Service stacks in the market today.There could be more that I am unaware of, but at least the following contribute more significantly to the market share. &lt;br /&gt;
&lt;ol&gt;&lt;li&gt; Apache Axis1 and Apache Axis2 &lt;/li&gt;
&lt;li&gt;Apache CXF&lt;/li&gt;
&lt;li&gt;Spring-WS&lt;/li&gt;
&lt;li&gt; Sun’s Metro available via Java EE 5 GlassFish container&lt;/li&gt;
&lt;li&gt; JbossWS&lt;/li&gt;
&lt;li&gt;XFire - which is now merged and transformed to being CXF.&lt;/li&gt;
&lt;/ol&gt;This article is a comparative interview with each of the web service stack’s Principal Engineers and their vision for their product. &lt;a href="http://www.infoq.com/articles/os-ws-stacks-background"&gt;http://www.infoq.com/articles/os-ws-stacks-background&lt;/a&gt;  The second article is a comparison between Apache’s 3 products – Axis1, Axis2 and CXF. &lt;a href="http://www.theserverside.com/tt/articles/article.tss?l=AxisAxis2andCXF"&gt;http://www.theserverside.com/tt/articles/article.tss?l=AxisAxis2andCXF&lt;/a&gt;  Both of these articles are non-biased articles with no claims of one being better than the other. They leave it up to users to pick the one most matching their needs and demands.  Sun has now published the standards for Web Services and it has now become imperative for all the Web Service stacks to provide implementations of those for conformance. Every web service stack provides the core functionality of:&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;&lt;li&gt;Providing an easy-to-use deployment option.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Correct Web service/operation invocation for the particular message(SOAP/REST). This further involves in the following order - &lt;/li&gt;
&lt;/ol&gt;&lt;ul&gt;&lt;li&gt;Receiving the message over the correct transport endpoint(Endpoint is an abstraction to represent URL and port), &lt;/li&gt;
&lt;li&gt;Figure out the operation intended to perform based on the message, and then &lt;/li&gt;
&lt;li&gt;Invoke the correct Java method mapping to the operation.&lt;/li&gt;
&lt;/ul&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3.&amp;nbsp; Pre-processing the messages via handlers to perform various functions like authentication, logging, custom processing etc.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 4. Marshaling/Unmarshaling mechanism of the request and response structures to/from Java&amp;lt;=&amp;gt;XML.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 5.&amp;nbsp; In addition, today's web service stacks are expected to provide implementations for the various WS-* standards that exist.&lt;br /&gt;
&lt;br /&gt;
With respect to points # 2 and # 4 above, Mark Hansen has correctly pointed out:&lt;br /&gt;
&lt;i&gt;The key technology for efficient SOA is efficient and accurate Java/XML mapping or more generically known as the OXM (Object-XML Mapping)as pointed out by Spring-WS. At the SOA level, system standards are specified using platform independent XML messages (SOAP/REST) and WSDL operations (which themselves are in XML). But at the language level (Java/C#/VB etc), the systems that are the real engines behind the functionality of SOA are implemented using objects and methods. The more seamless effortless and accurate OXM solution that a web service engine provides the more popular it will be.&lt;/i&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pragmaticjava.blogspot.com/feeds/845576239251306897/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3088683402556685885&amp;postID=845576239251306897' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/845576239251306897?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/845576239251306897?v=2'/><link rel='alternate' type='text/html' href='http://pragmaticjava.blogspot.com/2008/09/overview-of-web-service-stacks.html' title='Overview of Web Service Stacks'/><author><name>pragmaticjava</name><uri>http://www.blogger.com/profile/04234725971961576090</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry gd:etag='W/&quot;DEAHQno4eip7ImA9WxRVFUQ.&quot;'><id>tag:blogger.com,1999:blog-3088683402556685885.post-6939958707082365019</id><published>2008-09-28T16:18:00.000-07:00</published><updated>2008-11-13T09:18:53.432-08:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2008-11-13T09:18:53.432-08:00</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='JWS'/><category scheme='http://www.blogger.com/atom/ns#' term='JAXB'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Web Services'/><category scheme='http://www.blogger.com/atom/ns#' term='JSR 181'/><category scheme='http://www.blogger.com/atom/ns#' term='JAX-WS'/><category scheme='http://www.blogger.com/atom/ns#' term='JAX-RPC'/><title>Programming Java Web Services</title><content type='html'>For someone who is a total newbie to the world of Java Web Services(JWS), here's a list of the different JSRs/standards within the realm of JWS that are available with Java EE 5 and Java SE 6. They all have a particular purpose in the whole orchestration of JWS.
&lt;ol&gt;&lt;span style="font-weight: bold;"&gt;&lt;li&gt; JAX-WS 2.0 (Java API for Xml-Web Services) - specified by JSR 224. &lt;/li&gt;&lt;/span&gt;
This was formerly JAX-RPC 1.1. JAX-RPC 1.1 was a standards-based implementation, but the binding and parsing layers underneath it were proprietary. When JAX-RPC 1.1 needed a major overhaul, the next JAX-RPC version would have been JAX-RPC 2.0 But the industry evolved more than just doing RPC-style web services. So to accommodate the message-style web services as well, which are becoming more and more common, "RPC" was dropped to become a more general JAX-WS 2.0

&lt;span style="font-weight: bold;"&gt;&lt;li&gt;JAXB 2.0 (Java API for Xml Binding) - specified by JSR 222.&lt;/li&gt;&lt;/span&gt;
This specification defines and nominates JAXB as the default mechanism for serializing and de-serializing the XML messages contained within the SOAP message and Java objects. There are sure other ways to do this job via other Java-XML binding mechanisms - like XMLBeans, JiBX, Castor etc. But the JWS specs (defined by Sun) decided to make JAXB 2.0 as the "default" standard.

&lt;span style="font-weight: bold;"&gt;&lt;li&gt;WS-Metadata 2.0 (Web Services Metadata) - specified by JSR 181.&lt;/li&gt;&lt;/span&gt;
Deploying Web services is quite a feat. One would normally require a set of deployment descriptors a la typical J2EE applications. But from Java EE 5  onwards, we now have web services-specific metadata annotations to achieve the deployment.

&lt;span style="font-weight: bold;"&gt;&lt;li&gt;WSEE 1.2 - Web Services for Java EE - specified by JSR 109.&lt;/li&gt;&lt;/span&gt;
This defines the program model and run-time beahvior of Web Services in the Java EE container.
&lt;/ol&gt;
All these standards can be complex to understand at first, and after surfing a lot on the web for an in-depth perspective, I have finally landed on the book "&lt;a href="http://www.soabook.com/"&gt;SOA Using Java Web Services&lt;/a&gt;" by Mark D. Hansen.</content><link rel='replies' type='application/atom+xml' href='http://pragmaticjava.blogspot.com/feeds/6939958707082365019/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3088683402556685885&amp;postID=6939958707082365019' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/6939958707082365019?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/6939958707082365019?v=2'/><link rel='alternate' type='text/html' href='http://pragmaticjava.blogspot.com/2008/09/programming-java-web-services.html' title='Programming Java Web Services'/><author><name>pragmaticjava</name><uri>http://www.blogger.com/profile/04234725971961576090</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry gd:etag='W/&quot;AkEEQXg7eyp7ImA9WhZaEkU.&quot;'><id>tag:blogger.com,1999:blog-3088683402556685885.post-1642229181840982085</id><published>2008-08-12T18:38:00.000-07:00</published><updated>2011-06-28T12:16:40.603-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-06-28T12:16:40.603-07:00</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='Spring-Core'/><category scheme='http://www.blogger.com/atom/ns#' term='Dependency Injection'/><category scheme='http://www.blogger.com/atom/ns#' term='J2EE'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><title>Why do J2EE applications need Spring? The core of Spring explained...</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt; What is the core of spring? The real purpose of why it came to being and is so popular.&lt;/span&gt;  Most Java/J2EE application code tend to become monolithic (read a single large code base) over time - i.e. the application code slowly diminishes to maintain its modularized form with the result that the dependency relation graph between the classes/objects gets really ugly with no standard form.  Secondly the applications also need a lot of infrastructure services - like Life Cycle Management of their objects and important resources like database connections etc, Database Access, Transaction Management and many more.Even simple Java applications would at least require efficient management of their objects and its dependencies. Although standard J2EE API and the application servers implementing those API claim to provide all the infrastructure services, applications still tend to become monolithic and unwieldy.  So we need simplicity and freedom in the following areas:&lt;br /&gt;
&lt;br /&gt;
1. &lt;span style="font-weight: bold;"&gt;Externally configurable objects&lt;/span&gt; - It is always better to be able to configure objects externally, i.e. set their values externally without recompilation of Java code or involving developers. The whole beauty of the general concept of configuration is that any change made to it does not require a rebuild or redeployment.&lt;br /&gt;
&lt;br /&gt;
2. &lt;span style="font-weight: bold;"&gt;Simple POJO based programming&lt;/span&gt; - If we are just able to concentrate on programming business logic and not spend time of writing infrastructural code, we speed up the time to deliver the project by at least 40%.  Simplicity and speed usually are natural if we adopt the POJO-based programming model. But for a real application, we have to add code to the POJOs to access databases, coordinate transactions, locate services provided by the container/environment, and so on. We would like these tasks to be performed declaratively via configuration (and via annotations), without disturbing the POJO code.&lt;br /&gt;
&lt;br /&gt;
3. &lt;span style="font-weight: bold;"&gt;Dependency Resolution &lt;/span&gt;- Java interfaces do provide a clear separation between a contract and implementation. Ideally we would want the client class to be dependent only on the interface class. But we still have to look up the implementation class that we want to use. If it is hard-coded in Java code, we lose the advantage of interfaces, because the client class now depends on the interface class and the implementation class.  Eg. Let's say we have an interface I and 2 concrete implementations of it - say C1 and C2.  The whole idea of having interface is to shield client from the concrete classes at compile-time. But the client class still had to know about C1 at compile-time. But the client class still ends up having something like this: &lt;br /&gt;
&lt;pre name="code" class="java"&gt;I iobj1 = new C1();
iobj1.executeMethod();
&lt;/pre&gt;We do have to be aware of C1, otherwise we would never be able to work without real implementations. But it is better to have awareness outside of Java code.&lt;br /&gt;
&lt;br /&gt;
4. &lt;span style="font-weight: bold;"&gt;Lookup of Resources&lt;/span&gt; - A Java object A, say, depending on another Java resource B or a resource like Database C, should not be concerned with looking up for them. We again need a way to externally configure lookup code.  &lt;span style="font-style: italic; font-weight: bold;"&gt;So how does Spring help us?&lt;/span&gt; &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Spring helps us achieve the above by wiring the dependencies between objects, all external to Java code.&lt;/li&gt;
&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Spring is essentially a technology dedicated to enabling you to build applications using POJOs.The components/objects are simple POJOs providing simple getters and setters. The container wires all the objects passing the dependent objects to POJO properties or constructors.Spring achieves the above using the Dependency Injection mechanism.&lt;/li&gt;
&lt;/ul&gt;&lt;ul&gt;&lt;li&gt; Most importantly, Spring itself is modular and has a layered architecture. This means we can use just the core JavaBeans configuration management without using the MVC framework or AOP support or DAO support. This means we can create modularized applications of any kind; so you are not restricted to creating web-based enterprise Java applications.&lt;/li&gt;
&lt;/ul&gt;A more detailed discussion on what Spring does and does not can be found &lt;a href="http://www.theserverside.com/tt/articles/article.tss?l=SpringFramework"&gt;here&lt;/a&gt;.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pragmaticjava.blogspot.com/feeds/1642229181840982085/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3088683402556685885&amp;postID=1642229181840982085' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/1642229181840982085?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/1642229181840982085?v=2'/><link rel='alternate' type='text/html' href='http://pragmaticjava.blogspot.com/2008/08/why-do-j2ee-applications-need-spring.html' title='Why do J2EE applications need Spring? The core of Spring explained...'/><author><name>pragmaticjava</name><uri>http://www.blogger.com/profile/04234725971961576090</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry gd:etag='W/&quot;DE8HRnw8fyp7ImA9WxRVFUQ.&quot;'><id>tag:blogger.com,1999:blog-3088683402556685885.post-2182858056792179370</id><published>2008-08-03T12:13:00.000-07:00</published><updated>2008-11-13T09:20:37.277-08:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2008-11-13T09:20:37.277-08:00</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='software design principle'/><category scheme='http://www.blogger.com/atom/ns#' term='interface'/><category scheme='http://www.blogger.com/atom/ns#' term='code'/><category scheme='http://www.blogger.com/atom/ns#' term='Program'/><title>Program to an interface, not an implementation</title><content type='html'>In the introduction of the GoF book, the GoF mention an important principle of reusable object-oriented design. The principle is: "Program to an  interface, not an implementation".

The basic reason behind it is to achieve the flexibility in choosing different implementations at run-time as many times via the interface. This is achieved because of the polymorphism feature of the OO languages. The power of interfaces is best understood in design patterns. Most of the design patterns such as Strategy, State, Command, Abstract Factory Method are actually the above principle in practice.

Now how do we try to abide by the principle? The best way is to strive for having method signatures with more generic, interface or parent class type method parameters and return types.  Also it is advisable to declare class member variables to be of a more generic, interface or parent class type rather than a concrete implementation.

The advantages of using interfaces (pure interfaces and/or abstract base classes) are as follows:
&lt;ul&gt;&lt;li&gt;It is always painless to depend on interfaces. Client classes depending on the interfaces remain unaware of the concrete classes they use indirectly via the interface , as long as the concrete classes adhere to the interface that clients expect. This makes the clients more resilient to changes in implementation details. &lt;/li&gt;&lt;li&gt;The above aspect makes unit testing also very easy. In order to test a client class that depends on a complex computation exposed by an interface, we can create a mock stub object that implements the interface to replace the complex computation object.&lt;/li&gt;&lt;li&gt;Depending on interfaces has benefits even beyond just programming. The more we depend on concrete classes, the more complex dependency structures become, as a result our build scripts and build processes also tend to be more unwieldy.&lt;/li&gt;&lt;/ul&gt;Erich Gamma, one of the GoF, explains in an &lt;a href="http://www.artima.com/lejava/articles/designprinciples.html"&gt;interview: &lt;/a&gt;

"&lt;span style="font-style: italic;"&gt;This principle is really about dependency relationships which  have to be carefully managed in a large app. It's easy to add a dependency on a class. It's  almost too easy; just add an import statement and modern Java IDEs like  Eclipse even write this statement for you.Interestingly the inverse isn't that easy and  getting rid of an unwanted dependency can be real refactoring work or even worse, block  you from reusing the code in another context. For this reason you have to develop with  open eyes when it comes to introducing dependencies. This principle tells us that  depending on an interface is often beneficial.&lt;/span&gt;"</content><link rel='replies' type='application/atom+xml' href='http://pragmaticjava.blogspot.com/feeds/2182858056792179370/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3088683402556685885&amp;postID=2182858056792179370' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/2182858056792179370?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3088683402556685885/posts/default/2182858056792179370?v=2'/><link rel='alternate' type='text/html' href='http://pragmaticjava.blogspot.com/2008/08/program-to-interface-not-implementation.html' title='Program to an interface, not an implementation'/><author><name>pragmaticjava</name><uri>http://www.blogger.com/profile/04234725971961576090</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry></feed>