Save This Page
Home » commons-discovery-0.4-src » org.apache.commons » discovery » tools » [javadoc | source]
org.apache.commons.discovery.tools
public class: DiscoverSingleton [javadoc | source]
java.lang.Object
   org.apache.commons.discovery.tools.DiscoverSingleton

Discover singleton service providers. This

DiscoverSingleton instances are cached by the Discovery service, keyed by a combination of

This DOES allow multiple instances of a given singleton class to exist for different class loaders and different group contexts.

In the context of this package, a service interface is defined by a Service Provider Interface (SPI). The SPI is expressed as a Java interface, abstract class, or (base) class that defines an expected programming interface.

DiscoverSingleton provides the find methods for locating and instantiating a singleton instance of an implementation of a service (SPI). Each form of find varies slightly, but they all perform the same basic function. The simplest find methods are intended for direct use by components looking for a service. If you are not sure which finder(s) to use, you can narrow your search to one of these:

The DiscoverSingleton.find methods proceed as follows:

Variances for various forms of the find methods are discussed with each such method. Variances include the following concepts:

IMPLEMENTATION NOTE - This implementation is modelled after the SAXParserFactory and DocumentBuilderFactory implementations (corresponding to the JAXP pluggability APIs) found in Apache Xerces.

Method from org.apache.commons.discovery.tools.DiscoverSingleton Summary:
find,   find,   find,   find,   find,   find,   release,   release
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.commons.discovery.tools.DiscoverSingleton Detail:
 public static Object find(Class spiClass) throws DiscoveryException 
    Find implementation of SPI.
 public static Object find(Class spiClass,
    Properties properties) throws DiscoveryException 
    Find implementation of SPI.
 public static Object find(Class spiClass,
    String defaultImpl) throws DiscoveryException 
    Find implementation of SPI.
 public static Object find(Class spiClass,
    Properties properties,
    String defaultImpl) throws DiscoveryException 
    Find implementation of SPI.
 public static Object find(Class spiClass,
    String propertiesFileName,
    String defaultImpl) throws DiscoveryException 
    Find implementation of SPI.
 public static Object find(ClassLoaders loaders,
    SPInterface spi,
    PropertiesHolder properties,
    DefaultClassHolder defaultImpl) throws DiscoveryException 
    Find implementation of SPI.
 public static synchronized  void release() 
    Release all internal references to previously created service instances associated with the current thread context class loader. The release() method is called for service instances that implement the Service interface. This is useful in environments like servlet containers, which implement application reloading by throwing away a ClassLoader. Dangling references to objects in that class loader would prevent garbage collection.
 public static synchronized  void release(Class spiClass) 
    Release any internal references to a previously created service instance associated with the current thread context class loader. If the SPI instance implements Service, then call release().