com.uwyn.rife.tools
Class SingletonFactory<T>

java.lang.Object
  extended by com.uwyn.rife.tools.SingletonFactory<T>

public class SingletonFactory<T>
extends Object

Maintains a map of singletons of various classes, instantiating new ones as needed.

Since:
1.6
Version:
$Revision: $
Author:
Steven Grimm (koreth[remove] at midwinter dot com)

Constructor Summary
SingletonFactory(Class<T> klass)
           
 
Method Summary
 T getInstance(HierarchicalProperties properties, String propertyName, Class relativeTo)
          Returns an instance of a class based on a required property name from a properties collection.
 T getInstance(String className)
          Returns a singleton instance of a class.
 T getInstance(String className, String identifier)
          Returns a singleton with a particular identifier, or creates one with a particular class if none exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SingletonFactory

public SingletonFactory(Class<T> klass)
Method Detail

getInstance

public T getInstance(String className,
                     String identifier)
              throws ClassNotFoundException,
                     InstantiationException,
                     IllegalAccessException
Returns a singleton with a particular identifier, or creates one with a particular class if none exists.

Parameters:
className - the name of the class a singleton has to be obtained for
identifier - an identifier to differentiate several singletons for the same class
Returns:
the requested singleton instance
Throws:
ClassNotFoundException
InstantiationException
IllegalAccessException
Since:
1.6

getInstance

public T getInstance(String className)
              throws ClassNotFoundException,
                     InstantiationException,
                     IllegalAccessException
Returns a singleton instance of a class.

Parameters:
className - the name of the class a singleton has to be obtained for
Returns:
the requested singleton instance
Throws:
ClassNotFoundException
InstantiationException
IllegalAccessException
Since:
1.6

getInstance

public T getInstance(HierarchicalProperties properties,
                     String propertyName,
                     Class relativeTo)
              throws MandatoryPropertyMissingException,
                     ClassNotFoundException,
                     InstantiationException,
                     IllegalAccessException
Returns an instance of a class based on a required property name from a properties collection.

Parameters:
properties - The properties where the class name has to be obtained from
propertyName - Which property contains the class name
relativeTo - Class whose package should be used if no package is specified in the property
Returns:
the requested singleton instance
Throws:
MandatoryPropertyMissingException
ClassNotFoundException
InstantiationException
IllegalAccessException
Since:
1.6


Copyright © 2001-2007 Uwyn sprl/bvba. All Rights Reserved.