Top Description Fields Constructors Methods
javax.faces

public final Class FactoryFinder

extends Object
Class Inheritance
Static Imports
javax.faces.ServletContextFacesContextFactory.SERVLET_CONTEXT_FINDER_NAME

FactoryFinder implements the standard discovery algorithm for all factory objects specified in the JavaServer Faces APIs. For a given factory class name, a corresponding implementation class is searched for based on the following algorithm. Items are listed in order of decreasing search precedence:

If any of the injectionProvider found on any of the steps above happen to have a one-argument constructor, with argument the type being the abstract factory class, that constructor is invoked, and the previous match is passed to the constructor. For example, say the container vendor provided an implementation of javax.faces.context.FacesContextFactory, and identified it in META-INF/services/javax.faces.context.FacesContextFactory in a jar on the webapp ClassLoader. Also say this implementation provided by the container vendor had a one argument constructor that took a FacesContextFactory instance. The FactoryFinder system would call that one-argument constructor, passing the implementation of FacesContextFactory provided by the JavaServer Faces implementation.

If a Factory implementation does not provide a proper one-argument constructor, it must provide a zero-arguments constructor in order to be successfully instantiated.

Once the name of the factory implementation class is located, the web application class loader for the calling application is requested to load this class, and a corresponding instance of the class will be created. A side effect of this rule is that each web application will receive its own instance of each factory class, whether the JavaServer Faces implementation is included within the web application or is made visible through the container's facilities for shared libraries.

Field Summary

Modifier and TypeField and Description
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
FACES_CONTEXT_FACTORY

The property name for the javax.faces.context.FacesContextFactory class name.

pack-priv static final CurrentThreadToServletContext
public static final String
FLASH_FACTORY

The property name for the javax.faces.context.FlashFactory class name.

public static final String
FLOW_HANDLER_FACTORY

The property name for the javax.faces.flow.FlowHandlerFactory class name.

public static final String
LIFECYCLE_FACTORY

The property name for the javax.faces.lifecycle.LifecycleFactory class name.

public static final String
public static final String
RENDER_KIT_FACTORY

The property name for the javax.faces.render.RenderKitFactory class name.

public static final String
public static final String
public static final String
public static final String

Constructor Summary

AccessConstructor and Description
pack-priv
FactoryFinder()

Package-private constructor to disable instantiation of this class.

Method Summary

Modifier and TypeMethod and Description
public static Object

Returns:

the found factory instance
getFactory
(String
Fully qualified name of the JavaServer Faces factory for which an implementation instance is requested
factoryName
)

Create (if necessary) and return a per-web-application instance of the appropriate implementation class for the specified JavaServer Faces factory class, based on the discovery algorithm described in the class description.

private static void
public static void
releaseFactories()

Release any references to factory instances associated with the class loader for the calling web application.

public static void
setFactory(String
the name to be used in a subsequent call to getFactory.
factoryName
,
String
the fully qualified class name of the factory corresponding to factoryName.
implName
)

This method will store the argument factoryName/implName mapping in such a way that getFactory will find this mapping when searching for a match.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

APPLICATION_FACTORYback to summary
public static final String APPLICATION_FACTORY

The property name for the javax.faces.application.ApplicationFactory class name.

CLIENT_WINDOW_FACTORYback to summary
public static final String CLIENT_WINDOW_FACTORY

The property name for the javax.faces.lifecycle.ClientWindowFactory class name.

Since
2.2
EXCEPTION_HANDLER_FACTORYback to summary
public static final String EXCEPTION_HANDLER_FACTORY

The property name for the javax.faces.context.ExceptionHandlerFactory class name.

EXTERNAL_CONTEXT_FACTORYback to summary
public static final String EXTERNAL_CONTEXT_FACTORY

The property name for the javax.faces.context.ExternalContextFactory class name.

FACELET_CACHE_FACTORYback to summary
public static final String FACELET_CACHE_FACTORY

The property name for the javax.faces.view.facelets.FaceletCacheFactory class name.

Since
2.1
FACES_CONTEXT_FACTORYback to summary
public static final String FACES_CONTEXT_FACTORY

