You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by re...@apache.org on 2008/04/15 09:40:23 UTC
svn commit: r648145 -
/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java
Author: reinhard
Date: Tue Apr 15 00:40:21 2008
New Revision: 648145
URL: http://svn.apache.org/viewvc?rev=648145&view=rev
Log:
lazy initialization
(... have to figure out why an advice around the init() method on servlets doesn't work as expected)
Modified:
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java
Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java?rev=648145&r1=648144&r2=648145&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java Tue Apr 15 00:40:21 2008
@@ -63,6 +63,8 @@
*/
private static final String PARAM_PASS_THROUGH = "pass-through";
+ private boolean initialized;
+
protected RequestProcessor processor;
@@ -72,7 +74,6 @@
*/
public void init() throws ServletException {
super.init();
- this.processor = new RequestProcessor(getServletContext());
}
/**
@@ -80,6 +81,10 @@
*/
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
+ if (!initialized) {
+ this.processor = new RequestProcessor(getServletContext());
+ initialized = true;
+ }
this.processor.service(request, response);
}
Re: svn commit: r648145 - /cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java
Posted by Joerg Heinicke <jo...@gmx.de>.
On 15.04.2008 03:40, reinhard@apache.org wrote:
> Author: reinhard
> Date: Tue Apr 15 00:40:21 2008
> New Revision: 648145
>
> URL: http://svn.apache.org/viewvc?rev=648145&view=rev
> Log:
> lazy initialization
> (... have to figure out why an advice around the init() method on servlets doesn't work as expected)
I don't know exactly how it is set up, but I guess init() is configured
as a init-method as in Initialization callbacks [1]. This would explain
why there is no advice: First the object is instantiated, then
initialized and afterwards wrapped by whatever. See Juergen's
explanation [2]. With AspectJ the behavior might be different because
there is no longer a target object and a proxy.
Joerg
[1]
http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans-factory-lifecycle-initializingbean
[2] http://jira.springframework.org/browse/SPR-2740