From 0191d4ca9e89f1aa57c04dc9010bdd127340dc93 Mon Sep 17 00:00:00 2001 From: remm Date: Fri, 1 Sep 2006 14:17:58 +0000 Subject: [PATCH] - Patch submitted by Bill Burke (who thinks annotations should occur for JSPs) to do JSP annotation processing. git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@439330 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/jasper/servlet/JspServletWrapper.java | 26 ++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/java/org/apache/jasper/servlet/JspServletWrapper.java b/java/org/apache/jasper/servlet/JspServletWrapper.java index 942e8544f..d1f98dd10 100644 --- a/java/org/apache/jasper/servlet/JspServletWrapper.java +++ b/java/org/apache/jasper/servlet/JspServletWrapper.java @@ -37,6 +37,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.jsp.tagext.TagInfo; +import org.apache.AnnotationProcessor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.jasper.JasperException; @@ -146,10 +147,17 @@ public class JspServletWrapper { try { servletClass = ctxt.load(); theServlet = (Servlet) servletClass.newInstance(); - } catch( IllegalAccessException ex1 ) { - throw new JasperException( ex1 ); - } catch( InstantiationException ex ) { - throw new JasperException( ex ); + AnnotationProcessor annotationProcessor = (AnnotationProcessor) config.getServletContext().getAttribute(AnnotationProcessor.class.getName()); + if (annotationProcessor != null) { + annotationProcessor.processAnnotations(theServlet); + annotationProcessor.postConstruct(theServlet); + } + } catch (IllegalAccessException e) { + throw new JasperException(e); + } catch (InstantiationException e) { + throw new JasperException(e); + } catch (Exception e) { + throw new JasperException(e); } theServlet.init(config); @@ -402,6 +410,16 @@ public class JspServletWrapper { public void destroy() { if (theServlet != null) { theServlet.destroy(); + AnnotationProcessor annotationProcessor = (AnnotationProcessor) config.getServletContext().getAttribute(AnnotationProcessor.class.getName()); + if (annotationProcessor != null) { + try { + annotationProcessor.preDestroy(theServlet); + } catch (Exception e) { + // Log any exception, since it can't be passed along + log.error(Localizer.getMessage("jsp.error.file.not.found", + e.getMessage()), e); + } + } } } -- 2.11.0