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



Oddjob provides some Annotations for interaction with the Framework. Doesn't this introduce a dependency which is against the principle of an unobtrusive framework? No - because annotations can be specified in a descriptor that we will get to later.

Supported Annotations

A property that is normally configured as an element is to be configured as an attribute.
The property is a component, this is a child job in Oddjob.
The property is CDATA in the XML (such as Echo's text property).
Hide the property from the designer.
Configuration Lifecycle:
Callback for when the bean has been initialised. All static properties have been set.
Callback for when the bean has been configured. All dynamic properties have been set.
Callback to clear up resources.
Job Lifecycle:
Method to run a job if the job isn't Runnable or Callable
Method to run to stop a job.
Callback to reset state in a job after an Exception or if it is Incomplete.
Callback to reset a job if it is in any Finished stated.
Like run, but for a Service.
For a FallibleComponent
For an AsyncJob
Do not show the property in the properties tab of the UI.
Property to set as a destination in a Bean Bus.
The standard Java annotation for dependency injection is described later


Here's a Job with lots of Annotations:

package org.oddjob.devguide;

import org.oddjob.arooa.deploy.annotations.ArooaAttribute;
import org.oddjob.arooa.deploy.annotations.ArooaComponent;
import org.oddjob.arooa.life.Configured;
import org.oddjob.arooa.life.Destroy;
import org.oddjob.arooa.life.Initialised;
import org.oddjob.framework.adapt.HardReset;
import org.oddjob.framework.adapt.Run;
import org.oddjob.framework.adapt.SoftReset;
import org.oddjob.framework.adapt.Stop;

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

public class AnnotationsInJob {

    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">
    <bean class="org.oddjob.devguide.AnnotationsInJob" file="${oddjob.file}">
        <echo>I'm a child job</echo>

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