Package org.apache.activemq.util
Class FactoryFinder<T>
- java.lang.Object
-
- org.apache.activemq.util.FactoryFinder<T>
-
public class FactoryFinder<T> extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceFactoryFinder.ObjectFactoryThe strategy that the FactoryFinder uses to find load and instantiate Objects can be changed out by calling thesetObjectFactory(org.apache.activemq.util.FactoryFinder.ObjectFactory)method with a custom implementation of ObjectFactory.protected static classFactoryFinder.StandaloneObjectFactoryThe default implementation of Object factory which works well in standalone applications.
-
Constructor Summary
Constructors Constructor Description FactoryFinder(String path, Class<T> requiredType, String allowedImpls)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StringbuildAllowedImpls(Class<?>... classes)static booleancontainsPathSeparators(String str)static FactoryFinder.ObjectFactorygetObjectFactory()TnewInstance(String key)Creates a new instance of the given keystatic voidsetObjectFactory(FactoryFinder.ObjectFactory objectFactory)static <T> voidvalidateClass(Class<?> clazz, Class<T> requiredType, Set<Class<? extends T>> allowedImpls)
-
-
-
Constructor Detail
-
FactoryFinder
public FactoryFinder(String path, Class<T> requiredType, String allowedImpls)
- Parameters:
path- The path to search for implsrequiredType- Required interface type that any impl must implementallowedImpls- The list of allowed implementations. If null or asterisk then all impls of the requiredType are allowed.
-
-
Method Detail
-
getObjectFactory
public static FactoryFinder.ObjectFactory getObjectFactory()
-
setObjectFactory
public static void setObjectFactory(FactoryFinder.ObjectFactory objectFactory)
-
newInstance
public T newInstance(String key) throws IllegalAccessException, InstantiationException, IOException, ClassNotFoundException
Creates a new instance of the given key- Parameters:
key- is the key to add to the path to find a text file containing the factory name- Returns:
- a newly created instance
- Throws:
IllegalAccessExceptionInstantiationExceptionIOExceptionClassNotFoundException
-
containsPathSeparators
public static boolean containsPathSeparators(String str)
-
validateClass
public static <T> void validateClass(Class<?> clazz, Class<T> requiredType, Set<Class<? extends T>> allowedImpls) throws InstantiationException
- Throws:
InstantiationException
-
-