Package javax.ws.rs.sse
Class FactoryFinder
java.lang.Object
javax.ws.rs.sse.FactoryFinder
Factory finder utility class.
- Since:
- 2.1
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static <T> ObjectFinds the implementationClassfor the given factory name, or if that fails, finds theClassfor the given fallback class name and create its instance.private static ClassLoaderprivate static ObjectnewInstance(String className, ClassLoader classLoader) Creates an instance of the specified class using the specifiedClassLoaderobject.
-
Field Details
-
LOGGER
-
-
Constructor Details
-
FactoryFinder
private FactoryFinder()
-
-
Method Details
-
getContextClassLoader
-
newInstance
private static Object newInstance(String className, ClassLoader classLoader) throws ClassNotFoundException Creates an instance of the specified class using the specifiedClassLoaderobject.- Parameters:
className- name of the class to be instantiated.classLoader- class loader to be used.- Returns:
- instance of the specified class.
- Throws:
ClassNotFoundException- if the given class could not be found or could not be instantiated.
-
find
static <T> Object find(String factoryId, String fallbackClassName, Class<T> service) throws ClassNotFoundException Finds the implementationClassfor the given factory name, or if that fails, finds theClassfor the given fallback class name and create its instance. The arguments supplied MUST be used in order. If using the first argument is successful, the second one will not be used.This method is package private so that this code can be shared.
- Type Parameters:
T- type of the service to be found.- Parameters:
factoryId- the name of the factory to find, which is a system property.fallbackClassName- the implementation class name, which is to be used only if nothing else. is found;nullto indicate that there is no fallback class name.service- service to be found.- Returns:
- the instance of the specified service; may not be
null. - Throws:
ClassNotFoundException- if the given class could not be found or could not be instantiated.
-