You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@cocoon.apache.org by st...@outerthought.org on 2004/06/08 06:00:05 UTC
[WIKI-UPDATE] UsingOJBWithJCS Tutorials OJBBlock Tue Jun 8 06:00:04 2004
Page: http://wiki.cocoondev.org/Wiki.jsp?page=UsingOJBWithJCS , version: 1 on Mon Jun 8 04:11:35 2004 by AntonioGallardo
New page created:
+ !!!Using OJB with JCS.
+
+ This page will explain you in 4 steps how to configure [Apache JCS|http-link-tojakarta.apache.org/turbine/jcs/] as Object Cache for OJB in Cocoon.
+
+ !!Prerequisites
+ * You have already [configured OJB|OJBBlock]
+
+ !!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 [few drawbacks|http-link-todb.apache.org/ojb/objectcache.html#Shipped%20cache%20implementations]
+ *Since Cocoon 2.1.5 the default cache implementation is based in Apache JCS.
+ *Apache JCS is a distributed caching system for server-side java applications. It is far more powerful.
+
+ !!Platform
+ I think it works in any configuration, but just in case, here is the tested platform:
+
+ * Linux Fedora Core 2
+ * J2SDK 1.4.2_04
+ * Apache Tomcat 5.0.24
+ * Cocoon 2.1.5
+
+ !!Steps
+
+ !1. 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
+ }}}
+
+ !2. Tell OJB we will 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
+ }}}
+
+ !3. 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>
+ }}}
+
+ The last 4 parameters (starting with __jcs.region.ojbDefault__) define the cache region that OJB will use.
+ You can tell JCS how many OJB Object will be able to cache by changing the value of the parameter {{jcs.region.ojbDefault.cacheattributes.MaxObjects}}
+
+ !4. That is all!
+
+ Now restart you Tomcat and start using JCS. you will notice performance improvement. Good Luck!
+
+ !!More info:
+ * [Cocoon Store|http-link-tococoon.apache.org/2.1/developing/stores.html] - What are the stores in Cocoon?
+ * [JCS Logging] - How to redirect the JCS messages to a file (very easy too!)
+
+ -- [Antonio Gallardo]
+
Page: http://wiki.cocoondev.org/Wiki.jsp?page=Tutorials , version: 76 on Mon Jun 8 03:31:37 2004 by 24.91.189.219
- * [Presentation on Cocoon Web Publishing framework with example|http-link-to-subrahmanya.50megs.com/publishdocs/Cocoonp.ppt] -- An Technical Presentation Given by [Subrahmanya Nayak|http-link-to-www.subrahmanya.50megs.com/] ! Currently not reachable (forbidden access)
? --------------------------------------------
+ * [Presentation on Cocoon Web Publishing framework with example|http-link-to-subrahmanya.50megs.com/publishdocs/Cocoonp.ppt] -- An Technical Presentation Given by [Subrahmanya Nayak|http-link-to-www.subrahmanya.50megs.com/]
Page: http://wiki.cocoondev.org/Wiki.jsp?page=OJBBlock , version: 12 on Mon Jun 8 04:39:05 2004 by AntonioGallardo
- __See Also__: [OJBWithJDO]
+ __See Also__: [OJBWithJDO], [UsingOJBWithJCS]