org.eclipse.jst.jsf.core.internal.provisional.jsfappconfig
Class JSFAppConfigManager

java.lang.Object
  extended byorg.eclipse.jst.jsf.core.internal.provisional.jsfappconfig.JSFAppConfigManager
All Implemented Interfaces:
java.util.EventListener, org.eclipse.core.resources.IResourceChangeListener

public class JSFAppConfigManager
extends java.lang.Object
implements org.eclipse.core.resources.IResourceChangeListener

JSFAppConfigManager provides an entry point to an entire JSF application configuration, which is defined in one or more application configuration resource files.


Field Summary
protected  java.util.List configLocaters
          Collection of IJSFAppConfigLocater instances.
protected  java.util.List configProvidersChangeListeners
          Collection of IJSFAppConfigProvidersChangeListener instances.
protected  org.eclipse.jst.jsf.core.internal.provisional.jsfappconfig.JSFAppConfigManager.FacesConfigChangeAdapter facesConfigChangeAdapter
          Single FacesConfigChangeAdapter instance.
protected  java.util.Map facesConfigChangeListeners
          Map of application configuration model EMF classes to IFacesConfigChangeListener instances.
static org.eclipse.core.runtime.QualifiedName KEY_SESSIONPROPERTY
          Key that is used for the IProject instance's session property that holds a JSFAppConfigManager instance.
protected  org.eclipse.core.resources.IProject project
          IProject instance to which this JSFAppConfigManager instance is keyed.
 
Method Summary
 void addFacesConfigChangeAdapter(FacesConfigType facesConfig)
          Adds this instance's FacesConfigChangeAdapter instance to the passed application configuration model's adapters collection.
 java.lang.Object addFacesConfigChangeListener(java.lang.Class emfClass, IFacesConfigChangeListener listener)
          Adds an instance of IFacesConfigChangeListener.
 boolean addJSFAppConfigProvidersChangeListener(IJSFAppConfigProvidersChangeListener listener)
          Adds an instance of IJSFAppConfigProvidersChangeListener.
protected  void changeProject(org.eclipse.core.resources.IProject newProject)
          Called to respond to a change in the IProject instance to which this instance belongs.
protected  void finalize()
           
 java.util.List getApplications()
          Gets list of all ApplicationType instances from all known faces-config models; list may be empty.
 java.util.List getComponents()
          Gets list of all ComponentType instances from all known faces-config models; list may be empty.
 java.util.List getConverters()
          Gets list of all ConverterType instances from all known faces-config models; list may be empty.
 java.util.List getFacesConfigModels()
          Gets all FacesConfigType instances from all IJSFAppConfigProvider instances.
 java.util.List getFactories()
          Gets list of all FactoryType instances from all known faces-config models; list may be empty.
protected static JSFAppConfigManager getFromSessionProperty(org.eclipse.core.resources.IProject project)
          Attempts to get a JSFAppConfigManager instance from a session property of the passed IProject instance.
static JSFAppConfigManager getInstance(org.eclipse.core.resources.IProject project)
          Gets a JSFAppConfigManager instance that is keyed to the passed IProject parameter.
 java.util.Set getJSFAppConfigProviders()
          Gets all IJSFAppConfigProvider instances from all IJSFAppConfigLocater instances.
 java.util.List getLifecycles()
          Gets list of all LifecycleType instances from all known faces-config models; list may be empty.
 java.util.List getManagedBeans()
          Gets list of all ManagedBeanType instances from all known faces-config models; list may be empty.
 java.util.List getNavigationRules()
          Gets list of all NavigationRuleType instances from all known faces-config models; list may be empty.
 java.util.List getNavigationRulesForPage(org.eclipse.core.resources.IFile pageFile)
          Gets list of all NavigationRuleType instances from all known faces-config models where the navigation-rule's from-view-id value matches the web content folder-relative value of the passed IFile instance; list may be empty.
 org.eclipse.core.resources.IProject getProject()
          Gets this instance's IProject instance.
 java.util.List getReferencedBeans()
          Gets list of all ReferencedBeanType instances from all known faces-config models; list may be empty.
 java.util.List getRenderKits()
          Gets list of all RenderKitType instances from all known faces-config models; list may be empty.
 java.util.List getValidators()
          Gets list of all ValidatorType instances from all known faces-config models; list may be empty.
protected  void initialize()
          Initializes instance by: creating facesConfigChangeListeners collection, creating configProvidersChangeListeners collection, creating and populating configLocaters collection, invoking the startLocating() method on all configLocaters, setting instance as a session property of the IProject instance, adding a resource change listener to the workspace.
 void notifyFacesConfigChangeListeners(org.eclipse.emf.common.notify.Notification notification)
          Notifies IFacesConfigChangeListener instances of model changes in which they registered interest.
 void notifyJSFAppConfigProvidersChangeListeners(IJSFAppConfigProvider configProvider, int eventType)
          Notifies all IJSFAppConfigProvidersChangeListener instances of a change in the Set of IJSFAppConfigProvider instances.
protected  void populateConfigLocaters()
          Populates configLocaters Set with "built-in" set of IJSFAppConfigLocater implementations.
 void removeFacesConfigChangeAdapter(FacesConfigType facesConfig)
          Removes this instance's FacesConfigChangeAdapter instance from the passed application configuration model's adapters collection.
 java.lang.Object removeFacesConfigChangeListener(java.lang.Class emfClass)
          Removes an instance of IFacesConfigChangeListener.
 boolean removeJSFAppConfigProvidersChangeListener(IJSFAppConfigProvidersChangeListener listener)
          Removes an instance of IJSFAppConfigProvidersChangeListener.
 void resourceChanged(org.eclipse.core.resources.IResourceChangeEvent event)
           
protected  void setAsSessionProperty()
          Sets this JSFAppConfigManager instance as a session property of its IProject instance.
protected  void startConfigLocaters()
          Instructs set of IJSFAppConfigLocater instances to start locating JSF application configuration resources.
protected  void stopConfigLocaters()
          Instructs set of IJSFAppConfigLocater instances to stop locating JSF application configuration resources.
protected  void unsetAsSessionProperty()
          Unsets this JSFAppConfigManager instance as a session property of its IProject instance.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_SESSIONPROPERTY

public static final org.eclipse.core.runtime.QualifiedName KEY_SESSIONPROPERTY
Key that is used for the IProject instance's session property that holds a JSFAppConfigManager instance.


project

protected org.eclipse.core.resources.IProject project
IProject instance to which this JSFAppConfigManager instance is keyed.


configLocaters

protected java.util.List configLocaters
Collection of IJSFAppConfigLocater instances.


configProvidersChangeListeners

protected java.util.List configProvidersChangeListeners
Collection of IJSFAppConfigProvidersChangeListener instances.


facesConfigChangeListeners

protected java.util.Map facesConfigChangeListeners
Map of application configuration model EMF classes to IFacesConfigChangeListener instances.


facesConfigChangeAdapter

protected org.eclipse.jst.jsf.core.internal.provisional.jsfappconfig.JSFAppConfigManager.FacesConfigChangeAdapter facesConfigChangeAdapter
Single FacesConfigChangeAdapter instance.

Method Detail

getInstance

public static JSFAppConfigManager getInstance(org.eclipse.core.resources.IProject project)
Gets a JSFAppConfigManager instance that is keyed to the passed IProject parameter. May return null if the project is not valid or if a CoreException is thrown while attempting to get or set the instance as a session property.

Parameters:
project - IProject instance to which the returned JSFAppConfigManager instance is keyed.
Returns:
JSFAppConfigManager instance, or null.

getFromSessionProperty

