Skip to content

Annotation-based configuration of ATG Nucleus components

Notifications You must be signed in to change notification settings

sdianov/atg-nucleus-annotations

Repository files navigation

Annotation-based configuration of ATG Nucleus components

This project contains collection of Java annotations that allows to configure Oracle Web Commerce (ATG) Nucleus components without ".property" files.


This project is heavily inspired by Spring annotation-based configuration. The main idea is very simple: the annotation processors generate property files from annotation values and place these files into additional Nucleus config layer.

MANIFEST.MF file for your ATG module should look like this:

ATG-Config: /target/genconfig /config

Each module will have two config layers: autogenerated layer (should be ignored in VCS) and ordinary layer for manual component definitions. It is a good idea to place ordinary config layer after generated config in 'ATG-Config' section so you can override generated values if needed.

Annotation List:

NucleusComponent - exports annotated Java class as a Nucleus component. If component name is not set, it will be built from class full name.

NucleusInject - injects existing Nucleus component into this component property. Can infer injected component name from the type of property annotated with @NucleusComponent

NucleusValue - sets the property value for this Nucleus component. Allows scalar values, lists, maps and references.

Please see Javadoc for the detailed documentation.

Example:

For the following Java class:

package org.example;

@NucleusComponent(scope = Scope.GLOBAL)
public class ExampleDroplet extends DynamoServlet {

    ...

    @NucleusInject(name = "/atg/userprofiling/ProfileTools")
    public void setProfileTools(ProfileTools pProfileTools) {
        this.profileTools = pProfileTools;
    }

    @NucleusValue(
            list = {"123", "456"})
    public void setListValue(List<String> listValue) {
        this.listValue = listValue;
    }

    ...
}

Compilation will generate new property file '{genconfig}/org/example/ExampleDroplet.properties' with the following content:

# /org/example/ExampleDroplet
$class=org.example.ExampleDroplet
$scope=global

profileTools=/atg/userprofiling/ProfileTools

listValue=\
    123,\
    456

Usage:

Clone the repository. Set the 'atg.root' and 'atg.version' properties in pom.xml to correct values. Install artifacts into local maven repository by running 'mvn clean install' command from root directory.

Add atg-annotations.jar as a compile dependency. Add atg-annotation-processors.jar as a provided dependency

    <dependency>
        <groupId>com.github.sdianov</groupId>
        <artifactId>atg-annotations</artifactId>
        <version>1.0</version>
    </dependency>
    <dependency>
        <groupId>com.github.sdianov</groupId>
        <artifactId>atg-annotations-processors</artifactId>
        <version>1.0</version>
        <scope>provided</scope>
    </dependency>

By default, generated property files will be placed under the folder CLASS_OUTPUT/../genconfig.
You can also set file path explicitly by setting java parameter "-Aatggendir" .

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${version}</version>
        <configuration>
            <compilerArgument>-Aatggendir=${basedir}/build/genconfig</compilerArgument>
        </configuration>
    </plugin>

Releases

No releases published

Packages

No packages published

Languages