org.oddjob.framework
Class ServicesJob

java.lang.Object
  extended by org.oddjob.framework.BaseComponent
      extended by org.oddjob.framework.BasePrimary
          extended by org.oddjob.framework.SimpleJob
              extended by org.oddjob.framework.ServicesJob
All Implemented Interfaces:
Runnable, ArooaContextAware, ArooaSessionAware, ServiceProvider, Forceable, PropertyChangeNotifier, Iconic, LogEnabled, Resetable, Stateful

public class ServicesJob
extends SimpleJob
implements ServiceProvider

Description

Allows objects to be registered that will automatically be injected into subsequent components that are configured for automatic dependency injection.

Example

The Development guide has numerous examples using this job.
Author:
rob

Nested Class Summary
static class ServicesJob.ServiceDefinition
          Definition of a service.
 
Field Summary
 
Fields inherited from class org.oddjob.framework.SimpleJob
stateHandler, stop
 
Fields inherited from class org.oddjob.framework.BaseComponent
iconHelper
 
Constructor Summary
ServicesJob()
           
 
Method Summary
protected  int execute()
          Execute this job.
 Services getServices()
          Provider the services.
protected  void onReset()
          Allow sub classes to do something on reset.
 void setRegisteredServices(int index, ServicesJob.ServiceDefinition serviceDef)
           
 
Methods inherited from class org.oddjob.framework.SimpleJob
fireDestroyedState, force, getStateChanger, hardReset, onDestroy, onStop, run, sleep, softReset, stateHandler, stop
 
Methods inherited from class org.oddjob.framework.BasePrimary
configure, getName, logger, logger, loggerName, save, setName, toString
 
Methods inherited from class org.oddjob.framework.BaseComponent
addIconListener, addPropertyChangeListener, addStateListener, configure, destroy, firePropertyChange, getArooaSession, iconForId, initialise, lastStateEvent, onConfigured, onInitialised, removeIconListener, removePropertyChangeListener, removeStateListener, save, setArooaContext, setArooaSession
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.oddjob.Stateful
addStateListener, lastStateEvent, removeStateListener
 

Constructor Detail

ServicesJob

public ServicesJob()
Method Detail

execute

protected int execute()
               throws Throwable
Description copied from class: SimpleJob
Execute this job.

Specified by:
execute in class SimpleJob
Returns:
0 if the job is complete, anything else otherwise.
Throws:
Exception - If the unexpected occurs.
Throwable

onReset

protected void onReset()
Description copied from class: SimpleJob
Allow sub classes to do something on reset.

Overrides:
onReset in class SimpleJob

getServices

public Services getServices()
Description copied from interface: ServiceProvider
Provider the services.

Specified by:
getServices in interface ServiceProvider

Property: services

Description: Provide access to the registered services.

Services are registered by name using object toString and then if qualified ';' and the qualifier. If this job has an id my-services and the service has a toString of MyCafe and it is qualified with qualifier Vegetarian then it could be referenced as:

 ${my-services.services.service(MyCafe;Vegetarian)}
 
Returns:
The services. May be null.

setRegisteredServices

public void setRegisteredServices(int index,
                                  ServicesJob.ServiceDefinition serviceDef)