[jboss-svn-commits] JBL Code SVN: r14821 - in labs/shotoku/trunk: shotoku-feeds/src/java/org/jboss/shotoku/feeds/service and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Sep 3 05:36:48 EDT 2007
Author: adamw
Date: 2007-09-03 05:36:48 -0400 (Mon, 03 Sep 2007)
New Revision: 14821
Added:
labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/Releasable.java
labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/ValueInit.java
labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/service/FeedsCacheItemDataSource.java
Log:
Init values; removing administrated services.
Added: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/Releasable.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/Releasable.java (rev 0)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/Releasable.java 2007-09-03 09:36:48 UTC (rev 14821)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * An interface which represents a cache item value which can be "released" - after
+ * a new value has been placed in the cache.
+ * @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
+ */
+public interface Releasable {
+ /**
+ * Objects that are placed in the cache and have some resources that should
+ * be released after placing a new value in the cache should implement this
+ * interface. This method is invoked after a new value has been placed in the
+ * cache. All exceptions are ignored.
+ * @throws Throwable
+ */
+ public void release() throws Throwable;
+}
Added: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/ValueInit.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/ValueInit.java (rev 0)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/ValueInit.java 2007-09-03 09:36:48 UTC (rev 14821)
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * A class which represents either an initial value, which can be either a "dummy" one,
+ * that is, a value that needs to be updated as soon as possible, or a real value, which
+ * can be updated after a normal update interval.
+ * Instances can be obtained using the
+ * {@link ValueInit#realValue(Object)} and {@link ValueInit#dummyValue(Object)} methods.
+ * @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
+ */
+public class ValueInit<T> {
+ private boolean realValue;
+ private T initValue;
+
+ private ValueInit(boolean realValue, T initValue) {
+ this.realValue = realValue;
+ this.initValue = initValue;
+ }
+
+ public static <T> ValueInit<T> dummyValue(T value) {
+ return new ValueInit<T>(false, value);
+ }
+
+ public static <T> ValueInit<T> realValue(T value) {
+ return new ValueInit<T>(true, value);
+ }
+
+ public T getValue() {
+ return initValue;
+ }
+
+ public boolean hasRealValue() {
+ return realValue;
+ }
+}
Added: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/service/FeedsCacheItemDataSource.java
===================================================================
--- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/service/FeedsCacheItemDataSource.java (rev 0)
+++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/service/FeedsCacheItemDataSource.java 2007-09-03 09:36:48 UTC (rev 14821)
@@ -0,0 +1,32 @@
+package org.jboss.shotoku.feeds.service;
+
+import org.jboss.shotoku.cache.CacheItemDataSource;
+import org.jboss.shotoku.cache.ValueChange;
+import org.jboss.shotoku.cache.ValueInit;
+import org.jboss.shotoku.feeds.DummyFeedsDescriptor;
+import org.jboss.shotoku.feeds.FeedsDescriptor;
+import org.jboss.shotoku.feeds.FeedsDescriptorImpl;
+import org.jboss.shotoku.feeds.FeedsService;
+
+public class FeedsCacheItemDataSource implements CacheItemDataSource<String, FeedsDescriptor> {
+ private FeedsService feedsService;
+
+ public FeedsCacheItemDataSource(FeedsService feedsService) {
+ this.feedsService = feedsService;
+ }
+
+ public String getInfo() {
+ return null;
+ }
+
+ public ValueInit<? extends FeedsDescriptor> init(String key) {
+ return ValueInit.dummyValue(new DummyFeedsDescriptor(key));
+ }
+
+ public ValueChange<? extends FeedsDescriptor> update(String key, FeedsDescriptor currentObject) {
+ return ValueChange.changeToReleaseOld(new FeedsDescriptorImpl(key, feedsService.getConf(),
+ feedsService.getRemoteConnectionTimeout(),
+ feedsService.getRemoteReadTimeout()), currentObject);
+ }
+
+}
More information about the jboss-svn-commits
mailing list