cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: xml-cocoon2/src/java/org/apache/cocoon/sitemap AbstractSitemap.java
Date Wed, 30 Jan 2002 10:14:48 GMT
cziegeler    02/01/30 02:14:48

  Modified:    src/java/org/apache/cocoon/sitemap AbstractSitemap.java
  Log:
  Applied patch for "Throw actual exception in AbstractSitemap.invokeMethod"
  PR: #6039
  Submitted by: proyal@managingpartners.com (Peter Royal)
  
  Revision  Changes    Path
  1.4       +23 -5     xml-cocoon2/src/java/org/apache/cocoon/sitemap/AbstractSitemap.java
  
  Index: AbstractSitemap.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/sitemap/AbstractSitemap.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractSitemap.java	15 Jan 2002 07:42:02 -0000	1.3
  +++ AbstractSitemap.java	30 Jan 2002 10:14:48 -0000	1.4
  @@ -20,6 +20,7 @@
   import org.apache.avalon.framework.logger.AbstractLoggable;
   import org.apache.avalon.framework.thread.ThreadSafe;
   import org.apache.cocoon.Constants;
  +import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.acting.Action;
   import org.apache.cocoon.components.CocoonComponentManager;
   import org.apache.cocoon.components.classloader.RepositoryClassLoader;
  @@ -37,6 +38,7 @@
   
   import java.io.IOException;
   import java.io.InputStream;
  +import java.lang.reflect.InvocationTargetException;
   import java.net.URL;
   import java.util.ArrayList;
   import java.util.List;
  @@ -47,7 +49,7 @@
    * Base class for generated <code>Sitemap</code> classes
    *
    * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  - * @version CVS $Revision: 1.3 $ $Date: 2002/01/15 07:42:02 $
  + * @version CVS $Revision: 1.4 $ $Date: 2002/01/30 10:14:48 $
    */
   public abstract class AbstractSitemap extends AbstractLoggable implements Sitemap, Disposable,
ThreadSafe {
       private Context context;
  @@ -368,16 +370,32 @@
        *
        * @exception Exception If an error occurs during method invocation
        */
  -    protected boolean invokeMethod(String methodName, Class[] argTypes, Object[] argValues)
throws Exception {
  +    protected boolean invokeMethod(String methodName, Class[] argTypes, Object[] argValues)
  +    throws Exception {
           try {
  -            getLogger().debug("Dynamically invoking " + methodName);
  +            if ( this.getLogger().isDebugEnabled() )
  +                this.getLogger().debug("Dynamically invoking " + methodName);
  +
               java.lang.reflect.Method method = this.getClass().getDeclaredMethod(methodName,
argTypes);
               return ((Boolean)method.invoke(this, argValues)).booleanValue();
           } catch (NoSuchMethodException e) {
               getLogger().error("AbstractSitemap:invokeMethod()", e);
               int prefix = methodName.indexOf("_");
  -            throw new Exception("Sitemap: " + methodName.substring(0, prefix) + " '" +
  -                methodName.substring(prefix + 1) + "' not found");
  +            throw new ProcessingException("Sitemap: " + methodName.substring(0, prefix)
+ " '" +
  +                methodName.substring(prefix + 1) + "' not found", e);
  +        } catch (InvocationTargetException e) {
  +            final Throwable t = e.getTargetException();
  +
  +            if (t == null) {
  +                throw e;
  +            } else if (t instanceof Error) {
  +                throw (Error) t;
  +            } else if (t instanceof Exception) {
  +                throw (Exception) t;
  +            } else {
  +                getLogger().error("Unknown target exception type: " + t.getClass().getName());
  +                throw e;
  +            }
           } catch (Exception e) {
               getLogger().error("AbstractSitemap:invokeMethod()", e);
               throw e;
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message