Add Mojarra present checks

For cases where isMyFacesInUse cannot properly detect due to issues in
dependent libraries (e.g. Tomahawk) we also check if Mojarra is
even present to strengthen those checks.

Issue: SWF-1687
This commit is contained in:
Rossen Stoyanchev
2016-06-24 09:42:12 -04:00
parent bcfae26e6f
commit e3f220bbae
4 changed files with 14 additions and 5 deletions

View File

@@ -44,7 +44,7 @@ public class FlowRenderKit extends RenderKitWrapper {
}
private ResponseStateManager initResponseStateManager(ResponseStateManager wrapped) {
if (!JsfRuntimeInformation.isMyFacesInUse()) {
if (JsfRuntimeInformation.isMojarraPresent() && !JsfRuntimeInformation.isMyFacesInUse()) {
return new FlowResponseStateManager(wrapped);
}
Constructor<?> constructor;

View File

@@ -71,6 +71,9 @@ public class JsfRuntimeInformation {
}
private static final boolean mojarraPresent =
ClassUtils.isPresent("com.sun.faces.context.FacesContextImpl", CLASSLOADER);
private static final boolean myFacesPresent =
ClassUtils.isPresent("org.apache.myfaces.webapp.MyFacesServlet", CLASSLOADER);
@@ -109,6 +112,10 @@ public class JsfRuntimeInformation {
}
public static boolean isMojarraPresent() {
return mojarraPresent;
}
public static boolean isMyFacesPresent() {
return myFacesPresent;
}

View File

@@ -40,6 +40,7 @@ import org.springframework.webflow.execution.RequestContext;
import org.springframework.webflow.execution.View;
import org.springframework.webflow.execution.ViewFactory;
import static org.springframework.faces.webflow.JsfRuntimeInformation.isMojarraPresent;
import static org.springframework.faces.webflow.JsfRuntimeInformation.isPortletRequest;
/**
@@ -162,7 +163,7 @@ public class JsfViewFactory implements ViewFactory {
private void processTree(FacesContext context, UIComponent component) {
Object mojarraTreeHandler = null;
if (!JsfRuntimeInformation.isMyFacesInUse()) {
if (isMojarraPresent() && !JsfRuntimeInformation.isMyFacesInUse()) {
mojarraTreeHandler = new MojarraProcessTreeHandler().handleBefore(context, component);
}

View File

@@ -127,11 +127,12 @@ public class PortletExternalContextImpl extends ExternalContext {
}
private Flash createFlash() {
if (JsfRuntimeInformation.isMyFacesInUse()) {
return new MyFacesFlashFactory().newFlash(this);
} else {
if (JsfRuntimeInformation.isMojarraPresent() && !JsfRuntimeInformation.isMyFacesInUse()) {
return new MojarraFlashFactory().newFlash(this);
}
else {
return new MyFacesFlashFactory().newFlash(this);
}
}
public void dispatch(String path) throws IOException {