The property name for the javax.faces.context.FacesContextFactory class name.

FACTORIES_CACHEback to summary
pack-priv static final CurrentThreadToServletContext FACTORIES_CACHE
FLASH_FACTORYback to summary
public static final String FLASH_FACTORY

The property name for the javax.faces.context.FlashFactory class name.

Since
2.2
FLOW_HANDLER_FACTORYback to summary
public static final String FLOW_HANDLER_FACTORY

The property name for the javax.faces.flow.FlowHandlerFactory class name.

Since
2.2
LIFECYCLE_FACTORYback to summary
public static final String LIFECYCLE_FACTORY

The property name for the javax.faces.lifecycle.LifecycleFactory class name.

PARTIAL_VIEW_CONTEXT_FACTORYback to summary
public static final String PARTIAL_VIEW_CONTEXT_FACTORY

The property name for the javax.faces.context.PartialViewContextFactory class name.

RENDER_KIT_FACTORYback to summary
public static final String RENDER_KIT_FACTORY

The property name for the javax.faces.render.RenderKitFactory class name.

SEARCH_EXPRESSION_CONTEXT_FACTORYback to summary
public static final String SEARCH_EXPRESSION_CONTEXT_FACTORY

The property name for the javax.faces.component.search.SearchExpressionContext class name.

TAG_HANDLER_DELEGATE_FACTORYback to summary
public static final String TAG_HANDLER_DELEGATE_FACTORY

The property name for the javax.faces.view.facelets.TagHandlerDelegate class name.

VIEW_DECLARATION_LANGUAGE_FACTORYback to summary
public static final String VIEW_DECLARATION_LANGUAGE_FACTORY

The property name for the javax.faces.view.ViewDeclarationLanguage class name.

VISIT_CONTEXT_FACTORYback to summary
public static final String VISIT_CONTEXT_FACTORY

The property name for the javax.faces.component.visit.VisitContextFactory class name.

Constructor Detail

FactoryFinderback to summary
pack-priv FactoryFinder()

Package-private constructor to disable instantiation of this class.

Method Detail

getFactoryback to summary
public static Object getFactory(String factoryName) throws FacesException

Create (if necessary) and return a per-web-application instance of the appropriate implementation class for the specified JavaServer Faces factory class, based on the discovery algorithm described in the class description.

The standard injectionProvider and wrappers in JSF all implement the interface FacesWrapper. If the returned Object is an implementation of one of the standard injectionProvider, it must be legal to cast it to an instance of FacesWrapper and call FacesWrapper#getWrapped on the instance.

Parameters
factoryName:String

Fully qualified name of the JavaServer Faces factory for which an implementation instance is requested

Returns:Object

the found factory instance

Exceptions
FacesException:
  • if the web application class loader cannot be identified
  • if an instance of the configured factory implementation class cannot be loaded
  • if an instance of the configured factory implementation class cannot be instantiated
IllegalArgumentException:
if factoryName does not identify a standard JavaServer Faces factory name
IllegalStateException:
if there is no configured factory implementation class for the specified factory name
NullPointerException:
if factoryname is null
reInitializeFactoryManagerback to summary
private static void reInitializeFactoryManager()
Annotations
@SuppressWarnings:unused
releaseFactoriesback to summary
public static void releaseFactories() throws FacesException

Release any references to factory instances associated with the class loader for the calling web application. This method must be called during of web application shutdown.

Exceptions
FacesException:
if the web application class loader cannot be identified
setFactoryback to summary
public static void setFactory(String factoryName, String implName)

This method will store the argument factoryName/implName mapping in such a way that getFactory will find this mapping when searching for a match.

This method has no effect if getFactory() has already been called looking for a factory for this factoryName.

This method can be used by implementations to store a factory mapping while parsing the Faces configuration file

Parameters
factoryName:String

the name to be used in a subsequent call to getFactory.

implName:String

the fully qualified class name of the factory corresponding to factoryName.

Exceptions
IllegalArgumentException:
if factoryName does not identify a standard JavaServer Faces factory name
NullPointerException:
if factoryname is null