[jboss-cvs] JBossAS SVN: r65921 - projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Oct 8 13:26:12 EDT 2007


Author: bstansberry at jboss.com
Date: 2007-10-08 13:26:12 -0400 (Mon, 08 Oct 2007)
New Revision: 65921

Added:
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/Cacheable.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/IntegratedObjectStore.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/ItemInUseException.java
   projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/PassivatingIntegratedObjectStore.java
Log:
First draft of clustering support

Added: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/Cacheable.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/Cacheable.java	                        (rev 0)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/Cacheable.java	2007-10-08 17:26:12 UTC (rev 65921)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.cache;
+
+
+/**
+ * An object that can be cached.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public interface Cacheable extends Identifiable
+{
+   /** Possible states of the entry.  See elements for details. */
+//   public static enum State { 
+//      /**
+//       * A reference to the entry's {@link CacheEntry#getObject container object} 
+//       * has *not* been handed out to a caller and there is no need to
+//       * invoke any @PostActivate callback before handing out a reference.
+//       */
+//      READY,
+//      /** 
+//       * A reference to the entry's {@link CacheEntry#getObject container object} 
+//       * has been handed out to a caller and has not yet been released.
+//       * 
+//       * @see Cache#get(Object)
+//       * @see Cache#peek(Object)
+//       * @see Cache#release(Identifiable)
+//       */
+//      IN_USE,
+//      /**
+//       * A reference to the entry's {@link CacheEntry#getObject container object} 
+//       * has *not* been handed out to a caller, but any @PostActivate callback 
+//       * should be invoked before handing out a reference.
+//       */
+//      PASSIVATED 
+//   };
+//   
+//   State getCacheState();
+//   
+//   void setCacheState(State state);
+   
+//   void setLastUsed(long lastUsed);
+   
+   /**
+    * Gets whether this object is in use by a caller.
+    */
+   boolean isInUse();
+   
+   /**
+    * Sets whether this object is in use by a caller.
+    * 
+    * @param inUse
+    */
+   void setInUse(boolean inUse);
+   
+   /**
+    * Gets the timestamp of the last time this object was in use.
+    * 
+    * @return
+    */
+   long getLastUsed();
+}

Added: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/IntegratedObjectStore.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/IntegratedObjectStore.java	                        (rev 0)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/IntegratedObjectStore.java	2007-10-08 17:26:12 UTC (rev 65921)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.cache;
+
+/**
+ * A in-memory store for identifiable objects that integrates a persistent store. 
+ * Note that this class does NOT call any callbacks.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public interface IntegratedObjectStore<T extends Cacheable>
+{
+   /**
+    * Put a new entry into the store.
+    * 
+    * @param entry the object to store. Cannot be <code>null</code>.
+    */
+   void insert(T entry);
+   
+   /**
+    * Gets the entry with the given id from the store.
+    * 
+    * @param key {@link Identifiable#getId() id} of the entry.
+    *           Cannot be <code>null</code>.
+    * @return the object store under <code>id</code>. May return <code>null</code>
+    */
+   T get(Object key);
+   
+   /**
+    * Replicate an already cached item. Only valid for 
+    * {@link #isClustered() clustered} stores, as the purpose of this
+    * method is to advise the store that the state of it's locally cached copy 
+    * of an entry has changed and that any other caches in the cluster should
+    * be made aware of the new state.
+    * 
+    * @param  entry the entry to replicate
+    *           
+    * @throws UnsupportedOperationException if {@link #isClustered()} returns
+    *                                       <code>false</code>
+    */
+   void replicate(T entry);
+   
+   /**
+    * Remove the object with the given key from the store.
+    * 
+    * @param key {@link Identifiable#getId() id} of the entry.
+    *           Cannot be <code>null</code>.
+    *           
+    * @return the object that was cached under <code>key</code>
+    */
+   T remove(Object key);
+   
+   /**
+    * Remove the entry with the given key from any in-memory store
+    * while retaining it in the persistent store.
+    * 
+    * @param entry the entry to passivate
+    */
+   void passivate(T entry);
+   
+   /**
+    * Gets whether this store supports clustering functionality.
+    * 
+    * @return <code>true</code> if clustering is supported, <code>false</code>
+    *         otherwise
+    */
+   boolean isClustered();
+   
+   /**
+    * Perform any initialization work.
+    */
+   void start();
+   
+   /**
+    * Perform any shutdown work.
+    */
+   void stop();
+}

