Developer guide for Camel integration into JOnAS 5(camel-jonas5).

JOnAS Team

This work is licensed under the Creative Commons Attribution-ShareAlike License. To view a copy of this license,visit http://creativecommons.org/licenses/by-sa/2.0/deed.en or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.


1. Developing camel-jonas5.
1.1. Getting camel-jonas5 From the SVN Repository
1.2. Building from source.
1.2.1. Requirements
1.2.2. Optional Requirements
1.2.3. Compiling camel-jonas5.
1.2.4. Maven assembly
1.2.5. Testing
1.3. Code Conventions in camel-jonas5
1.3.1. File Organization
1.3.2. Indentation / whitespace
1.3.3. JavaDoc Comments
1.3.4. Statements
1.4. Contributing to camel-jonas5
1.4.1. Mailing Lists
1.4.2. Ideas for Contributing

This guide explains how to contribute to camel-jonas5.

Developing camel-jonas5.

1.1. Getting camel-jonas5 From the SVN Repository

Anyone can check out source code from the SVN server using the following command (for GUI SVN client use, configuration values are the same as for command line use):

svn checkout svn://svn.forge.objectweb.org/svnroot/jonas/sub-projects/camel-jonas5/trunk

It is also possible to retrieve a particular branch or a particular tag. For example:

svn checkout svn://svn.forge.objectweb.org/svnroot/jonas/sub-projects/camel-jonas5/tags/camel-jonas5-1.6.2

Access for developers is available using :

svn checkout svn+ssh://developername@svn.forge.objectweb.org/svnroot/jonas/sub-projects/camel-jonas5/trunk

1.2. Building from source.

1.2.1. Requirements

1.2.1.1. JDK

A Java SE 5 is required to build the project. Make sure that the JDK used to build camel-jonas5 is compliant with the new Java 5 features.

1.2.1.2. Maven

The maven tool is used with pom.xml files. This tool is available at http://maven.apache.org. The 2.0.7 or later version is recommanded

1.2.2. Optional Requirements

1.2.2.1. Eclipse

The camel-jonas5 project provides .project and .classpath for Eclipse 3.1 or greater. A project is ready to use once the source has been imported using the Eclipse tool. Eclipse tool is available at http://www.eclipse.org.

1.2.2.2. Eclipse Plugins

1.2.2.2.1. Checkstyle Plugin

The eclipse-checkstyle plugin(version 4 or greater) is used to check the javadoc of camel-jonas5 project. A warning will print if the camel-jonas5 coding convention is not used.

This plugin is available at

http://eclipse-cs.sourceforge.net.

1.2.2.2.2. AnyEdit Plugin

As part of the coding convention, the use of tabulation characters is disallowed. Files should contain only spaces. The AnyEdit plugin allows tabs to be converted to spaces when saving the file. Also, trailing spaces can be removed automatically.

This plugin is available at http://andrei.gmxhome.de/anyedit/.

1.2.2.2.3. Maven 2 plugin

To compile camel-jonas5 under eclipse, use m2eclipse plugin available at http://m2eclipse.codehaus.org/.

1.2.2.2.4. Subversion plugin

camel-jonas5 uses subversion as revision control system. The use of stable version of Subversive is advised. This plugin is available at http://www.polarion.org/index.php?page=overview&project=subversive.

1.2.3. Compiling camel-jonas5.

To compile camel-jonas5, launch the command mvn in the root directory of the project.

[Note] Note

The default maven goal is install if not specified.

Once the command has been run successfully, the maven artifacts generated by maven are available in the maven local repository. The target directories contain the generated jars or assemblies.

mvn clean install is used to clean and regenerate classes.

1.2.4. Maven assembly

camel-jonas5 generates a ready to use JOnAS assembly extended with everything needed for Camel integration(bundles, configuration files, ...), in package-with-jonas/target folder.

More infos on how to launch JOnAS could be found here http://jonas.ow2.org/JONAS_5_1_1/doc/doc-en/html/index.html

1.2.5. Testing

Most modules of camel-jonas5 contain unit tests. Integration tests are also avaible incamel-service-itests

Those integration tests unpack the JOnAS 5 assembly, start the server, deploy some application examples, perform testing, and stop the server. A continuous integration platform(bamboo) compile the project on each svn commit, and deploy maven artifacts that are generated.

1.3. Code Conventions in camel-jonas5

Contributions should follow the camel-jonas5 code convention. A good document to begin with is Java code convention. Other conventions are also listed in this document.

In addition, camel-jonas5 uses tools to check the compliance: the checkstyle plugin and the eclipse checkstyle plugin. The configuration settings are available on JOnAS SVN.

1.3.1. File Organization

1.3.1.1. Header

All files should have a header that contains the LGPL and the date.

If a file is modified, the modification year should be appended to the existing year, which is the year it was initially created. For example, if the create date is '1999' or '2004' it should be edited to '1999-2006' or '2004-2006', respectively.

Also, the tag $Id: code_convention.xml 314 2006-04-04 09:39:43Z pinheirg $ should be added. The following is a header example:

        /** 
        * JOnAS: Java(TM) Open Application Server 
        * Copyright (C) 2010 Bull S.A.S. 
        * Contact: jonas-team@ow2.org 
        * This library is free software; you can redistribute it and/or 
        * modify it under the terms of the GNU Lesser General Public 
        * License as published by the Free Software Foundation; either 
        * version 2.1 of the License, or any later version. 
        * This library is distributed in the hope that it will be useful, 
        * but WITHOUT ANY WARRANTY; without even the implied warranty of 
        * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
        * Lesser General Public License for more details.
        * You should have received a copy of the GNU Lesser General Public 
        * License along with this library; if not, write to the Free Software 
        * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
        * *
        --------------------------------------------------------------------------
        * $Id: code_convention.xml 19620 2010-04-01 14:13:01Z eyindanga $ *
        --------------------------------------------------------------------------
        */

1.3.1.2. Imports

Imports should reference a valid class name, instead of using wildcard imports. Wildcard imports are not authorized.

For example, if the interface and class List and ArrayList are used, the imports should not be as follows:

 import java.util.*; 

The imports should have each class as follow:

 import java.util.List; import java.util.ArrayList;
        

The classes should not have an unused import.

[Note] Note

The Eclipse IDE provides facilities to do this job. There is the option Organize Imports (Shift+Ctrl+O) in the menu Source that correctly inserts the imports and removes the unused imports. However, this option does not work well with 'import static'.

1.3.1.3. Class and Interface Declarations

The class and interface names should begin with an uppercase letter. Also, each class and interface has an @author tag in the comment. For example:

 
        /** 
        * This is an example that shows a class/interface declaration. 
        * @author Loris Bouzonnet 
        * @author Stephane Zeng 
        */
        public class ClassExample implements InterfaceExample { }
        

1.3.2. Indentation / whitespace

1.3.2.1. Indentation

The space character is used instead of the tab character. The number of spaces for an indent is 4 spaces.

Wrapping a single source line into multiple lines should follow the Java code convention.

1.3.2.2. Whitespace

Any trailing spaces should be removed. Eclipse provides a plugin that removes the trailing spaces and converts the tab into spaces. The plugin is AnyEdit.

Use whitespaces in for() loop, while(), when concatenating strings. One space should be added before the operator and another after the operator. For example, the correct syntax is:

 for (int i = 0; i < arTest.length; i++) { String
        strResult = "The element " + i + " has the value " + arTest[i]; }
        

The following code does not adhere to the convention:

 for (int i = 0; i< arTest.length; i++) { String
        strResult = "The element "+ i+" has the value "+arTest[i]; }
        

1.3.3. JavaDoc Comments

All methods and attributes (including protected and private) must have a comment. The parameters, the exceptions thrown, and the method return should have a comment in the method comment. For example:

 
      /** 
      * This is an example that is used in the JOnAS Code Convention. 
      */ 
      private int intValue; 
      
      /** 
      * This is an example method to show a class comment. 
      * @param a an example of parameter. 
      * @param b other example of parameter. 
      * @return the method result. 
      * @throws Exception the exception thrown by the method. 
      */ 
      public int add(final int a, final int b) throws Exception { return a + b; } 

1.3.4. Statements

1.3.4.1. If/else

Braces must be used in the if/else blocks, even if there is a single statement. To illustrate:

 if (true) { doThis(); } 

The following is not allowed:

 if (true) doThis(); 

The position of the braces should be the same as in the first example. The following format is incorrect:

 if (true) { test1(); test2(); } 

1.3.4.2. Try/catch

All exceptions require a statement; no silent catching is allowed. For example:

 try { doThis(); } catch (Exception e) { // should not
        occur } 

A logger can be used:

 try { doThis(); } catch (Exception e) {
        logger.logDebug("Exception while doing .....", e); } 

1.3.4.3. Naming Conventions

1.3.4.3.1. Static Final Attributes

Declarations are static final, not final static. This is a JLS recommendation.

1.3.4.3.2. Constants

Constants should be static and final, and should adhere to the following:

 '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$' 

1.3.4.3.3. No Magic Numbers, Use Constants

Constants must be used in the code and magic number must be avoided. For example, the following is not allowed:

 private int myAttribute = 5; 

The correct format is:

 
        /* Default value */
        private static final int DEFAULT_VALUE = 5; 
        /* This attribute is initialized with the default value */ 
        private int myAttribute = DEFAULT_VALUE; 
1.3.4.3.4. Attribute Name

The attribute name should not have an underscore ( _ ). The _ is valid for constants that are in uppercase.

Use pValue and mValue instead of p_Value and m_Value.

The pattern for attribute name is:

 '^[a-z][a-zA-Z0-9]*$' 

1.4. Contributing to camel-jonas5

1.4.1. Mailing Lists

Developers wanting to contribute information about camel-jonas5 can share their thoughts via the JOnAS mailing list.

The steps necessary for subscribing to the list are described here.

Mailing lists for JOnAS are available here.

1.4.2. Ideas for Contributing

There are many ways to contribute to camel-jonas5. New ideas are also welcome.

The following is a list of some of the ways to make contributions:

  • Documentation: Improve or add to the existing documentation, create new chapters, translate, etc.

  • Code: Bug fix, improvements, new features.

  • Tests: Add new tests to the current test suite.