|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.geotools.factory.FactoryFinder
FactoryRegistry
, which is built
on top of a J2SE class (ServiceRegistry
).
Guidlines are provided in the org.geotools.factory
package
description.
This code was mostly spiked from SAXParserFactory, which I know runs in
applets. The former way of doing things was to use System.getProperty, which
cause security problems. Because EVERYTHING in geotools uses factories, I
thought, "hey, we should make a class for this, or something". The other
problem was using the ServiceProvider thing from sun, BUT THIS COMPLETELY
VIOLATES ALL THE PRINCIPLES OF MAKING OUR CODE JVM INDEPENDENT!!!!!!!!!!!
This package works the same way.
The mechanism for finding factories (which must implement Factory) is as
follows:
The ClassLoader used to search for resources can be specfied, and if not provided, the search mechanism uses first Thread.getContextClassLoader and then falls back on the system ClassLoader.
- Look up key in System properties. If key doesn't exist or a SecurityException is thrown, fall through. Otherwise attempt to instantiate the given class.
- Search the resource paths for the key in META-INF/services. If the resource is found, the file is read and the class is instantiated. If the resource does not exist, fall through
- Finally, each call to findFactory must provide a default implementation class name. If this class is found, it is instantiated and used. If not, a grave error is thrown (FactoryConfigurationError).
Method Summary | |
static java.util.Iterator |
factories(java.lang.Class key)
Deprecated. A convenience method for factories(key,null). |
static java.util.Iterator |
factories(java.lang.Class key,
java.lang.ClassLoader loader)
Deprecated. Obtain an Iterator of Factory Objects which are found using the given key. |
static java.lang.ClassLoader[] |
findClassLoaders()
Deprecated. Returns the context class loaded (if available) as well as the system class loader. |
static Factory |
findFactory(java.lang.String factoryKey,
java.lang.String defaultImpl)
Deprecated. A convienience method for calling findFactory(factoryKey,defaultImpl,null). |
static Factory |
findFactory(java.lang.String factoryKey,
java.lang.String defaultImpl,
java.lang.ClassLoader classLoader)
Deprecated. Find a Factory using the given key, the given default backup implementation, and the specified ClassLoader. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static java.lang.ClassLoader[] findClassLoaders()
public static Factory findFactory(java.lang.String factoryKey, java.lang.String defaultImpl, java.lang.ClassLoader classLoader) throws FactoryConfigurationError, java.lang.ClassCastException
factoryKey
- The key to search for an implementation with.defaultImpl
- The name of a default implementation to use.classLoader
- The ClassLoader to search in. May be null.
FactoryConfigurationError
- If the given arguments do not yield a findable, instantiable
Factory.
java.lang.ClassCastException
- If the given arguments yield an Object which is not a Factorypublic static Factory findFactory(java.lang.String factoryKey, java.lang.String defaultImpl) throws FactoryConfigurationError, java.lang.ClassCastException
factoryKey
- The key to search for an implementation with.defaultImpl
- The name of a default implementation to use.
FactoryConfigurationError
- If the given arguments do not yield a findable, instantiable
Factory.
java.lang.ClassCastException
- If the given arguments yield an Object which is not a Factorypublic static java.util.Iterator factories(java.lang.Class key)
key
- The key to search with. The actual key to search with will be
key.getName().
public static java.util.Iterator factories(java.lang.Class key, java.lang.ClassLoader loader)
key
- The key to search with. The actual key to search with will be
key.getName().loader
- The ClassLoader to search for resources with.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |