org.eclipse.jst.jsf.core.jsfappconfig
Class JSFAppConfigUtils

java.lang.Object
  extended by org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigUtils

public class JSFAppConfigUtils
extends java.lang.Object

JSFAppConfigUtils provides utility methods useful in processing of a JSF application configuration.

Provisional API - subject to change


Field Summary
static java.lang.String CONFIG_FILES_CONTEXT_PARAM_NAME
          Name of JSF CONFIG_FILES context parameter ("javax.faces.CONFIG_FILES").
static java.lang.String FACES_CONFIG_IN_JAR_PATH
          Location in JAR file of application configuration resource file ("META-INF/faces-config.xml").
 
Constructor Summary
JSFAppConfigUtils()
           
 
Method Summary
static java.util.List getConfigFileJARsFromClasspath(org.eclipse.core.resources.IProject project)
          Gets list of JAR file names, where each file name represents a JAR on the classpath that contains a /META-INF/faces-config.xml entry.
static java.util.List getConfigFilesFromContextParam(org.eclipse.core.resources.IProject project)
          Gets list of application configuration file names as listed in the JSF CONFIG_FILES context parameter ("javax.faces.CONFIG_FILES").
static org.eclipse.wst.common.project.facet.core.IProjectFacetVersion getProjectFacet(org.eclipse.core.resources.IProject project)
          Get the facet version for the project
static org.eclipse.wst.common.componentcore.resources.IVirtualFolder getWebContentFolder(org.eclipse.core.resources.IProject project)
          Gets an IVirtualFolder instance which represents the root context's web content folder.
static org.eclipse.core.runtime.IPath getWebContentFolderRelativePath(org.eclipse.core.resources.IFile file)
          Gets an IPath instance representing the path of the passed IFile instance relative to the web content folder.
static boolean isValidJSFProject(org.eclipse.core.resources.IProject project)
          Tests if the passed IProject instance is a valid JSF project in the following ways: project is not null and is accessible, project has the JSF facet set on it.
static boolean isValidJSFProject(org.eclipse.core.resources.IProject project, java.lang.String minVersion)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIG_FILES_CONTEXT_PARAM_NAME

public static final java.lang.String CONFIG_FILES_CONTEXT_PARAM_NAME
Name of JSF CONFIG_FILES context parameter ("javax.faces.CONFIG_FILES").

See Also:
Constant Field Values

FACES_CONFIG_IN_JAR_PATH

public static final java.lang.String FACES_CONFIG_IN_JAR_PATH
Location in JAR file of application configuration resource file ("META-INF/faces-config.xml").

See Also:
Constant Field Values
Constructor Detail

JSFAppConfigUtils

public JSFAppConfigUtils()
Method Detail

isValidJSFProject

public static boolean isValidJSFProject(org.eclipse.core.resources.IProject project,
                                        java.lang.String minVersion)
Parameters:
project -
minVersion -
Returns:
true if project is a JSF facet project and the version of the project is at least minVersion.

isValidJSFProject

public static boolean isValidJSFProject(org.eclipse.core.resources.IProject project)
Tests if the passed IProject instance is a valid JSF project in the following ways:

Parameters:
project - IProject instance to be tested.
Returns:
true if the IProject instance is a valid JSF project, else false.

getProjectFacet

public static org.eclipse.wst.common.project.facet.core.IProjectFacetVersion getProjectFacet(org.eclipse.core.resources.IProject project)
Get the facet version for the project

Parameters:
project -
Returns:
the project facet version or null if could not be found or if project is not accessible

getWebContentFolder

public static org.eclipse.wst.common.componentcore.resources.IVirtualFolder getWebContentFolder(org.eclipse.core.resources.IProject project)
Gets an IVirtualFolder instance which represents the root context's web content folder.

Parameters:
project - IProject instance for which to get the folder.
Returns:
IVirtualFolder instance which represents the root context's web content folder.

getWebContentFolderRelativePath

public static org.eclipse.core.runtime.IPath getWebContentFolderRelativePath(org.eclipse.core.resources.IFile file)
Gets an IPath instance representing the path of the passed IFile instance relative to the web content folder.

Parameters:
file - IFile instance for which a path is required.
Returns:
IPath instance representing the path relative to the web content folder.

getConfigFilesFromContextParam

public static java.util.List getConfigFilesFromContextParam(org.eclipse.core.resources.IProject project)
Gets list of application configuration file names as listed in the JSF CONFIG_FILES context parameter ("javax.faces.CONFIG_FILES"). Will return an empty list if WebArtifactEdit is null, if WebApp is null, if context parameter does not exist, or if trimmed context parameter's value is an empty String.

Parameters:
project - IProject instance for which to get the context parameter's value.
Returns:
List of application configuration file names as listed in the JSF CONFIG_FILES context parameter ("javax.faces.CONFIG_FILES"); list may be empty.

getConfigFileJARsFromClasspath

public static java.util.List getConfigFileJARsFromClasspath(org.eclipse.core.resources.IProject project)
                                                     throws org.eclipse.core.runtime.CoreException,
                                                            java.io.IOException
Gets list of JAR file names, where each file name represents a JAR on the classpath that contains a /META-INF/faces-config.xml entry. Will return an empty list if no such JAR files are located.

Parameters:
project - IProject instance for which to scan the classpath.
Returns:
List of JAR file names, where each file name represents a JAR on the classpath that contains a ...META-INF/faces-config.xml entry; list may be empty.
Throws:
org.eclipse.core.runtime.CoreException - Thrown when underlying calls into JavaCore fail.
java.io.IOException - Thrown when attempt to open JAR to determine if it contains a /META-INF/faces-config.xml entry fails.