[Home] [Index] [Previous] [Next]

The Descriptor


Oddjob looks for a descriptor file on the classpath. A descriptor file isn't necessary but if it finds one it will use it to when configuring jobs. The descriptor file name is META-INF/arooa.xml.


Here's a descriptor that allows the job we saw in the previous section to be created without any dependency on Oddjob:

<arooa:descriptor xmlns:arooa="http://rgordon.co.uk/oddjob/arooa">
        <arooa:bean-def element="my-job" className="org.oddjob.devguide.NoAnnotationsInJob">
                <arooa:property name="file" type="ATTRIBUTE"/>
                <arooa:property name="child" type="COMPONENT"/>
                <arooa:annotation name="org.oddjob.arooa.life.Initialised" method="init"/>
                <arooa:annotation name="org.oddjob.arooa.life.Configured" method="configure"/>
                <arooa:annotation name="org.oddjob.arooa.life.Destroy" method="destroy"/>
                <arooa:annotation name="org.oddjob.framework.adapt.Run" method="go"/>
                <arooa:annotation name="org.oddjob.framework.adapt.Stop" method="halt"/>
                <arooa:annotation name="org.oddjob.framework.adapt.SoftReset" method="reset"/>
                <arooa:annotation name="org.oddjob.framework.adapt.HardReset" method="reset"/>

Here's the Job without Annotations:

package org.oddjob.devguide;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class NoAnnotationsInJob {

    public File file;

    public final List<Object> children = new ArrayList<>();

    public void go() {
        for (Object child : children) {
            if (child instanceof Runnable) {
                ((Runnable) child).run();

    public void halt() {

    public void reset() {

    public void init() {
        System.out.println("Initialising we know we have children " + children );

    public void configure() {
        System.out.println("Configured - we now know that file is " + file);

    public void destroy() {
        System.out.println("Destroying - we still have " + file + " and " + children + " but not for long.");

    public File getFile() {
        return file;

    public void setFile(File file) {
        this.file = file;

    public void setChild(int index, Object child) {
        if (child == null) {
        else {
            this.children.add(index, child);

    public String toString() {
        return "AnnotationsInJob";

And its configuration:

<oddjob id="oddjob">
    <my-job file="${oddjob.file}">
        <echo>I'm a child job</echo>

[Home] [Index] [Previous] [Next]