[jboss-svn-commits] JBL Code SVN: r14217 - in labs/shotoku/trunk: shotoku-aop and 14 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Aug 14 12:51:44 EDT 2007
Author: adamw
Date: 2007-08-14 12:51:44 -0400 (Tue, 14 Aug 2007)
New Revision: 14217
Added:
labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/service/DummyRenewableCacheService.java
labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/tools/CacheTools.java
Removed:
labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuCache.java
labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/UpdateThread.java
labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/UpdateThreadData.java
labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/ConcurrentHashSet.java
labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/ConcurrentSet.java
labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/KeyValue.java
labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Pair.java
labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Triple.java
labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Tuples.java
labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/ChangeType.java
labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/tools/Tools.java
Modified:
labs/shotoku/trunk/maven.xml
labs/shotoku/trunk/project.properties
labs/shotoku/trunk/shotoku-aop/project.xml
labs/shotoku/trunk/shotoku-base-service/project.xml
labs/shotoku/trunk/shotoku-base-service/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java
labs/shotoku/trunk/shotoku-base/project.xml
labs/shotoku/trunk/shotoku-base/src/etc/shotoku.properties.sample
labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java
labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuCacheItem.java
labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuService.java
labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Constants.java
labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/RenewableCacheItem.java
labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/service/RenewableCacheService.java
labs/shotoku/trunk/shotoku-feeds/project.xml
labs/shotoku/trunk/shotoku-file-access/project.xml
labs/shotoku/trunk/shotoku-svn/project.xml
Log:
Integrating shotoku-cache with the rest of shotoku
Modified: labs/shotoku/trunk/maven.xml
===================================================================
--- labs/shotoku/trunk/maven.xml 2007-08-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/maven.xml 2007-08-14 16:51:44 UTC (rev 14217)
@@ -1,110 +1,116 @@
<project xmlns:j="jelly:core" xmlns:ant="jelly:ant" xmlns:u="jelly:util" xmlns:maven="jelly:maven">
- <!-- Dummy goals required by Labs build -->
- <goal name="prj-install">
- </goal>
- <goal name="clean">
- </goal>
- <goal name="deploy">
- </goal>
- <goal name="build">
- </goal>
+ <!-- Dummy goals required by Labs build -->
+ <goal name="prj-install">
+ </goal>
+ <goal name="clean">
+ </goal>
+ <goal name="deploy">
+ </goal>
+ <goal name="build">
+ </goal>
- <!-- Helper goals -->
+ <!-- Helper goals -->
- <goal name="prj-clean">
- <ant:delete dir="${maven.build.dir}"/>
- <ant:delete dir="${maven.build.dest}"/>
- </goal>
+ <goal name="prj-clean">
+ <ant:delete dir="${maven.build.dir}"/>
+ <ant:delete dir="${maven.build.dest}"/>
+ </goal>
- <goal name="shotoku-all-projects">
- <u:tokenize var="subprjs" delim=",">${shotoku.subprojects}</u:tokenize>
- <j:forEach items="${subprjs}" var="subprojectId">
- <maven:reactor
+ <goal name="shotoku-all-projects">
+ <u:tokenize var="subprjs" delim=",">${shotoku.subprojects}</u:tokenize>
+ <j:forEach items="${subprjs}" var="subprojectId">
+ <maven:reactor
includes="shotoku-${subprojectId}/project.xml"
excludes="" basedir="." banner="Shotoku build"
goals="${goal}" ignoreFailures="false" />
- </j:forEach>
- </goal>
+ </j:forEach>
+ </goal>
- <!-- Main goals -->
+ <!-- Main goals -->
- <goal name="shotoku:build">
- <j:set var="goal" value="build" />
- <attainGoal name="shotoku-all-projects" />
- </goal>
+ <goal name="shotoku:build">
+ <ant:ant dir="shotoku-cache" inheritrefs="false" target="dist" />
+ <j:set var="goal" value="build" />
+ <attainGoal name="shotoku-all-projects" />
+ </goal>
- <goal name="shotoku:deploy">
- <ant:delete dir="${shotoku.jar.dest}" />
+ <goal name="shotoku:deploy">
+ <j:set var="jboss.home" value="${local.server.dir}" />
+ <ant:ant dir="shotoku-cache" inheritAll="true" target="deploy" />
- <j:set var="goal" value="deploy" />
- <attainGoal name="shotoku-all-projects" />
+ <!-- -->
- <!-- Copying the libraries -->
- <ant:copy
+ <ant:delete dir="${shotoku.jar.dest}" />
+
+ <j:set var="goal" value="deploy" />
+ <attainGoal name="shotoku-all-projects" />
+
+ <!-- Copying the libraries -->
+ <ant:copy
todir="${shotoku.jar.dest}" overwrite="true"
file="${maven.repo.local}/commons-configuration/jars/commons-configuration-1.1.jar" />
- <ant:copy
+ <ant:copy
todir="${shotoku.jar.dest}" overwrite="true"
file="${maven.repo.local}/commons-lang/jars/commons-lang-2.1.jar" />
- <ant:copy
+ <ant:copy
todir="${shotoku.jar.dest}" overwrite="true">
- <ant:fileset dir="${maven.repo.local}/velocity/jars">
- <ant:filename name="velocity*-1.4.jar" />
- </ant:fileset>
- </ant:copy>
+ <ant:fileset dir="${maven.repo.local}/velocity/jars">
+ <ant:filename name="velocity*-1.4.jar" />
+ </ant:fileset>
+ </ant:copy>
- <!-- Constructing the sar -->
- <ant:copy todir="target/${shotoku.sar.dir}">
- <ant:fileset dir="src/app" flatten="true" overwrite="true">
- <ant:filename name="**" />
- </ant:fileset>
- </ant:copy>
+ <!-- Constructing the sar -->
+ <ant:copy todir="target/${shotoku.sar.dir}">
+ <ant:fileset dir="src/app" flatten="true" overwrite="true">
+ <ant:filename name="**" />
+ </ant:fileset>
+ </ant:copy>
- <j:set var="jar.to.dir" value="target/${shotoku.sar.dir}" />
- <attainGoal name="dir-to-jar" />
+ <j:set var="jar.to.dir" value="target/${shotoku.sar.dir}" />
+ <attainGoal name="dir-to-jar" />
- <!-- Copying the sar to the deploy directory. -->
- <ant:copy todir="${local.deploy.dir}" file="target/${shotoku.sar.dir}" />
- </goal>
+ <!-- Copying the sar to the deploy directory. -->
+ <ant:copy todir="${local.deploy.dir}" file="target/${shotoku.sar.dir}" />
+ </goal>
- <goal name="all">
- <attainGoal name="shotoku:clean" />
- <attainGoal name="shotoku:build" />
- <attainGoal name="shotoku:deploy" />
- </goal>
+ <goal name="all">
+ <attainGoal name="shotoku:clean" />
+ <attainGoal name="shotoku:build" />
+ <attainGoal name="shotoku:deploy" />
+ </goal>
- <goal name="shotoku:clean">
- <attainGoal name="prj-clean" />
- <u:tokenize var="subprjs" delim=",">${shotoku.subprojects}</u:tokenize>
- <j:forEach items="${subprjs}" var="subprojectId">
- <ant:delete dir="shotoku-${subprojectId}/target" />
- </j:forEach>
- </goal>
+ <goal name="shotoku:clean">
+ <attainGoal name="prj-clean" />
+ <u:tokenize var="subprjs" delim=",">${shotoku.subprojects}</u:tokenize>
+ <j:forEach items="${subprjs}" var="subprojectId">
+ <ant:delete dir="shotoku-${subprojectId}/target" />
+ </j:forEach>
+ </goal>
- <!-- Distribution building -->
+ <!-- Distribution building -->
- <goal name="dist">
- <attainGoal name="all" />
- <ant:mkdir dir="target" />
- <ant:copy todir="target/binary/${shotoku.sar.dir}" overwrite="true">
- <ant:fileset dir="target/${shotoku.sar.dir}" />
- </ant:copy>
- <ant:copy tofile="target/binary/shotoku-aop.aop"
+ <goal name="dist">
+ <attainGoal name="all" />
+ <ant:mkdir dir="target" />
+ <ant:copy todir="target/binary/${shotoku.sar.dir}" overwrite="true">
+ <ant:fileset dir="target/${shotoku.sar.dir}" />
+ </ant:copy>
+ <ant:copy tofile="target/binary/shotoku-aop.aop"
file="shotoku-aop/target/shotoku-aop.jar" />
- <u:tokenize var="subprjs" delim=",">${shotoku.subprojects.cms}</u:tokenize>
- <j:forEach items="${subprjs}" var="subprojectId">
- <j:set var="jar.to.dir"
+ <u:tokenize var="subprjs" delim=",">${shotoku.subprojects.cms}</u:tokenize>
+ <j:forEach items="${subprjs}" var="subprojectId">
+ <j:set var="jar.to.dir"
value="target/binary/${shotoku.sar.dir}/shotoku-${subprojectId}.ejb3" />
- <attainGoal name="jar-to-dir" />
- </j:forEach>
+ <attainGoal name="jar-to-dir" />
+ </j:forEach>
- <ant:tar destfile="target/shotoku-${version}-binary.tar.gz"
+ <ant:tar destfile="target/shotoku-${version}-binary.tar.gz"
compression="gzip"
basedir="target/binary"
excludes="**/HomeTest*,**/shotoku.properties"
/>
- <ant:tar destfile="target/shotoku-${version}-source.tar.gz"
+ <ant:tar destfile="target/shotoku-${version}-source.tar.gz"
compression="gzip"
basedir=""
includes="shotoku-*/**,lib/**"
@@ -112,21 +118,21 @@
/>-->
</goal>
- <goal name="jar-to-dir">
- <ant:unjar src="${jar.to.dir}" dest="temp" />
- <ant:delete file="${jar.to.dir}" />
- <ant:move todir="${jar.to.dir}">
- <ant:fileset dir="temp" />
- </ant:move>
- </goal>
+ <goal name="jar-to-dir">
+ <ant:unjar src="${jar.to.dir}" dest="temp" />
+ <ant:delete file="${jar.to.dir}" />
+ <ant:move todir="${jar.to.dir}">
+ <ant:fileset dir="temp" />
+ </ant:move>
+ </goal>
- <goal name="dir-to-jar">
- <ant:move todir="temp">
- <ant:fileset dir="${jar.to.dir}" />
- </ant:move>
- <ant:jar basedir="temp" destfile="${jar.to.dir}" />
- <ant:delete dir="temp" />
- </goal>
+ <goal name="dir-to-jar">
+ <ant:move todir="temp">
+ <ant:fileset dir="${jar.to.dir}" />
+ </ant:move>
+ <ant:jar basedir="temp" destfile="${jar.to.dir}" />
+ <ant:delete dir="temp" />
+ </goal>
- <property environment="env" />
+ <property environment="env" />
</project>
Modified: labs/shotoku/trunk/project.properties
===================================================================
--- labs/shotoku/trunk/project.properties 2007-08-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/project.properties 2007-08-14 16:51:44 UTC (rev 14217)
@@ -42,3 +42,7 @@
maven.jar.shotoku-tags=${shotoku.root.dir}/shotoku-tags/target/shotoku-tags.jar
maven.jar.jboss-blog-common=${shotoku.root.dir}/lib/jboss-blog/jboss-blog-common.jar
+
+maven.jar.shotoku-cache=${shotoku.root.dir}/shotoku-cache/dist/shotoku-cache.jar
+maven.jar.jboss-cache=${shotoku.root.dir}/shotoku-cache/lib/jboss-cache.jar
+maven.jar.jgroups=${shotoku.root.dir}/shotoku-cache/lib/jgroups.jar
Modified: labs/shotoku/trunk/shotoku-aop/project.xml
===================================================================
--- labs/shotoku/trunk/shotoku-aop/project.xml 2007-08-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-aop/project.xml 2007-08-14 16:51:44 UTC (rev 14217)
@@ -18,6 +18,24 @@
<version>1.0</version>
<jar>jboss-aop.jar</jar>
</dependency>
+
+ <dependency>
+ <groupId>shotoku-cache</groupId>
+ <artifactId>shotoku-cache</artifactId>
+ <jar>shotoku-cache.jar</jar>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss-cache</groupId>
+ <artifactId>jboss-cache</artifactId>
+ <jar>jboss-cache.jar</jar>
+ </dependency>
+
+ <dependency>
+ <groupId>jgroups</groupId>
+ <artifactId>jgroups</artifactId>
+ <jar>jgroups.jar</jar>
+ </dependency>
</dependencies>
<build>
Modified: labs/shotoku/trunk/shotoku-base/project.xml
===================================================================
--- labs/shotoku/trunk/shotoku-base/project.xml 2007-08-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-base/project.xml 2007-08-14 16:51:44 UTC (rev 14217)
@@ -46,6 +46,24 @@
<artifactId>jboss-blog-common</artifactId>
<jar>jboss-blog-common.jar</jar>
</dependency>
+
+ <dependency>
+ <groupId>shotoku-cache</groupId>
+ <artifactId>shotoku-cache</artifactId>
+ <jar>shotoku-cache.jar</jar>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss-cache</groupId>
+ <artifactId>jboss-cache</artifactId>
+ <jar>jboss-cache.jar</jar>
+ </dependency>
+
+ <dependency>
+ <groupId>jgroups</groupId>
+ <artifactId>jgroups</artifactId>
+ <jar>jgroups.jar</jar>
+ </dependency>
</dependencies>
<build>
Modified: labs/shotoku/trunk/shotoku-base/src/etc/shotoku.properties.sample
===================================================================
--- labs/shotoku/trunk/shotoku-base/src/etc/shotoku.properties.sample 2007-08-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-base/src/etc/shotoku.properties.sample 2007-08-14 16:51:44 UTC (rev 14217)
@@ -41,12 +41,6 @@
# the client
shotoku.transfer.buffer.size = 1024
-# Interval between service (and cache) updates, in milliseconds
-shotoku.service.interval = 10000
-
-# Number of created update threads (used for updating cache items)
-shotoku.updatethread.count = 10
-
#
# Feeds configuration
# -------------------
Modified: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java
===================================================================
--- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java 2007-08-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java 2007-08-14 16:51:44 UTC (rev 14217)
@@ -444,16 +444,6 @@
private static int transferBufferSize;
/**
- * Default interval of the Shotoku service.
- */
- private static int defaultServiceInterval;
-
- /**
- * Default update thread count.
- */
- private static int defaultUpdateThreadCount;
-
- /**
* Map (content manager impl class name -> content manager constructor).
*/
private static Map<String, Constructor> contentManagers;
@@ -550,13 +540,6 @@
transferBufferSize = props.getInt(
Constants.PROPERTIES_TRANSFER_BUF_SIZE,
Constants.DEFAULT_TRANSFER_BUF_SIZE);
- defaultServiceInterval = props.getInt(
- Constants.PROPERTIES_SERVICE_INTERVAL,
- Constants.DEFAULT_SERVICE_INTERVAL);
- defaultUpdateThreadCount = props.getInt(
- Constants.PROPERTIES_UPDATETHREAD_COUNT,
- Constants.DEFAULT_UPDATETHREAD_COUNT);
-
// Getting ids of defined content managers.
String[] ids = props.getStringArray(Constants.PROPERTIES_IDS);
@@ -811,22 +794,4 @@
public static int getTransferBufferSize() {
return transferBufferSize;
}
-
- /**
- * Gets the default Shotoku service interval.
- *
- * @return Default Shotoku service interval.
- */
- public static int getDefaultServiceInterval() {
- return defaultServiceInterval;
- }
-
- /**
- * Getst the default update thread count.
- *
- * @return Default update thread count.
- */
- public static int getDefaultUpdateThreadCount() {
- return defaultUpdateThreadCount;
- }
}
Deleted: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuCache.java
===================================================================
--- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuCache.java 2007-08-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuCache.java 2007-08-14 16:51:44 UTC (rev 14217)
@@ -1,56 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., 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;
-
-import org.jboss.shotoku.tools.Tools;
-
-/**
- * A global cache.
- * @author Adam Warski (adamw at aster.pl)
- */
-public class ShotokuCache {
- /**
- * Places the given object in the cache, binding it with the given key.
- * @param key Key for the object.
- * @param o Object to place in the cache.
- */
- public static void put(Object key, Object o) {
- Tools.getService().put(key, o);
- }
-
- /**
- * Gets an object from the cache, which is bound to the given key.
- * @param key Key for which to get the object.
- * @return Object bound with the given key, or null this key is not bound.
- */
- public static Object get(Object key) {
- return Tools.getService().get(key);
- }
-
- /**
- * Removes a binding for the key in the cache, in one exists.
- * @param key Key to remove.
- */
- public static void remove(Object key) {
- Tools.getService().remove(key);
- }
-}
Modified: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuCacheItem.java
===================================================================
--- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuCacheItem.java 2007-08-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuCacheItem.java 2007-08-14 16:51:44 UTC (rev 14217)
@@ -21,13 +21,7 @@
*/
package org.jboss.shotoku.cache;
-import org.jboss.shotoku.tools.Tools;
-import org.jboss.shotoku.tools.Pair;
-import org.jboss.shotoku.tools.ConcurrentSet;
-import org.jboss.shotoku.tools.ConcurrentHashSet;
-import org.jboss.shotoku.exceptions.CacheException;
import org.jboss.shotoku.ContentManager;
-import org.jboss.shotoku.service.ShotokuService;
import java.util.*;
@@ -42,14 +36,8 @@
* @param <T> Type of the object that will be stored in the cache.
* @author Adam Warski (adamw at aster.pl)
*/
-public abstract class ShotokuCacheItem<K, T> {
- private String keyBase;
- private ConcurrentSet<K> keys;
- private ConcurrentSet<K> keysDuringUpdate;
+public abstract class ShotokuCacheItem<K, T> extends RenewableCacheItem<K, T> {
private final Map<K, ContentManager> cmForKeys = new HashMap<K, ContentManager>();
- private long lastUpdate;
- private long interval;
- private ShotokuService service;
/**
*
@@ -58,131 +46,14 @@
* the service timer interval. The interval should be given in milliseconds.
*/
public ShotokuCacheItem(long interval) {
- this.keyBase = Tools.getService().getNextKeyBase();
- this.interval = interval;
-
- lastUpdate = 0;
- keys = new ConcurrentHashSet<K>();
- keysDuringUpdate = new ConcurrentHashSet<K>();
-
- service = Tools.getService();
-
- service.register(this);
+ super(null, null, interval, 0);
}
public ShotokuCacheItem() {
this(0);
}
- private Pair<String, K> createKey(K key) {
- return new Pair<String, K>(keyBase, key);
- }
-
/**
- * Binds the given key with the given object in the cache. The real key to
- * which the object will be bound is: keyBase/key.
- * @param key Key of the object.
- * @param object Object that should be bound.
- * @throws CacheException
- */
- public final void put(K key, T object) throws CacheException {
- if (!keys.contains(key)) {
- throw new CacheException("Key " + key + " is not handled by this " +
- "ShotokuCacheItem.");
- }
-
- ShotokuCache.put(createKey(key), object);
- }
-
- /**
- * Gets an object that is bound to the given key in the cache.
- * 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.
- */
- @SuppressWarnings("unchecked")
- public final T get(K key) {
- synchronized(this) {
- if (!keys.contains(key)) {
- T ret = init(key);
- ShotokuCache.put(createKey(key), ret);
-
- // We have to initialize a new object.
- keys.add(key);
-
- return ret;
- }
- }
-
- return (T) ShotokuCache.get(createKey(key));
- }
-
- /**
- * Removes all keys handled by this ShotokuCacheItem from the cache.
- */
- public final void remove() {
- for (K key : keys) {
- ShotokuCache.remove(createKey(key));
- }
- }
-
- /**
- * Called by the Shotoku service. You shouldn't call it from inside your
- * program.
- */
- public final void update() {
- long now = Calendar.getInstance().getTimeInMillis();
-
- if (now - lastUpdate >= interval) {
- for (final K key : keys) {
- if (keysDuringUpdate.add(key)) {
- service.acquireUpdateThread().setAndSignalData(new UpdateThreadData() {
- public void execute() {
- try {
- update(key, get(key));
- service.touch(createKey(key));
- } finally {
- keysDuringUpdate.remove(key);
- }
- }
- });
- }
- }
-
- lastUpdate = now;
- }
- }
-
- /**
- * Notifies the cache item that it should reset its set of keys that
- * are during update, most probably beacuse the managing service has
- * been restarted (so updates of all keys that have been updated got
- * interrupted).
- */
- public void resetKeysDuringUpdate() {
- keysDuringUpdate.clear();
- }
-
- /**
- * Called by the service periodically to update the object held.
- * If the object in the cache should be changed, the implementing
- * method must call put(key, newObject).
- * @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
- * before, and thus, which hasn't been yet initialized. Here,
- * put(key, initialObject) should not 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.
- */
- public abstract T init(K key);
-
- /**
* Use this to bind a content manager with a key. There will always be
* at most one content manager for each key. On first call for a given
* key, initContentManager(key) will be called.
Deleted: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/UpdateThread.java
===================================================================
--- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/UpdateThread.java 2007-08-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/UpdateThread.java 2007-08-14 16:51:44 UTC (rev 14217)
@@ -1,66 +0,0 @@
-package org.jboss.shotoku.cache;
-
-import org.jboss.shotoku.service.ShotokuService;
-import org.jboss.shotoku.service.AdministratedService;
-import org.apache.log4j.Logger;
-
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-
-/**
- * @author Adam Warski (adamw at aster.pl)
- */
-public class UpdateThread extends Thread {
- private static final Logger log =
- Logger.getLogger(AdministratedService.class);
-
- private ShotokuService service;
- private BlockingQueue<UpdateThreadData> queue;
- private boolean runnable;
-
- public UpdateThread(ShotokuService service) {
- this.service = service;
-
- queue = new LinkedBlockingQueue<UpdateThreadData>();
- runnable = true;
-
- setDaemon(true);
- }
-
- public void setAndSignalData(UpdateThreadData data) {
- queue.offer(data);
- }
-
- public void signalExit() {
- setAndSignalData(new UpdateThreadData() {
- public void execute() { runnable = false; }
- });
- }
-
- public void run() {
- while (true) {
- UpdateThreadData data;
- try {
- data = queue.take();
-
- try {
- data.execute();
- } catch (Throwable t) {
- log.error("Exception while executing an update thread data.", t);
- }
-
- // Data may have been set and signaled just to notify the thread
- // to exit.
- if (!runnable) {
- break;
- }
- } catch (InterruptedException e) {
- log.error("Update thread interrupted.", e);
- }
-
- service.releaseUpdateThread(this);
- }
-
- service.updateThreadExited(this);
- }
-}
Deleted: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/UpdateThreadData.java
===================================================================
--- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/UpdateThreadData.java 2007-08-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/UpdateThreadData.java 2007-08-14 16:51:44 UTC (rev 14217)
@@ -1,9 +0,0 @@
-package org.jboss.shotoku.cache;
-
-/**
- * Function that should be executed by an update thread.
- * @author Adam Warski (adamw at aster.pl)
- */
-public abstract class UpdateThreadData {
- public abstract void execute();
-}
Modified: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuService.java
===================================================================
--- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuService.java 2007-08-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuService.java 2007-08-14 16:51:44 UTC (rev 14217)
@@ -21,9 +21,6 @@
*/
package org.jboss.shotoku.service;
-import org.jboss.shotoku.cache.ShotokuCacheItem;
-import org.jboss.shotoku.cache.UpdateThread;
-
import java.util.Set;
/**
@@ -31,30 +28,6 @@
* @author Adam Warski (adamw at aster.pl)
*/
public interface ShotokuService extends AdministratedService {
- /*
- * CACHE
- */
-
- public Object get(Object key);
- public void put(Object key, Object o);
- /**
- * 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 touch(Object key);
- public void register(ShotokuCacheItem cacheItem);
- public void remove(Object key);
-
- /**
- * Gets a next unique key base for a shotoku cache item.
- */
- public String getNextKeyBase();
-
- public UpdateThread acquireUpdateThread();
- public void releaseUpdateThread(UpdateThread ut);
- public void updateThreadExited(UpdateThread ut);
-
public void addAdministratedService(AdministratedServiceGetter asg);
public Set<AdministratedServiceGetter> getAdministratedServices();
}
Deleted: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/ConcurrentHashSet.java
===================================================================
--- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/ConcurrentHashSet.java 2007-08-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/ConcurrentHashSet.java 2007-08-14 16:51:44 UTC (rev 14217)
@@ -1,86 +0,0 @@
-package org.jboss.shotoku.tools;
-
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.Iterator;
-import java.util.Collection;
-
-/**
- * @author Adam Warski (adamw at aster.pl)
- */
-public class ConcurrentHashSet<K> implements ConcurrentSet<K> {
- private ConcurrentMap<K, Boolean> map;
-
- public ConcurrentHashSet() {
- map = new ConcurrentHashMap<K, Boolean>();
- }
-
- public int size() {
- return map.size();
- }
-
- public boolean isEmpty() {
- return map.isEmpty();
- }
-
- public boolean contains(Object o) {
- return map.containsKey(o);
- }
-
- public Iterator<K> iterator() {
- return map.keySet().iterator();
- }
-
- public Object[] toArray() {
- return map.keySet().toArray();
- }
-
- public <T>T[] toArray(T[] a) {
- return map.keySet().toArray(a);
- }
-
- public boolean add(K o) {
- return map.putIfAbsent(o, Boolean.TRUE) == null;
- }
-
- public boolean remove(Object o) {
- return map.keySet().remove(o);
- }
-
- public boolean containsAll(Collection<?> c) {
- return map.keySet().containsAll(c);
- }
-
- public boolean addAll(Collection<? extends K> c) {
- boolean ret = false;
- for (K o : c) {
- ret |= add(o);
- }
-
- return ret;
- }
-
- public boolean retainAll(Collection<?> c) {
- boolean ret = false;
- for (Object o : c) {
- if (!map.containsKey(o)) {
- map.remove(o);
- }
- }
-
- return ret;
- }
-
- public boolean removeAll(Collection<?> c) {
- boolean ret = false;
- for (Object o : c) {
- ret |= remove(o);
- }
-
- return ret;
- }
-
- public void clear() {
- map.clear();
- }
-}
Deleted: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/ConcurrentSet.java
===================================================================
--- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/ConcurrentSet.java 2007-08-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/ConcurrentSet.java 2007-08-14 16:51:44 UTC (rev 14217)
@@ -1,10 +0,0 @@
-package org.jboss.shotoku.tools;
-
-import java.util.Set;
-
-/**
- * @author Adam Warski (adamw at aster.pl)
- */
-public interface ConcurrentSet<K> extends Set<K> {
-
-}
Modified: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Constants.java
===================================================================
--- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Constants.java 2007-08-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Constants.java 2007-08-14 16:51:44 UTC (rev 14217)
@@ -35,8 +35,6 @@
public static final String PROPERTIES_EMBEDDED = PROPERTIES_PREFIX + ".embedded";
public static final String PROPERTIES_TRANSFER_BUF_SIZE = PROPERTIES_PREFIX + ".transfer.buffer.size";
- public static final String PROPERTIES_SERVICE_INTERVAL = PROPERTIES_PREFIX + ".service.interval";
- public static final String PROPERTIES_UPDATETHREAD_COUNT = PROPERTIES_PREFIX + ".updatethread.count";
private static final String VELOCITY_RL = "shotoku.resource.loader";
public static final String VELOCITY_RL_PREFIX = VELOCITY_RL + ".prefix";
@@ -50,8 +48,6 @@
*/
public static final String DEFAULT_ID = "default";
public static final int DEFAULT_TRANSFER_BUF_SIZE = 1024;
- public static final int DEFAULT_SERVICE_INTERVAL = 5000;
- public static final int DEFAULT_UPDATETHREAD_COUNT = 10;
/**
* <code>SHOTOKU_SERVICE_NAME</code> - name under which the shotoku service is
Deleted: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/KeyValue.java
===================================================================
--- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/KeyValue.java 2007-08-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/KeyValue.java 2007-08-14 16:51:44 UTC (rev 14217)
@@ -1,39 +0,0 @@
-package org.jboss.shotoku.tools;
-
-/**
- * A pair of objects, but only the first one is considered in the equals()
- * and hashCode() methods.
- * @param <T1>
- * @param <T2>
- * @author Adam Warski (adamw at aster.pl)
- */
-public class KeyValue<T1, T2> {
- private T1 obj1;
- private T2 obj2;
-
- public KeyValue(T1 obj1, T2 obj2) {
- this.obj1 = obj1;
- this.obj2 = obj2;
- }
-
- public T1 getFirst() {
- return obj1;
- }
-
- public T2 getSecond() {
- return obj2;
- }
-
- public boolean equals(Object o) {
- if (o instanceof KeyValue) {
- KeyValue p = (KeyValue) o;
- return p.getFirst().equals(obj1);
- }
-
- return false;
- }
-
- public int hashCode() {
- return obj1.hashCode();
- }
-}
Deleted: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Pair.java
===================================================================
--- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Pair.java 2007-08-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Pair.java 2007-08-14 16:51:44 UTC (rev 14217)
@@ -1,63 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., 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.tools;
-
-/**
- * A pair of objects.
- * @param <T1>
- * @param <T2>
- * @author Adam Warski (adamw at aster.pl)
- */
-public class Pair<T1, T2> {
- private T1 obj1;
- private T2 obj2;
-
- public Pair(T1 obj1, T2 obj2) {
- this.obj1 = obj1;
- this.obj2 = obj2;
- }
-
- public T1 getFirst() {
- return obj1;
- }
-
- public T2 getSecond() {
- return obj2;
- }
-
- public boolean equals(Object o) {
- if (o instanceof Pair) {
- Pair p = (Pair) o;
- return p.getFirst().equals(obj1) && p.getSecond().equals(obj2);
- }
-
- return false;
- }
-
- public int hashCode() {
- return obj1.hashCode() + obj2.hashCode();
- }
-
- public String toString() {
- return "(" + obj1.toString() + ", " + obj2.toString() + ")";
- }
-}
Deleted: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Triple.java
===================================================================
--- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Triple.java 2007-08-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Triple.java 2007-08-14 16:51:44 UTC (rev 14217)
@@ -1,50 +0,0 @@
-package org.jboss.shotoku.tools;
-
-/**
- * A triple of objects.
- * @param <T1>
- * @param <T2>
- * @param <T3>
- * @author Adam Warski (adamw at aster.pl)
- */
-public class Triple<T1, T2, T3> {
- private T1 obj1;
- private T2 obj2;
- private T3 obj3;
-
- public Triple(T1 obj1, T2 obj2, T3 obj3) {
- this.obj1 = obj1;
- this.obj2 = obj2;
- this.obj3 = obj3;
- }
-
- public T1 getFirst() {
- return obj1;
- }
-
- public T2 getSecond() {
- return obj2;
- }
-
- public T3 getThird() {
- return obj3;
- }
-
- public boolean equals(Object o) {
- if (o instanceof Triple) {
- Triple t = (Triple) o;
- return t.getFirst().equals(obj1) && t.getSecond().equals(obj2)
- && t.getThird().equals(obj3);
- }
-
- return false;
- }
-
- public int hashCode() {
- return obj1.hashCode() + obj2.hashCode() + obj3.hashCode();
- }
-
- public String toString() {
- return "(" + obj1.toString() + ", " + obj2.toString()+ ", " + obj3.toString() + ")";
- }
-}
Deleted: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Tuples.java
===================================================================
--- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Tuples.java 2007-08-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Tuples.java 2007-08-14 16:51:44 UTC (rev 14217)
@@ -1,14 +0,0 @@
-package org.jboss.shotoku.tools;
-
-/**
- * @author Adam Warski (adamw at aster.pl)
- */
-public class Tuples {
- public static<A, B> Pair<A, B> tuple(A a, B b) {
- return new Pair<A, B>(a, b);
- }
-
- public static<A, B, C> Triple<A, B, C> tuple(A a, B b, C c) {
- return new Triple<A, B, C>(a, b, c);
- }
-}
Modified: labs/shotoku/trunk/shotoku-base-service/project.xml
===================================================================
--- labs/shotoku/trunk/shotoku-base-service/project.xml 2007-08-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-base-service/project.xml 2007-08-14 16:51:44 UTC (rev 14217)
@@ -32,6 +32,24 @@
<artifactId>jboss-annotations-ejb3</artifactId>
<jar>jboss-annotations-ejb3.jar</jar>
</dependency>
+
+ <dependency>
+ <groupId>shotoku-cache</groupId>
+ <artifactId>shotoku-cache</artifactId>
+ <jar>shotoku-cache.jar</jar>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss-cache</groupId>
+ <artifactId>jboss-cache</artifactId>
+ <jar>jboss-cache.jar</jar>
+ </dependency>
+
+ <dependency>
+ <groupId>jgroups</groupId>
+ <artifactId>jgroups</artifactId>
+ <jar>jgroups.jar</jar>
+ </dependency>
</dependencies>
<build>
Modified: labs/shotoku/trunk/shotoku-base-service/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java
===================================================================
--- labs/shotoku/trunk/shotoku-base-service/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java 2007-08-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-base-service/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java 2007-08-14 16:51:44 UTC (rev 14217)
@@ -26,17 +26,11 @@
import org.jboss.annotation.ejb.Management;
import org.jboss.annotation.ejb.Service;
import org.jboss.shotoku.ContentManager;
-import org.jboss.shotoku.cache.ShotokuCacheItem;
-import org.jboss.shotoku.cache.UpdateThread;
import org.jboss.shotoku.tools.Constants;
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.concurrent.ConcurrentMap;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.LinkedBlockingQueue;
import java.util.Set;
/**
@@ -62,180 +56,25 @@
*/
ContentManager.setup();
- log.info("ContentManager setup completed. Getting the default service timer interval...");
- updateThreadCount = ContentManager.getDefaultUpdateThreadCount();
+ log.info("ContentManager setup completed.");
- setTimerInterval(ContentManager.getDefaultServiceInterval());
-
super.afterCreate();
}
public void start() throws Exception {
- super.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 (ShotokuCacheItem sci : cacheItems) {
- sci.resetKeysDuringUpdate();
- }
-
- super.afterStart();
}
public void stop() {
- super.stop();
-
- signalExitAllUpdateThreads();
- toRemove = 0;
- log.info("All update threads stopped.");
}
public void destroy() {
-
}
/*
- * Cache handling
- */
-
- private final ConcurrentMap<Object, Object> cache =
- new ConcurrentHashMap<Object, Object>();
- private final ConcurrentSet<ShotokuCacheItem> cacheItems =
- new ConcurrentHashSet<ShotokuCacheItem>();
- private final ConcurrentMap<Object, Long> lastUpdates =
- new ConcurrentHashMap<Object, Long>();
-
- public Object get(Object key) {
- Object ret = cache.get(key);
- if (Null.getInstance().equals(ret)) {
- return null;
- } else {
- return ret;
- }
- }
-
- public void put(Object key, Object o) {
- touch(key);
-
- if (o == null) {
- cache.put(key, Null.getInstance());
- } else {
- cache.put(key, o);
- }
- }
-
- public void touch(Object key) {
- lastUpdates.put(key, System.currentTimeMillis());
- }
-
- public void remove(Object key) {
- cache.remove(key);
- }
-
- public void register(ShotokuCacheItem cacheItem) {
- cacheItems.add(cacheItem);
- }
-
- private int counter = 0;
- private final Object counterSync = new Object();
-
- public String getNextKeyBase() {
- int c;
- synchronized(counterSync) { c = counter++; }
-
- return Constants.SHOTOKU_CACHE_KEY_BASE + c;
- }
-
- /*
- * Update threads management.
- */
-
- private final ConcurrentSet<UpdateThread> allUpdateThreads =
- new ConcurrentHashSet<UpdateThread>();
- private final LinkedBlockingQueue<UpdateThread> updateThreads =
- new LinkedBlockingQueue<UpdateThread>();
- private int updateThreadCount;
- /**
- * Number of threads that should be removed, instead of returned
- */
- private volatile int toRemove = 0;
-
- public int getUpdateThreadsCount() {
- return updateThreads.size();
- }
-
- public void setUpdateThreadCount(int n) {
- synchronized (updateThreads) {
- int current = updateThreads.size();
-
- if (current < n) {
- for (int i=current; i<n; i++) {
- UpdateThread ut = new UpdateThread(this);
- updateThreads.offer(ut);
- allUpdateThreads.add(ut);
- ut.start();
- }
- } else if (n < current) {
- toRemove += current - n;
- }
- }
-
- log.info("Update thread count set to: " + n + ".");
- updateThreadCount = n;
- }
-
- public UpdateThread acquireUpdateThread() {
- try {
- return updateThreads.take();
- } catch (InterruptedException e) {
- log.error("Error while acquireing an update thread (interrupted).", e);
- return null;
- }
- }
-
- public void releaseUpdateThread(UpdateThread ut) {
- if (toRemove != 0) {
- synchronized (updateThreads) {
- if (toRemove != 0) {
- ut.signalExit();
- toRemove--;
- return;
- }
- }
- }
-
- updateThreads.offer(ut);
- }
-
- public void updateThreadExited(UpdateThread ut) {
- allUpdateThreads.remove(ut);
- }
-
- private void signalExitAllUpdateThreads() {
- for (UpdateThread ut : allUpdateThreads) {
- ut.signalExit();
- }
- }
-
- /*
* Update function.
*/
public void update() {
- for (ShotokuCacheItem sci : cacheItems) {
- try {
- sci.update();
- } catch (Throwable t) {
- log.error("Exception while updating a cache item.", t);
- }
- }
}
/*
@@ -255,25 +94,7 @@
}
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 (ShotokuCacheItem 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/ChangeType.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/ChangeType.java 2007-08-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/ChangeType.java 2007-08-14 16:51:44 UTC (rev 14217)
@@ -1,35 +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;
-
-/**
- * Describes the possible type of changes which can be made on a
- * resource.
- * @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
- */
-public enum ChangeType {
- MODIFIED,
- ADDED,
- DELETED,
- NONE
-}
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-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/RenewableCacheItem.java 2007-08-14 16:51:44 UTC (rev 14217)
@@ -25,7 +25,7 @@
import org.apache.log4j.Logger;
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
-import org.jboss.shotoku.tools.Tools;
+import org.jboss.shotoku.tools.CacheTools;
import org.jboss.shotoku.tools.ConcurrentSet;
import org.jboss.shotoku.tools.ConcurrentHashSet;
import org.jboss.shotoku.cache.service.DummyRenewableCacheService;
@@ -94,7 +94,7 @@
*/
public RenewableCacheItem(Fqn fqn, String mbeanName, long interval, long timeout) {
if (mbeanName == null) {
- mbeanName = Tools.DEFAULT_RENEWABLE_CACHE_MBEAN;
+ mbeanName = CacheTools.DEFAULT_RENEWABLE_CACHE_MBEAN;
}
this.mbeanName = mbeanName;
@@ -136,7 +136,7 @@
keysDuringUpdate.clear();
try {
- service = Tools.getService(mbeanName);
+ service = CacheTools.getService(mbeanName);
} catch (MalformedObjectNameException e) {
log.error("No RenewableCacheService bound to "
+ mbeanName + " in cache item "
Added: labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/service/DummyRenewableCacheService.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/service/DummyRenewableCacheService.java (rev 0)
+++ labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/service/DummyRenewableCacheService.java 2007-08-14 16:51:44 UTC (rev 14217)
@@ -0,0 +1,88 @@
+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;
+
+/**
+ * A dummy (containing no-ops) implementation of the
+ * {@link RenewableCacheService}.
+ * @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
+ */
+public class DummyRenewableCacheService implements RenewableCacheServiceMBean {
+ public void addUpdateThreadData(UpdateThreadData data) {
+ }
+
+ public Fqn generateNextFqn() {
+ return null;
+ }
+
+ public Object get(Fqn fqn, Object key) throws CacheException {
+ return null;
+ }
+
+ public long getInterval() {
+ return 0;
+ }
+
+ public long getLastUpdate() {
+ return 0;
+ }
+
+ public String getServiceDescription() {
+ return null;
+ }
+
+ public TreeCacheMBean getTreeCache() {
+ return null;
+ }
+
+ public int getUpdateThreadCount() {
+ return 0;
+ }
+
+ public Date lastUpdateDate() {
+ return null;
+ }
+
+ public long lastUpdateSecondsAgo() {
+ return 0;
+ }
+
+ public void put(Fqn fqn, Object key, Object o) throws CacheException {
+ }
+
+ public void register(RenewableCacheItem cacheItem) {
+ }
+
+ public void remove(Fqn fqn, Object key) throws CacheException {
+ }
+
+ public void setInterval(long interval) {
+ }
+
+ public void setLastUpdate(long lastUpdate) {
+ }
+
+ public void setTreeCache(TreeCacheMBean treeCache) {
+ }
+
+ public void setUpdateThreadCount(int n) {
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+ public void unregister(RenewableCacheItem cacheItem) throws CacheException {
+ }
+
+ public void update() {
+ }
+}
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-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/cache/service/RenewableCacheService.java 2007-08-14 16:51:44 UTC (rev 14217)
@@ -31,7 +31,7 @@
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.shotoku.tools.CacheTools;
import org.apache.log4j.Logger;
import java.util.Calendar;
@@ -184,7 +184,7 @@
int c;
synchronized(counterSync) { c = counter++; }
- return new Fqn(new Object[] {Tools.GENERATED_FQN_BASE, c});
+ return new Fqn(new Object[] {CacheTools.GENERATED_FQN_BASE, c});
}
/*
Added: labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/tools/CacheTools.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/tools/CacheTools.java (rev 0)
+++ labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/tools/CacheTools.java 2007-08-14 16:51:44 UTC (rev 14217)
@@ -0,0 +1,108 @@
+/******************************************************************************
+ * 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.tools;
+
+import javax.management.MalformedObjectNameException;
+
+import org.jboss.mx.util.MBeanProxyExt;
+import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.shotoku.cache.service.RenewableCacheServiceMBean;
+
+/**
+ * Utility, helper functions used internally.
+ *
+ * @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
+ */
+public class CacheTools {
+ /**
+ * The first part of automatically generated fqn-s for cache item nodes.
+ */
+ public static final String GENERATED_FQN_BASE = "ShotokuRenewableCache";
+
+ /**
+ * Name of the default {@link RenewableCacheServiceMBean} mbean.
+ */
+ public static final String DEFAULT_RENEWABLE_CACHE_MBEAN = "shotoku:service=RenewableCache";
+
+ /**
+ * Gets a reference to an mbean with the given name.
+ * @param mbeanName Name of the mbean to get.
+ * @return A reference to the mbean.
+ * @throws MalformedObjectNameException
+ */
+ public static RenewableCacheServiceMBean getService(String mbeanName) throws MalformedObjectNameException {
+ return (RenewableCacheServiceMBean) MBeanProxyExt.create(
+ RenewableCacheServiceMBean.class, mbeanName,
+ MBeanServerLocator.locate());
+ }
+
+ /**
+ * Checks if the given string is empty (null or "").
+ *
+ * @param s String to check.
+ * @return True iff the given string is null or equal to "".
+ */
+ public static boolean isEmpty(String s) {
+ return (s == null) || ("".equals(s));
+ }
+
+ /**
+ * Converts the given object to a String in a null-safe way.
+ * @param o Object to convert.
+ * @return Result of o.toString() or null if o is null.
+ */
+ public static String toString(Object o) {
+ if (o == null) {
+ return null;
+ }
+
+ return o.toString();
+ }
+
+ /**
+ * Converts the given object to a String in a null-safe way.
+ * Never returns a null.
+ * @param o Object to convert.
+ * @return Result of o.toString() or an emptys tring if o is null.
+ */
+ public static String toStringNotNull(Object o) {
+ if (o == null) {
+ return "";
+ }
+
+ return o.toString();
+ }
+
+ /**
+ * Checks if two objects are equal - either both null, or
+ * their equals method returns true.
+ * @param obj1 First object to compare.
+ * @param obj2 Second object to compare.
+ * @return True iff both objects are equal to null or if
+ * their equals method returns true.
+ */
+ public static boolean objectsEqual(Object obj1, Object obj2) {
+ return (obj1 == null && obj2 == null) ||
+ ((obj1 != null) && (obj1.equals(obj2)));
+ }
+}
Deleted: 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-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-cache/src/java/org/jboss/shotoku/tools/Tools.java 2007-08-14 16:51:44 UTC (rev 14217)
@@ -1,108 +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.tools;
-
-import javax.management.MalformedObjectNameException;
-
-import org.jboss.mx.util.MBeanProxyExt;
-import org.jboss.mx.util.MBeanServerLocator;
-import org.jboss.shotoku.cache.service.RenewableCacheServiceMBean;
-
-/**
- * Utility, helper functions used internally.
- *
- * @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
- */
-public class Tools {
- /**
- * The first part of automatically generated fqn-s for cache item nodes.
- */
- public static final String GENERATED_FQN_BASE = "ShotokuRenewableCache";
-
- /**
- * Name of the default {@link RenewableCacheServiceMBean} mbean.
- */
- public static final String DEFAULT_RENEWABLE_CACHE_MBEAN = "shotoku:service=RenewableCache";
-
- /**
- * Gets a reference to an mbean with the given name.
- * @param mbeanName Name of the mbean to get.
- * @return A reference to the mbean.
- * @throws MalformedObjectNameException
- */
- public static RenewableCacheServiceMBean getService(String mbeanName) throws MalformedObjectNameException {
- return (RenewableCacheServiceMBean) MBeanProxyExt.create(
- RenewableCacheServiceMBean.class, mbeanName,
- MBeanServerLocator.locate());
- }
-
- /**
- * Checks if the given string is empty (null or "").
- *
- * @param s String to check.
- * @return True iff the given string is null or equal to "".
- */
- public static boolean isEmpty(String s) {
- return (s == null) || ("".equals(s));
- }
-
- /**
- * Converts the given object to a String in a null-safe way.
- * @param o Object to convert.
- * @return Result of o.toString() or null if o is null.
- */
- public static String toString(Object o) {
- if (o == null) {
- return null;
- }
-
- return o.toString();
- }
-
- /**
- * Converts the given object to a String in a null-safe way.
- * Never returns a null.
- * @param o Object to convert.
- * @return Result of o.toString() or an emptys tring if o is null.
- */
- public static String toStringNotNull(Object o) {
- if (o == null) {
- return "";
- }
-
- return o.toString();
- }
-
- /**
- * Checks if two objects are equal - either both null, or
- * their equals method returns true.
- * @param obj1 First object to compare.
- * @param obj2 Second object to compare.
- * @return True iff both objects are equal to null or if
- * their equals method returns true.
- */
- public static boolean objectsEqual(Object obj1, Object obj2) {
- return (obj1 == null && obj2 == null) ||
- ((obj1 != null) && (obj1.equals(obj2)));
- }
-}
Modified: labs/shotoku/trunk/shotoku-feeds/project.xml
===================================================================
--- labs/shotoku/trunk/shotoku-feeds/project.xml 2007-08-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-feeds/project.xml 2007-08-14 16:51:44 UTC (rev 14217)
@@ -120,6 +120,24 @@
<war.bundle>true</war.bundle>
</properties>
</dependency>
+
+ <dependency>
+ <groupId>shotoku-cache</groupId>
+ <artifactId>shotoku-cache</artifactId>
+ <jar>shotoku-cache.jar</jar>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss-cache</groupId>
+ <artifactId>jboss-cache</artifactId>
+ <jar>jboss-cache.jar</jar>
+ </dependency>
+
+ <dependency>
+ <groupId>jgroups</groupId>
+ <artifactId>jgroups</artifactId>
+ <jar>jgroups.jar</jar>
+ </dependency>
</dependencies>
<build>
Modified: labs/shotoku/trunk/shotoku-file-access/project.xml
===================================================================
--- labs/shotoku/trunk/shotoku-file-access/project.xml 2007-08-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-file-access/project.xml 2007-08-14 16:51:44 UTC (rev 14217)
@@ -53,6 +53,24 @@
<war.bundle>true</war.bundle>
</properties>
</dependency>
+
+ <dependency>
+ <groupId>shotoku-cache</groupId>
+ <artifactId>shotoku-cache</artifactId>
+ <jar>shotoku-cache.jar</jar>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss-cache</groupId>
+ <artifactId>jboss-cache</artifactId>
+ <jar>jboss-cache.jar</jar>
+ </dependency>
+
+ <dependency>
+ <groupId>jgroups</groupId>
+ <artifactId>jgroups</artifactId>
+ <jar>jgroups.jar</jar>
+ </dependency>
</dependencies>
<build>
Modified: labs/shotoku/trunk/shotoku-svn/project.xml
===================================================================
--- labs/shotoku/trunk/shotoku-svn/project.xml 2007-08-14 16:49:45 UTC (rev 14216)
+++ labs/shotoku/trunk/shotoku-svn/project.xml 2007-08-14 16:51:44 UTC (rev 14217)
@@ -18,6 +18,24 @@
<artifactId>shotoku-base</artifactId>
<jar>shotoku-base.jar</jar>
</dependency>
+
+ <dependency>
+ <groupId>shotoku-cache</groupId>
+ <artifactId>shotoku-cache</artifactId>
+ <jar>shotoku-cache.jar</jar>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss-cache</groupId>
+ <artifactId>jboss-cache</artifactId>
+ <jar>jboss-cache.jar</jar>
+ </dependency>
+
+ <dependency>
+ <groupId>jgroups</groupId>
+ <artifactId>jgroups</artifactId>
+ <jar>jgroups.jar</jar>
+ </dependency>
</dependencies>
<build>
More information about the jboss-svn-commits
mailing list