|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.iparelan.util.UtilObject
com.iparelan.util.FactoryLoader
@Copyright(value="Copyright © 2008, Iparelan Solutions, LLC. All rights reserved.") public final class FactoryLoader
A Service
Locator that loads an AbstractFactory
.
Field Summary |
---|
Fields inherited from class com.iparelan.util.UtilObject |
---|
LOGGER, MSGS, UTILITIES_LOGGER_NAME |
Constructor Summary | |
---|---|
private |
FactoryLoader()
Not instantiable. |
Method Summary | ||
---|---|---|
private static Logger |
getLogger()
Produces a viable logger. |
|
static
|
load(Class<T> factoryService)
Produces an AbstractFactory as configured in some file of the
META-INF/services directory. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
private FactoryLoader()
Method Detail |
---|
public static <T extends AbstractFactory> T load(Class<T> factoryService)
AbstractFactory
as configured in some file of the
META-INF/services
directory. The file name is the ClassLoader.html
binary name of factoryService
.
Implementation Note: Due to the details of the
ServiceLoader
class, several errors may be raised in
the computation of this method. The policy of this implementation is to
log all of the errors to the Configuration
logger, then to
raise only the most recent error to callers.
Implementation Note: Several service providers may
be registered for any particular service as described by ServiceLoader
. The policy of this implementation is to
produce the first viable service discovered.
factoryService
- The type of factory service to load. May not be
null
.
AbstractFactory
. Never null
.
ServiceConfigurationError
- Iff a service provider cannot be loaded.
NullPointerException
- Iff factoryService
is null
.ServiceLoader.iterator()
AbstractFactory
, but it really could be more general.
ServiceLoader.loadInstalled(Class)
instead of ServiceLoader.load(Class)
. The issue is whether
the "extension class loader" or the "system class loader" should be
used to get the service provider. The extension class loader
apparently avoids the application's classpath, which might be
altered by a malicious user. Formalling install the service as an
extension and locking down the JVM (as on a CD-ROM or other
read-only storage) might be preferable.
private static Logger getLogger()
null
.
AssertionError
- Iff a viable logger cannot be acquired.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |