[jboss-svn-commits] JBL Code SVN: r14628 - in labs/shotoku/trunk/shotoku-cache: cache-admin and 6 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Aug 27 03:19:20 EDT 2007
Author: adamw
Date: 2007-08-27 03:19:20 -0400 (Mon, 27 Aug 2007)
New Revision: 14628
Added:
labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/UnregisteredException.java
Removed:
labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/DummyRenewableCacheService.java
Modified:
labs/shotoku/trunk/shotoku-cache/build.xml
labs/shotoku/trunk/shotoku-cache/cache-admin/build.xml
labs/shotoku/trunk/shotoku-cache/cache-base/
labs/shotoku/trunk/shotoku-cache/cache-base/build.xml
labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/CacheItem.java
labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/CacheAlert.java
labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/CacheAlertFactory.java
labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/CacheAlertImpl.java
labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/DummyRenewableCacheMonitorService.java
labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/RenewableCacheMonitorServiceMBean.java
labs/shotoku/trunk/shotoku-cache/cache-service/build.xml
labs/shotoku/trunk/shotoku-cache/cache-test/build.xml
Log:
Start/stop of service
Modified: labs/shotoku/trunk/shotoku-cache/build.xml
===================================================================
--- labs/shotoku/trunk/shotoku-cache/build.xml 2007-08-27 06:05:07 UTC (rev 14627)
+++ labs/shotoku/trunk/shotoku-cache/build.xml 2007-08-27 07:19:20 UTC (rev 14628)
@@ -16,6 +16,7 @@
<property name="src.web" value="${src}/web"/>
<property name="build" value="build"/>
<property name="dist" value="dist"/>
+ <property name="docs" value="docs"/>
<!-- Dependency jars filesets definitions -->
<fileset id="jboss.lib.1" dir="${jboss.lib}">
@@ -83,4 +84,10 @@
<param name="modules.list" value="cache-admin" />
</antcall>
</target>
+
+ <target name="docs">
+ <antcall target="each-module">
+ <param name="target.name" value="docs" />
+ </antcall>
+ </target>
</project>
Modified: labs/shotoku/trunk/shotoku-cache/cache-admin/build.xml
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-admin/build.xml 2007-08-27 06:05:07 UTC (rev 14627)
+++ labs/shotoku/trunk/shotoku-cache/cache-admin/build.xml 2007-08-27 07:19:20 UTC (rev 14628)
@@ -62,4 +62,8 @@
<target name="undeploy">
<delete file="${jboss.deploy}/${war.name}" />
</target>
+
+ <target name="docs">
+
+ </target>
</project>
Property changes on: labs/shotoku/trunk/shotoku-cache/cache-base
___________________________________________________________________
Name: svn:ignore
- .classpath
.project
.settings
build
target
bin
dist
+ docs
.classpath
.project
.settings
build
target
bin
dist
Modified: labs/shotoku/trunk/shotoku-cache/cache-base/build.xml
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/build.xml 2007-08-27 06:05:07 UTC (rev 14627)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/build.xml 2007-08-27 07:19:20 UTC (rev 14628)
@@ -47,4 +47,14 @@
<target name="undeploy">
<delete file="${jboss.lib}/${jar.name}" />
</target>
+
+ <target name="docs">
+ <mkdir dir="${docs}" />
+
+ <javadoc destdir="${docs}">
+ <fileset dir="${src.java}" defaultexcludes="yes">
+ <include name="**/*"/>
+ </fileset>
+ </javadoc>
+ </target>
</project>
Modified: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/CacheItem.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/CacheItem.java 2007-08-27 06:05:07 UTC (rev 14627)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/CacheItem.java 2007-08-27 07:19:20 UTC (rev 14628)
@@ -28,7 +28,6 @@
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;
import org.jboss.shotoku.cache.service.RenewableCacheServiceMBean;
import java.util.*;
@@ -66,6 +65,11 @@
private String mbeanName;
private int id;
+ /**
+ * A flag that indicates if this cache item is registered.
+ */
+ private volatile boolean registered;
+
private ConcurrentMap<K, Long> keysUpdates;
/**
* Double-update-start prevention: if a key is already in that set, it won't be updated.
@@ -164,6 +168,8 @@
}
service.register(this);
+
+ registered = true;
}
}
}
@@ -174,10 +180,11 @@
*/
public synchronized void unregister() {
try {
- RenewableCacheServiceMBean oldService = service;
- service = new DummyRenewableCacheService();
+ // Setting this flag blocks any put()s into the cache, as well as makes calling get()
+ // throw an exception.
+ registered = false;
- oldService.unregister(this);
+ service.unregister(this);
} catch (CacheException e) {
log.error("Error while unregistering a cache item " + this.getClass() + ".", e);
}
@@ -266,7 +273,7 @@
/**
* Binds the given key with the given object in the associated TreeCache
* node. Should be only called
- * from the {@link #update(Object, Object)} method to put new values in the
+ * from the {@link #update()} method to put new values in the
* cache (if not called during an update, this method has no effect).
* @param key Key of the object.
* @param object Object that should be bound.
@@ -276,6 +283,10 @@
return;
}
+ if (!registered) {
+ return;
+ }
+
try {
service.put(fqn, key, object);
} catch (CacheException e) {
@@ -294,6 +305,10 @@
if (!keysUpdates.containsKey(key)) {
T ret = dataSource.init(key);
try {
+ if (!registered) {
+ throw new UnregisteredException();
+ }
+
service.put(fqn, key, ret);
} catch (CacheException e) {
log.error("Error while putting a value for key \""
@@ -311,6 +326,10 @@
}
try {
+ if (!registered) {
+ throw new UnregisteredException();
+ }
+
return (T) service.get(fqn, key);
} catch (CacheException e) {
log.error("Error while getting a value for key \"" + key + "\" in cache item " + this.getClass() + ".", e);
@@ -338,6 +357,7 @@
if (change.hasValue()) {
put(key, change.getValue());
}
+ } catch (UnregisteredException e) {
} finally {
keysInUpdate.remove(key);
keysDuringUpdate.remove(key);
Added: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/UnregisteredException.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/UnregisteredException.java (rev 0)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/UnregisteredException.java 2007-08-27 07:19:20 UTC (rev 14628)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * 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;
+
+/**
+ *
+ * @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
+ */
+public class UnregisteredException extends RuntimeException {
+
+ public UnregisteredException() {
+ super();
+ }
+
+ public UnregisteredException(String arg0, Throwable arg1) {
+ super(arg0, arg1);
+ }
+
+ public UnregisteredException(String arg0) {
+ super(arg0);
+ }
+
+ public UnregisteredException(Throwable arg0) {
+ super(arg0);
+ }
+}
Deleted: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/DummyRenewableCacheService.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/DummyRenewableCacheService.java 2007-08-27 06:05:07 UTC (rev 14627)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/DummyRenewableCacheService.java 2007-08-27 07:19:20 UTC (rev 14628)
@@ -1,125 +0,0 @@
-package org.jboss.shotoku.cache.service;
-
-import java.util.Date;
-import java.util.Set;
-
-import org.jboss.cache.CacheException;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.TreeCacheMBean;
-import org.jboss.shotoku.cache.CacheItemOperations;
-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(CacheItemOperations<?,?> 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(CacheItemOperations<?,?> cacheItem) throws CacheException {
- }
-
- public void update() {
- }
-
- public Set<? extends CacheItemOperations<?,?>> getCacheItemsOperations() {
- return null;
- }
-
- public int getCurrentQueueSize() {
- return 0;
- }
-
- public RenewableCacheStatistics getStatistics() {
- return null;
- }
-
- public int getBusyThreadCount() {
- return 0;
- }
-
- public int getIdleThreadCount() {
- return 0;
- }
-
- public void reportThreadBusy() {
-
- }
-
- public void reportThreadIdle() {
-
- }
-
- public void reportThreadNew() {
-
- }
-
- public void reportThreadExit() {
-
- }
-}
Modified: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/CacheAlert.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/CacheAlert.java 2007-08-27 06:05:07 UTC (rev 14627)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/CacheAlert.java 2007-08-27 07:19:20 UTC (rev 14628)
@@ -1,3 +1,25 @@
+/******************************************************************************
+ * 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.monitor;
import org.jboss.shotoku.cache.CacheItem;
Modified: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/CacheAlertFactory.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/CacheAlertFactory.java 2007-08-27 06:05:07 UTC (rev 14627)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/CacheAlertFactory.java 2007-08-27 07:19:20 UTC (rev 14628)
@@ -1,3 +1,25 @@
+/******************************************************************************
+ * 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.monitor;
import java.io.ByteArrayOutputStream;
@@ -3,4 +25,8 @@
import java.io.PrintWriter;
+/**
+ *
+ * @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
+ */
public class CacheAlertFactory {
public static CacheAlert createAlertKeyNotUpdated(Object key) {
Modified: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/CacheAlertImpl.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/CacheAlertImpl.java 2007-08-27 06:05:07 UTC (rev 14627)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/CacheAlertImpl.java 2007-08-27 07:19:20 UTC (rev 14628)
@@ -1,3 +1,25 @@
+/******************************************************************************
+ * 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.monitor;
import java.text.DateFormat;
Modified: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/DummyRenewableCacheMonitorService.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/DummyRenewableCacheMonitorService.java 2007-08-27 06:05:07 UTC (rev 14627)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/DummyRenewableCacheMonitorService.java 2007-08-27 07:19:20 UTC (rev 14628)
@@ -1,3 +1,25 @@
+/******************************************************************************
+ * 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.monitor;
import java.util.HashSet;
@@ -7,6 +29,10 @@
import org.jboss.shotoku.cache.CacheItemOperations;
import org.jboss.shotoku.cache.service.RenewableCacheServiceMBean;
+/**
+ *
+ * @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
+ */
public class DummyRenewableCacheMonitorService implements RenewableCacheMonitorServiceMBean {
public void clearAlerts() {
Modified: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/RenewableCacheMonitorServiceMBean.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/RenewableCacheMonitorServiceMBean.java 2007-08-27 06:05:07 UTC (rev 14627)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/RenewableCacheMonitorServiceMBean.java 2007-08-27 07:19:20 UTC (rev 14628)
@@ -1,3 +1,25 @@
+/******************************************************************************
+ * 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.monitor;
import java.util.List;
Modified: labs/shotoku/trunk/shotoku-cache/cache-service/build.xml
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-service/build.xml 2007-08-27 06:05:07 UTC (rev 14627)
+++ labs/shotoku/trunk/shotoku-cache/cache-service/build.xml 2007-08-27 07:19:20 UTC (rev 14628)
@@ -58,4 +58,8 @@
<target name="undeploy">
<delete dir="${jboss.deploy}/${sar.name}" />
</target>
+
+ <target name="docs">
+
+ </target>
</project>
Modified: labs/shotoku/trunk/shotoku-cache/cache-test/build.xml
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-test/build.xml 2007-08-27 06:05:07 UTC (rev 14627)
+++ labs/shotoku/trunk/shotoku-cache/cache-test/build.xml 2007-08-27 07:19:20 UTC (rev 14628)
@@ -55,4 +55,8 @@
<target name="undeploy">
<delete file="${jboss.deploy}/${war.name}" />
</target>
+
+ <target name="docs">
+
+ </target>
</project>
More information about the jboss-svn-commits
mailing list