Skip to main content
Jump to: navigation, search

SMILA/Development Guidelines

Revision as of 10:51, 25 February 2011 by (Talk | contribs) (Eclipse code formatter profile)

This page covers a collection of development guidelines whose compliance should ensure that SMILA appears as a unified product rather than as a loose collection of parts worked on by a variety of individuals each with their own styles and ways of working. Furthermore it contains information on the used software components and requirements and provides descriptions (how-tos) of common tasks (e.g. setting up the development environment).

How-to manuals

How to set up the development environment

SMILA committers and contributors can find the instructions for setting up their development environment at How to set up the development environment.

How to set up the integration environment

SMILA integrators can find the instructions for setting up their integration environment at How to set up the integration environment.

How to set up the test environment

Find this how-to manual at How to set up the test environment.

How to build a SMILA-Distribution

Find this how-to manual at How to build a SMILA-Distribution.

Run and manage the connectivity framework

At the time of writing this there is the possibility to start SMILA as a separate application as described below:

  1. Update from SVN and refresh.
  2. Execute build and unzip to an arbitrary folder.
  3. Create the folder c:\data and add some TXT and/or HTML files (for file system crawler).
  4. Launch the application by calling SMILA.exe.
  5. Run JConsole and connect to local.
  6. Switch to the the MBeans/Operations tab.
  7. Open the SMILA/CrawlerController branch in JConsole and select "Operations".
  8. Start the file system crawler by launching the "startCrawl()" operation and passing the "file" parameter.
  9. Start the web crawler by launching the "startCrawl()" operation and passing the "web" parameter.
  10. Have a look at the Eclipse console log and enjoy ;)

Development requirements

Official JVM

The officially JVM needed for this project is > Java 1.6_04. (see Mail)

OSGi runtime

The OSGi implementation of Equinox of Eclipse 3.5 (Galileo) or later and the corresponding OSGi specification(s).  

Development conventions

Project setup

The project folder setup is defined for this project at SMILA Java Project Setup.

Description of make.xml

For a description of the build file make.xml refer to Introduction to make.xml.

Continuous integration

Everyone should be aware of the following workflow with Bamboo:

Bamboo should improve the source code quality but it should not be used as a (JUnit) test server. Therefore each developer should check his code before committing it to subversion regarding:

  • Compilation errors
  • Checkstyle (see Brox Coding Conventions)
  • Tests: Run a local build with the build.xml to test all existing JUnit tests.
    (see Development Guidelines for the setup)
    Be aware that running tests in Eclipse doesn't mean that they run with the pdebbuild.
  • Build process: Check if your bundles and your test bundle is fully integrated in the whole build process
    (see How to integrate new bundle into build process and How to integrate test bundle into build process)

We have added a feature to the build.xml: The failed JUnit tests are reported at the end of the build output.

Furthermore the full JUnit reports are generate under and the error messages from the JUnit reports are stored under

Everyone should monitor the trunk at the build server and if there is a "red" build everyone should look if he has committed the error.

If the error could not be solved within the next build, the developer should inform the developer team that there is a problem with the build and that he is working on the solution.

File header & copyright notice

For guidelines on file header and copyright notices see Project Guidelines.

Eclipse code formatter profile

The Eclipse code formatter file is available in trunk at SMILA.builder/eclipse-formatter/Eclipse-formatter-Brox-3.2-3.3.xml.

You can also download the latest versions of Eclipse-formatter-Brox-3.2-3.3 and brox_checks here: Brox-Eclipse-Files

To import the Eclipse code formatter profile:

  1. Download the profile configuration file.
  2. Select Window > Preferences in Eclipse and switch to the Java > Code Style > Formatter preferences page.
  3. Click the Import button and select the downloaded formatter file.
formatter vs. save actions
most source files have been edited with the save action turned on: "remove trailing white spaces on all lines". If you dont have this set then formatting the whole file will result in a lot white space of changes, which is cumbersome as is clutters diffs and poses problems to patches. So plz turn this feature on.


Each Eclipse project (bundles) should follow the Brox Coding Conventions.

The file containing the Checkstyle rules is available in trunk at SMILA.builder/checkstyle/brox_checks.xml.

You can also download the latest versions of Eclipse-formatter-Brox-3.2-3.3 and brox_checks here: Brox-Eclipse-Files

The rules currently do not work with Checkstyle 5, please use a 4.x version of Checkstyle.

Eclipse checkstyle plugin.

The eclipse-cs Checkstyle plugin integrates the source code analyzer Checkstyle into Eclipse IDE. By using this plugin your code is constantly inspected for problems. Within the Eclipse workbench you are notified of problems via the Eclipse Problems View and source code annotations just as you would see with compiler errors or warnings. The Checkstyle Eclipse plugin can be obtained from the update site: [1]. Instructions about how to set up the Checkstyle plugin for your project can be obtained from [2].

