Eskatos’s thoughts on JEE development

A maven plugin to repackage your java archives : jaroverlay-maven-plugin

Posted in jaroverlay-maven-plugin, maven by eskatos on August 3rd, 2008

In the Java EE 5 TutorialDevelopment Roles” chapter we can see the following three roles, from the code to the deployment :

  • Application Component Provider: “The application component provider is the company or person who creates web components, enterprise beans, applets, or application clients for use in Java EE applications.”
  • Application Assembler: “The application assembler is the company or person who receives application modules from component providers and assembles them into a Java EE application EAR file.”
  • Application Deployer and Administrator: “The application deployer and administrator is the company or person who configures and deploys the Java EE application …”

This page says that this is the Application Assembler job to configure the deployment descriptor before packaging the EAR.

Beside that, artifact produced by mavenized enterprise projects are EARs, already packaged. Plus, it often is the developer (or Application Component Provider) that write the packaging configuration.

Next comes the “configuration for deployment” time. Here, if deployment dependant configuration is in deployment descriptors you would have to unpack the EAR and possibly nested java archives (WARs and/or JARs) to get a hand on all deployment descriptors.

This task can be quite cumbersome and time consuming (really dumb too). (more…)

asadmin-maven-plugin-0.2 released

Posted in asadmin-maven-plugin by eskatos on July 20th, 2008

I released the second version of asadmin-maven-plugin today.

It added the following features :

  • Issue#1: support for maven projects with “ejb” packaging
  • support for (un)deploying to remote glassfish instance (thanks to Larry Sanderson that provided the patch)

The following issues were fixed :

  • Issue#2: asadmin is not found when only glassfishHome is specified and glassfishHome/bin not in PATH (thanks to streifi that provided a patch)
  • Issue#3: asadmin:start-domain hangs on windows (thanks again to streifi)

Go to the project’s page for more information.

Tagged with: , ,

Customer i18n overlays with GWT

Posted in HOWTOs by eskatos on July 19th, 2008

I’m building a web backoffice for an IT product with GWT for several month now. I had to internationalize all the UI. GWT provides several mechanisms for i18n. I use Constants and Messages because I love the compile time check and the fact that deferred binding permutations provide a download as small as possible to the users.

All this worked well until we wanted to provide customers the ability to change how things are named in our product. In the UI layer of course !

Like said above, GWT is using deferred binding to provide a Constant/Message implementation per locale. I extended this mechanism to provide a Constant/message implementation per locale and a given GWT property.

Enough talk, lets see how this is done.
(more…)

Tagged with:

Maven plugins for Glassfish ecosystem

Posted in asadmin-maven-plugin by eskatos on March 28th, 2008

This post is only a snapshot of what is available at the time of writing to use Glassfish from maven., seen from the perspective of a simple maven plugin developer (simple plugin or simple developer ?).

Before beginning asadmin-maven-plugin, I searched and tried several ways to use Glassfish from maven. Main use case is simply deployment and undeployment of applications.

There are two ways to do this “programmatically” :

  • using the asadmin command, Glassfish specific,
  • and using the JSR-88 api, app-server agnostic

(more…)

Tagged with: , , ,

A repository for asadmin-maven-plugin

Posted in asadmin-maven-plugin by eskatos on March 26th, 2008

To ease the use of asadmin-maven-plugin I have set up a public repository that you can add to your maven settings / poms / proxies for maven to be able to download the plugin automagically.

The repositories are :

Here is the xml snippet you could add to your pom.xml file :

    <pluginRepositories>
        <pluginRepository>
            <id>asadmin-maven-plugin-releases-repository</id>
            <name>asadmin-maven-plugin-releases-repository</name>
            <url>http://asadmin-maven-plugin.googlecode.com/svn/trunk/repository/releases</url>
            <releases><enabled>true</enabled></releases>
            <snapshots><enabled>false</enabled></snapshots>
        </pluginRepository>
        <pluginRepository>
            <id>asadmin-maven-plugin-snapshots-repository</id>
            <name>asadmin-maven-plugin-snapshots-repository</name>
            <url>http://asadmin-maven-plugin.googlecode.com/svn/trunk/repository/snapshots</url>
            <releases><enabled>false</enabled></releases>
            <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
    </pluginRepositories>