protected static JSFAppConfigManager getFromSessionProperty(org.eclipse.core.resources.IProject project)
Attempts to get a JSFAppConfigManager instance from a session property of the passed IProject instance. Will return null if the session property has not yet been set.

Parameters:
project - IProject instance from which to retrieve the JSFAppConfigManager instance.
Returns:
JSFAppConfigManager instance, or null.

setAsSessionProperty

protected void setAsSessionProperty()
Sets this JSFAppConfigManager instance as a session property of its IProject instance.


unsetAsSessionProperty

protected void unsetAsSessionProperty()
Unsets this JSFAppConfigManager instance as a session property of its IProject instance.


getProject

public org.eclipse.core.resources.IProject getProject()
Gets this instance's IProject instance.

Returns:
This instance's IProject instance.

initialize

protected void initialize()
Initializes instance by:


populateConfigLocaters

protected void populateConfigLocaters()
Populates configLocaters Set with "built-in" set of IJSFAppConfigLocater implementations.


startConfigLocaters

protected void startConfigLocaters()
Instructs set of IJSFAppConfigLocater instances to start locating JSF application configuration resources.


stopConfigLocaters

protected void stopConfigLocaters()
Instructs set of IJSFAppConfigLocater instances to stop locating JSF application configuration resources.


resourceChanged

public void resourceChanged(org.eclipse.core.resources.IResourceChangeEvent event)
Specified by:
resourceChanged in interface org.eclipse.core.resources.IResourceChangeListener

changeProject

protected void changeProject(org.eclipse.core.resources.IProject newProject)
Called to respond to a change in the IProject instance to which this instance belongs. Changes the cached IProject instance, stops all config locaters, starts all config locaters.

Parameters:
newProject - New IProject instance to which this manager belongs.

addJSFAppConfigProvidersChangeListener

public boolean addJSFAppConfigProvidersChangeListener(IJSFAppConfigProvidersChangeListener listener)
Adds an instance of IJSFAppConfigProvidersChangeListener.

Parameters:
listener - An instance of IJSFAppConfigProvidersChangeListener.
Returns:
true if added, else false.

removeJSFAppConfigProvidersChangeListener

public boolean removeJSFAppConfigProvidersChangeListener(IJSFAppConfigProvidersChangeListener listener)
Removes an instance of IJSFAppConfigProvidersChangeListener.

Parameters:
listener - an instance of IJSFAppConfigProvidersChangeListener.
Returns:
true if removed, else false.

notifyJSFAppConfigProvidersChangeListeners

public void notifyJSFAppConfigProvidersChangeListeners(IJSFAppConfigProvider configProvider,
                                                       int eventType)
Notifies all IJSFAppConfigProvidersChangeListener instances of a change in the Set of IJSFAppConfigProvider instances.

Parameters:
configProvider - IJSFAppConfigProvider instance that has changed.
eventType - Event type.

addFacesConfigChangeListener

public java.lang.Object addFacesConfigChangeListener(java.lang.Class emfClass,
                                                     IFacesConfigChangeListener listener)
Adds an instance of IFacesConfigChangeListener.

NOTE: Calling this method will cause all application configuration models to be loaded, to ensure that a FacesConfigChangeAdapter has been added to each model.

Parameters:
emfClass - EMF class in which the listener is interested.
listener - IFacesConfigChangeListener instance.
Returns:
Previous IFacesConfigChangeListener, or null.

removeFacesConfigChangeListener

public java.lang.Object removeFacesConfigChangeListener(java.lang.Class emfClass)
Removes an instance of IFacesConfigChangeListener.

Parameters:
emfClass - EMF class in which the listener was interested.
Returns:
Removed IFacesConfigChangeListener, or null.

notifyFacesConfigChangeListeners

public void notifyFacesConfigChangeListeners(org.eclipse.emf.common.notify.Notification notification)
Notifies IFacesConfigChangeListener instances of model changes in which they registered interest.

Parameters:
notification - EMF Notification instance that describes the model change.