To use the plugin for all projects:

  1. Click Window > Preferences in Eclipse.
  2. Select the Checkstyle preference page and click the New button.
  3. Select External Configuration File as Type and point to the location of the file brox_checks.xml.
  4. The Checkstyle configuration profile should be named (while importing): "Brox Coding Conventions 1.06".

The complete manual and other information on the plugin may be obtained from [3].

Creation of bundles

For information on creating and integrating bundles refer to the following pages:

Version number

Until further notice all SMILA bundles have the version number 0.5.0.

XML schemas, namespace convention, and versioning

This subject is still very open to discussion right now, but I suggest to do the following:

  1. when defining a schema a name space must be defined also
    1. the URL of the namespace shall be like so: http://org.eclipse.eilf/<rest of bundle as path>/<version>##- <rest of bundle as path> means that the '.' are converted to '/'. In case the bundle defines more than one schema then use the either packages or other properly identifying names (plz discuss this) to further qualify the name space.
  • <version>
    As we continue to develop the application, schemas will change over time. there are basically two options here: either encode the version in the *:name space or have an extra well defined attribute that needs to be added to the XML messages to tell which schema version it conforms to. Doing *:this with an attribute seem to be much more error prone (likely to be forgotten) and less xml-natural. (subject needs further discussion).
    Further it is not clear how and when we will version a particular schema as those under development might be still very volatile. So the current *:idea is to version a schema on a milestone and releases.
    Another idea is to integrate versioning in the daily build process where the version number may be constructed from
    • Date / time stamp
    • Build number
    • Revision number

Example: http://org.eclipse.eilf/processing/bpel/xml/Record/0.7

Naming conventions for launch files (.launch)

It is a good thing to share your launches and many do so already which helps greatly to run tests quickly from within Eclipse. However, in order that at least I don't get confused, we need to define a naming scheme for the .launch files!

Preliminary convention: <bundle name>[_config name].launch

The [config name] part is optional and needed when several .launch files exist for the same bundle but with different settings.

Generated source code goes into code/gen source folder (like Jaxb)

All generated source code (eg. JAXB) goes into the distinct source code folder code/gen. Where possible all generated classes should also have their own package. Reasons:

  • Separate generated source code from handwritten code
  • Easier filtering for Checkstyle

(see Setup for JAXB code generation and How to implement a crawler for details specific to creating crawler configurations.)

Sources of third party bundles

If you have to implement third party bundles into the SMILA project, please insert the sources into the 3rdPartySources folder, not into the new bundle folder. Each third party bundle should have an own folder suffixed by the corresponding version number, e.g. 3rdPartySources\org.apache.tomcat-6.0.16\

Logging guidelines

In SMILA apache commons logging is used with log4j. The are located in SMILA.application. Here are some guidelines how and when logging should be used:

  • avoid static references to Log if possible
private final Log _log = LogFactory.getLog(MyClass.class);
  • always check log level before logging, e.g.
if (_log.isErrorEnabled()) {
    _log.error("Your error message", e);
  • do not log exceptions before throwing new exceptions, e.g.
if( paramXY == null ) {
    if (_log.isErrorEnabled()) {
        _log.error("paramXY is not set");
    throw new NullPointerException("paramXY is not set");

I advise against this as it only causes the same message to be repeated at least twice, namely when the exception is created and then when the exception is logged itself. IMO it is sufficient to have a verbose error msg and this then is reported along with the stack trace when the exception is logged. if the exception is handled then this message is even confusing b/c u have ERROR log entry but wonder: what happened then? if u deem the condition so extraordinary and dangerous we could log it as WARN, but since we don't log the eception here it should not be level ERROR.

Even worse than this is sometimes the habit to log an exception before (re)throwing or wrapping it, which I have seen often (in general, not this project in particular). this then has the effect that u have the same exception logged several times which makes the log very verbose and confusing. as u think u have lot of problems/exception when it fact it is only that one case.
Log and throw makes only sense in a client-server architecture. We have no clients except Jconsole and the JmxAgent, and these clients use JMX for the commmuncation, thus Exceptions are not "forwarded".

I think we should use the Rule: Never log and throw. Because the "process" that catches the exception is responsible for logging.

see: Mail thread

When to use what log level and what information to provide?

FATAL designates very severe error events that will presumably lead the application to abort.
ERROR designates error events that might still allow the application to continue running.
WARN designates potentially harmful situations.
INFO for the "high level" information. For example - interesting runtime events (startup/shutdown).
DEBUG only for the software developer interesting messages (detailed information on the flow through the system).

A good resource on how to use the levels in regard to the Enterprise context offers JCL Best Practices.

Read here further about Useful Log Messages for Smila.

Used technologies

OSGi related information

Copyright © Eclipse Foundation, Inc. All Rights Reserved.