Date: 2004-08-23T00:39:30 Editor: BertrandDelacretaz <[EMAIL PROTECTED]> Wiki: Cocoon Wiki Page: UsingOJBWithJCS URL: http://wiki.apache.org/cocoon/UsingOJBWithJCS
Updated link to OJB default cache drawbacks Change Log: ------------------------------------------------------------------------------ @@ -8,7 +8,7 @@ == Facts == * Object Cache helps to improve the database performance. * OJB is able to use different Object Cache Implementations. - * The default OJB Object Cache Implementation is fast, but has [http://db.apache.org/ojb/objectcache.html#Shipped%20cache%20implementations some drawbacks]. + * The default OJB Object Cache Implementation is fast, but has [http://db.apache.org/ojb/docu/guides/objectcache.html#ObjectCacheDefaultImpl some drawbacks]. * Since Cocoon 2.1.5 the default cache implementation is based on Apache JCS. * Apache JCS is a distributed caching system for server-side java applications. It is far more powerful. @@ -25,41 +25,41 @@ === Let your servlet breathe calm === My first attempt to setup this configuration failed because of a {{{OutOfMemoryError}}}. The problem showed to be that the servlet does not had enough memory to run. ie: add this lines in {{{catalina.sh}}}: -{{{ -# Set Java Options -JAVA_OPTS='-Xms32m -Xmx128m' -if [ -r "$JAVA_OPTS"/bin/setenv.sh ]; then - . "$JAVA_OPTS"/bin/setenv.sh -fi +{{{ +# Set Java Options +JAVA_OPTS='-Xms32m -Xmx128m' +if [ -r "$JAVA_OPTS"/bin/setenv.sh ]; then + . "$JAVA_OPTS"/bin/setenv.sh +fi }}} === Tell OJB to use JCS === In your {{{OJB.properties}}} file, find the '''Object Cache''' section. Comment the line where is {{{ObjectCacheDefaultImpl}}} and uncomment the line where is {{{ObjectCacheJCSPerClassImpl}}}. ie: -{{{ -#------------------------------------------------------------------- -# Object cache -#------------------------------------------------------------------- -... -#ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCacheDefaultImpl -... -ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCacheJCSPerClassImpl +{{{ +#------------------------------------------------------------------- +# Object cache +#------------------------------------------------------------------- +... +#ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCacheDefaultImpl +... +ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCacheJCSPerClassImpl }}} === Tell Cocoon that OJB will use JCS === Cocoon is shipped with a default JCS configuration. Cocoon allow to define new cache regions for JCS via {{{cocoon.xconf}}}. We need to configure the default region used by the JCS !ObjectCache implementation for OJB. Search <store> and add this parameters: -{{{ -<store logger="core.store"> - <parameter name="maxobjects" value="10000"/> - <parameter name="use-cache-directory" value="true"/> - <parameter name="jcs.region.ojbDefault" value="DC"/> - <parameter name="jcs.region.ojbDefault.cacheattributes" - value="org.apache.jcs.engine.CompositeCacheAttributes"/> - <parameter name="jcs.region.ojbDefault.cacheattributes.MaxObjects" value="1000"/> - <parameter name="jcs.region.ojbDefault.cacheattributes.MemoryCacheName" - value="org.apache.jcs.engine.memory.lru.LRUMemoryCache"/> -</store> +{{{ +<store logger="core.store"> + <parameter name="maxobjects" value="10000"/> + <parameter name="use-cache-directory" value="true"/> + <parameter name="jcs.region.ojbDefault" value="DC"/> + <parameter name="jcs.region.ojbDefault.cacheattributes" + value="org.apache.jcs.engine.CompositeCacheAttributes"/> + <parameter name="jcs.region.ojbDefault.cacheattributes.MaxObjects" value="1000"/> + <parameter name="jcs.region.ojbDefault.cacheattributes.MemoryCacheName" + value="org.apache.jcs.engine.memory.lru.LRUMemoryCache"/> +</store> }}} The last 4 parameters (starting with '''jcs.region.ojbDefault''') define the cache region that OJB will use.
