kaz 02/02/18 18:31:01
Modified: xdocs UsingJCSBasicWeb.xml
Log:
Fixed some formatting changes that inadvertently clobbered some of
James' changes, oops :)
Revision Changes Path
1.4 +122 -122 jakarta-turbine-stratum/xdocs/UsingJCSBasicWeb.xml
Index: UsingJCSBasicWeb.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-stratum/xdocs/UsingJCSBasicWeb.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- UsingJCSBasicWeb.xml 19 Feb 2002 02:08:28 -0000 1.3
+++ UsingJCSBasicWeb.xml 19 Feb 2002 02:31:01 -0000 1.4
@@ -169,7 +169,6 @@
return instance;
}
-}
]]></source>
<p>
To get a BookVObj we will need some access methods in the
@@ -178,94 +177,94 @@
book data. The methods might look like:
</p>
<source><![CDATA[
-/**
- * Retrieves a BookVObj. Default to look in the cache.
- */
-public BookVObj getBookVObj(int id)
-{
- return getBookVObj(id, true);
-}
-
-/**
- * Retrieves a BookVObj. Second argument decides whether to look
- * in the cache. Returns a new value object if one can't be
- * loaded from the database. Database cache synchronization is
- * handled by removing cache elements upon modification.
- */
-public BookVObj getBookVObj(int id, boolean fromCache)
-{
- BookVObj vObj = null;
-
- // First, if requested, attempt to load from cache
-
- if (fromCache)
+ /**
+ * Retrieves a BookVObj. Default to look in the cache.
+ */
+ public BookVObj getBookVObj(int id)
{
- vObj = (BookVObj) bookCache.get("BookVObj" + id);
+ return getBookVObj(id, true);
}
-
- // Either fromCache was false or the object was not found, so
- // call loadBookVObj to create it
-
- if (vObj == null)
- {
- vObj = loadvObj(id);
+
+ /**
+ * Retrieves a BookVObj. Second argument decides whether to look
+ * in the cache. Returns a new value object if one can't be
+ * loaded from the database. Database cache synchronization is
+ * handled by removing cache elements upon modification.
+ */
+ public BookVObj getBookVObj(int id, boolean fromCache)
+ {
+ BookVObj vObj = null;
+
+ // First, if requested, attempt to load from cache
+
+ if (fromCache)
+ {
+ vObj = (BookVObj) bookCache.get("BookVObj" + id);
+ }
+
+ // Either fromCache was false or the object was not found, so
+ // call loadBookVObj to create it
+
+ if (vObj == null)
+ {
+ vObj = loadvObj(id);
+ }
+
+ return vObj;
}
-
- return vObj;
-}
-
-/**
- * Creates a BookVObj based on the id of the BOOK table. Data
- * access could be direct JDBC, some or mapping tool, or an EJB.
- */
-public BookVObj loadBookVObj(int id)
-{
- BookVObj vObj = new BookVObj();
-
- vObj.bookID = id;
-
- try
- {
- boolean found = false;
-
- // load the data and set the rest of the fields
- // set found to true if it was found
-
- found = true;
-
- // cache the value object if found
-
- if (found)
+
+ /**
+ * Creates a BookVObj based on the id of the BOOK table. Data
+ * access could be direct JDBC, some or mapping tool, or an EJB.
+ */
+ public BookVObj loadBookVObj(int id)
+ {
+ BookVObj vObj = new BookVObj();
+
+ vObj.bookID = id;
+
+ try
{
- // could use the defaults like this
- // bookCache.put( "BookVObj" + id, vObj );
- // or specify special characteristics
-
- // get the default attributes and copy them,
- // then make changes to specific values
-
- IElementAttributes attr =
- bookCache.getElementAttributes().copy();
-
- attr.setIsEternal(false);
-
- // expire after an hour
-
- attr.setMaxLifeSeconds(60 * 120);
-
- // put to cache with custom attributes
-
- bookCache.put("BookVObj" + id, vObj, attr);
+ boolean found = false;
+
+ // load the data and set the rest of the fields
+ // set found to true if it was found
+
+ found = true;
+
+ // cache the value object if found
+
+ if (found)
+ {
+ // could use the defaults like this
+ // bookCache.put( "BookVObj" + id, vObj );
+ // or specify special characteristics
+
+ // get the default attributes and copy them,
+ // then make changes to specific values
+
+ IElementAttributes attr =
+ bookCache.getElementAttributes().copy();
+
+ attr.setIsEternal(false);
+
+ // expire after an hour
+
+ attr.setMaxLifeSeconds(60 * 120);
+
+ // put to cache with custom attributes
+
+ bookCache.put("BookVObj" + id, vObj, attr);
+ }
+
+ }
+ catch (Exception e)
+ {
+ // Handle failure putting object to cache
}
-
- }
- catch (Exception e)
- {
- // Handle failure putting object to cache
+
+ return vObj;
}
-
- return vObj;
-}
]]></source>
<p>
We will also need a method to insert and update book data. To
@@ -273,37 +272,38 @@
core book data is created. The method might look like:
</p>
<source><![CDATA[
-/**
- * Stores BookVObj's in database. Clears old items and caches
- * new.
- */
-public int storeBookVObj(BookVObj vObj)
-{
- try
+ /**
+ * Stores BookVObj's in database. Clears old items and caches
+ * new.
+ */
+ public int storeBookVObj(BookVObj vObj)
{
- // since any cached data is no longer valid, we should
- // remove the item from the cache if it an update.
-
- if (vObj.bookID != 0)
+ try
{
- bookCache.remove("BookVObj" + vObj.bookID);
- }
-
- // get the default attributes, copy, and modify
-
- IElementAttributes attr =
- bookCache.getElementAttributes().copy();
- attr.setIsEternal(false);
- attr.setMaxLifeSeconds(60 * 120);
-
- // put the new object in the cache
-
- bookCache.put("BookVObj" + id, vObj, attr);
- }
- catch (Exception e)
- {
- // Handle failure removing object or putting object to cache.
- }
+ // since any cached data is no longer valid, we should
+ // remove the item from the cache if it an update.
+
+ if (vObj.bookID != 0)
+ {
+ bookCache.remove("BookVObj" + vObj.bookID);
+ }
+
+ // get the default attributes, copy, and modify
+
+ IElementAttributes attr =
+ bookCache.getElementAttributes().copy();
+ attr.setIsEternal(false);
+ attr.setMaxLifeSeconds(60 * 120);
+
+ // put the new object in the cache
+
+ bookCache.put("BookVObj" + id, vObj, attr);
+ }
+ catch (Exception e)
+ {
+ // Handle failure removing object or putting object to cache.
+ }
+ }
}
]]></source>
<p>
@@ -357,45 +357,45 @@
# sets the default aux value for any non configured caches
jcs.default=DC,RFailover
jcs.default.cacheattributes=
-org.apache.stratum.jcs.engine.CompositeCacheAttributes
+ org.apache.stratum.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=1000
jcs.default.cacheattributes.MemoryCacheName=
-org.apache.stratum.jcs.engine.memory.lru.LRUMemoryCache
+ org.apache.stratum.jcs.engine.memory.lru.LRUMemoryCache
# SYSTEM CACHE
# should be defined for the storage of group attribute list
jcs.system.groupIdCache=DC,RFailover
jcs.system.groupIdCache.cacheattributes=
-org.apache.stratum.jcs.engine.CompositeCacheAttributes
+ org.apache.stratum.jcs.engine.CompositeCacheAttributes
jcs.system.groupIdCache.cacheattributes.MaxObjects=10000
jcs.system.groupIdCache.cacheattributes.MemoryCacheName=
-org.apache.stratum.jcs.engine.memory.lru.LRUMemoryCache
+ org.apache.stratum.jcs.engine.memory.lru.LRUMemoryCache
# CACHE REGIONS AVAILABLE
# Regions preconfigured for caching
jcs.region.bookCache=DC,RFailover
jcs.region.bookCache.cacheattributes=
-org.apache.stratum.jcs.engine.CompositeCacheAttributes
+ org.apache.stratum.jcs.engine.CompositeCacheAttributes
jcs.region.bookCache.cacheattributes.MaxObjects=1200
jcs.region.bookCache.cacheattributes.MemoryCacheName=
-org.apache.stratum.jcs.engine.memory.lru.LRUMemoryCache
+ org.apache.stratum.jcs.engine.memory.lru.LRUMemoryCache
# AUXILIARY CACHES AVAILABLE
# Primary Disk Cache -- faster than the rest because of memory key storage
jcs.auxiliary.DC=
-org.apache.stratum.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
+ org.apache.stratum.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
jcs.auxiliary.DC.attributes=
-org.apache.stratum.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
+ org.apache.stratum.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
jcs.auxiliary.DC.attributes.DiskPath=/usr/opt/bookstore/raf
# Remote RMI Cache set up to failover
jcs.auxiliary.RFailover=
-org.apache.stratum.jcs.auxiliary.remote.RemoteCacheFactory
+ org.apache.stratum.jcs.auxiliary.remote.RemoteCacheFactory
jcs.auxiliary.RFailover.attributes=
-org.apache.stratum.jcs.auxiliary.remote.RemoteCacheAttributes
+ org.apache.stratum.jcs.auxiliary.remote.RemoteCacheAttributes
jcs.auxiliary.RFailover.attributes.RemoteTypeName=LOCAL
jcs.auxiliary.RFailover.attributes.FailoverServers=scriptserver:1102
jcs.auxiliary.RFailover.attributes.GetOnly=false
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>