fipaos
Class FIPAOSFactory


public class FIPAOSFactory

This class provides a mechanism to obtain an instance of a particular class that
implements a particular Interface. In general these are classes implementing
Factory paterns - this centralised Factory location point enables seemless addition
of new Factory's to be made at runtime

Once this class has been loaded, it will search the classpath for files called
fipaos-factory.properties. The contents of these file are expected
to be in Java Properties file-format, and each line should be of the form:

<factory-interface-class>=<factory-instance-class>


The class definitions for each of the classes defined in these files will
be created - the static initialisers of these classes should then use
FIPAOSFactory.setFactoryInstance()
to change the factory associated with
an appropriate interface (this enables the factory instance associated to delegate
to the previously assigned factory if necessary, rather than always overwriting)


Method Summary
 static ObjectgetFactoryInstance(Class iface)
          Returns an instance of a class that implements the given interface, or null
if one couldn't be found
 static voidloadClasses(Properties properties)
          Method to enumerate all keys/values in the given Properties object, and
invoke Class.forName() on them to force a class of the name given to be loaded
 static voidmain(String[] args)
           
 static synchronized voidpopulateFactories()
           
 static ObjectsetFactoryInstance(Class iface, Object instance)
          Adds an instance of a class that implements the given interface to the
list of known instances

Method Detail

getFactoryInstance

public static Object getFactoryInstance(Class iface)
Returns an instance of a class that implements the given interface, or null
if one couldn't be found

loadClasses

public static void loadClasses(Properties properties)
Method to enumerate all keys/values in the given Properties object, and
invoke Class.forName() on them to force a class of the name given to be loaded

main

public static void main(String[] args)

populateFactories

public static synchronized void populateFactories()
throws java.io.IOException

setFactoryInstance

public static Object setFactoryInstance(Class iface, Object instance)
Adds an instance of a class that implements the given interface to the
list of known instances
Returns: The previously assigned value for the given interface

Association Links

to Class java.util.Map

Map of interfaces to lists of instances of that interface