Development FAQ

What IDE should I use?

There are no IDEs at the moment that support OSGi environment but Eclipse. Currently we use latest Eclipse 3.5 version (Eclipse 3 Keyboard Shortcuts).

What Java version we support?

There are no reasons to be not compatible with Java 5. Nevertheless, you may use Java 6 for development but don't forget to set 5.0 language compliance level.

What code style we use?

SevenHats is an open source project so we use Eclipse built-in code style (default code style) to be compatible with Equinox and Spring projects we are based on.

What logging library I have to use?;

We use Apache commons log factory that is configured to use log4j implementation. Again, that is how all Spring projects do.

Sample code:

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class MyClass {

   private static final Log LOG = LogFactory.getLog(MyClass.class);


How to add library and when library should be added as bundle?

The libraries, which are used from different bundles should be wrapped into a bundle and added to platform project.

  • Navigate to File -> New -> Project -> Plug-in Development -> Plug-in from Existing JAR archives;
  • Select JAR to be wrapped (by clicking 'Add' or 'Add External...'), click 'Next';
  • Input bundle name, in 'Target Platform' group select 'an OSGI framework' radio-button. Check 'Analyze library contents and add dependencies'. Equinox must be selected in combo-box;
  • Make sure that 'Unzip the JAR archives into the project' check-box is selected;
  • Select 'Export -> Plug-in Development -> Deployable plug-ins and fragments' on the newly created project;
  • Select platform as a Destination Directory;
  • Restart Eclipse, rebuild projects. In Run Configuration select newly added library.

How to specify port for embedded Jetty

An http port for embedded Jetty can be specified by passing the following parameter to java:

-Dorg.eclipse.equinox.http.jetty.http.port=<The port number>

One of standard values is -Dorg.eclipse.equinox.http.jetty.http.port=8080.

Building SevenHats

To build SevenHats, please use buildAll target of Ant build file located at <SevenHats home>/Build/scripts/build.xml. This will run the dependecies check, compilation and tests (both unit and functional). It is recommended to run the build locally before checking in the changes.

For detailed process description please see this article

Launching SevenHats-based application

To launch SevenHats-based application you should go through the following procedure:

  • Put all platform bundles into a single folder. Let's call it platform.
  • Put all application bundles into another folder. Let's call it bundles.
  • Create configuration file for this launch using createConfig ant task (see more details here). Sample ant build configuration file looks as follows:
    <project name="sevenhats.sample">
    <property name="platform.folder" value="platform/" />
    <property name="bundles.folder" value="bundles/" />
    <property name="framework.file.path" value="${platform.folder}/org.eclipse.osgi_3.3.2.R33x_v20080105.jar" />
    <property name="bundles.configpath" value="configuration/config.ini" />
    <path id="classpath">
    <fileset dir="lib">
    <include name="**/*.jar" />
    <taskdef name="createConfig" classname="org.sevenhats.util.ant.CreateConfigIniTask" classpathref="classpath" />
    <path id="compiledBundles">
    <fileset dir="${bundles.folder}">
    	<include name="*.jar" />
    <path id="platformFolderPath">
    <fileset dir="${platform.folder}">
    <include name="*.jar" />
    <target name="createConfiguration">
    	<createConfig 	bundlesfolderpath="compiledBundles" 
    			framework="${framework.file.path}" />
  • Launch framework with the following command:
java -Declipse.ignoreApp=true -Dosgi.noShutdown=true -Dorg.eclipse.equinox.http.jetty.http.port=8080 -classpath org.eclipse.equinox.launcher_1.0.1.R33x_v20070828.jar org.eclipse.equinox.launcher.Main -console

where org.eclipse.equinox.launcher_1.0.1.R33x_v20070828.jar is a eclipse launcher library (it may have different version: org.eclipse.equinox.launcher_1.0.1.R33x_vXXXXXXX.jar)

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.