Class FactoryFinder
- java.lang.Object
-
- javax.faces.FactoryFinder
-
public final class FactoryFinder extends java.lang.ObjectFactoryFinder 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 the JavaServer Faces configuration file bundled into the
WEB-INFdirectory of the webapp contains afactoryentry of the given factory class name, that factory is used.If the JavaServer Faces configuration files named by the
javax.faces.CONFIG_FILESServletContextinit parameter contain anyfactoryentries of the given factory class name, those injectionProvider are used, with the last one taking precedence.If there are any JavaServer Faces configuration files bundled into the
META-INFdirectory of any jars on theServletContext's resource paths, thefactoryentries of the given factory class name in those files are used, with the last one taking precedence.If a
META-INF/services/{factory-class-name}resource is visible to the web application class loader for the calling application (typically as a injectionProvider of being present in the manifest of a JAR file), its first line is read and assumed to be the name of the factory implementation class to use.If none of the above steps yield a match, the JavaServer Faces implementation specific class is used.
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
FacesContextFactory, and identified it inMETA-INF/services/javax.faces.context.FacesContextFactoryin a jar on the webapp ClassLoader. Also say this implementation provided by the container vendor had a one argument constructor that took aFacesContextFactoryinstance. TheFactoryFindersystem would call that one-argument constructor, passing the implementation ofFacesContextFactoryprovided 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
Fields Modifier and Type Field Description static java.lang.StringAPPLICATION_FACTORYThe property name for theApplicationFactoryclass name.static java.lang.StringCLIENT_WINDOW_FACTORYThe property name for theClientWindowFactoryclass name.static java.lang.StringEXCEPTION_HANDLER_FACTORYThe property name for theExceptionHandlerFactoryclass name.static java.lang.StringEXTERNAL_CONTEXT_FACTORYThe property name for theExternalContextFactoryclass name.static java.lang.StringFACELET_CACHE_FACTORYThe property name for theFaceletCacheFactoryclass name.static java.lang.StringFACES_CONTEXT_FACTORYThe property name for theFacesContextFactoryclass name.static java.lang.StringFLASH_FACTORYThe property name for theFlashFactoryclass name.static java.lang.StringFLOW_HANDLER_FACTORYThe property name for theFlowHandlerFactoryclass name.static java.lang.StringLIFECYCLE_FACTORYThe property name for theLifecycleFactoryclass name.static java.lang.StringPARTIAL_VIEW_CONTEXT_FACTORYThe property name for thePartialViewContextFactoryclass name.static java.lang.StringRENDER_KIT_FACTORYThe property name for theRenderKitFactoryclass name.static java.lang.StringTAG_HANDLER_DELEGATE_FACTORYThe property name for theTagHandlerDelegateclass name.static java.lang.StringVIEW_DECLARATION_LANGUAGE_FACTORYThe property name for theViewDeclarationLanguageclass name.static java.lang.StringVISIT_CONTEXT_FACTORYThe property name for theVisitContextFactoryclass name.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.ObjectgetFactory(java.lang.String 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.static voidreleaseFactories()Release any references to factory instances associated with the class loader for the calling web application.static voidsetFactory(java.lang.String factoryName, java.lang.String implName)This method will store the argumentfactoryName/implNamemapping in such a way thatgetFactory(java.lang.String)will find this mapping when searching for a match.
-
-
-
Field Detail
-
APPLICATION_FACTORY
public static final java.lang.String APPLICATION_FACTORY
The property name for the
ApplicationFactoryclass name.- See Also:
- Constant Field Values
-
CLIENT_WINDOW_FACTORY
public static final java.lang.String CLIENT_WINDOW_FACTORY
The property name for the
ClientWindowFactoryclass name.- Since:
- 2.2
- See Also:
- Constant Field Values
-
EXCEPTION_HANDLER_FACTORY
public static final java.lang.String EXCEPTION_HANDLER_FACTORY
The property name for the
ExceptionHandlerFactoryclass name.- See Also:
- Constant Field Values
-
EXTERNAL_CONTEXT_FACTORY
public static final java.lang.String EXTERNAL_CONTEXT_FACTORY
The property name for the
ExternalContextFactoryclass name.- See Also:
- Constant Field Values
-
FACES_CONTEXT_FACTORY
public static final java.lang.String FACES_CONTEXT_FACTORY
The property name for the
FacesContextFactoryclass name.- See Also:
- Constant Field Values
-
FACELET_CACHE_FACTORY
public static final java.lang.String FACELET_CACHE_FACTORY
The property name for the
FaceletCacheFactoryclass name.- Since:
- 2.1
- See Also:
- Constant Field Values
-
FLASH_FACTORY
public static final java.lang.String FLASH_FACTORY
The property name for the
FlashFactoryclass name.- Since:
- 2.2
- See Also:
- Constant Field Values
-
FLOW_HANDLER_FACTORY
public static final java.lang.String FLOW_HANDLER_FACTORY
The property name for the
FlowHandlerFactoryclass name.- Since:
- 2.2
- See Also:
- Constant Field Values
-
PARTIAL_VIEW_CONTEXT_FACTORY
public static final java.lang.String PARTIAL_VIEW_CONTEXT_FACTORY
The property name for the
PartialViewContextFactoryclass name.- See Also:
- Constant Field Values
-
VISIT_CONTEXT_FACTORY
public static final java.lang.String VISIT_CONTEXT_FACTORY
The property name for the
VisitContextFactoryclass name.- See Also:
- Constant Field Values
-
LIFECYCLE_FACTORY
public static final java.lang.String LIFECYCLE_FACTORY
The property name for the
LifecycleFactoryclass name.- See Also:
- Constant Field Values
-
RENDER_KIT_FACTORY
public static final java.lang.String RENDER_KIT_FACTORY
The property name for the
RenderKitFactoryclass name.- See Also:
- Constant Field Values
-
VIEW_DECLARATION_LANGUAGE_FACTORY
public static final java.lang.String VIEW_DECLARATION_LANGUAGE_FACTORY
The property name for the
ViewDeclarationLanguageclass name.- See Also:
- Constant Field Values
-
TAG_HANDLER_DELEGATE_FACTORY
public static final java.lang.String TAG_HANDLER_DELEGATE_FACTORY
The property name for the
TagHandlerDelegateclass name.- See Also:
- Constant Field Values
-
-
Method Detail
-
getFactory
public static java.lang.Object getFactory(java.lang.String factoryName) throws FacesExceptionCreate (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 returnedObjectis an implementation of one of the standard injectionProvider, it must be legal to cast it to an instance ofFacesWrapperand callFacesWrapper.getWrapped()on the instance.- Parameters:
factoryName- Fully qualified name of the JavaServer Faces factory for which an implementation instance is requested- Throws:
FacesException- if the web application class loader cannot be identifiedFacesException- if an instance of the configured factory implementation class cannot be loadedFacesException- if an instance of the configured factory implementation class cannot be instantiatedjava.lang.IllegalArgumentException- iffactoryNamedoes not identify a standard JavaServer Faces factory namejava.lang.IllegalStateException- if there is no configured factory implementation class for the specified factory namejava.lang.NullPointerException- iffactorynameis null
-
setFactory
public static void setFactory(java.lang.String factoryName, java.lang.String implName)This method will store the argument
factoryName/implNamemapping in such a way thatgetFactory(java.lang.String)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 thisfactoryName.This method can be used by implementations to store a factory mapping while parsing the Faces configuration file
- Throws:
java.lang.IllegalArgumentException- iffactoryNamedoes not identify a standard JavaServer Faces factory namejava.lang.NullPointerException- iffactorynameis null
-
releaseFactories
public static void releaseFactories() throws FacesExceptionRelease 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.
- Throws:
FacesException- if the web application class loader cannot be identified
-
-