cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r648758 - /cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapServlet.java
Date Wed, 16 Apr 2008 17:22:48 GMT
Author: reinhard
Date: Wed Apr 16 10:22:29 2008
New Revision: 648758

URL: http://svn.apache.org/viewvc?rev=648758&view=rev
Log:
lazy initialization for the Corona sitemap servlet

Modified:
    cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapServlet.java

Modified: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapServlet.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapServlet.java?rev=648758&r1=648757&r2=648758&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapServlet.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapServlet.java
Wed Apr 16 10:22:29 2008
@@ -49,17 +49,27 @@
 
     private BeanFactory beanFactory;
     private Sitemap sitemap;
+    private boolean initialized;
+
+    private ServletConfig servletConfig;
 
     @Override
     public void init(ServletConfig servletConfig) throws ServletException {
-        super.init(servletConfig);
+        this.servletConfig = servletConfig;
+        super.init(this.servletConfig);
+    }
 
-        try {
-            SitemapBuilder sitemapBuilder = (SitemapBuilder) this.beanFactory.getBean(SitemapBuilder.class.getName());
-            URL url = servletConfig.getServletContext().getResource("/sitemap.xmap");
-            this.sitemap = sitemapBuilder.build(url);
-        } catch (Exception e) {
-            throw new ServletException(e);
+    private void lazyInitialize(ServletConfig servletConfig) throws ServletException {
+        if (!this.initialized) {
+            try {
+                SitemapBuilder sitemapBuilder = (SitemapBuilder) this.beanFactory.getBean(SitemapBuilder.class
+                        .getName());
+                URL url = servletConfig.getServletContext().getResource("/sitemap.xmap");
+                this.sitemap = sitemapBuilder.build(url);
+            } catch (Exception e) {
+                throw new ServletException(e);
+            }
+            this.initialized = true;
         }
     }
 
@@ -80,6 +90,7 @@
 
     @Override
     protected void service(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
+        this.lazyInitialize(servletConfig);
         try {
             SitemapDelegator.setSitemapServlet(this);
 



Mime
View raw message