Improve isMyFacesInUse check
The check now accounts for the possibility of a FacesContextFactory being wrapped. Issue: SWF-1650
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.faces.webflow;
|
||||
|
||||
import javax.faces.FacesWrapper;
|
||||
import javax.faces.FactoryFinder;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
@@ -25,7 +26,8 @@ import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
|
||||
/**
|
||||
* Helper class to provide information about the JSF runtime environment such as JSF version and implementation.
|
||||
* Helper class to provide information about the JSF runtime environment such as
|
||||
* JSF version and implementation.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Phillip Webb
|
||||
@@ -89,7 +91,10 @@ public class JsfRuntimeInformation {
|
||||
try {
|
||||
Class<?> clazz = classLoader.loadClass("org.apache.myfaces.context.FacesContextFactoryImpl");
|
||||
Object factory = FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
|
||||
return clazz.isInstance(factory);
|
||||
while (!clazz.isInstance(factory) && factory instanceof FacesWrapper) {
|
||||
factory = ((FacesWrapper) factory).getWrapped();
|
||||
}
|
||||
return (factory != null && clazz.isInstance(factory));
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
return false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2004-2012 the original author or authors.
|
||||
* Copyright 2004-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,6 +29,7 @@ import org.springframework.faces.webflow.JsfRuntimeInformation;
|
||||
/**
|
||||
* {@link FacesContextFactory} to support portlet environments.
|
||||
* @author Phillip Webb
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class PortletFacesContextFactory extends FacesContextFactory {
|
||||
|
||||
@@ -38,6 +39,12 @@ public class PortletFacesContextFactory extends FacesContextFactory {
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public FacesContextFactory getWrapped() {
|
||||
return this.factory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FacesContext getFacesContext(Object context, Object request, Object response, Lifecycle lifecycle)
|
||||
throws FacesException {
|
||||
|
||||
Reference in New Issue
Block a user