Top Fields Constructors Methods
javax.faces

pack-priv final Class FactoryFinderInstance

extends Object
Class Inheritance
Static Imports
com.sun.faces.util.Util.generateCreatedBy, .Util.getContextClassLoader2, .Util.isAnyNull, .Util.isOneOf, java.text.MessageFormat.format, java.util.Collections.binarySearch, .Collections.unmodifiableMap, java.util.logging.Level.SEVERE, javax.faces.FactoryFinder.APPLICATION_FACTORY, .FactoryFinder.CLIENT_WINDOW_FACTORY, .FactoryFinder.EXCEPTION_HANDLER_FACTORY, .FactoryFinder.EXTERNAL_CONTEXT_FACTORY, .FactoryFinder.FACELET_CACHE_FACTORY, .FactoryFinder.FACES_CONTEXT_FACTORY, .FactoryFinder.FACTORIES_CACHE, .FactoryFinder.FLASH_FACTORY, .FactoryFinder.FLOW_HANDLER_FACTORY, .FactoryFinder.LIFECYCLE_FACTORY, .FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY, .FactoryFinder.RENDER_KIT_FACTORY, .FactoryFinder.SEARCH_EXPRESSION_CONTEXT_FACTORY, .FactoryFinder.TAG_HANDLER_DELEGATE_FACTORY, .FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY, .FactoryFinder.VISIT_CONTEXT_FACTORY, .ServletContextFacesContextFactory.SERVLET_CONTEXT_FINDER_NAME, .ServletContextFacesContextFactory.SERVLET_CONTEXT_FINDER_REMOVAL_NAME

Field Summary

Modifier and TypeField and Description
private final String
private final Map<String, Object>
private final Map<String, Class<?>>
factoryClasses

Map of Class instances for our factory names.

private final List<String>
factoryNames

The set of JavaServer Faces factory classes for which the factory discovery mechanism is supported.

private static final String
private final ReentrantReadWriteLock
private static final Logger
private final Map<String, List<String>>
private ServletContextFacesContextFactory

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
addFactory(String factoryName, String implementationClassName)

private List<String>
asSortedList(String... names)

private Map<String, Class<?>>
pack-priv void
private void
pack-priv Collection<Object>
pack-priv Object
getFactory(String factoryName)

private Class<?>

Returns:

the java.lang.Class for the argument factory.
getFactoryClass
(String factoryClassName)

private Object
getImplementationInstance(ClassLoader
Class loader for the web application that will be loading the implementation class
classLoader
,
String factoryName, List<String>
A List of implementations for a given factory class.
implementations
)

Load and return an instance of the specified implementation class using the following algorithm.

private Object
getImplGivenPreviousImpl(ClassLoader
the ClassLoader from which to load the class
classLoader
,
String
the fully qualified class name of the factory.
factoryName
,
String
the fully qualified class name of a class that implements the factory.
factoryImplClassName
,
Object
if non-null, the factory instance to be passed to the constructor of the new factory.
previousFactoryImplementation
)

Implement the decorator pattern for the factory implementation.

private List<String>
getImplNameFromServices(ClassLoader classLoader, String factoryName)

Perform the logic to get the implementation class for the second step of FactoryFinder#getImplementationInstance(ClassLoader, String, java.util.List).

pack-priv InjectionProvider
private void
injectImplementation(String implementationName, Object implementation)

private void
logNoFactory(String factoryName)

private void
private void
notNullFactory(String factoryName, Object factory)

private String
pack-priv void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

createdByback to summary
private final String createdBy
factoriesback to summary
private final Map<String, Object> factories
factoryClassesback to summary
private final Map<String, Class<?>> factoryClasses

Map of Class instances for our factory names.

factoryNamesback to summary
private final List<String> factoryNames

The set of JavaServer Faces factory classes for which the factory discovery mechanism is supported. The entries in this list must be alphabetically ordered according to the entire string of the *value* of each of the literals, not just the last part of the literal!

INJECTION_PROVIDER_KEYback to summary
private static final String INJECTION_PROVIDER_KEY
lockback to summary
private final ReentrantReadWriteLock lock
LOGGERback to summary
private static final Logger LOGGER
savedFactoryNamesback to summary
private final Map<String, List<String>> savedFactoryNames
servletContextFinderback to summary
private ServletContextFacesContextFactory servletContextFinder

