org.apache.myfaces.trinidadinternal.config
Class GlobalConfiguratorImpl

java.lang.Object
  extended by org.apache.myfaces.trinidad.config.Configurator
      extended by org.apache.myfaces.trinidadinternal.config.GlobalConfiguratorImpl

public class GlobalConfiguratorImpl
extends org.apache.myfaces.trinidad.config.Configurator

This is the implementation of the Trinidad's Global configurator. It provides the entry point for all other configurators. This class is responsible for enforcing the contract outlined by the Configurator abstract class, but allows a more "relaxed" implementation of the APIs called for by the Configurator class, making it more convenient to use ConfiguratorServices from within the Trinidad renderkit. Where appropriate, these differences will be documented for the benifit of the Trindad developer.

Version:
$Revision$ $Date$
Author:
Scott O'Bryan (latest modification by $Author$)
See Also:
Configurator

Method Summary
 void beginRequest(javax.faces.context.ExternalContext externalContext)
          Executes the beginRequest methods of all of the configurator services.
 void destroy()
          Cleans up the current configurator.
 void endRequest(javax.faces.context.ExternalContext externalContext)
          Ends the currently begun request.
 javax.faces.context.ExternalContext getExternalContext(javax.faces.context.ExternalContext externalContext)
          Returns an externalContext for this configurator and all of the configurator services.
static GlobalConfiguratorImpl getInstance()
          Returns a GlobalConfigurator instance for the current context's class loader.
 void init(javax.faces.context.ExternalContext externalContext)
          Initializes the global configurator and the configurator services.
static boolean isRequestStarted(javax.faces.context.ExternalContext ec)
          Returns true if the request has not been stated for the current "virtual" request.
 
Methods inherited from class org.apache.myfaces.trinidad.config.Configurator
disableConfiguratorServices, isConfiguratorServiceDisabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static final GlobalConfiguratorImpl getInstance()
Returns a GlobalConfigurator instance for the current context's class loader. The GlobalConfigurator is responsible for enforcing the contract on the other methods of this class. This means that if init(ExternalContext) is called multiple times, the global configurator will call all subordinate configurators only once. Likewise, the GlobalConfigurator will return exceptions when the contract is expressly violated (like if getExternalContext(ExternalContext) is called before a {beginRequest(ExternalContext).

Returns:
a GlobalConfigurator or null is one was unable to be obtained.

isRequestStarted

public static boolean isRequestStarted(javax.faces.context.ExternalContext ec)
Returns true if the request has not been stated for the current "virtual" request. In the servlet environment this will be true after beginRequest(ExternalContext) is executed and before endRequest(ExternalContext) is executed. This will generally happen once per request. In the Portlet Environment, the request must be be started and ended at the beginning and end of both the actionRequest and the RenderRequest.

Parameters:
ec -
Returns:

beginRequest

public void beginRequest(javax.faces.context.ExternalContext externalContext)
Executes the beginRequest methods of all of the configurator services. This method will also initizlize the configurator if it has not already been initialized, so there may be no need to call the init(ExternalContext) method directly. This method also ensures that the requestContext is attached before the beginRequest methods are called, so there is no reason to initialize the request context before calling this method. In portal environments, it is important to execute this method once for each Portlet action and render request so that the requestContext may be properly initialized even though the underlying services will be called only once per physical request.

Overrides:
beginRequest in class org.apache.myfaces.trinidad.config.Configurator
Parameters:
externalContext - the externalContext to use to begin the request.
See Also:
Configurator.beginRequest(javax.faces.context.ExternalContext)

destroy

public void destroy()
Cleans up the current configurator. This will execute the destroy method on all of the configurator services. Generally this will be called by Trinidad's context listener when the context is destroyed, but it may be used manually to allow the configurator to be re-initialized. Calling this method while the configurator is not initialized will not re-execute the destroy methods on the services.

Overrides:
destroy in class org.apache.myfaces.trinidad.config.Configurator
See Also:
Configurator.destroy()

endRequest

public void endRequest(javax.faces.context.ExternalContext externalContext)
Ends the currently begun request. It is important to note that this should be executed only once per physical request.

Overrides:
endRequest in class org.apache.myfaces.trinidad.config.Configurator
See Also:
Configurator.endRequest(javax.faces.context.ExternalContext)

getExternalContext

public javax.faces.context.ExternalContext getExternalContext(javax.faces.context.ExternalContext externalContext)
Returns an externalContext for this configurator and all of the configurator services. If this method is executed before beginRequest(ExternalContext) then this method will call beginRequest(). It is important to note, however, that even though beginRequest does not need to be explicitly called, {endRequest(ExternalContext) does need to be called when the request has completed or the contract to the configurators will be broken.

Overrides:
getExternalContext in class org.apache.myfaces.trinidad.config.Configurator
Parameters:
externalContext - the ExternalContext object that should be wrapped.
Returns:
a decorated ExternalContext object

init

public void init(javax.faces.context.ExternalContext externalContext)
Initializes the global configurator and the configurator services. This method need not be called directly as it will be called from beginRequest(ExternalContext) if needed. It is also possible to execute this method more then once, although if initialization has already happened then a call to this method will not do anything. To re-initialize this class, call destroy() first and then call this method.

Overrides:
init in class org.apache.myfaces.trinidad.config.Configurator
Parameters:
externalContext - the externalContext needed to initialize this class
See Also:
Configurator.init(javax.faces.context.ExternalContext)


Copyright © 2001-2007 Apache Software Foundation. All Rights Reserved.