getJSFAppConfigProviders

public java.util.Set getJSFAppConfigProviders()
Gets all IJSFAppConfigProvider instances from all IJSFAppConfigLocater instances.

Returns:
Set of all IJSFAppConfigProvider instances.

getFacesConfigModels

public java.util.List getFacesConfigModels()
Gets all FacesConfigType instances from all IJSFAppConfigProvider instances.

Returns:
List of all FacesConfigType instances.

finalize

protected void finalize()

getManagedBeans

public java.util.List getManagedBeans()
Gets list of all ManagedBeanType instances from all known faces-config models; list may be empty.

Returns:
List of all ManagedBeanType instances from all known faces-config models (list may be empty).

getValidators

public java.util.List getValidators()
Gets list of all ValidatorType instances from all known faces-config models; list may be empty.

Returns:
List of all ValidatorType instances from all known faces-config models (list may be empty).

getConverters

public java.util.List getConverters()
Gets list of all ConverterType instances from all known faces-config models; list may be empty.

Returns:
List of all ConverterType instances from all known faces-config models (list may be empty).

getNavigationRules

public java.util.List getNavigationRules()
Gets list of all NavigationRuleType instances from all known faces-config models; list may be empty.

Returns:
List of all NavigationRuleType instances from all known faces-config models (list may be empty).

getNavigationRulesForPage

public java.util.List getNavigationRulesForPage(org.eclipse.core.resources.IFile pageFile)
Gets list of all NavigationRuleType instances from all known faces-config models where the navigation-rule's from-view-id value matches the web content folder-relative value of the passed IFile instance; list may be empty. Matching is performed in the same manner as for a JSF implementation's default NavigationHandler.

Parameters:
pageFile - IFile instance to match against the from-view-id value of all NavigationRuleType instances. File is assumed to be relative to the web content folder, but may be expressed in a more complete form; its path will be calculated relative to the web content folder.
Returns:
List of all NavigationRuleType instances from all known faces-config models where the navigation-rule's from-view-id value matches the web content folder-relative value of the passed IFile instance (list may be empty).

getApplications

public java.util.List getApplications()
Gets list of all ApplicationType instances from all known faces-config models; list may be empty.

Returns:
List of all ApplicationType instances from all known faces-config models (list may be empty).

getFactories

public java.util.List getFactories()
Gets list of all FactoryType instances from all known faces-config models; list may be empty.

Returns:
List of all FactoryType instances from all known faces-config models (list may be empty).

getComponents

public java.util.List getComponents()
Gets list of all ComponentType instances from all known faces-config models; list may be empty.

Returns:
List of all ComponentType instances from all known faces-config models (list may be empty).

getReferencedBeans

public java.util.List getReferencedBeans()
Gets list of all ReferencedBeanType instances from all known faces-config models; list may be empty.

Returns:
List of all ReferencedBeanType instances from all known faces-config models (list may be empty).

getRenderKits

public java.util.List getRenderKits()
Gets list of all RenderKitType instances from all known faces-config models; list may be empty.

Returns:
List of all RenderKitType instances from all known faces-config models (list may be empty).

getLifecycles

public java.util.List getLifecycles()
Gets list of all LifecycleType instances from all known faces-config models; list may be empty.

Returns:
List of all LifecycleType instances from all known faces-config models (list may be empty).

addFacesConfigChangeAdapter

public void addFacesConfigChangeAdapter(FacesConfigType facesConfig)
Adds this instance's FacesConfigChangeAdapter instance to the passed application configuration model's adapters collection.

Parameters:
facesConfig - Application configuration model's root object.

removeFacesConfigChangeAdapter

public void removeFacesConfigChangeAdapter(FacesConfigType facesConfig)
Removes this instance's FacesConfigChangeAdapter instance from the passed application configuration model's adapters collection.

Parameters:
facesConfig - Application configuration model's root object.