Skip to content

Commit

Permalink
Added Faces#isSystemTest() and Faces#isProduction()
Browse files Browse the repository at this point in the history
  • Loading branch information
BalusC committed Dec 20, 2016
1 parent 89971c0 commit c267b1c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
26 changes: 26 additions & 0 deletions src/main/java/org/omnifaces/util/Faces.java
Expand Up @@ -318,6 +318,32 @@ public static boolean isDevelopment() {
return FacesLocal.isDevelopment(getContext()); return FacesLocal.isDevelopment(getContext());
} }


/**
* Returns whether we're in system test stage. This will be the case when the <code>javax.faces.PROJECT_STAGE</code>
* context parameter in <code>web.xml</code> is set to <code>SystemTest</code>.
* <p>
* This is also available in EL as <code>#{faces.systemTest}</code>.
* @return <code>true</code> if we're in system test stage, otherwise <code>false</code>.
* @see Application#getProjectStage()
* @since 2.6
*/
public static boolean isSystemTest() {
return FacesLocal.isSystemTest(getContext());
}

/**
* Returns whether we're in production stage. This will be the case when the <code>javax.faces.PROJECT_STAGE</code>
* context parameter in <code>web.xml</code> is set to <code>Production</code>.
* <p>
* This is also available in EL as <code>#{faces.production}</code>.
* @return <code>true</code> if we're in production stage, otherwise <code>false</code>.
* @see Application#getProjectStage()
* @since 2.6
*/
public static boolean isProduction() {
return FacesLocal.isProduction(getContext());
}

/** /**
* Determines and returns the faces servlet mapping used in the current request. If JSF is prefix mapped (e.g. * Determines and returns the faces servlet mapping used in the current request. If JSF is prefix mapped (e.g.
* <code>/faces/*</code>), then this returns the whole path, with a leading slash (e.g. <code>/faces</code>). If JSF * <code>/faces/*</code>), then this returns the whole path, with a leading slash (e.g. <code>/faces</code>). If JSF
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/org/omnifaces/util/FacesLocal.java
Expand Up @@ -166,7 +166,23 @@ public static ProjectStage getProjectStage(FacesContext context) {
* @see Faces#isDevelopment() * @see Faces#isDevelopment()
*/ */
public static boolean isDevelopment(FacesContext context) { public static boolean isDevelopment(FacesContext context) {
return context.getApplication().getProjectStage() == ProjectStage.Development; return getProjectStage(context) == ProjectStage.Development;
}

/**
* {@inheritDoc}
* @see Faces#isSystemTest()
*/
public static boolean isSystemTest(FacesContext context) {
return getProjectStage(context) == ProjectStage.SystemTest;
}

/**
* {@inheritDoc}
* @see Faces#isProduction()
*/
public static boolean isProduction(FacesContext context) {
return getProjectStage(context) == ProjectStage.Production;
} }


/** /**
Expand Down

0 comments on commit c267b1c

Please sign in to comment.