[FrontPage] [TitleIndex] [WordIndex

deegree3 IDE settings and coding practices

This page documents common IDE settings and practices for deegree 3 core developers.

1. Eclipse Settings

As most settings are the same for deegree2 and deegree3, please refer to the description at Eclipse#HowToConfigureEclipse.

1.1. Eclipse compiler settings

Todo: add description

1.2. Eclipse code style (code templates and formatter)

deegree source code uses a customized coding style, consisting of headers, comment styles, specific indentation, etc. These settings are defined in Eclipse.

1.3. SVN templates to be used

At the moment there are no deegree3-specific commit templates. Therefore please refer to Eclipse/CommitTemplates.

2. Coding Practices

2.1. Logging

In deegree 3, we're usually using log4j for logging (through slf4j). It is generally a nice thing to have a 'template' log4j.properties, where the important classes are listed together with a description what is logged on which level, like this:

# logs very important information

# logs the most important information

This information is now generated automatically using annotations. You can annotate a class using the LoggingNotes annotation, like this:

@LoggingNotes(debug = "logs the most important information", trace = "logs very important information")
public class MostImportantClass {

You can optionally set the text for warn, info, error, debug and trace, corresponding to the log level of the same name. The above annotation will generate exactly the log4j.properties snippet as shown (speling mistakes which I integrated are excluded).

2.1.1. Package logging

For packages, we have the PackageLoggingNotes. These can be used to generate a section header, and to generate package level descriptions as shown above. So additionally, you have the (optional) title parameter for the annotation. To make a package level annotation, create a new package-info.java file in your package, with content like this:

@PackageLoggingNotes(title = "the WMS section", debug = "logs debugging stuff", warn = "logs possible problems")
package org.deegree.services.wms;

2.1.2. Making actual use of it

To generate a useful log4j.properties template, you'll have to check out d3_core and d3_services. Edit the build.properties as appropriate, and run the ant target make-log4j.properties in d3_services. This will give you a proper log4j.properties in d3_services/build/.

2.2. XMLStreamWriter

XMLStreamReader and XMLStreamWriter are used heavily in deegree 3 for processing streams of XML. Special care has to be taken in order to use XMLStreamWriter in a way that is compatible with different StaX implementations (e.g. bundled versions with JDK, Woodstox, StaX implementation on Oracle Weblogic). Problems occur when dealing with qualified element/attribute names and binding namespaces.

Best practices:


2018-04-20 12:04