Constructor Detail

FactoryFinderInstanceback to summary
pack-priv FactoryFinderInstance(FacesContext facesContext)
FactoryFinderInstanceback to summary
pack-priv FactoryFinderInstance(FacesContext facesContext, FactoryFinderInstance toCopy)

Method Detail

addFactoryback to summary
pack-priv void addFactory(String factoryName, String implementationClassName)
asSortedListback to summary
private List<String> asSortedList(String... names)
buildFactoryClassesMapback to summary
private Map<String, Class<?>> buildFactoryClassesMap()
clearInjectionProviderback to summary
pack-priv void clearInjectionProvider()
copyInjectionProviderFromFacesContextback to summary
private void copyInjectionProviderFromFacesContext(FacesContext facesContext)
getFactoriesback to summary
pack-priv Collection<Object> getFactories()
getFactoryback to summary
pack-priv Object getFactory(String factoryName)
Annotations
@SuppressWarnings:unchecked
getFactoryClassback to summary
private Class<?> getFactoryClass(String factoryClassName)
Returns:Class<?>

the java.lang.Class for the argument factory.

getImplementationInstanceback to summary
private Object getImplementationInstance(ClassLoader classLoader, String factoryName, List<String> implementations) throws FacesException

Load and return an instance of the specified implementation class using the following algorithm.

  1. If the argument implementations list has more than one element, or exactly one element, interpret the last element in the list to be the fully qualified class name of a class implementing factoryName. Instantiate that class and save it for return. If the implementations list has only one element, skip this step.

  2. Look for a resource called /META-INF/services/<factoryName>. If found, interpret it as a properties file, and read out the first entry. Interpret the first entry as a fully qualify class name of a class that implements factoryName. If we have an instantiated factory from the previous step and the implementing class has a one arg constructor of the type for factoryName, instantiate it, passing the instantiated factory from the previous step. If there is no one arg constructor, just instantiate the zero arg constructor. Save the newly instantiated factory for return, replacing the instantiated factory from the previous step.

  3. Treat each remaining element in the implementations list as a fully qualified class name of a class implementing factoryName. If the currentKeyrent element has a one arg constructor of the type for factoryName, instantiate it, passing the instantiated factory from the previous or step iteration. If there is no one arg constructor, just instantiate the zero arg constructor, replacing the instantiated factory from the previous step or iteration.

  4. Return the saved factory

Parameters
classLoader:ClassLoader

Class loader for the web application that will be loading the implementation class

implementations:List<String>

A List of implementations for a given factory class.

Exceptions
FacesException:
  • if the specified implementation class cannot be loaded
  • if an instance of the specified implementation class cannot be instantiated
getImplGivenPreviousImplback to summary
private Object getImplGivenPreviousImpl(ClassLoader classLoader, String factoryName, String factoryImplClassName, Object previousFactoryImplementation)

Implement the decorator pattern for the factory implementation.

If previousImpl is non-null and the class named by the argument implName has a one arg contstructor of type factoryName, instantiate it, passing previousImpl to the constructor.

Otherwise, we just instantiate and return implName.

Parameters
classLoader:ClassLoader

the ClassLoader from which to load the class

factoryName:String

the fully qualified class name of the factory.

factoryImplClassName:String

the fully qualified class name of a class that implements the factory.

previousFactoryImplementation:Object

if non-null, the factory instance to be passed to the constructor of the new factory.

getImplNameFromServicesback to summary
private List<String> getImplNameFromServices(ClassLoader classLoader, String factoryName)

Perform the logic to get the implementation class for the second step of FactoryFinder#getImplementationInstance(ClassLoader, String, java.util.List).

getInjectionProviderback to summary
pack-priv InjectionProvider getInjectionProvider()
injectImplementationback to summary
private void injectImplementation(String implementationName, Object implementation)
logNoFactoryback to summary
private void logNoFactory(String factoryName)
logPreDestroyFailback to summary
private void logPreDestroyFail(Object factory, Exception ex)
notNullFactoryback to summary
private void notNullFactory(String factoryName, Object factory)
readLineFromStreamback to summary
private String readLineFromStream(InputStream stream) throws IOException
releaseFactoriesback to summary
pack-priv void releaseFactories()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
validateFactoryNameback to summary
private void validateFactoryName(String factoryName)