Plus, if you browse the source tree you’ll find two exemple projects, a WAR and an EAR, that use this plugin.

Tagged with: , , ,

A simple maven plugin for Glassfish: asadmin-maven-plugin

Posted in asadmin-maven-plugin by eskatos on March 24th, 2008

To seamlessly use Glassfish from maven projects, JSR-88 seems to be answer. The cargo maven plugin has JSR-88 support planned but this will take time.

I published some days ago a maven plugin that simply wraps the asadmin command and aims to provide maven integration for starting, stopping glassfish and deploying and undeploying applications and modules.

Go to the Google Code page of asadmin-maven-plugin to download a preview version named asadmin-maven-plugin-0.1-SNAPSHOT : http://code.google.com/p/asadmin-maven-plugin/

The api is designed for easy extensibility so feel free to submit contributions !
(more…)

Tagged with: , ,

A simple^W dumb Map wrapper to use with JAXB

Posted in HOWTOs by eskatos on March 14th, 2008

I sometimes need to use java.util.Map objects in WebServices. As I’m building all my WebServices with the JAX-WS RI (using the Metro bundle). The block responsible for XML (un)marshalling of POJO, named JAXB, does not allows to directly use Maps as a soap operation parameter. For this purpose I’ve written the following simple class that allows me to wrap Maps in a POJO that JAXB is able to (un)marshall :

public class JAXBMapWrapper<KT, VT> {

    private Map<KT, VT> wrappedMap;

    public JAXBMapWrapper() {
        wrappedMap = new HashMap<KT, VT>();
    }

    public Map<KT, VT> getWrappedMap() {
        return wrappedMap;
    }

    public void setWrappedMap(final Map<KT, VT> givenMap) {
        wrappedMap = givenMap;
    }

}

ATTENTION : I posted this some days ago and removed the post after understanding that this is simpler on the service side but that the client side gets cumbersome generated classes.. but google cache indexed the post in less than half a day.

Just don’t use this ! :) If you need to transmit Maps over JAX-WS webservices, do it the XmlAdapter way as advertised in the official Unofficial JAXB Guide instead.

Tagged with: , ,

Could it be dared to say that java is overdesigned ?

Posted in Various Links by eskatos on March 8th, 2008

Java 7 is coming. And it’s an awesome project ! Now that java is distributed under the GPL, developers can believe that the JSR way of doing things will be more and more pragmatic.

The title of this post is a little bit coarse but this is the feeling java gives to developpers who “learn and use java to create and run programs that make devices and internet useful for people“.

I just read some articles about jdk7 changes that I want to share :

About the new framework for fork-join style parallel decomposition and the ParallelArray class in java.util.concurrent :

About the first attempt to give packages and visibility modifiers a lift :

The first ones are really exciting ! The one about the superpackages scares me a little. I know it’s the first “public” communication about it but I sincerely hope that the final solution will be presented with successfull examples of complex implementations, ie. will be pragmatic.

Tagged with:

JAXB Custom Binding for Joda-Time

Posted in Tools by eskatos on November 24th, 2007

I’m extensively using Joda-Time for handling time in my Java development, client or server side. Joda-Time is the codebase of the coming RI implementation of JSR-310 that will hopefully ship in Java 7.

I often need to work with dates in web services implementations, here is the JAXB custom binding lines I use to un/marshall JodaTime types to standard xs:date and xs:dateTime XML Schema types.

Note : I’m using the RI implementation of JAXB spec bundled in Metro.
(more…)

Tagged with: , , , ,

Classpath tools : jcfind and JWhich

Posted in Tools by eskatos on October 20th, 2007

Deep understanding of Java classpath is something that is too often neglected. I won’t write an article about classpath, internet is full of readings about it :

Here come JWhich and jcfind. Both are classpath reflection tools.

JWhich provides a command line interface and a Java api where jcfind only has command line interface and is written in python.

I prefer to use jcfind from the command line because it’s really faster than Which4j and the command line is more practical. In Java software, I use the JWhich API that is really easy to use. The big drawback of using Which4j from command line is that you must provide a full class name, using it’s API you can search for a class simple name.

Tagged with: ,