java.lang.Object
jakarta.activation.FactoryFinder
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ServiceLoaderUtil.ExceptionHandler<RuntimeException> private static final Loggerprivate static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static <T> TFinds the implementationClassobject for the given factory type.private static StringfromSystemProperty(String factoryId) private static StringgetSystemProperty(String property) private static booleanisOsgi()private static voidprivate static <T> TlookupUsingOSGiServiceLoader(String factoryId) private static <T> TnewInstance(String className, String defaultClassName, ClassLoader tccl)
-
Field Details
-
logger
-
EXCEPTION_HANDLER
-
OSGI_SERVICE_LOADER_CLASS_NAME
- See Also:
-
-
Constructor Details
-
FactoryFinder
FactoryFinder()
-
-
Method Details
-
find
static <T> T find(Class<T> factoryClass, String defaultClassName, boolean tryFallback) throws RuntimeException Finds the implementationClassobject for the given factory type. If it fails andtryFallbackistruefinds theClassobject for the given default class name. The arguments supplied must be used in order Note the default class name may be needed even if fallback is not to be attempted in order to check if requested type is fallback.This method is package private so that this code can be shared.
- Parameters:
factoryClass- factory abstract class or interface to be founddefaultClassName- the implementation class name, which is to be used only if nothing else is found;nullto indicate that there is no default class nametryFallback- whether to try the default class as a fallback- Returns:
- the
Classobject of the specified message factory; may not benull - Throws:
RuntimeException- if there is no factory found
-
newInstance
private static <T> T newInstance(String className, String defaultClassName, ClassLoader tccl) throws RuntimeException - Throws:
RuntimeException
-
fromSystemProperty
-
getSystemProperty
-
logFound
-
isOsgi
private static boolean isOsgi() -
lookupUsingOSGiServiceLoader
-