Top Description Fields Constructors Methods
jakarta.ws.rs.client

pack-priv final Class FactoryFinder

extends Object
Class Inheritance
Imports
java.io.File, .FileInputStream, .IOException, java.security.AccessController, .PrivilegedAction, java.util.Properties, .ServiceLoader, java.util.logging.Level, .Logger

Factory finder utility class.
Authors
Paul Sandoz, Marc Hadley, Marek Potociar
Since
2.0

Field Summary

Modifier and TypeField and Description
private static final Logger

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static <
type of the service to be found.
T
>
Object

Returns:

the instance of the specified service; may not be null.
find
(final String
the name of the factory to find, which is a system property.
factoryId
,
final Class<T>
service to be found.
service
)

Finds the implementation Class for the given factory name and create its instance.

private static <T> T
findFirstService(final String factoryId, final ClassLoader cl, final Class<T> service)

private static ClassLoader
pack-priv static ClassLoader
private static Object

Returns:

instance of the specified class.
newInstance
(final String
name of the class to be instantiated.
className
,
final ClassLoader
class loader to be used.
classLoader
)

Creates an instance of the specified class using the specified ClassLoader object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGGERback to summary
private static final Logger LOGGER

Constructor Detail

FactoryFinderback to summary
private FactoryFinder()

Method Detail

findback to summary
pack-priv static <T> Object find(final String factoryId, final Class<T> service) throws ClassNotFoundException

Finds the implementation Class for the given factory name and create its instance.

This method is package private so that this code can be shared.

Parameters
<T>
type of the service to be found.
factoryId:String

the name of the factory to find, which is a system property.

service:Class<T>

service to be found.

Returns:Object

the instance of the specified service; may not be null.

Exceptions
ClassNotFoundException:
if the given class could not be found or could not be instantiated.
findFirstServiceback to summary
private static <T> T findFirstService(final String factoryId, final ClassLoader cl, final Class<T> service)
getClassLoaderback to summary
private static ClassLoader getClassLoader()
getContextClassLoaderback to summary
pack-priv static ClassLoader getContextClassLoader()
newInstanceback to summary
private static Object newInstance(final String className, final ClassLoader classLoader) throws ClassNotFoundException

Creates an instance of the specified class using the specified ClassLoader object.

Parameters
className:String

name of the class to be instantiated.

classLoader:ClassLoader

class loader to be used.

Returns:Object

instance of the specified class.

Exceptions
ClassNotFoundException:
if the given class could not be found or could not be instantiated.