This developer guide is intended for people who wish to work on Fosstrak's EPCIS repository implementation and contribute to the project. It outlines the steps to follow for setting up the development environment and helps developers to find their way through the code.
If you just want to set up your own EPCIS repository for use in your own project, you should follow the User Guide. Generally, it is advisable if you first read the User Guide before continuing with the developer guide.
If you cannot find your answer here, feel free to ask the Fosstrak mailing list.
This section of the developer guide describes the first steps for getting started with the project. It includes a description on how to set up the development environment, how to obtain the sources, and how to build and deploy the application.
Make sure you have the following prerequisites installed:
First thing you need to do is checking out the sourcecode from the Git repository (see Download section). In the following we will use the EPCIS_HOME variable to refer to the location where you checked out the sources.
We recommend using the Eclipse IDE to work on the Fosstrak projects. Please follow these steps to set up the projects in Eclipse:
mvn eclipse:configure-workspace -Declipse.workspace=<path-to-your-eclipse-workspace>
mvn eclipse:eclipse -DdownloadSources
If you do not want to download all the sources, ignore the -DdownloadSources switch.
The first time you work on the project you need to get all the dependencies and install them into your local Maven repository. The following command will do all that for you:
mvn install
Building the project is straight forward:
mvn compile
In order to deploy and undeploy the application to and from Tomcat, we use the tomcat-maven-plugin. This plugin communicates with the Tomcat Manager and thus needs to know the username and password to access the Manager application. Add the following block to your M2_HOME/conf/settings.xml file and specify the correct username and password:
<server> <id>tomcat-manager</id> <username>admin</username> <password>1234</password> </server>
Now, you can use the following commands to deploy, undeploy, or redeploy the application. Make sure you run these commands from the EPCIS_HOME/epcis-repository directory because the maven-tomcat-plugin is only available to the epcis-repository sub-module.
mvn tomcat:deploy mvn tomcat:undeploy mvn tomcat:redeploy
Note: if you use Tomcat 7, then you need to adjust the URL to the manager application in the tomcat-maven-plugin configuration to match the required path for Tomcat 7. Just un-comment the <url> element in the corresponding plugin section in EPCIS_HOME/epcis-repository/pom.xml.
You can also manually deploy the application by placing the WAR file directly into Tomcat's webapps directory. Run the following command and grab the WAR file from EPCIS_HOME/epcis-repository/target
mvn package
Now you are ready to go and start working on the project.
This section helps developers to find their way through the code.
Fosstrak's EPCIS project is a multimodule project. Currently, it includes five modules which inherit from the base epcis-module:
This module contains the common functionality (such as parsers) as well as the JAXB data binding of the EPCIS schema (which is used by the epcis-repository, the epcis-queryclient, and the epcis-captureclient modules).
This module consists of a capture client GUI and a simple capture client API library which can be used to send EPCIS events to an EPCIS repository.
This module consists of a query client GUI, a query callback client, and a query control client API which can be used to send queries to an EPCIS repository.
This module contains the actual implementation of the bindings defined in the EPCIS specification.
This module contains tests to check interoperability compliance with the EPICS standard.
We use the standard Maven directory layout for all the modules:
+- pom.xml -> top-level POM file +- src/ | +- config/ -> top-level configuration files, e.g., checkstyle configs | +- main/ | | +- assembly/ -> assembly descriptor for generating the source distribution | | `- filters/ -> filter properties for the build profiles | `- site/ -> project documentation | +- epcis-captureclient/ +- epcis-commons/ +- epcis-queryclient/ +- epcis-repository/ +- pom.xml -> module POM file `- src/ +- changes/ -> documentation for all changes +- main/ | +- assembly/ -> assembly descriptor for the binary distribution | +- java/ -> Java source files | +- resources/ -> class path resources, e.g., config files, hibernate mappings, WSDLs, XSDs | +- sql/ -> database scripts | `- webapp/ | +- META-INF/ -> webapp context configurations | `- static/ -> static web content, e.g., images, CSS | `- WEB-INF/ -> deployment descriptor, JSPs +- site/ -> module documentation `- test/ -> Test resources and source files
An introduction to build profiles is given in the http://maven.apache.org/guides/introduction/introduction-to-profiles.html}Maven documentation. We currently use two different build profiles, called env-dev and env-prod. The build properties for the two profiles are given in the dev.properties and prod.properties file, respectively. They are located at EPCIS_HOME/src/main/filters.
By default the env-prod profile is activated. A different profile can be activated on the command line by specifying a profile explicitly using the -P switch, or by providing a property named env with the corresponding value. The following examples show the two possibilities for building the project using the env-dev profile:
mvn compile -Penv-dev mvn compile -Denv=dev
A developer can activate the developement profile permanently by specifying an activeProfile element in his local settings.xml file. That way, he can also override properties from the development environment without touching the dev.properties file. The following is an example excerpt from the settings.xml file which shows how to permanently activate the env-dev profile:
<profiles> <profile> <id>env-dev</id> <properties> <db.username>myname</db.username> <db.password>mysecret</db.password> <db.database>mydb</db.database> </properties> </profile> </profiles> <activeProfiles> <activeProfile>env-dev</activeProfile> </activeProfiles>
The main web site (including this documentation) can be generated by using the following command:
mvn site -N
In order to generate all module reports and to test the whole site navigation before a live deploy, you can execute the following command which will generate the web site in the specified directory:
mvn site:stage -DstagingDirectory=d:\testsite