Added: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/ItemInUseException.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/ItemInUseException.java	                        (rev 0)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/ItemInUseException.java	2007-10-08 17:26:12 UTC (rev 65921)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.cache;
+
+/**
+ * Exception indicating an object is "in use" and thus some action
+ * on it is illegal.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision: 1.1 $
+ */
+public class ItemInUseException extends IllegalStateException
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 0L;
+
+   /**
+    * Create a new ItemInUseException.
+    * 
+    */
+   public ItemInUseException()
+   {      
+   }
+
+   /**
+    * Create a new ItemInUseException.
+    * 
+    * @param s
+    */
+   public ItemInUseException(String s)
+   {
+      super(s);
+   }
+
+   /**
+    * Create a new ItemInUseException.
+    * 
+    * @param cause
+    */
+   public ItemInUseException(Throwable cause)
+   {
+      super(cause);
+   }
+
+   /**
+    * Create a new ItemInUseException.
+    * 
+    * @param message
+    * @param cause
+    */
+   public ItemInUseException(String message, Throwable cause)
+   {
+      super(message, cause);
+   }
+
+}

Added: projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/PassivatingIntegratedObjectStore.java
===================================================================
--- projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/PassivatingIntegratedObjectStore.java	                        (rev 0)
+++ projects/ejb3/branches/cluster-dev/ejb3-cache/src/main/java/org/jboss/ejb3/cache/PassivatingIntegratedObjectStore.java	2007-10-08 17:26:12 UTC (rev 65921)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.cache;
+
+/**
+ * An {@link IntegratedObjectStore} that is able to use its knowledge of
+ * when objects are accessed to coordinate the passivation and removal of 
+ * cached objects.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public interface PassivatingIntegratedObjectStore<T extends Cacheable>
+   extends IntegratedObjectStore<T>
+{
+   /**
+    * Gets how often, in seconds, this object should process 
+    * {@link #runPassivation() passivations} and
+    * {@link #runExpiration() expirations}.
+    * 
+    * @return  interval, in seconds, at which passivations and expirations
+    *          are processed. A value of less than 1 means this object will 
+    *          not itself initiate processing, depending instead on an external 
+    *          caller to do so.
+    */
+   int getInterval();
+   
+   /**
+    * Sets how often, in seconds, this object should process 
+    * {@link #runPassivation() passivations} and
+    * {@link #runExpiration() expirations}.
+    * 
+    * @param seconds  interval, in seconds, at which passivations and
+    *                 expirations should be processed. A value of less than 1 
+    *                 means this object will not itself initiate processing, 
+    *                 depending instead on an external caller to do so.
+    */
+   void setInterval(int seconds);
+   
+   /**
+    * Determine what cached objects need to be passivated and 
+    * {@link PassivatingCache#passivate(Object) tell the cache to passivate them}.
+    *
+    */
+   void runPassivation();
+   
+   /**
+    * Check what cached objects need to be removed and 
+    * {@link Cache#remove(Object) tell the cache to remove them}.
+    *
+    */
+   void runExpiration();
+   
+   /**
+    * Handback provided by the controlling {@link PassivatingCache} to
+    * allow the actual {@link PassivatingCache#passivate(Object) passivate}
+    * and {@link Cache#remove(Object) remove} calls.
+    * 
+    * @param cache
+    */
+   void setPassivatingCache(PassivatingCache<T> cache);
+   
+   // TODO determine what the standard configurations are
+   
+//   int getPassivationTimeout();
+//   void setPassivationTimeout(int timeout);
+//   
+//   int getRemovalTimeout();   
+//   void setRemovalTimeout(int timeout);
+}




More information about the jboss-cvs-commits mailing list