Code cleanup/optimizations
SECTION: Modified Files
----------------------------
M src/com/sun/faces/application/ApplicationImpl.java
- Leverage ReflectionUtils
- leverage vararg definitions
M src/com/sun/faces/application/StateManagerImpl.java
- Leverage ReflectionUtils
M src/com/sun/faces/application/ViewHandlerImpl.java
- Removed duplicate code. Use the methods defined
in Util instead.
M src/com/sun/faces/config/ConfigureListener.java
- Removed System.out.println
- Clear the ReflectionUtil cache for this application
M src/com/sun/faces/util/Util.java
- Leverage ReflectionUtils
A src/com/sun/faces/util/ReflectionUtils.java
- New utility class to cache reflection objects.
When profiling the implementation there were several
spots in the code that used reflection quite a bit
without cacheing the result (ApplicationImpl's newConverter()
method as an example).
- This class will eventually have the same functionality
to follow our usage pattern of commons-beanutils so
that we can remove the compile dependency on that library.
SECTION: Diffs
----------------------------
Index: src/com/sun/faces/application/ApplicationImpl.java
===================================================================
RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/application/ApplicationImpl.java,v
retrieving revision 1.81
diff -u -r1.81 ApplicationImpl.java
--- src/com/sun/faces/application/ApplicationImpl.java 1 Sep 2006 01:22:31 -0000 1.81
+++ src/com/sun/faces/application/ApplicationImpl.java 11 Sep 2006 19:39:00 -0000
@@ -57,8 +57,9 @@
import javax.faces.event.ActionListener;
import javax.faces.validator.Validator;
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -81,9 +82,8 @@
import com.sun.faces.el.VariableResolverChainWrapper;
import com.sun.faces.el.VariableResolverImpl;
import com.sun.faces.util.MessageUtils;
+import com.sun.faces.util.ReflectionUtils;
import com.sun.faces.util.Util;
-import java.beans.PropertyEditor;
-import java.beans.PropertyEditorManager;
/**
@@ -1024,9 +1024,9 @@
try {
result = clazz.newInstance();
} catch (Throwable t) {
- Object[] params = {clazz.getName()};
throw new FacesException((MessageUtils.getExceptionMessageString(
- MessageUtils.CANT_INSTANTIATE_CLASS_ERROR_MESSAGE_ID, params)), t);
+ MessageUtils.CANT_INSTANTIATE_CLASS_ERROR_MESSAGE_ID,
+ clazz.getName())), t);
}
return result;
}
@@ -1076,38 +1076,29 @@
clazz = (Class) value;
}
- Constructor ctor = null;
+ Constructor ctor =
+ ReflectionUtils.lookupConstructor(Util.getCurrentLoader(this),
+ clazz,
+ Class.class);
Throwable cause = null;
- try {
- ctor = clazz.getConstructor(new Class[] { Class.class });
- result = ctor.newInstance(targetClass);
- } catch (SecurityException ex) {
- cause = ex;
- } catch (NoSuchMethodException ex) {
- // Take no action.
- } catch (IllegalArgumentException ex) {
- cause = ex;
- } catch (IllegalAccessException ex) {
- cause = ex;
- } catch (InvocationTargetException ex) {
- cause = ex;
- } catch (InstantiationException ex) {
- cause = ex;
- }
- // If there was no one-argument ctor that takes a Class.
- if (null == ctor) {
+ if (ctor != null) {
+ try {
+ result = ctor.newInstance(targetClass);
+ } catch (Exception e) {
+ cause = e;
+ }
+ } else {
try {
result = clazz.newInstance();
- } catch (Throwable t) {
- cause = t;
+ } catch (Exception e) {
+ cause = e;
}
- }
+ }
- if (null != cause) {
- Object[] params = {clazz.getName()};
+ if (null != cause) {
throw new FacesException((MessageUtils.getExceptionMessageString(
MessageUtils.CANT_INSTANTIATE_CLASS_ERROR_MESSAGE_ID,
- params)), cause);
+ clazz.getName())), cause);
}
return result;
Index: src/com/sun/faces/application/StateManagerImpl.java
===================================================================
RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/application/StateManagerImpl.java,v
retrieving revision 1.56
diff -u -r1.56 StateManagerImpl.java
--- src/com/sun/faces/application/StateManagerImpl.java 6 Sep 2006 20:44:04 -0000 1.56
+++ src/com/sun/faces/application/StateManagerImpl.java 11 Sep 2006 19:39:00 -0000
@@ -40,7 +40,6 @@
import java.io.ObjectOutput;
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -52,23 +51,22 @@
import java.util.logging.Logger;
import com.sun.faces.RIConstants;
-import com.sun.faces.io.FastStringWriter;
import com.sun.faces.config.WebConfiguration;
import com.sun.faces.config.WebConfiguration.WebContextInitParameter;
+import com.sun.faces.io.FastStringWriter;
import com.sun.faces.renderkit.RenderKitUtils;
+import com.sun.faces.util.DebugUtil;
import com.sun.faces.util.LRUMap;
import com.sun.faces.util.MessageUtils;
+import com.sun.faces.util.ReflectionUtils;
import com.sun.faces.util.TypedCollections;
import com.sun.faces.util.Util;
-import com.sun.faces.util.DebugUtil;
public class StateManagerImpl extends StateManager {
private static final Logger LOGGER =
Util.getLogger(Util.FACES_LOGGER + Util.APPLICATION_LOGGER);
- private static final Object[] STATE_PLACEHOLDER = new Object[0];
-
- private HashMap<String, Boolean> responseStateManagerInfo = null;
+ private static final Object[] STATE_PLACEHOLDER = new Object[0];
private char requestIdSerial;
@@ -97,9 +95,7 @@
Object id;
ResponseStateManager rsm =
RenderKitUtils.getResponseStateManager(context, renderKitId);
- if (hasDeclaredMethod(renderKitId,
- rsm,
- "getState")) {
+ if (hasGetStateMethod(rsm)) {
Object[] stateArray = (Object[]) rsm.getState(context, viewId);
id = stateArray[0];
} else {
@@ -293,9 +289,7 @@
String renderKitId = context.getViewRoot().getRenderKitId();
ResponseStateManager rsm =
RenderKitUtils.getResponseStateManager(context, renderKitId);
- if (hasDeclaredMethod(renderKitId,
- rsm,
- "getState")) {
+ if (hasGetStateMethod(rsm)) {
Object[] stateArray = new Object[2];
stateArray[0] = state.getStructure();
stateArray[1] = state.getState();
@@ -492,32 +486,20 @@
* Looks for the presence of a declared method (by name) in the specified
* class and returns a <code>boolean</code> outcome (true, if the method
* exists).
- *
- * @param renderKitId The object that will be used for the lookup. This key
- * will also be stored in the <code>Map</code> with a corresponding
- * <code>Boolean</code> value indicating the result of the search.
+ *
* @param instance The instance of the class that will be used as
- * the search domain.
- * @param methodName The name of the method we are looking for.
+ * the search domain.
*
* @return <code>true</code> if the method exists, otherwise
* <code>false</code>
*/
- private boolean hasDeclaredMethod(String renderKitId,
- ResponseStateManager instance,
- String methodName) {
-
- boolean result;
- if (responseStateManagerInfo == null) {
- responseStateManagerInfo = new HashMap<String, Boolean>();
- }
- Boolean value = responseStateManagerInfo.get(renderKitId);
- if (value != null) {
- return value;
- }
- result = Util.hasDeclaredMethod(instance, methodName);
- responseStateManagerInfo.put(renderKitId, result);
- return result;
+ private boolean hasGetStateMethod(ResponseStateManager instance) {
+
+ return (ReflectionUtils.lookupMethod(Util.getCurrentLoader(this),
+ instance.getClass(),
+ "getState",
+ FacesContext.class,
+ String.class) != null);
}
@@ -557,11 +539,9 @@
ResponseStateManager rsm =
RenderKitUtils.getResponseStateManager(context, renderKitId);
Object[] treeStructure;
- if (hasDeclaredMethod(renderKitId,
- rsm,
- "getState")) {
+ if (hasGetStateMethod(rsm)){
- Object[] stateArray = (Object[]) rsm.getState(context, viewId);
+ Object[] stateArray = (Object[]) rsm.getState(context, viewId);
treeStructure = (Object[]) stateArray[0];
} else {
treeStructure = (Object[]) rsm
Index: src/com/sun/faces/application/ViewHandlerImpl.java
===================================================================
RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/application/ViewHandlerImpl.java,v
retrieving revision 1.82
diff -u -r1.82 ViewHandlerImpl.java
--- src/com/sun/faces/application/ViewHandlerImpl.java 6 Sep 2006 00:04:02 -0000 1.82
+++ src/com/sun/faces/application/ViewHandlerImpl.java 11 Sep 2006 19:39:00 -0000
@@ -46,7 +46,6 @@
import javax.faces.render.ResponseStateManager;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.jstl.core.Config;
@@ -79,15 +78,7 @@
+ Util.APPLICATION_LOGGER);
private static final String AFTER_VIEW_CONTENT = RIConstants.FACES_PREFIX+
- "AFTER_VIEW_CONTENT";
-
- /**
- * <p>The <code>request</code> scoped attribute to store the
- * {_at_link javax.faces.webapp.FacesServlet} path of the original
- * request.</p>
- */
- private static final String INVOCATION_PATH =
- RIConstants.FACES_PREFIX + "INVOCATION_PATH";
+ "AFTER_VIEW_CONTENT";
//
// Relationship Instance Variables
@@ -212,20 +203,11 @@
assert(false);
}
- response.flushBuffer(); // PENDING(edburns): necessary?
+ response.flushBuffer();
// remove the AFTER_VIEW_CONTENT from the view root
extContext.getRequestMap().remove(AFTER_VIEW_CONTENT);
-
- // PENDING (visvan) do we need this any more since we save the tree
- // after encode ??
- /* if (!context.getExternalContext().getRequestMap().containsKey(RIConstants.SAVED_STATE)) {
- // if we didn't serialize the state, or we didn't save it in
- // the client, we need to manually remove the transient
- // children and facets.
- removeTransientChildrenAndFacets(context, viewToRender,
- new HashSet());
- } */
+
}
/**
@@ -279,17 +261,17 @@
ExternalContext extContext = context.getExternalContext();
- String mapping = getFacesMapping(context);
+ String mapping = Util.getFacesMapping(context);
UIViewRoot viewRoot = null;
- if (mapping != null && !isPrefixMapped(mapping)) {
+ if (mapping != null && !Util.isPrefixMapped(mapping)) {
viewId = convertViewId(context, viewId);
}
// maping could be null if a non-faces request triggered
// this response.
if (extContext.getRequestPathInfo() == null && mapping != null &&
- isPrefixMapped(mapping)) {
+ Util.isPrefixMapped(mapping)) {
// this was probably an initial request
// send them off to the root of the web application
try {
@@ -413,7 +395,7 @@
throw new NullPointerException(message);
}
- String mapping = getFacesMapping(context);
+ String mapping = Util.getFacesMapping(context);
String requestURI =
updateRequestURI(viewToExecute.getViewId(), mapping);
@@ -434,7 +416,7 @@
String newViewId = requestURI;
// If we have a valid mapping (meaning we were invoked via the
// FacesServlet) and we're extension mapped, do the replacement.
- if (!isPrefixMapped(mapping)) {
+ if (!Util.isPrefixMapped(mapping)) {
if (logger.isLoggable(Level.FINE)) {
logger.fine( "Found URL pattern mapping to FacesServlet "
+ mapping);
@@ -446,15 +428,13 @@
}
}
-
viewToExecute.setViewId(newViewId);
ExternalContext extContext = context.getExternalContext();
// update the JSTL locale attribute in request scope so that JSTL
// picks up the locale from viewRoot. This attribute must be updated
// before the JSTL setBundle tag is called because that is when the
- // new LocalizationContext object is created based on the locale.
- // PENDING: this only works for servlet based requests
+ // new LocalizationContext object is created based on the locale.
if (extContext.getRequest()
instanceof ServletRequest) {
Config.set((ServletRequest)
@@ -671,7 +651,7 @@
context.getExternalContext().getRequestContextPath();
// Acquire the mapping used to execute this request (if any)
- String mapping = getFacesMapping(context);
+ String mapping = Util.getFacesMapping(context);
// If no mapping can be identified, just return a server-relative path
if (mapping == null) {
@@ -679,7 +659,7 @@
}
// Deal with prefix mapping
- if (isPrefixMapped(mapping)) {
+ if (Util.isPrefixMapped(mapping)) {
if (mapping.equals("/*")) {
return contextPath + viewId;
} else {
@@ -709,125 +689,7 @@
}
}
-
-
- /**
- * <p>Returns the URL pattern of the
- * {_at_link javax.faces.webapp.FacesServlet} that
- * is executing the current request. If there are multiple
- * URL patterns, the value returned by
- * <code>HttpServletRequest.getServletPath()</code> and
- * <code>HttpServletRequest.getPathInfo()</code> is
- * used to determine which mapping to return.</p>
- * If no mapping can be determined, it most likely means
- * that this particular request wasn't dispatched through
- * the {_at_link javax.faces.webapp.FacesServlet}.
- *
- * @param context the {_at_link FacesContext} of the current request
- * @return the URL pattern of the {_at_link javax.faces.webapp.FacesServlet}
- * or <code>null</code> if no mapping can be determined
- * @throws NullPointerException if <code>context</code> is null
- */
- private String getFacesMapping(FacesContext context) {
-
- if (context == null) {
- String message = MessageUtils.getExceptionMessageString
- (MessageUtils.NULL_PARAMETERS_ERROR_MESSAGE_ID, "context");
- throw new NullPointerException(message);
- }
-
- // Check for a previously stored mapping
- ExternalContext extContext = context.getExternalContext();
- String mapping =
- (String) extContext.getRequestMap().get(INVOCATION_PATH);
-
- if (mapping == null) {
-
- Object request = extContext.getRequest();
- String servletPath = null;
- String pathInfo = null;
-
- // first check for javax.servlet.forward.servlet_path
- // and javax.servlet.forward.path_info for non-null
- // values. if either is non-null, use this
- // information to generate determine the mapping.
-
- if (request instanceof HttpServletRequest) {
- servletPath = extContext.getRequestServletPath();
- pathInfo = extContext.getRequestPathInfo();
- }
-
-
- mapping = getMappingForRequest(servletPath, pathInfo);
- if (mapping == null) {
- if (logger.isLoggable(Level.FINE)) {
- logger.log(Level.FINE,
- "jsf.faces_servlet_mapping_cannot_be_determined_error",
- new Object[]{servletPath});
- }
- }
- }
-
- // if the FacesServlet is mapped to /* throw an
- // Exception in order to prevent an endless
- // RequestDispatcher loop
- if ("/*".equals(mapping)) {
- throw new FacesException(MessageUtils.getExceptionMessageString(
- MessageUtils.FACES_SERVLET_MAPPING_INCORRECT_ID));
- }
-
- if (mapping != null) {
- extContext.getRequestMap().put(INVOCATION_PATH, mapping);
- }
- if (logger.isLoggable(Level.FINE)) {
- logger.log(Level.FINE,
- "URL pattern of the FacesServlet executing the current request "
- + mapping);
- }
- return mapping;
- }
-
-
- /**
- * <p>Return the appropriate {_at_link javax.faces.webapp.FacesServlet} mapping
- * based on the servlet path of the current request.</p>
- *
- * @param servletPath the servlet path of the request
- * @param pathInfo the path info of the request
- * @see HttpServletRequest#getServletPath()
- * @return the appropriate mapping based on the current request
- */
- private String getMappingForRequest(String servletPath, String pathInfo) {
-
- if (servletPath == null) {
- return null;
- }
- if (logger.isLoggable(Level.FINE)) {
- logger.log(Level.FINE, "servletPath " + servletPath);
- logger.log(Level.FINE, "pathInfo " + pathInfo);
- }
- // If the path returned by HttpServletRequest.getServletPath()
- // returns a zero-length String, then the FacesServlet has
- // been mapped to '/*'.
- if (servletPath.length() == 0) {
- return "/*";
- }
-
- // presence of path info means we were invoked
- // using a prefix path mapping
- if (pathInfo != null) {
- return servletPath;
- } else if (servletPath.indexOf('.') < 0) {
- // if pathInfo is null and no '.' is present, assume the
- // FacesServlet was invoked using prefix path but without
- // any pathInfo - i.e. GET /contextroot/faces or
- // GET /contextroot/faces/
- return servletPath;
- } else {
- // Servlet invoked using extension mapping
- return servletPath.substring(servletPath.lastIndexOf('.'));
- }
- }
+
/**
* <p>if the specified mapping is a prefix mapping, and the provided
@@ -841,7 +703,7 @@
*/
private String updateRequestURI(String uri, String mapping) {
- if (!isPrefixMapped(mapping)) {
+ if (!Util.isPrefixMapped(mapping)) {
return uri;
} else {
int length = mapping.length() + 1;
@@ -860,19 +722,7 @@
}
return uri;
}
- }
-
-
- /**
- * <p>Returns true if the provided <code>url-mapping</code> is
- * a prefix path mapping (starts with <code>/</code>).</p>
- *
- * @param mapping a <code>url-pattern</code>
- * @return true if the mapping starts with <code>/</code>
- */
- private static boolean isPrefixMapped(String mapping) {
- return (mapping.charAt(0) == '/');
- }
+ }
/**
Index: src/com/sun/faces/config/ConfigureListener.java
===================================================================
RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/config/ConfigureListener.java,v
retrieving revision 1.84
diff -u -r1.84 ConfigureListener.java
--- src/com/sun/faces/config/ConfigureListener.java 30 Aug 2006 17:42:50 -0000 1.84
+++ src/com/sun/faces/config/ConfigureListener.java 11 Sep 2006 19:39:00 -0000
@@ -113,6 +113,7 @@
import com.sun.faces.spi.ManagedBeanFactory;
import com.sun.faces.util.MessageUtils;
import com.sun.faces.util.Util;
+import com.sun.faces.util.ReflectionUtils;
import com.sun.org.apache.commons.digester.Digester;
/**
@@ -270,8 +271,7 @@
return tlsExternalContext.get();
}
- public void contextInitialized(ServletContextEvent sce) {
- long start = System.currentTimeMillis();
+ public void contextInitialized(ServletContextEvent sce) {
ServletContext context = sce.getServletContext();
webConfig = WebConfiguration.getInstance(context);
logOverriddenContextConfigValues();
@@ -472,9 +472,7 @@
associate.setContextName(getServletContextIdentifier(context));
}
- tlsExternalContext.set(null);
- System.out.println("INIT TIME: "
- + (System.currentTimeMillis() - start));
+ tlsExternalContext.set(null);
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.log(Level.INFO,
"jsf.config.listener.version.complete",
@@ -496,6 +494,7 @@
// Release any allocated application resources
FactoryFinder.releaseFactories();
+ ReflectionUtils.clearCache(Util.getCurrentLoader(this));
tlsExternalContext.set(new ServletContextAdapter(context));
ApplicationAssociate
.clearInstance(tlsExternalContext.get());
Index: src/com/sun/faces/util/Util.java
===================================================================
RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/util/Util.java,v
retrieving revision 1.198
diff -u -r1.198 Util.java
--- src/com/sun/faces/util/Util.java 5 Sep 2006 23:00:30 -0000 1.198
+++ src/com/sun/faces/util/Util.java 11 Sep 2006 19:39:00 -0000
@@ -56,7 +56,6 @@
import java.beans.FeatureDescriptor;
import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
@@ -65,9 +64,9 @@
import java.util.Locale;
import java.util.Map;
import java.util.StringTokenizer;
-import java.util.regex.Pattern;
import java.util.logging.Level;
import java.util.logging.Logger;
+import java.util.regex.Pattern;
import com.sun.faces.RIConstants;
import com.sun.faces.renderkit.RenderKitImpl;
@@ -548,35 +547,36 @@
public static Object createInstance(String className,
Class rootType,
Object root) {
- Class clazz = null;
+ Class clazz;
Object returnObject = null;
if (className != null) {
try {
clazz = Util.loadClass(className, returnObject);
- if (clazz != null) {
+ if (clazz != null) {
// Look for an adapter constructor if we've got
// an object to adapt
if ((rootType != null) && (root != null)) {
- try {
- Class[] parameterTypes = new Class[]{rootType};
- Constructor construct =
- clazz.getConstructor(parameterTypes);
- Object[] parameters = new Object[]{root};
- returnObject = construct.newInstance(parameters);
- } catch (NoSuchMethodException nsme) {
- if (LOGGER.isLoggable(Level.FINE)) {
- LOGGER.log(Level.FINE,
- "jsf.util.no.adapter.ctor.available",
- new Object[] {
- clazz.getName(),
- rootType.getName()
- });
- }
- }
+
+ Constructor construct =
+ ReflectionUtils.lookupConstructor(
+ Util.getCurrentLoader(null),
+ clazz,
+ rootType);
+ if (construct != null) {
+ returnObject = construct.newInstance(root);
+ }
}
- if (returnObject == null) {
+ }
+ if (clazz != null && returnObject == null) {
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE,
+ "jsf.util.no.adapter.ctor.available",
+ new Object[]{
+ clazz.getName(),
+ rootType.getName()
+ });
+ }
returnObject = clazz.newInstance();
- }
}
} catch (Exception e) {
if (LOGGER.isLoggable(Level.SEVERE)) {
@@ -714,11 +714,7 @@
}
return expression;
}
-
- //
- // General Methods
- //
-
+
public static void parameterNonNull(Object param) throws FacesException {
if (null == param) {
@@ -915,41 +911,31 @@
* servlet and portlet cases, without introducing a compile-time
* dependency on the portlet api.</p>
*
- */
-
+ */
public static String getContentTypeFromResponse(Object response) {
- String result = null;
- if (null != response) {
- Method method = null;
-
- try {
- method = response.getClass().getMethod("getContentType",
- RIConstants.EMPTY_CLASS_ARGS);
- if (null != method) {
- Object obj = method.invoke(response, RIConstants.EMPTY_METH_ARGS);
- if (null != obj) {
- result = obj.toString();
- }
- }
- }
- catch (NoSuchMethodException nsme) {
- throw new FacesException(nsme);
- }
- catch (IllegalAccessException iae) {
- throw new FacesException(iae);
- }
- catch (IllegalArgumentException iare) {
- throw new FacesException(iare);
- }
- catch (InvocationTargetException ite) {
- throw new FacesException(ite);
- }
- catch (SecurityException e) {
- throw new FacesException(e);
- }
- }
- return result;
- }
+ String result = null;
+ if (null != response) {
+
+ try {
+ Method method = ReflectionUtils.lookupMethod(
+ Util.getCurrentLoader(response),
+ response.getClass(),
+ "getContentType",
+ RIConstants.EMPTY_CLASS_ARGS
+ );
+ if (null != method) {
+ Object obj =
+ method.invoke(response, RIConstants.EMPTY_METH_ARGS);
+ if (null != obj) {
+ result = obj.toString();
+ }
+ }
+ } catch (Exception e) {
+ throw new FacesException(e);
+ }
+ }
+ return result;
+ }
public static boolean prefixViewTraversal(FacesContext context,
UIComponent root,
@@ -986,24 +972,7 @@
fd.setValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME, designTime);
return fd;
}
-
- /** <p>Checks for the existence of a method specified by the "methodName"
- * argument, on the "instance" argument.</p>
- */
- public static boolean hasDeclaredMethod(Object instance, String methodName) {
- boolean result = false;
- // Look for the presence of the method by method name.
- Class c = instance.getClass();
- Method[] methods = c.getDeclaredMethods();
-
- for (int i = 0; i < methods.length; i++) {
- if (methods[i].getName().equals(methodName)) {
- result = true;
- break;
- }
- }
- return result;
- }
+
/**
* <p>A slightly more efficient version of
@@ -1087,6 +1056,14 @@
new Object[]{servletPath});
}
}
+ }
+
+ // if the FacesServlet is mapped to /* throw an
+ // Exception in order to prevent an endless
+ // RequestDispatcher loop
+ if ("/*".equals(mapping)) {
+ throw new FacesException(MessageUtils.getExceptionMessageString(
+ MessageUtils.FACES_SERVLET_MAPPING_INCORRECT_ID));
}
if (mapping != null) {
SECTION: New Files
----------------------------
SEE ATTACHMENTS