commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/define BeanTag.java
Date Mon, 15 Jul 2002 21:31:35 GMT
jvanzyl     2002/07/15 14:31:35

  Modified:    jelly/src/java/org/apache/commons/jelly/tags/define
                        BeanTag.java
  Log:
  o Adding some information to the log when the method invocation fails and
    additionally grab the properties of the bean and spit them out so we
    can see what's set and what's not set. This let me figure out what was
    wrong with a bunch of dynamic maven jelly beans. Shouldn't cost anything
    as it only occurs when the invocation fails.
  
  Revision  Changes    Path
  1.2       +37 -2     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/define/BeanTag.java
  
  Index: BeanTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/define/BeanTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BeanTag.java	25 Jun 2002 19:12:28 -0000	1.1
  +++ BeanTag.java	15 Jul 2002 21:31:34 -0000	1.2
  @@ -62,11 +62,15 @@
   package org.apache.commons.jelly.tags.define;
   
   import java.lang.reflect.Method;
  +import java.lang.reflect.InvocationTargetException;
  +import java.util.HashMap;
  +import java.util.Iterator;
   import java.util.HashMap;
  -import java.util.Map;
   
   import org.apache.commons.beanutils.ConvertingWrapDynaBean;
   
  +import org.apache.commons.collections.BeanMap;
  +
   import org.apache.commons.jelly.DynaBeanTagSupport;
   import org.apache.commons.jelly.JellyContext;
   import org.apache.commons.jelly.Script;
  @@ -121,8 +125,39 @@
           
           // now, I may invoke the 'execute' method if I have one
           if ( method != null ) {
  -            method.invoke( bean, emptyArgs );
  +            try
  +            {
  +                method.invoke( bean, emptyArgs );
  +            }
  +            catch (IllegalAccessException e)
  +            {
  +                methodInvocationError(bean, method, e);
  +            }
  +            catch (IllegalArgumentException e)
  +            {
  +                methodInvocationError(bean, method, e);
  +            }
  +            catch (InvocationTargetException e)
  +            {
  +                methodInvocationError(bean, method, e);
  +            }
           }
  +    }
  +    
  +    private void methodInvocationError(Object bean, Method method, Exception e) throws
Exception {
  +        log.error("Could not invoke " + method, e);
  +        BeanMap beanMap = new BeanMap(bean);
  +        
  +        log.error("Bean properties:");
  +        for (Iterator i = beanMap.keySet().iterator(); i.hasNext();)
  +        {
  +            String property = (String) i.next();
  +            Object value = beanMap.get(property);
  +            log.error(property + " -> " + value);
  +        }
  +        
  +        log.error(beanMap);
  +        throw e;
       }
       
       // Properties
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message