[jboss-svn-commits] JBL Code SVN: r14190 - in labs/shotoku/trunk/shotoku-cache: src/etc/META-INF and 6 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Aug 13 17:46:35 EDT 2007
Author: adamw
Date: 2007-08-13 17:46:35 -0400 (Mon, 13 Aug 2007)
New Revision: 14190
Added:
labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/service/RenewableCacheServiceMBean.java
Removed:
labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/service/RenewableCacheServiceImpl.java
Modified:
labs/shotoku/trunk/shotoku-cache/build.xml
labs/shotoku/trunk/shotoku-cache/src/etc/META-INF/jboss-service.xml
labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/RenewableCacheItem.java
labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/UpdateThread.java
labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/service/RenewableCacheService.java
labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/tools/Tools.java
labs/shotoku/trunk/shotoku-cache/test/build.xml
labs/shotoku/trunk/shotoku-cache/test/src/java/org/jboss/shotoku/cache/test/TestCacheItem.java
labs/shotoku/trunk/shotoku-cache/test/src/java/org/jboss/shotoku/cache/test/TestServlet.java
labs/shotoku/trunk/shotoku-cache/test/src/web/WEB-INF/web.xml
Log:
Working test
Modified: labs/shotoku/trunk/shotoku-cache/build.xml
===================================================================
--- labs/shotoku/trunk/shotoku-cache/build.xml 2007-08-13 20:30:26 UTC (rev 14189)
+++ labs/shotoku/trunk/shotoku-cache/build.xml 2007-08-13 21:46:35 UTC (rev 14190)
@@ -1,84 +1,96 @@
<?xml version='1.0' encoding='UTF-8'?>
<project name="Shotoku Renewable Cache" default="build" basedir=".">
- <!-- Configuration of deployment -->
- <property name="jboss.home" value="/home/adamw/jboss/jboss-cache" />
- <property name="jboss.conf" value="default" />
+ <!-- Configuration of deployment -->
+ <property name="jboss.home" value="/home/adamw/jboss/jboss-cache" />
+ <property name="jboss.conf" value="default" />
- <!-- Name of the service archive which will contain the blog application -->
+ <!-- Name of the service archive which will contain the blog application -->
<property name="jar.lib.name" value="shotoku-cache.jar" />
<property name="jar.service.name" value="shotoku-cache-service.jar" />
- <property name="sar.name" value="shotoku-cache-service.sar" />
+ <property name="sar.name" value="shotoku-cache-service.sar" />
- <!-- Configuration of source/ target directories -->
- <property name="src" value="src"/>
- <property name="src.java" value="${src}/java"/>
- <property name="src.meta" value="${src}/etc"/>
- <property name="build" value="build"/>
- <property name="dist" value="${basedir}/dist"/>
+ <!-- Configuration of source/ target directories -->
+ <property name="src" value="src"/>
+ <property name="src.java" value="${src}/java"/>
+ <property name="src.meta" value="${src}/etc"/>
+ <property name="build" value="build"/>
+ <property name="dist" value="${basedir}/dist"/>
- <!-- Helper properties: built using the above ones -->
- <property name="dist.sar.dir" value="${dist}/${sar.name}" />
- <property name="dist.sar.lib.dir" value="${dist.sar.dir}/lib" />
+ <!-- Helper properties: built using the above ones -->
+ <property name="dist.sar.dir" value="${dist}/${sar.name}" />
+ <property name="dist.sar.lib.dir" value="${dist.sar.dir}/lib" />
<property name="dist.lib.dir" value="${dist}" />
-
- <property name="deploy.dir" value="${jboss.home}/server/${jboss.conf}/deploy" />
- <!-- Dependency jars filesets definitions -->
- <fileset id="classpath" dir="lib"><include name="**/*.jar"/></fileset>
+ <property name="deploy.sar.dir" value="${jboss.home}/server/${jboss.conf}/deploy" />
+ <property name="deploy.lib.dir" value="${jboss.home}/server/${jboss.conf}/lib" />
+
+ <!-- Dependency jars filesets definitions -->
+ <fileset id="classpath" dir="lib">
+ <include name="**/*.jar"/>
+ </fileset>
<path id="classpath.jars">
- <fileset refid="classpath" />
+ <fileset refid="classpath" />
</path>
- <!-- Main tasks -->
- <target name="clean">
- <delete dir="${dist}" />
- <delete dir="${build}" />
- </target>
+ <!-- Main tasks -->
+ <target name="clean">
+ <delete dir="${dist}" />
+ <delete dir="${build}" />
+ </target>
- <target name="build" depends="clean">
- <mkdir dir="${build}" />
-
- <!-- Compiling the source -->
- <javac srcdir="${src.java}" destdir="${build}" target="1.5" source="1.5">
- <classpath refid="classpath.jars" />
- </javac>
- </target>
+ <target name="build" depends="clean">
+ <mkdir dir="${build}" />
- <target name="dist" depends="build">
- <mkdir dir="${dist.sar.dir}" />
- <mkdir dir="${dist.sar.lib.dir}" />
- <mkdir dir="${dist.lib.dir}" />
-
- <!-- Copying the meta information -->
- <copy todir="${dist.sar.dir}">
- <fileset dir="${src.meta}"><include name="**/*" /></fileset>
- </copy>
+ <!-- Compiling the source -->
+ <javac srcdir="${src.java}" destdir="${build}" target="1.5" source="1.5">
+ <classpath refid="classpath.jars" />
+ </javac>
+ </target>
- <!-- Creating the jars with the classes -->
- <jar destfile="${dist.sar.lib.dir}/${jar.service.name}"
+ <target name="dist" depends="build">
+ <mkdir dir="${dist.sar.dir}" />
+ <mkdir dir="${dist.sar.lib.dir}" />
+ <mkdir dir="${dist.lib.dir}" />
+
+ <!-- Copying the meta information -->
+ <copy todir="${dist.sar.dir}">
+ <fileset dir="${src.meta}">
+ <include name="**/*" />
+ </fileset>
+ </copy>
+
+ <!-- Creating the jars with the classes -->
+ <jar destfile="${dist.sar.lib.dir}/${jar.service.name}"
basedir="${build}"
includes="**/*ServiceImpl*" />
-
- <jar destfile="${dist.lib.dir}/${jar.lib.name}"
+
+ <jar destfile="${dist.lib.dir}/${jar.lib.name}"
basedir="${build}"
excludes="**/*ServiceImpl*" />
- </target>
+ </target>
- <target name="deploy" depends="dist,undeploy">
- <!-- Copying the sar directory to the jboss deploy dir -->
- <copy todir="${deploy.dir}">
- <fileset dir="${dist}">
- <include name="${sar.name}/**" />
- </fileset>
- </copy>
- </target>
+ <target name="deploy" depends="dist,undeploy">
+ <!-- Copying the sar directory to the jboss deploy dir -->
+ <copy todir="${deploy.sar.dir}">
+ <fileset dir="${dist}">
+ <include name="${sar.name}/**" />
+ </fileset>
+ </copy>
- <target name="undeploy">
- <!-- Deleting old deployment -->
- <delete dir="${deploy.dir}/${sar.name}" />
- </target>
-
+ <copy todir="${deploy.lib.dir}">
+ <fileset dir="${dist}">
+ <include name="${jar.lib.name}" />
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="undeploy">
+ <!-- Deleting old deployment -->
+ <delete dir="${deploy.sar.dir}/${sar.name}" />
+ <delete dir="${deploy.lib.dir}/${jar.lib.name}" />
+ </target>
+
<target name="test" depends="dist">
<ant dir="test" inheritrefs="true" target="all" />
</target>
Modified: labs/shotoku/trunk/shotoku-cache/src/etc/META-INF/jboss-service.xml
===================================================================
--- labs/shotoku/trunk/shotoku-cache/src/etc/META-INF/jboss-service.xml 2007-08-13 20:30:26 UTC (rev 14189)
+++ labs/shotoku/trunk/shotoku-cache/src/etc/META-INF/jboss-service.xml 2007-08-13 21:46:35 UTC (rev 14190)
@@ -3,125 +3,115 @@
PUBLIC "-//JBoss//DTD MBean Service 4.0//EN"
"http://www.jboss.org/j2ee/dtd/jboss-service_4_0.dtd">
<server>
- <mbean
- code="org.jboss.shotoku.cache.service.RenewableCacheServiceImpl"
- name="shotoku:service=RenewableCache" xmbean-dd=""
- xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
- <xmbean />
+ <mbean code="org.jboss.shotoku.cache.service.RenewableCacheService"
+ name="shotoku:service=RenewableCache">
<attribute name="Interval">60000</attribute>
+ <attribute name="UpdateThreadCount">3</attribute>
<depends optional-attribute-name="TreeCache"
proxy-type="attribute">
shotoku:service=TreeCache
</depends>
</mbean>
- <mbean code="org.jboss.cache.TreeCache" name="shotoku:service=TreeCache">
- <!-- Configure the TransactionManager -->
- <attribute name="TransactionManagerLookupClass">
- org.jboss.cache.DummyTransactionManagerLookup
- </attribute>
+ <mbean code="org.jboss.cache.TreeCache"
+ name="shotoku:service=TreeCache">
+ <!-- Configure the TransactionManager -->
+ <attribute name="TransactionManagerLookupClass">
+ org.jboss.cache.BatchModeTransactionManagerLookup
+ </attribute>
- <!--
- Node locking scheme :
- PESSIMISTIC (default)
- OPTIMISTIC
- -->
- <attribute name="NodeLockingScheme">PESSIMISTIC</attribute>
+ <!--
+ Node locking level : SERIALIZABLE
+ REPEATABLE_READ (default)
+ READ_COMMITTED
+ READ_UNCOMMITTED
+ NONE
+ -->
+ <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
- <!--
- Node locking isolation level :
- SERIALIZABLE
- REPEATABLE_READ (default)
- READ_COMMITTED
- READ_UNCOMMITTED
- NONE
-
- (ignored if NodeLockingScheme is OPTIMISTIC)
- -->
- <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
+ <!--
+ Valid modes are LOCAL
+ REPL_ASYNC
+ REPL_SYNC
+ INVALIDATION_ASYNC
+ INVALIDATION_SYNC
+ -->
+ <attribute name="CacheMode">LOCAL</attribute>
- <!-- Lock parent before doing node additions/removes -->
- <attribute name="LockParentForChildInsertRemove">
- true
- </attribute>
+ <!-- Name of cluster. Needs to be the same for all clusters, in order
+ to find each other
+ -->
+ <attribute name="ClusterName">TreeCache-Cluster</attribute>
- <!-- Valid modes are LOCAL
- REPL_ASYNC
- REPL_SYNC
- INVALIDATION_ASYNC
- INVALIDATION_SYNC
- -->
- <attribute name="CacheMode">LOCAL</attribute>
+ <!-- JGroups protocol stack properties. Can also be a URL,
+ e.g. file:/home/bela/default.xml
+ <attribute name="ClusterProperties"></attribute>
+ -->
- <!-- Whether each interceptor should have an mbean
- registered to capture and display its statistics. -->
- <attribute name="UseInterceptorMbeans">true</attribute>
+ <attribute name="ClusterConfig">
+ <config>
+ <!-- UDP: if you have a multihomed machine,
+ set the bind_addr attribute to the appropriate NIC IP address -->
+ <!-- UDP: On Windows machines, because of the media sense feature
+ being broken with multicast (even after disabling media sense)
+ set the loopback attribute to true -->
+ <UDP mcast_addr="228.1.2.3" mcast_port="48866"
+ ip_ttl="64" ip_mcast="true" mcast_send_buf_size="150000"
+ mcast_recv_buf_size="80000" ucast_send_buf_size="150000"
+ ucast_recv_buf_size="80000" loopback="false" />
+ <PING timeout="2000" num_initial_members="3"
+ up_thread="false" down_thread="false" />
+ <MERGE2 min_interval="10000" max_interval="20000" />
+ <FD shun="true" up_thread="true" down_thread="true" />
+ <VERIFY_SUSPECT timeout="1500" up_thread="false"
+ down_thread="false" />
+ <pbcast.NAKACK gc_lag="50"
+ retransmit_timeout="600,1200,2400,4800" max_xmit_size="8192"
+ up_thread="false" down_thread="false" />
+ <UNICAST timeout="600,1200,2400" window_size="100"
+ min_threshold="10" down_thread="false" />
+ <pbcast.STABLE desired_avg_gossip="20000"
+ up_thread="false" down_thread="false" />
+ <FRAG frag_size="8192" down_thread="false"
+ up_thread="false" />
+ <pbcast.GMS join_timeout="5000"
+ join_retry_timeout="2000" shun="true" print_local_addr="true" />
+ <pbcast.STATE_TRANSFER up_thread="false"
+ down_thread="false" />
+ </config>
+ </attribute>
- <!-- Name of cluster. Needs to be the same for all TreeCache nodes in a
- cluster, in order to find each other -->
- <attribute name="ClusterName">JBoss-Cache-Cluster</attribute>
- <!-- Uncomment next three statements to enable JGroups multiplexer.
- This configuration is dependent on the JGroups multiplexer being
- registered in an MBean server such as JBossAS. -->
- <!--
- <depends>jgroups.mux:name=Multiplexer</depends>
- <attribute name="MultiplexerService">jgroups.mux:name=Multiplexer</attribute>
- <attribute name="MultiplexerStack">udp</attribute>
- -->
+ <!--
+ The max amount of time (in milliseconds) we wait until the
+ initial state (ie. the contents of the cache) are retrieved from
+ existing members in a clustered environment
+ -->
+ <attribute name="InitialStateRetrievalTimeout">
+ 20000
+ </attribute>
- <!-- JGroups protocol stack properties. ClusterConfig isn't used if the
- multiplexer is enabled and successfully initialized. -->
- <attribute name="ClusterConfig">
- <config>
- <!-- UDP: if you have a multihomed machine,
- set the bind_addr attribute to the appropriate NIC IP address
- -->
- <!-- UDP: On Windows machines, because of the media sense feature
- being broken with multicast (even after disabling media sense)
- set the loopback attribute to true
- -->
- <UDP mcast_addr="228.1.2.3" mcast_port="45566"
- ip_ttl="64" ip_mcast="true" mcast_send_buf_size="150000"
- mcast_recv_buf_size="80000" ucast_send_buf_size="150000"
- ucast_recv_buf_size="80000" loopback="false" />
- <PING timeout="2000" num_initial_members="3"
- up_thread="false" down_thread="false" />
- <MERGE2 min_interval="10000" max_interval="20000" />
- <FD shun="true" up_thread="true" down_thread="true" />
- <VERIFY_SUSPECT timeout="1500" up_thread="false"
- down_thread="false" />
- <pbcast.NAKACK gc_lag="50" max_xmit_size="8192"
- retransmit_timeout="600,1200,2400,4800" up_thread="false"
- down_thread="false" />
- <UNICAST timeout="600,1200,2400" window_size="100"
- min_threshold="10" down_thread="false" />
- <pbcast.STABLE desired_avg_gossip="20000"
- up_thread="false" down_thread="false" />
- <FRAG frag_size="8192" down_thread="false"
- up_thread="false" />
- <pbcast.GMS join_timeout="5000"
- join_retry_timeout="2000" shun="true" print_local_addr="true" />
- <pbcast.STATE_TRANSFER up_thread="false"
- down_thread="false" />
- </config>
- </attribute>
+ <!--
+ Number of milliseconds to wait until all responses for a
+ synchronous call have been received.
+ -->
+ <attribute name="SyncReplTimeout">20000</attribute>
- <!-- The max amount of time (in milliseconds) we wait until the
- initial state (ie. the contents of the cache) are retrieved from
- existing members in a clustered environment
- -->
- <attribute name="InitialStateRetrievalTimeout">5000</attribute>
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
+ <attribute name="LockAcquisitionTimeout">15000</attribute>
- <!-- Number of milliseconds to wait until all responses for a
- synchronous call have been received.
- -->
- <attribute name="SyncReplTimeout">10000</attribute>
+ <!-- Name of the eviction policy class. -->
+ <attribute name="EvictionPolicyClass"></attribute>
- <!-- Max number of milliseconds to wait for a lock acquisition -->
- <attribute name="LockAcquisitionTimeout">15000</attribute>
-
- <depends>jboss:service=Naming</depends>
- <depends>jboss:service=TransactionManager</depends>
- </mbean>
+ <!--
+ Indicate whether to use region based marshalling or not. Set this to true if you are running under a scoped
+ class loader, e.g., inside an application server. Default is "false".
+ -->
+ <attribute name="UseRegionBasedMarshalling">
+ false
+ </attribute>
+
+ <depends>jboss:service=Naming</depends>
+ <depends>jboss:service=TransactionManager</depends>
+ </mbean>
</server>
\ No newline at end of file
Modified: labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/RenewableCacheItem.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/RenewableCacheItem.java 2007-08-13 20:30:26 UTC (rev 14189)
+++ labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/RenewableCacheItem.java 2007-08-13 21:46:35 UTC (rev 14190)
@@ -29,6 +29,7 @@
import org.jboss.shotoku.tools.ConcurrentSet;
import org.jboss.shotoku.tools.ConcurrentHashSet;
import org.jboss.shotoku.cache.service.RenewableCacheService;
+import org.jboss.shotoku.cache.service.RenewableCacheServiceMBean;
import org.jboss.shotoku.exceptions.RenewableCacheException;
import java.util.*;
@@ -38,14 +39,24 @@
import javax.management.MalformedObjectNameException;
/**
- * Extend this class if you want to store objects in the cache that
- * will be updated on every Shotoku service timer timeout. The cache
- * item will be auto-registered in the service upon construction - so
- * take care when constructing objects of this class.
+ * Extend this class if you want to store objects in a cache that
+ * will be updated on a regular intervals of time, by a service daemon
+ * thread. All data is held in one node of a {@link org.jboss.cache.TreeCache}.
+ * If a key is requested for the first time, it is initialized with the
+ * {@link #init(Object)} method. Later, the {@link #update(Object, Object)} method
+ * is called to (possibly) update the currently held value.
+ *
+ * The cache item will be auto-registered in the service upon construction
+ * --- so take care when constructing objects of this class. When you want to
+ * remove all keys that are handled by this cache item, simply call
+ * the {@link #unregister()} method.
+ *
* @param <K> Type of the key of the objects held in cache. The keys
* should bahave well as map keys (most probably, the hashCode() and
* equals() methods should be overriden).
- * @param <T> Type of the object that will be stored in the cache.
+ *
+ * @param <T> Type of the objects that will be stored in the cache.
+ *
* @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
*/
public abstract class RenewableCacheItem<K, T> implements RenewableCacheItemConfiguration<K> {
@@ -59,13 +70,27 @@
private ConcurrentMap<K, Long> keysUpdates;
private ConcurrentSet<K> keysDuringUpdate;
- private RenewableCacheService service;
+ private RenewableCacheServiceMBean service;
/**
+ * Creates and registeres a new cache item.
*
+ * @param fqn An fqn of the node, where data should be held. If it is null,
+ * a unique fqn will be auto-generated for this cache item.
+ *
+ * @param mbeanName A name of an {@link RenewableCacheService} mbean, which
+ * should be used to perform cache operations. This mbeans holds a reference
+ * to a {@link org.jboss.cache.TreeCache}. If it is null, a default mbean
+ * name will be used.
+ *
* @param interval Interval at which the update operation will be executed.
* Effectively, the interval will be rounded to the nearest multiplicity of
- * the service timer interval. The interval should be given in milliseconds.
+ * the service update thread interval. The interval should be given in milliseconds.
+ * If it is 0, the {@link #update()} method will be executed on every service
+ * thread update.
+ *
+ * @param timeout How long, at a maximum, an update method for a key can last. If this
+ * value is non-zero, and is exceeded, a monitoring thread will interupt the update.
*/
public RenewableCacheItem(Fqn fqn, String mbeanName, long interval, long timeout) {
if (mbeanName == null) {
@@ -82,7 +107,7 @@
}
if (fqn == null) {
- this.fqn = service.getNextFqn();
+ this.fqn = service.generateNextFqn();
} else {
this.fqn = fqn;
}
@@ -96,6 +121,12 @@
service.register(this);
}
+ /**
+ * Creates and registeres a new cache item, with default parameter values (see
+ * {@link #RenewableCacheItem(Fqn, String, long, long)}): the fqn will be auto-generated,
+ * a default cache mbean name will be used, update will happen on each service thread
+ * update and there will be no limit on the length of a key update.
+ */
public RenewableCacheItem() {
this(null, null, 0, 0);
}
@@ -137,8 +168,10 @@
}
/**
- * Binds the given key with the given object in the cache. The real key to
- * which the object will be bound is: keyBase/key.
+ * Binds the given key with the given object in the associated TreeCache
+ * node. Should be called
+ * from the {@link #update(Object, Object)} method to put new values in the
+ * cache.
* @param key Key of the object.
* @param object Object that should be bound.
* @throws RenewableCacheException
@@ -157,7 +190,8 @@
}
/**
- * Gets an object that is bound to the given key in the cache.
+ * Gets an object that is bound to the given key in the associated
+ * TreeCache node.
* If this object is not in the cache, it will be initialized.
* @param key Key of the object to get.
* @return Value of the object.
@@ -190,7 +224,7 @@
}
/**
- * Removes all keys handled by this ShotokuCacheItem from the cache.
+ * Removes all keys handled by this cache item from the associated TreeCache node.
*/
public final void unregister() {
try {
@@ -201,8 +235,8 @@
}
/**
- * Called by the Shotoku service. You shouldn't call it from inside your
- * program.
+ * Called by the update service. You shouldn't call it from inside your
+ * code.
*/
public final void update() {
long now = Calendar.getInstance().getTimeInMillis();
@@ -232,23 +266,24 @@
* been restarted (so updates of all keys that have been updated got
* interrupted).
*/
- public void resetKeysDuringUpdate() {
- keysDuringUpdate.clear();
- }
+ //public void resetKeysDuringUpdate() {
+ // keysDuringUpdate.clear();
+ //}
/**
- * Called by the service periodically to update the object held.
+ * Called by the service periodically to update the object held in the
+ * cache.
* If the object in the cache should be changed, the implementing
- * method must call put(key, newObject).
+ * method must call {@link #put(Object, Object)}.
* @param key Key of the object to update.
* @param currentObject Current value held in the cache.
*/
public abstract void update(K key, T currentObject);
/**
- * Called when the user demanded an object which hasn't been accessed
+ * Called when the user demands an object which hasn't been accessed
* before, and thus, which hasn't been yet initialized. Here,
- * put(key, initialObject) should not be called, as the returned object
+ * {@link #put(Object, Object)} should <b>not</b> be called, as the returned object
* is automatically placed in the cache.
* @param key Key of the object to initialize.
* @return Initial value of an object with the given key.
Modified: labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/UpdateThread.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/UpdateThread.java 2007-08-13 20:30:26 UTC (rev 14189)
+++ labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/UpdateThread.java 2007-08-13 21:46:35 UTC (rev 14190)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.shotoku.cache;
-import org.jboss.shotoku.cache.service.RenewableCacheService;
+import org.jboss.shotoku.cache.service.RenewableCacheServiceMBean;
import org.apache.log4j.Logger;
import java.util.concurrent.BlockingQueue;
@@ -33,12 +33,10 @@
*/
public class UpdateThread extends Thread {
private static final Logger log = Logger.getLogger(UpdateThread.class);
-
- private RenewableCacheService service;
+
private BlockingQueue<UpdateThreadData> queue;
- public UpdateThread(RenewableCacheService service, LinkedBlockingQueue<UpdateThreadData> queue) {
- this.service = service;
+ public UpdateThread(RenewableCacheServiceMBean service, LinkedBlockingQueue<UpdateThreadData> queue) {
this.queue = queue;
setDaemon(true);
Modified: labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/service/RenewableCacheService.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/service/RenewableCacheService.java 2007-08-13 20:30:26 UTC (rev 14189)
+++ labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/service/RenewableCacheService.java 2007-08-13 21:46:35 UTC (rev 14190)
@@ -24,35 +24,256 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
+import org.jboss.cache.TreeCacheMBean;
import org.jboss.shotoku.cache.RenewableCacheItem;
+import org.jboss.shotoku.cache.SignalExitUpdateThreadData;
import org.jboss.shotoku.cache.UpdateThread;
import org.jboss.shotoku.cache.UpdateThreadData;
+import org.jboss.shotoku.tools.ConcurrentSet;
+import org.jboss.shotoku.tools.ConcurrentHashSet;
+import org.jboss.shotoku.tools.Tools;
+import org.apache.log4j.Logger;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.concurrent.LinkedBlockingQueue;
+
/**
*
* @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
*/
-public interface RenewableCacheService {
+public class RenewableCacheService implements RenewableCacheServiceMBean {
+ private final static Logger log = Logger.getLogger(RenewableCacheServiceMBean.class);
+
+ private TreeCacheMBean treeCache;
+ private long interval;
+ private long lastUpdate;
+ private Thread updateThread;
+
/*
- * CACHE
+ * Service-handling functions.
*/
- public Object get(Fqn fqn, Object key) throws CacheException;
- public void put(Fqn fqn, Object key, Object o) throws CacheException;
- public void remove(Fqn fqn, Object key) throws CacheException;
+ public void start() {
+ log.info("Starting main update thread...");
+ startUpdateThread();
+
+ log.info("Starting update threads...");
+ setUpdateThreadCount(updateThreadCount);
+
+ //log.info("Reseting keys during update in cache items...");
+ // Reseting just in case - if any thread unexpectadly died.
+ //for (RenewableCacheItem sci : cacheItems) {
+ // sci.resetKeysDuringUpdate();
+ //}
+ }
+
+ public void stop() {
+ signalExitAllUpdateThreads();
+ getUpdateThread().interrupt();
+
+ log.info("All update threads stopped.");
+ }
- /**
- * Touch the last update time of a key, that is, notifies the
- * service that the given key is up to date.
- * @param key
+ public TreeCacheMBean getTreeCache() {
+ return treeCache;
+ }
+
+ public void setTreeCache(TreeCacheMBean treeCache) {
+ this.treeCache = treeCache;
+ }
+
+ public long getInterval() {
+ return interval;
+ }
+
+ public void setInterval(long interval) {
+ this.interval = interval;
+ }
+
+ public long getLastUpdate() {
+ return lastUpdate;
+ }
+
+ public void setLastUpdate(long lastUpdate) {
+ this.lastUpdate = lastUpdate;
+ }
+
+ public long lastUpdateSecondsAgo() {
+ return (System.currentTimeMillis() - getLastUpdate())/1000;
+ }
+
+ public Date lastUpdateDate() {
+ return new Date(getLastUpdate());
+ }
+
+ public Thread getUpdateThread() {
+ return updateThread;
+ }
+
+ public void setUpdateThread(Thread updateThread) {
+ this.updateThread = updateThread;
+ }
+
+ /*
+ *
+ */
+
+ public void startUpdateThread() {
+ Thread ut = new Thread() {
+ {
+ setDaemon(true);
+ }
+
+ public void run() {
+ while (true) {
+ try {
+ sleep(getInterval());
+ } catch (InterruptedException e) {
+ // Quit.
+ log.debug("Stopping update thread for " + getName() + " (interrupted).", e);
+ return;
+ }
+
+ try {
+ update();
+ } catch (Throwable t) {
+ // Making sure that an exception won't stop the thread.
+ log.error("Update method for " + getName() + " threw an exception.", t);
+ }
+
+ setLastUpdate(Calendar.getInstance().getTimeInMillis());
+ }
+ }
+ };
+
+ ut.start();
+ setUpdateThread(ut);
+ }
+
+ /*
+ * Cache handling
*/
- public void register(RenewableCacheItem cacheItem);
- public void unregister(RenewableCacheItem cacheItem) throws CacheException;
- /**
- * Gets a next unique key base for a shotoku cache item.
+ private final ConcurrentSet<RenewableCacheItem> cacheItems =
+ new ConcurrentHashSet<RenewableCacheItem>();
+
+ public Object get(Fqn fqn, Object key) throws CacheException {
+ return treeCache.get(fqn, key);
+ }
+
+ public void put(Fqn fqn, Object key, Object o) throws CacheException {
+ treeCache.put(fqn, key, o);
+ }
+
+ public void remove(Fqn fqn, Object key) throws CacheException {
+ treeCache.remove(fqn, key);
+ }
+
+ public void register(RenewableCacheItem cacheItem) {
+ cacheItems.add(cacheItem);
+ }
+
+ public void unregister(RenewableCacheItem cacheItem) throws CacheException {
+ cacheItems.remove(cacheItem);
+
+ for (Object key : cacheItem.getKeysUpdates().keySet()) {
+ remove(cacheItem.getFqn(), key);
+ }
+ }
+
+ private int counter = 0;
+ private final Object counterSync = new Object();
+
+ public Fqn generateNextFqn() {
+ int c;
+ synchronized(counterSync) { c = counter++; }
+
+ return new Fqn(new Object[] {Tools.GENERATED_FQN_BASE, c});
+ }
+
+ /*
+ * Update threads management.
*/
- public Fqn getNextFqn();
- public void addUpdateThreadData(UpdateThreadData data);
+ private final LinkedBlockingQueue<UpdateThreadData> updateThreadDataQueue =
+ new LinkedBlockingQueue<UpdateThreadData>();
+
+ private int updateThreadCount;
+
+ public void addUpdateThreadData(UpdateThreadData data) {
+ updateThreadDataQueue.offer(data);
+ }
+
+ public int getUpdateThreadCount() {
+ return updateThreadCount;
+ }
+
+ public void setUpdateThreadCount(int n) {
+ synchronized (updateThreadDataQueue) {
+ if (updateThreadCount < n) {
+ for (int i=updateThreadCount; i<n; i++) {
+ UpdateThread ut = new UpdateThread(this, updateThreadDataQueue);
+ ut.start();
+ }
+ } else if (n < updateThreadCount) {
+ for (int i=updateThreadCount; i>n; i--) {
+ updateThreadDataQueue.offer(new SignalExitUpdateThreadData());
+ }
+ }
+ }
+
+ log.info("Update thread count set to: " + n + ".");
+ updateThreadCount = n;
+ }
+
+ private void signalExitAllUpdateThreads() {
+ synchronized (updateThreadDataQueue) {
+ for (int i=0; i<updateThreadCount; i++) {
+ updateThreadDataQueue.offer(new SignalExitUpdateThreadData());
+ }
+ }
+ }
+
+ /*
+ * Update function.
+ */
+
+ public void update() {
+ for (RenewableCacheItem sci : cacheItems) {
+ try {
+ sci.update();
+ } catch (Throwable t) {
+ log.error("Exception while updating a cache item.", t);
+ }
+ }
+ }
+
+ /*
+ * Description functions.
+ */
+
+ public String getServiceDescription() {
+ /*long now = System.currentTimeMillis();
+
+ StringBuffer sb = new StringBuffer("Cache service.<br />");
+ sb.append("Currently storing ").append(cache.size()).append(" items in the cache ");
+ sb.append("and ").append(cacheItems.size()).append(" ShotokuCacheItem objects.<br />");
+ sb.append("Objects in cache:<br />");
+ for (Object key : cache.keySet()) {
+ sb.append(key.toString()).append(" : ").append(
+ cache.get(key).getClass().getName()).append(
+ ", last updated ").append((now - lastUpdates.get(key)) / 1000).append(
+ " seconds ago.<br />");
+ }
+
+ sb.append("Cache items:<br />");
+ for (RenewableCacheItem sci : cacheItems) {
+ sb.append(sci.getClass().getName()).append("<br />");
+ }
+
+ return sb.toString();*/
+
+ return null;
+ }
}
Deleted: labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/service/RenewableCacheServiceImpl.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/service/RenewableCacheServiceImpl.java 2007-08-13 20:30:26 UTC (rev 14189)
+++ labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/service/RenewableCacheServiceImpl.java 2007-08-13 21:46:35 UTC (rev 14190)
@@ -1,286 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.shotoku.cache.service;
-
-import org.jboss.cache.CacheException;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.TreeCache;
-import org.jboss.shotoku.cache.RenewableCacheItem;
-import org.jboss.shotoku.cache.SignalExitUpdateThreadData;
-import org.jboss.shotoku.cache.UpdateThread;
-import org.jboss.shotoku.cache.UpdateThreadData;
-import org.jboss.shotoku.tools.ConcurrentSet;
-import org.jboss.shotoku.tools.ConcurrentHashSet;
-import org.jboss.shotoku.tools.Tools;
-import org.jboss.system.ServiceMBeanSupport;
-import org.apache.log4j.Logger;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.concurrent.LinkedBlockingQueue;
-
-/**
- *
- * @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
- */
-public class RenewableCacheServiceImpl extends ServiceMBeanSupport implements RenewableCacheService {
- private final static Logger log = Logger.getLogger(RenewableCacheService.class);
-
- private TreeCache treeCache;
- private long interval;
- private long lastUpdate;
- private Thread updateThread;
-
- /*
- * Service-handling functions.
- */
-
- public void create() throws Exception {
- }
-
- public void start() throws Exception {
- log.info("Starting main update thread...");
- startUpdateThread();
-
- log.info("Starting update threads...");
- setUpdateThreadCount(updateThreadCount);
-
- //log.info("Reseting keys during update in cache items...");
- // Reseting just in case - if any thread unexpectadly died.
- //for (RenewableCacheItem sci : cacheItems) {
- // sci.resetKeysDuringUpdate();
- //}
- }
-
- public void stop() {
- signalExitAllUpdateThreads();
- getUpdateThread().interrupt();
-
- log.info("All update threads stopped.");
- }
-
- public void destroy() {
-
- }
-
- public TreeCache getTreeCache() {
- return treeCache;
- }
-
- public void setTreeCache(TreeCache treeCache) {
- this.treeCache = treeCache;
- }
-
- public long getInterval() {
- return interval;
- }
-
- public void setInterval(long interval) {
- this.interval = interval;
- }
-
- public long getLastUpdate() {
- return lastUpdate;
- }
-
- public void setLastUpdate(long lastUpdate) {
- this.lastUpdate = lastUpdate;
- }
-
- public long getLastUpdateSecondsAgo() {
- return (System.currentTimeMillis() - getLastUpdate())/1000;
- }
-
- public Date getLastUpdateDate() {
- return new Date(getLastUpdate());
- }
- public Thread getUpdateThread() {
- return updateThread;
- }
-
- public void setUpdateThread(Thread updateThread) {
- this.updateThread = updateThread;
- }
-
- /*
- *
- */
-
- public void startUpdateThread() {
- Thread ut = new Thread() {
- {
- setDaemon(true);
- }
-
- public void run() {
- while (true) {
- try {
- sleep(getInterval());
- } catch (InterruptedException e) {
- // Quit.
- log.debug("Stopping update thread for " + getName() + " (interrupted).", e);
- return;
- }
-
- try {
- update();
- } catch (Throwable t) {
- // Making sure that an exception won't stop the thread.
- log.error("Update method for " + getName() + " threw an exception.", t);
- }
-
- setLastUpdate(Calendar.getInstance().getTimeInMillis());
- }
- }
- };
-
- ut.start();
- setUpdateThread(ut);
- }
-
- /*
- * Cache handling
- */
-
- private final ConcurrentSet<RenewableCacheItem> cacheItems =
- new ConcurrentHashSet<RenewableCacheItem>();
-
- public Object get(Fqn fqn, Object key) throws CacheException {
- return treeCache.get(fqn, key);
- }
-
- public void put(Fqn fqn, Object key, Object o) throws CacheException {
- treeCache.put(fqn, key, o);
- }
-
- public void remove(Fqn fqn, Object key) throws CacheException {
- treeCache.remove(fqn, key);
- }
-
- public void register(RenewableCacheItem cacheItem) {
- cacheItems.add(cacheItem);
- }
-
- public void unregister(RenewableCacheItem cacheItem) throws CacheException {
- cacheItems.remove(cacheItem);
-
- for (Object key : cacheItem.getKeysUpdates().keySet()) {
- remove(cacheItem.getFqn(), key);
- }
- }
-
- private int counter = 0;
- private final Object counterSync = new Object();
-
- public Fqn getNextFqn() {
- int c;
- synchronized(counterSync) { c = counter++; }
-
- return new Fqn(new Object[] {Tools.GENERATED_FQN_BASE, c});
- }
-
- /*
- * Update threads management.
- */
-
- private final LinkedBlockingQueue<UpdateThreadData> updateThreadDataQueue =
- new LinkedBlockingQueue<UpdateThreadData>();
-
- private int updateThreadCount;
-
- public void addUpdateThreadData(UpdateThreadData data) {
- updateThreadDataQueue.offer(data);
- }
-
- public int getUpdateThreadCount() {
- return updateThreadCount;
- }
-
- public void setUpdateThreadCount(int n) {
- synchronized (updateThreadDataQueue) {
- if (updateThreadCount < n) {
- for (int i=updateThreadCount; i<n; i++) {
- UpdateThread ut = new UpdateThread(this, updateThreadDataQueue);
- ut.start();
- }
- } else if (n < updateThreadCount) {
- for (int i=updateThreadCount; i>n; i--) {
- updateThreadDataQueue.offer(new SignalExitUpdateThreadData());
- }
- }
- }
-
- log.info("Update thread count set to: " + n + ".");
- updateThreadCount = n;
- }
-
- private void signalExitAllUpdateThreads() {
- synchronized (updateThreadDataQueue) {
- for (int i=0; i<updateThreadCount; i++) {
- updateThreadDataQueue.offer(new SignalExitUpdateThreadData());
- }
- }
- }
-
- /*
- * Update function.
- */
-
- public void update() {
- for (RenewableCacheItem sci : cacheItems) {
- try {
- sci.update();
- } catch (Throwable t) {
- log.error("Exception while updating a cache item.", t);
- }
- }
- }
-
- /*
- * Description functions.
- */
-
- public String getServiceDescription() {
- /*long now = System.currentTimeMillis();
-
- StringBuffer sb = new StringBuffer("Cache service.<br />");
- sb.append("Currently storing ").append(cache.size()).append(" items in the cache ");
- sb.append("and ").append(cacheItems.size()).append(" ShotokuCacheItem objects.<br />");
- sb.append("Objects in cache:<br />");
- for (Object key : cache.keySet()) {
- sb.append(key.toString()).append(" : ").append(
- cache.get(key).getClass().getName()).append(
- ", last updated ").append((now - lastUpdates.get(key)) / 1000).append(
- " seconds ago.<br />");
- }
-
- sb.append("Cache items:<br />");
- for (RenewableCacheItem sci : cacheItems) {
- sb.append(sci.getClass().getName()).append("<br />");
- }
-
- return sb.toString();*/
-
- return null;
- }
-}
Added: labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/service/RenewableCacheServiceMBean.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/service/RenewableCacheServiceMBean.java (rev 0)
+++ labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/service/RenewableCacheServiceMBean.java 2007-08-13 21:46:35 UTC (rev 14190)
@@ -0,0 +1,82 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.shotoku.cache.service;
+
+import java.util.Date;
+
+import org.jboss.cache.CacheException;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.TreeCacheMBean;
+import org.jboss.shotoku.cache.RenewableCacheItem;
+import org.jboss.shotoku.cache.UpdateThreadData;
+
+/**
+ *
+ * @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
+ */
+public interface RenewableCacheServiceMBean {
+ /*
+ * CACHE
+ */
+
+ public Object get(Fqn fqn, Object key) throws CacheException;
+ public void put(Fqn fqn, Object key, Object o) throws CacheException;
+ public void remove(Fqn fqn, Object key) throws CacheException;
+
+ /**
+ * Touch the last update time of a key, that is, notifies the
+ * service that the given key is up to date.
+ * @param key
+ */
+ public void register(RenewableCacheItem cacheItem);
+ public void unregister(RenewableCacheItem cacheItem) throws CacheException;
+
+ /**
+ * Gets a next unique key base for a shotoku cache item.
+ */
+ public Fqn generateNextFqn();
+
+ public void addUpdateThreadData(UpdateThreadData data);
+
+ public TreeCacheMBean getTreeCache();
+ public void setTreeCache(TreeCacheMBean treeCache);
+
+ public long getInterval();
+ public void setInterval(long interval);
+
+ public long getLastUpdate();
+ public void setLastUpdate(long lastUpdate);
+
+ public long lastUpdateSecondsAgo();
+ public Date lastUpdateDate();
+
+ public int getUpdateThreadCount();
+ public void setUpdateThreadCount(int n);
+
+ public void update();
+
+ public String getServiceDescription();
+
+ public void start();
+ public void stop();
+}
Modified: labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/tools/Tools.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/tools/Tools.java 2007-08-13 20:30:26 UTC (rev 14189)
+++ labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/tools/Tools.java 2007-08-13 21:46:35 UTC (rev 14190)
@@ -26,7 +26,7 @@
import org.jboss.mx.util.MBeanProxyExt;
import org.jboss.mx.util.MBeanServerLocator;
-import org.jboss.shotoku.cache.service.RenewableCacheService;
+import org.jboss.shotoku.cache.service.RenewableCacheServiceMBean;
/**
* Utility, helper functions used internally.
@@ -38,9 +38,9 @@
public static final String DEFAULT_RENEWABLE_CACHE_MBEAN = "shotoku:service=RenewableCache";
- public static RenewableCacheService getService(String mbeanName) throws MalformedObjectNameException {
- return (RenewableCacheService) MBeanProxyExt.create(
- RenewableCacheService.class, mbeanName,
+ public static RenewableCacheServiceMBean getService(String mbeanName) throws MalformedObjectNameException {
+ return (RenewableCacheServiceMBean) MBeanProxyExt.create(
+ RenewableCacheServiceMBean.class, mbeanName,
MBeanServerLocator.locate());
}
Modified: labs/shotoku/trunk/shotoku-cache/test/build.xml
===================================================================
--- labs/shotoku/trunk/shotoku-cache/test/build.xml 2007-08-13 20:30:26 UTC (rev 14189)
+++ labs/shotoku/trunk/shotoku-cache/test/build.xml 2007-08-13 21:46:35 UTC (rev 14190)
@@ -2,10 +2,12 @@
<project name="Shotoku Renewable Cache Test" default="all" basedir=".">
<path id="classpath.test.jars">
- <fileset refid="classpath" />
- <fileset dir="../dist"><include name="shotoku-cache.jar"/></fileset>
+ <fileset refid="classpath" />
+ <fileset dir="../dist">
+ <include name="shotoku-cache.jar"/>
+ </fileset>
</path>
-
+
<target name="all">
<delete dir="dist" />
<delete dir="build" />
@@ -19,15 +21,25 @@
</javac>
<!-- -->
-
+
<copy todir="build">
- <fileset dir="src/web"><include name="**/*" /></fileset>
+ <fileset dir="src/web">
+ <include name="**/*" />
+ </fileset>
</copy>
-
+
<!-- -->
-
+
<mkdir dir="dist" />
-
+
<jar destfile="dist/shotoku-cache-test.war" basedir="build" />
+
+ <!-- -->
+
+ <copy todir="${deploy.sar.dir}">
+ <fileset dir="dist">
+ <include name="shotoku-cache-test.war" />
+ </fileset>
+ </copy>
</target>
</project>
Modified: labs/shotoku/trunk/shotoku-cache/test/src/java/org/jboss/shotoku/cache/test/TestCacheItem.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/test/src/java/org/jboss/shotoku/cache/test/TestCacheItem.java 2007-08-13 20:30:26 UTC (rev 14189)
+++ labs/shotoku/trunk/shotoku-cache/test/src/java/org/jboss/shotoku/cache/test/TestCacheItem.java 2007-08-13 21:46:35 UTC (rev 14190)
@@ -2,14 +2,14 @@
import org.jboss.shotoku.cache.RenewableCacheItem;
-public class TestCacheItem extends RenewableCacheItem<String, String> {
+public class TestCacheItem extends RenewableCacheItem<String, Integer> {
@Override
- public String init(String key) {
- return null;
+ public Integer init(String key) {
+ return 0;
}
@Override
- public void update(String key, String currentObject) {
-
+ public void update(String key, Integer currentObject) {
+ put(key, currentObject + 1);
}
}
Modified: labs/shotoku/trunk/shotoku-cache/test/src/java/org/jboss/shotoku/cache/test/TestServlet.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/test/src/java/org/jboss/shotoku/cache/test/TestServlet.java 2007-08-13 20:30:26 UTC (rev 14189)
+++ labs/shotoku/trunk/shotoku-cache/test/src/java/org/jboss/shotoku/cache/test/TestServlet.java 2007-08-13 21:46:35 UTC (rev 14190)
@@ -9,14 +9,17 @@
import javax.servlet.http.HttpServletResponse;
public class TestServlet extends HttpServlet {
-
+ private TestCacheItem tci;
+
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- System.out.println("X");
+ System.out.println(tci.get("A"));
}
@Override
public void init(ServletConfig config) throws ServletException {
+ tci = new TestCacheItem();
+
super.init(config);
}
Modified: labs/shotoku/trunk/shotoku-cache/test/src/web/WEB-INF/web.xml
===================================================================
--- labs/shotoku/trunk/shotoku-cache/test/src/web/WEB-INF/web.xml 2007-08-13 20:30:26 UTC (rev 14189)
+++ labs/shotoku/trunk/shotoku-cache/test/src/web/WEB-INF/web.xml 2007-08-13 21:46:35 UTC (rev 14190)
@@ -10,6 +10,6 @@
<servlet-mapping>
<servlet-name>CacheTestServlet</servlet-name>
- <url-pattern>*</url-pattern>
+ <url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
\ No newline at end of file
More information about the jboss-svn-commits
mailing list