javax.faces
Class FactoryFinder

java.lang.Object
  extended by javax.faces.FactoryFinder

public final class FactoryFinder
extends java.lang.Object

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 factories 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 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
static java.lang.String APPLICATION_FACTORY
          The property name for the ApplicationFactory class name.
static java.lang.String EXCEPTION_HANDLER_FACTORY
          

The property name for the ExceptionHandlerFactory class name.

static java.lang.String EXTERNAL_CONTEXT_FACTORY
          

The property name for the ExternalContextFactory class name.

static java.lang.String FACES_CONTEXT_FACTORY
          The property name for the FacesContextFactory class name.
static java.lang.String LIFECYCLE_FACTORY
          The property name for the LifecycleFactory class name.
static java.lang.String PARTIAL_VIEW_CONTEXT_FACTORY
          

The property name for the PartialViewContextFactory class name.

static java.lang.String RENDER_KIT_FACTORY
          The property name for the RenderKitFactory class name.
static java.lang.String TAG_HANDLER_DELEGATE_FACTORY
          

The property name for the TagHandlerDelegate class name.

static java.lang.String VIEW_DECLARATION_LANGUAGE_FACTORY
          

The property name for the ViewDeclarationLanguage class name.

static java.lang.String VISIT_CONTEXT_FACTORY
          

The property name for the VisitContextFactory class name.

 
Method Summary
static java.lang.Object getFactory(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 void releaseFactories()
          Release any references to factory instances associated with the class loader for the calling web application.
static void setFactory(java.lang.String factoryName, java.lang.String implName)
          This method will store the argument factoryName/implName mapping in such a way that getFactory(java.lang.String) will find this mapping when searching for a match.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

APPLICATION_FACTORY

public static final java.lang.String APPLICATION_FACTORY

The property name for the ApplicationFactory class name.

See Also:
Constant Field Values

EXCEPTION_HANDLER_FACTORY

public static final java.lang.String EXCEPTION_HANDLER_FACTORY

The property name for the ExceptionHandlerFactory class name.

See Also:
Constant Field Values

EXTERNAL_CONTEXT_FACTORY

public static final java.lang.String EXTERNAL_CONTEXT_FACTORY

The property name for the ExternalContextFactory class name.

See Also:
Constant Field Values

FACES_CONTEXT_FACTORY

public static final java.lang.String FACES_CONTEXT_FACTORY

The property name for the FacesContextFactory class name.

See Also:
Constant Field Values

PARTIAL_VIEW_CONTEXT_FACTORY

public static final java.lang.String PARTIAL_VIEW_CONTEXT_FACTORY

The property name for the PartialViewContextFactory class name.

See Also:
Constant Field Values

VISIT_CONTEXT_FACTORY

public static final java.lang.String VISIT_CONTEXT_FACTORY

The property name for the VisitContextFactory class name.

See Also:
Constant Field Values

LIFECYCLE_FACTORY

public static final java.lang.String LIFECYCLE_FACTORY

The property name for the LifecycleFactory class name.

See Also:
Constant Field Values

RENDER_KIT_FACTORY

public static final java.lang.String RENDER_KIT_FACTORY

The property name for the RenderKitFactory class 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 ViewDeclarationLanguage class 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 TagHandlerDelegate class name.

See Also:
Constant Field Values
Method Detail

getFactory

public static java.lang.Object getFactory(java.lang.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 factories and wrappers in JSF all implement the interface FacesWrapper. If the returned Object is an implementation of one of the standard factories, it must be legal to cast it to an instance of FacesWrapper and call FacesWrapper#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 identified
FacesException - if an instance of the configured factory implementation class cannot be loaded
FacesException - if an instance of the configured factory implementation class cannot be instantiated
java.lang.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
java.lang.NullPointerException - if factoryname is null

setFactory

public static void setFactory(java.lang.String factoryName,
                              java.lang.String implName)

This method will store the argument factoryName/implName mapping in such a way that getFactory(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 this factoryName.

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

Throws:
java.lang.IllegalArgumentException - if factoryName does not identify a standard JavaServer Faces factory name
java.lang.NullPointerException - if factoryname is null

releaseFactories

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.

Throws:
FacesException - if the web application class loader cannot be identified


Submit a bug or feature

Copyright © 2009, 2010, Oracle Corporation and/or its affiliates. All Rights Reserved. Use is subject to license terms.

Generated on 4-June-2010 04:34