org.oddjob.arooa
Class SimpleObjectFactory

java.lang.Object
  extended byorg.oddjob.arooa.SimpleObjectFactory
All Implemented Interfaces:
ObjectFactory

public class SimpleObjectFactory
extends java.lang.Object
implements ObjectFactory

A Simple object factory that uses property sets of name class pairs to create the objects.


Constructor Summary
SimpleObjectFactory()
           
SimpleObjectFactory(ObjectFactory parent)
           
 
Method Summary
 void addFile(java.io.File file)
          Add definitions fom a property file.
 void addProperties(java.util.Properties props)
          Add class definitions from properties.
 void addResource(java.lang.String classDefFileName)
          Add definitions fom a resource property file, i.e.
static void checkTaskClass(java.lang.Class taskClass)
          Checks whether or not a class is suitable for serving as Ant task.
 java.lang.Object createObject(java.lang.String name)
          Create the object for a given name.
static java.lang.Object createObjectFromClass(java.lang.String className)
           
static java.lang.Class loadClass(java.lang.String className)
           
 void set(java.lang.String key, java.lang.String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleObjectFactory

public SimpleObjectFactory(ObjectFactory parent)

SimpleObjectFactory

public SimpleObjectFactory()
Method Detail

addResource

public void addResource(java.lang.String classDefFileName)
Add definitions fom a resource property file, i.e. one that is on the class path.

Parameters:
classDefFileName - The file name.

addFile

public void addFile(java.io.File file)
Add definitions fom a property file.


addProperties

public void addProperties(java.util.Properties props)
Add class definitions from properties.

Parameters:
props - Class definition properties.

set

public void set(java.lang.String key,
                java.lang.String value)

checkTaskClass

public static void checkTaskClass(java.lang.Class taskClass)
                           throws ArooaException
Checks whether or not a class is suitable for serving as Ant task. Ant task implementation classes must be public, concrete, and have a no-arg constructor.

Parameters:
taskClass - The class to be checked. Must not be null.
Throws:
ArooaException - if the class is unsuitable for being an Ant task. An error level message is logged before this exception is thrown.

loadClass

public static java.lang.Class loadClass(java.lang.String className)

createObjectFromClass

public static java.lang.Object createObjectFromClass(java.lang.String className)
                                              throws ArooaException,
                                                     java.lang.IllegalAccessException,
                                                     java.lang.InstantiationException
Throws:
ArooaException
java.lang.IllegalAccessException
java.lang.InstantiationException

createObject

public java.lang.Object createObject(java.lang.String name)
                              throws ArooaException
Create the object for a given name.

Specified by:
createObject in interface ObjectFactory
Parameters:
name - The name of the object.
Returns:
The the created object.
Throws:
ArooaException - If creation failed.