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 2007/03/27 15:29:39 UTC

svn commit: r522901 - in /cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main: java/org/apache/cocoon/caching/impl/CacheImpl.java resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml

Author: reinhard
Date: Tue Mar 27 06:29:38 2007
New Revision: 522901

URL: http://svn.apache.org/viewvc?view=rev&rev=522901
Log:
CacheImpl: avalon->spring

Added:
    cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml   (with props)
Modified:
    cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/caching/impl/CacheImpl.java

Modified: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/caching/impl/CacheImpl.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/caching/impl/CacheImpl.java?view=diff&rev=522901&r1=522900&r2=522901
==============================================================================
--- cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/caching/impl/CacheImpl.java (original)
+++ cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/caching/impl/CacheImpl.java Tue Mar 27 06:29:38 2007
@@ -19,18 +19,11 @@
 import java.io.IOException;
 import java.io.Serializable;
 
-import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.parameters.ParameterException;
-import org.apache.avalon.framework.parameters.Parameterizable;
-import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
-import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.caching.Cache;
 import org.apache.cocoon.caching.CachedResponse;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.excalibur.store.Store;
 
 /**
@@ -42,34 +35,13 @@
  * @since 2.1
  * @version $Id$
  */
-public class CacheImpl
-extends AbstractLogEnabled
-implements Cache, ThreadSafe, Serviceable, Disposable, Parameterizable {
+public class CacheImpl implements Cache {
 
+    private Log logger = LogFactory.getLog(getClass());    
+    
     /** The store containing the cached responses */
     protected Store store;
 
-    /** The service manager */
-    protected ServiceManager manager;
-
-    /**
-     * Serviceable Interface
-     */
-    public void service (ServiceManager manager) throws ServiceException {
-        this.manager = manager;
-    }
-
-    /**
-     * Disposable Interface
-     */
-    public void dispose() {
-        if ( this.manager != null ) {
-            this.manager.release(this.store);
-            this.store = null;
-            this.manager = null;
-        }
-    }
-
     /**
      * Store a cached response
      * @param key         the key used by the caching algorithm to identify the
@@ -134,17 +106,16 @@
 	public boolean containsKey(Serializable key) {
 		return this.store.containsKey(key);
 	}
-
-    /* (non-Javadoc)
-     * @see org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
+    
+    /**
+     * Set the Store implementation
      */
-    public void parameterize(Parameters parameters) throws ParameterException {
-        String storeName = parameters.getParameter("store", Store.ROLE);
-        try {
-            this.store = (Store)this.manager.lookup(storeName);
-        } catch (ServiceException e) {
-            throw new ParameterException("Unable to lookup store: " + storeName, e);
-        }
+    public void setStore(Store store) {
+        this.store = store;
     }
+    
+    private Log getLogger() {
+        return this.logger;
+    }    
 
 }

Added: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml?view=auto&rev=522901
==============================================================================
--- cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml (added)
+++ cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml Tue Mar 27 06:29:38 2007
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- SVN $Id$ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
+
+  <!--+
+      | This is the Cocoon cache. This component is responsible for storing
+      | and retrieving cached responses. It can be used to monitor the cache
+      | or the investigate which responses are cached etc.
+      |
+      | The cache uses the store to save its values.
+      +-->
+  <bean name="org.apache.cocoon.caching.Cache" class="org.apache.cocoon.caching.impl.CacheImpl">
+    <property name="store" ref="org.apache.excalibur.store.Store"/>
+  </bean>
+
+</beans>
\ No newline at end of file

Propchange: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Re: svn commit: r522901 - in /cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main: java/org/apache/cocoon/caching/impl/CacheImpl.java resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Carsten Ziegeler wrote:
> Vadim Gritsenko wrote:
>> Last I checked, and since 2.2, it is impossible (or just really hard?) to start 
>> up cocoon without servlet context and related objects, which means it gotta be 
>> deployed and started as part of the webapp. If that is the case, IMHO there is 
>> no good reason to have it as part of the shared classloader.
>>
> Yes, that's true for "the framework Cocoon" - but perhaps not for the
> various parts/components.

Ok, that's good reason.

>>> As most of our components are singletons anyway, there isn't any memory
>>> problem here.
>> There are some generated poolable wrappers, IIRC - those aren't singletons and 
>> do represent good chunk of components (pipelines and all direct sitemap components).
>>
> Yes, sooner or later we hopefully get rid of these, too :)

Until then those wrapper could use static logger (if they need any), for 
efficiency :)

Vadim

Re: svn commit: r522901 - in /cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main: java/org/apache/cocoon/caching/impl/CacheImpl.java resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml

Posted by Carsten Ziegeler <cz...@apache.org>.
Vadim Gritsenko wrote:
> 
> Last I checked, and since 2.2, it is impossible (or just really hard?) to start 
> up cocoon without servlet context and related objects, which means it gotta be 
> deployed and started as part of the webapp. If that is the case, IMHO there is 
> no good reason to have it as part of the shared classloader.
> 
Yes, that's true for "the framework Cocoon" - but perhaps not for the
various parts/components.

>> As most of our components are singletons anyway, there isn't any memory
>> problem here.
> 
> There are some generated poolable wrappers, IIRC - those aren't singletons and 
> do represent good chunk of components (pipelines and all direct sitemap components).
> 
Yes, sooner or later we hopefully get rid of these, too :)

Carsten

-- 
Carsten Ziegeler
http://www.osoco.org/weblogs/rael/

Re: svn commit: r522901 - in /cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main: java/org/apache/cocoon/caching/impl/CacheImpl.java resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Carsten Ziegeler wrote:
> Vadim Gritsenko wrote:
>> Torsten Curdt wrote:
>>> On 28.03.2007, at 20:14, Vadim Gritsenko wrote:
>>>
>>>> reinhard@apache.org wrote:
>>>>> -public class CacheImpl
>>>>> -extends AbstractLogEnabled
>>>>> -implements Cache, ThreadSafe, Serviceable, Disposable, 
>>>>> Parameterizable {
>>>>> +public class CacheImpl implements Cache {
>>>>>  +    private Log logger = LogFactory.getLog(getClass());
>>>> Is there a reason why logger can not be static?
>>> http://wiki.apache.org/jakarta-commons/Logging/StaticLog
>> So since Cocoon is not and should not be deployed in container's shared class 
>> loader, usage of 'static' is preferred.
>>
> Hmm, why do you think "is not and should not"? Why not (I'm talking
> about 2.2+ here)?

Last I checked, and since 2.2, it is impossible (or just really hard?) to start 
up cocoon without servlet context and related objects, which means it gotta be 
deployed and started as part of the webapp. If that is the case, IMHO there is 
no good reason to have it as part of the shared classloader.


> In addition, with 2.2+ we provide separate artifacts for "common"
> components which might be used outside of Cocoon and might then be used
> via a shared class loader. So I think we should not use "static" here.

For reusable components - yes, I agree.


> As most of our components are singletons anyway, there isn't any memory
> problem here.

There are some generated poolable wrappers, IIRC - those aren't singletons and 
do represent good chunk of components (pipelines and all direct sitemap components).

Vadim

Re: svn commit: r522901 - in /cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main: java/org/apache/cocoon/caching/impl/CacheImpl.java resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml

Posted by Carsten Ziegeler <cz...@apache.org>.
Vadim Gritsenko wrote:
> Torsten Curdt wrote:
>> On 28.03.2007, at 20:14, Vadim Gritsenko wrote:
>>
>>> reinhard@apache.org wrote:
>>>> -public class CacheImpl
>>>> -extends AbstractLogEnabled
>>>> -implements Cache, ThreadSafe, Serviceable, Disposable, 
>>>> Parameterizable {
>>>> +public class CacheImpl implements Cache {
>>>>  +    private Log logger = LogFactory.getLog(getClass());
>>> Is there a reason why logger can not be static?
>> http://wiki.apache.org/jakarta-commons/Logging/StaticLog
> 
> So since Cocoon is not and should not be deployed in container's shared class 
> loader, usage of 'static' is preferred.
> 
Hmm, why do you think "is not and should not"? Why not (I'm talking
about 2.2+ here)?
In addition, with 2.2+ we provide separate artifacts for "common"
components which might be used outside of Cocoon and might then be used
via a shared class loader. So I think we should not use "static" here.
As most of our components are singletons anyway, there isn't any memory
problem here.

Carsten


-- 
Carsten Ziegeler
http://www.osoco.org/weblogs/rael/

Re: svn commit: r522901 - in /cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main: java/org/apache/cocoon/caching/impl/CacheImpl.java resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Torsten Curdt wrote:
> 
> On 28.03.2007, at 20:14, Vadim Gritsenko wrote:
> 
>> reinhard@apache.org wrote:
>>> -public class CacheImpl
>>> -extends AbstractLogEnabled
>>> -implements Cache, ThreadSafe, Serviceable, Disposable, 
>>> Parameterizable {
>>> +public class CacheImpl implements Cache {
>>>  +    private Log logger = LogFactory.getLog(getClass());
>>
>> Is there a reason why logger can not be static?
> 
> http://wiki.apache.org/jakarta-commons/Logging/StaticLog

So since Cocoon is not and should not be deployed in container's shared class 
loader, usage of 'static' is preferred.

Vadim

Re: svn commit: r522901 - in /cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main: java/org/apache/cocoon/caching/impl/CacheImpl.java resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml

Posted by Torsten Curdt <tc...@apache.org>.
On 28.03.2007, at 20:14, Vadim Gritsenko wrote:

> reinhard@apache.org wrote:
>> -public class CacheImpl
>> -extends AbstractLogEnabled
>> -implements Cache, ThreadSafe, Serviceable, Disposable,  
>> Parameterizable {
>> +public class CacheImpl implements Cache {
>>  +    private Log logger = LogFactory.getLog(getClass());
>
> Is there a reason why logger can not be static?

http://wiki.apache.org/jakarta-commons/Logging/StaticLog

cheers
--
Torsten



Re: svn commit: r522901 - in /cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main: java/org/apache/cocoon/caching/impl/CacheImpl.java resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml

Posted by Reinhard Poetz <re...@apache.org>.
Vadim Gritsenko wrote:
> reinhard@apache.org wrote:
>> -public class CacheImpl
>> -extends AbstractLogEnabled
>> -implements Cache, ThreadSafe, Serviceable, Disposable, Parameterizable {
>> +public class CacheImpl implements Cache {
>>  
>> +    private Log logger = LogFactory.getLog(getClass());    
> 
> Is there a reason why logger can not be static?

no (actually this line is the work some copy'n'paste action). thanks for 
spotting it.

-- 
Reinhard Pötz           Independent Consultant, Trainer & (IT)-Coach 

{Software Engineering, Open Source, Web Applications, Apache Cocoon}

                                        web(log): http://www.poetz.cc
--------------------------------------------------------------------

Re: svn commit: r522901 - in /cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main: java/org/apache/cocoon/caching/impl/CacheImpl.java resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml

Posted by Vadim Gritsenko <va...@reverycodes.com>.
reinhard@apache.org wrote:
> -public class CacheImpl
> -extends AbstractLogEnabled
> -implements Cache, ThreadSafe, Serviceable, Disposable, Parameterizable {
> +public class CacheImpl implements Cache {
>  
> +    private Log logger = LogFactory.getLog(getClass());    

Is there a reason why logger can not be static?

Vadim