Author: rhauch
Date: 2008-07-01 16:14:52 -0400 (Tue, 01 Jul 2008)
New Revision: 323
Added:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/BasicCachePolicy.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/ImmutableCachePolicy.java
Log:
DNA-115 - Create federation service
http://jira.jboss.com/jira/browse/DNA-115
Added two implementations of CachePolicy: a basic mutable implementation, and an
immutable version.
Added: trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/BasicCachePolicy.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/BasicCachePolicy.java
(rev 0)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/BasicCachePolicy.java 2008-07-01
20:14:52 UTC (rev 323)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.dna.spi.cache;
+
+/**
+ * @author Randall Hauch
+ */
+public class BasicCachePolicy implements CachePolicy {
+
+ private static final long serialVersionUID = 1L;
+ private long timeToCache;
+ private long timeToExpire;
+
+ public BasicCachePolicy() {
+ }
+
+ public BasicCachePolicy( long timeToCache,
+ long timeToExpire ) {
+ this.timeToCache = timeToCache;
+ this.timeToExpire = timeToExpire;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.cache.CachePolicy#getTimeToCache()
+ */
+ public long getTimeToCache() {
+ return this.timeToCache;
+ }
+
+ /**
+ * @param timeToCache Sets timeToCache to the specified value.
+ */
+ public void setTimeToCache( long timeToCache ) {
+ this.timeToCache = timeToCache;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.cache.CachePolicy#getTimeToExpire()
+ */
+ public long getTimeToExpire() {
+ return this.timeToExpire;
+ }
+
+ /**
+ * @param timeToExpire Sets timeToExpire to the specified value.
+ */
+ public void setTimeToExpire( long timeToExpire ) {
+ this.timeToExpire = timeToExpire;
+ }
+
+ public boolean isEmpty() {
+ return this.timeToCache == 0 && this.timeToExpire == 0;
+ }
+
+ public CachePolicy getUnmodifiable() {
+ return new ImmutableCachePolicy(this.getTimeToCache(), this.getTimeToExpire());
+ }
+
+}
Property changes on:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/BasicCachePolicy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/ImmutableCachePolicy.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/ImmutableCachePolicy.java
(rev 0)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/ImmutableCachePolicy.java 2008-07-01
20:14:52 UTC (rev 323)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.dna.spi.cache;
+
+/**
+ * @author Randall Hauch
+ */
+public class ImmutableCachePolicy implements CachePolicy {
+
+ private static final long serialVersionUID = 1L;
+ private final long timeToCache;
+ private final long timeToExpire;
+
+ public ImmutableCachePolicy( long timeToCache,
+ long timeToExpire ) {
+ this.timeToCache = timeToCache;
+ this.timeToExpire = timeToExpire;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.cache.CachePolicy#getTimeToCache()
+ */
+ public long getTimeToCache() {
+ return this.timeToCache;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.cache.CachePolicy#getTimeToExpire()
+ */
+ public long getTimeToExpire() {
+ return this.timeToExpire;
+ }
+
+ public CachePolicy getUnmodifiable() {
+ return this;
+ }
+
+}
Property changes on:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/ImmutableCachePolicy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain