|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.jbeans.bean.factory.FactoryManager
The FactoryManager can be used to locate a factory class for any given class or class name. This factory class must support the net.jbeans.bean.factory.Factory interface for creating an instance of a given class.
The FactoryManager uses three techniques for locating a factory for a given type. First, it provides a registerFactory method to allow a factory to be specifically registered for a given type. Second it tries to locate a suitable class by adding "Factory" to the full qualified classname of the given type (e.g. "foo.bah.FozFactory"). Finally it takes the simple classname (without the package name) adds "Factory" to it and looks in a search-path of packages for a matching class.
So for an input class foo.bah.Fred, the FactoryManager would first look in its tables to see if a factory had been registered for foo.bah.Fred and if so use that. Then it will look for a foo.bah.FredFactory class. Then it will look for (say) standardFactoryPackage.FredFactory class.
Constructor Summary | |
FactoryManager()
|
Method Summary | |
static Factory |
findFactory(java.lang.Class targetType)
Locate a value editor for a given target type. |
static java.lang.String[] |
getEditorSearchPath()
Gets the package names that will be searched for factories. |
static void |
registerFactory(java.lang.Class targetType,
java.lang.Class factoryClass)
Register a factory to be used to instantiate an object of a given target class. |
static void |
setFactorySearchPath(java.lang.String[] path)
Change the list of package names that will be used for finding factories. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public FactoryManager()
Method Detail |
public static void registerFactory(java.lang.Class targetType, java.lang.Class factoryClass)
targetType
- the Class object of the type to be instantiatedfactoryClass
- the Class object of the factory class. If
this is null, then any existing definition will be removed.public static Factory findFactory(java.lang.Class targetType)
targetType
- The Class object for the type to be edited
public static java.lang.String[] getEditorSearchPath()
This is initially set to {"net.jbeans.bean.factory"}.
public static void setFactorySearchPath(java.lang.String[] path)
path
- Array of package names.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |