rleland 2004/04/23 23:37:00 Modified: src/examples/org/apache/struts/webapp/exercise HtmlSettersAction.java src/share/org/apache/struts/action ActionForm.java DynaActionForm.java src/share/org/apache/struts/config FormPropertyConfig.java src/share/org/apache/struts/taglib TagUtils.java src/share/org/apache/struts/taglib/bean DefineTag.java src/share/org/apache/struts/taglib/tiles DefinitionTagSupport.java Log: Add logging to a few places where exceptions are thrown. Format one file Revision Changes Path 1.5 +5 -5 jakarta-struts/src/examples/org/apache/struts/webapp/exercise/HtmlSettersAction.java Index: HtmlSettersAction.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/examples/org/apache/struts/webapp/exercise/HtmlSettersAction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- HtmlSettersAction.java 14 Mar 2004 06:23:52 -0000 1.4 +++ HtmlSettersAction.java 24 Apr 2004 06:36:59 -0000 1.5 @@ -59,7 +59,7 @@ throws Exception { if (isCancelled(request)) - return (mapping.findForward("index")); + return (mapping.findForward("redirect-default")); else return (mapping.findForward("input")); 1.21 +5 -5 jakarta-struts/src/share/org/apache/struts/action/ActionForm.java Index: ActionForm.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionForm.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- ActionForm.java 14 Mar 2004 06:23:42 -0000 1.20 +++ ActionForm.java 24 Apr 2004 06:36:59 -0000 1.21 @@ -166,7 +166,7 @@ try { reset(mapping, (HttpServletRequest) request); } catch (ClassCastException e) { - ; + ;//FFIXME: Why would this every happen except a null } } 1.15 +6 -14 jakarta-struts/src/share/org/apache/struts/action/DynaActionForm.java Index: DynaActionForm.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/DynaActionForm.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- DynaActionForm.java 14 Mar 2004 06:23:42 -0000 1.14 +++ DynaActionForm.java 24 Apr 2004 06:37:00 -0000 1.15 @@ -122,13 +122,7 @@ * @param request The servlet request we are processing */ public void reset(ActionMapping mapping, ServletRequest request) { - - try { - reset(mapping, (HttpServletRequest) request); - } catch (ClassCastException e) { - ; - } - + super.reset(mapping,request); } @@ -147,9 +141,7 @@ * @param request The servlet request we are processing */ public void reset(ActionMapping mapping, HttpServletRequest request) { - - ; // Default implementation does nothing - + super.reset(mapping,request); } 1.15 +14 -5 jakarta-struts/src/share/org/apache/struts/config/FormPropertyConfig.java Index: FormPropertyConfig.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/FormPropertyConfig.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- FormPropertyConfig.java 14 Mar 2004 06:23:47 -0000 1.14 +++ FormPropertyConfig.java 24 Apr 2004 06:37:00 -0000 1.15 @@ -25,6 +25,8 @@ import java.io.Serializable; import java.lang.reflect.Array; import org.apache.commons.beanutils.ConvertUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** @@ -38,6 +40,12 @@ public class FormPropertyConfig implements Serializable { + /** + * The logging instance + */ + private static final Log log = + LogFactory.getLog(FormPropertyConfig.class); + // ----------------------------------------------------------- Constructors @@ -285,7 +293,8 @@ Array.set(initialValue, i, clazz.getComponentType().newInstance()); } catch (Throwable t) { - ; // Probably does not have a zero-args constructor + log.error("Unable to create instance of "+clazz.getName()+" there is probably no zero-arg constructor"); + //FIXME: Should we just dump the entire application/module ? } } } 1.34 +57 -62 jakarta-struts/src/share/org/apache/struts/taglib/TagUtils.java Index: TagUtils.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/TagUtils.java,v retrieving revision 1.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- TagUtils.java 14 Mar 2004 06:23:53 -0000 1.33 +++ TagUtils.java 24 Apr 2004 06:37:00 -0000 1.34 @@ -673,41 +673,38 @@ ActionErrors errors = new ActionErrors(); Object value = pageContext.findAttribute(paramName); - - try { - if (value == null) { - ; - - } else if (value instanceof String) { - errors.add( - ActionMessages.GLOBAL_MESSAGE, - new ActionMessage((String) value)); - - } else if (value instanceof String[]) { - String keys[] = (String[]) value; - for (int i = 0; i < keys.length; i++) { + if (value != null) { + try { + if (value instanceof String) { errors.add( ActionMessages.GLOBAL_MESSAGE, - new ActionMessage(keys[i])); + new ActionMessage((String) value)); + + } else if (value instanceof String[]) { + String keys[] = (String[]) value; + for (int i = 0; i < keys.length; i++) { + errors.add( + ActionMessages.GLOBAL_MESSAGE, + new ActionMessage(keys[i])); + } + + } else if (value instanceof ActionErrors) { + errors = (ActionErrors) value; + + } else { + throw new JspException( + messages.getMessage( + "actionErrors.errors", + value.getClass().getName())); } - } else if (value instanceof ActionErrors) { - errors = (ActionErrors) value; + } catch (JspException e) { + throw e; - } else { - throw new JspException( - messages.getMessage( - "actionErrors.errors", - value.getClass().getName())); + } catch (Exception e) { + log.debug(e, e); } - - } catch (JspException e) { - throw e; - - } catch (Exception e) { - log.debug(e, e); } - return errors; } @@ -822,44 +819,42 @@ ActionMessages am = new ActionMessages(); Object value = pageContext.findAttribute(paramName); - - try { - if (value == null) { - ; - } else if (value instanceof String) { - am.add( - ActionMessages.GLOBAL_MESSAGE, - new ActionMessage((String) value)); - - } else if (value instanceof String[]) { - String keys[] = (String[]) value; - for (int i = 0; i < keys.length; i++) { + if (value != null) { + try { + if (value instanceof String) { am.add( ActionMessages.GLOBAL_MESSAGE, - new ActionMessage(keys[i])); - } + new ActionMessage((String) value)); - } else if (value instanceof ActionErrors) { - ActionMessages m = (ActionMessages) value; - am.add(m); + } else if (value instanceof String[]) { + String keys[] = (String[]) value; + for (int i = 0; i < keys.length; i++) { + am.add( + ActionMessages.GLOBAL_MESSAGE, + new ActionMessage(keys[i])); + } + + } else if (value instanceof ActionErrors) { + ActionMessages m = (ActionMessages) value; + am.add(m); + + } else if (value instanceof ActionMessages) { + am = (ActionMessages) value; + + } else { + throw new JspException( + messages.getMessage( + "actionMessages.errors", + value.getClass().getName())); + } - } else if (value instanceof ActionMessages) { - am = (ActionMessages) value; + } catch (JspException e) { + throw e; - } else { - throw new JspException( - messages.getMessage( - "actionMessages.errors", - value.getClass().getName())); + } catch (Exception e) { + log.warn("Unable to retieve ActionMessage for paramName : "+paramName,e); } - - } catch (JspException e) { - throw e; - - } catch (Exception e) { - ; } - return am; } 1.27 +12 -5 jakarta-struts/src/share/org/apache/struts/taglib/bean/DefineTag.java Index: DefineTag.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/DefineTag.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- DefineTag.java 14 Mar 2004 06:23:45 -0000 1.26 +++ DefineTag.java 24 Apr 2004 06:37:00 -0000 1.27 @@ -28,6 +28,8 @@ import org.apache.struts.taglib.TagUtils; import org.apache.struts.util.MessageResources; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** @@ -39,6 +41,11 @@ public class DefineTag extends BodyTagSupport { + /** + * Commons logging instance. + */ + private static final Log log = LogFactory.getLog(DefineTag.class); + // ---------------------------------------------------- Protected variables /** @@ -241,7 +248,7 @@ inScope = TagUtils.getInstance().getScope(toScope); } } catch (JspException e) { - // toScope was invalid name so we default to PAGE_SCOPE + log.warn("toScope was invalid name so we default to PAGE_SCOPE",e); } pageContext.setAttribute(id, value, inScope); 1.6 +167 -170 jakarta-struts/src/share/org/apache/struts/taglib/tiles/DefinitionTagSupport.java Index: DefinitionTagSupport.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/tiles/DefinitionTagSupport.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- DefinitionTagSupport.java 14 Mar 2004 06:23:49 -0000 1.5 +++ DefinitionTagSupport.java 24 Apr 2004 06:37:00 -0000 1.6 @@ -17,180 +17,177 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.apache.struts.taglib.tiles; import java.io.Serializable; - import javax.servlet.jsp.tagext.TagSupport; - /** - * Common base class for tags dealing with Tiles definitions. - * This class defines properties used in Definition Tags. - * It also extends TagSupport. - */ -public class DefinitionTagSupport extends TagSupport implements Serializable -{ - /** Associated Controller type */ - protected String controllerType; - /** Associated Controller name (classname or url) */ - protected String controllerName; - - /** - * Role associated to definition. - */ - protected String role; - - /** - * Uri of page assoicated to this definition. - */ - protected String page; +/** + * Common base class for tags dealing with Tiles definitions. + * This class defines properties used in Definition Tags. + * It also extends TagSupport. + */ +public class DefinitionTagSupport extends TagSupport implements Serializable { + /** + * Associated Controller type + */ + protected String controllerType; + /** + * Associated Controller name (classname or url) + */ + protected String controllerName; + /** + * Role associated to definition. + */ + protected String role; + /** + * Uri of page assoicated to this definition. + */ + protected String page; /** * Release class properties. */ - public void release() - { - super.release(); - controllerType = null; - controllerName = null; - role = null; - page = null; - } - - /** - * Get controller type. - * Type can be 'classname', 'url'. - * @return Controller type. - */ - public String getControllerType() - { - return controllerType; - } - - /** - * Get controller name. - * Name denotes a fully qualified classname, or an url. - * Exact type can be specified with [EMAIL PROTECTED] #setControllerType}. - * @return Controller name. - */ - public String getControllerName() - { - return controllerName; - } - - /** - * Set associated controller type. - * Type denotes a fully qualified classname. - * @param controllerType Type of associated controller. - */ - public void setControllerType(String controllerType) - { - this.controllerType = controllerType; - } - - /** - * Set associated controller name. - * Name denotes a fully qualified classname, or an url. - * Exact type can be specified with [EMAIL PROTECTED] #setControllerType}. - * @param controller Controller classname or url. - */ - public void setController(String controller) - { - setControllerName(controller); ; - } - - /** - * Set associated controller name. - * Name denote a fully qualified classname, or an url. - * Exact type can be specified with setControllerType. - * @param controller Controller classname or url - */ - public void setControllerName(String controller) - { - this.controllerName = controller; - } - - /** - * Set associated controller name as an url, and controller - * type as "url". - * Name must be an url (not checked). - * Convenience method. - * @param controller Controller url - */ - public void setControllerUrl(String controller) - { - setControllerName( controller); - setControllerType( "url" ); - } - - /** - * Set associated controller name as a classtype and controller - * type as "classname". - * Name denotes a fully qualified classname. - * Convenience method. - * @param controller Controller classname. - */ - public void setControllerClass(String controller) - { - setControllerName( controller); - setControllerType( "classname" ); - } - - /** - * Get associated role. - * @return Associated role. - */ - public String getRole() - { - return role; - } - - /** - * Set associated role. - * @param role Associated role. - */ - public void setRole(String role) - { - this.role = role; - } - - /** - * Set the page. - * @param page Page. - */ - public void setPage(String page) - { - this.page = page; - } - - /** - * Get the page. - * @return Page. - */ - public String getPage() - { - return page; - } - - /** - * Get the template. - * Same as getPage(). - * @return Template. - */ - public String getTemplate() - { - return page; - } - - /** - * Set the template. - * Same as setPage(). - * @param template Template. - */ - public void setTemplate(String template) - { - this.page = template; - } + public void release() { + super.release(); + controllerType = null; + controllerName = null; + role = null; + page = null; + } + + /** + * Get controller type. + * Type can be 'classname', 'url'. + * + * @return Controller type. + */ + public String getControllerType() { + return controllerType; + } + + /** + * Get controller name. + * Name denotes a fully qualified classname, or an url. + * Exact type can be specified with [EMAIL PROTECTED] #setControllerType}. + * + * @return Controller name. + */ + public String getControllerName() { + return controllerName; + } + + /** + * Set associated controller type. + * Type denotes a fully qualified classname. + * + * @param controllerType Type of associated controller. + */ + public void setControllerType(String controllerType) { + this.controllerType = controllerType; + } + + /** + * Set associated controller name. + * Name denotes a fully qualified classname, or an url. + * Exact type can be specified with [EMAIL PROTECTED] #setControllerType}. + * + * @param controller Controller classname or url. + */ + public void setController(String controller) { + setControllerName(controller); + } + + /** + * Set associated controller name. + * Name denote a fully qualified classname, or an url. + * Exact type can be specified with setControllerType. + * + * @param controller Controller classname or url + */ + public void setControllerName(String controller) { + this.controllerName = controller; + } + + /** + * Set associated controller name as an url, and controller + * type as "url". + * Name must be an url (not checked). + * Convenience method. + * + * @param controller Controller url + */ + public void setControllerUrl(String controller) { + setControllerName(controller); + setControllerType("url"); + } + + /** + * Set associated controller name as a classtype and controller + * type as "classname". + * Name denotes a fully qualified classname. + * Convenience method. + * + * @param controller Controller classname. + */ + public void setControllerClass(String controller) { + setControllerName(controller); + setControllerType("classname"); + } + + /** + * Get associated role. + * + * @return Associated role. + */ + public String getRole() { + return role; + } + + /** + * Set associated role. + * + * @param role Associated role. + */ + public void setRole(String role) { + this.role = role; + } + + /** + * Set the page. + * + * @param page Page. + */ + public void setPage(String page) { + this.page = page; + } + + /** + * Get the page. + * + * @return Page. + */ + public String getPage() { + return page; + } + + /** + * Get the template. + * Same as getPage(). + * + * @return Template. + */ + public String getTemplate() { + return page; + } + + /** + * Set the template. + * Same as setPage(). + * + * @param template Template. + */ + public void setTemplate(String template) { + this.page = template; + } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]