[jboss-cvs] JBossAS SVN: r65275 - in projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache: impl and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Sep 10 05:45:16 EDT 2007


Author: wolfc
Date: 2007-09-10 05:45:16 -0400 (Mon, 10 Sep 2007)
New Revision: 65275

Modified:
   projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/Cache.java
   projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/StatefulObjectFactory.java
   projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/SimpleCache.java
Log:
Expanded cache interface

Modified: projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/Cache.java
===================================================================
--- projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/Cache.java	2007-09-10 09:37:00 UTC (rev 65274)
+++ projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/Cache.java	2007-09-10 09:45:16 UTC (rev 65275)
@@ -45,18 +45,45 @@
    T create(Class<?> initTypes[], Object initValues[]);
    
    /**
-    * Get the specified object from cache.
+    * Get the specified object from cache. This will mark
+    * the object as being in use.
     * 
     * @param key    the identifier of the object
     * @return       the object
-    * @throws NoSuchEJBException if the object does not exist
+    * @throws NoSuchEJBException    if the object does not exist
     */
    T get(Object key) throws NoSuchEJBException;
    
    /**
+    * Peek at an object which might be in use.
+    * 
+    * @param key    the identifier of the object
+    * @return       the object
+    * @throws NoSuchEJBException    if the object does not exist
+    */
+   T peek(Object key) throws NoSuchEJBException;
+   
+   /**
+    * Release the object from use.
+    * 
+    * @param obj    the object
+    */
+   void release(T obj);
+   
+   /**
     * Remove the specified object from cache.
     * 
     * @param key    the identifier of the object
     */
    void remove(Object key);
+   
+   /**
+    * Start the cache.
+    */
+   void start();
+   
+   /**
+    * Stop the cache.
+    */
+   void stop();
 }

Modified: projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/StatefulObjectFactory.java
===================================================================
--- projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/StatefulObjectFactory.java	2007-09-10 09:37:00 UTC (rev 65274)
+++ projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/StatefulObjectFactory.java	2007-09-10 09:45:16 UTC (rev 65275)
@@ -33,7 +33,22 @@
  */
 public interface StatefulObjectFactory<T>
 {
+   /**
+    * Creates a new stateful object by calling it's empty constructor,
+    * do injection, calling post-construct and finally calling the
+    * appropriate init method.
+    * 
+    * @param initTypes  the argument types for the init method
+    * @param initValues the arguments for the init method
+    * @return
+    */
    T create(Class<?> initTypes[], Object initValues[]);
    
+   /**
+    * Perform any cleanup actions on the object, such as
+    * calling the pre-destroy callback.
+    * 
+    * @param obj    the object
+    */
    void destroy(T obj);
 }

Modified: projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/SimpleCache.java
===================================================================
--- projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/SimpleCache.java	2007-09-10 09:37:00 UTC (rev 65274)
+++ projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/SimpleCache.java	2007-09-10 09:45:16 UTC (rev 65275)
@@ -71,6 +71,16 @@
       return obj;
    }
 
+   public T peek(Object key) throws NoSuchEJBException
+   {
+      return get(key);
+   }
+   
+   public void release(T obj)
+   {
+      // release does nothing
+   }
+   
    public void remove(Object key)
    {
       T obj;
@@ -81,4 +91,14 @@
       if(obj != null)
          factory.destroy(obj);
    }
+   
+   public void start()
+   {
+      // do nothing
+   }
+   
+   public void stop()
+   {
+      // do nothing
+   }
 }




More information about the jboss-cvs-commits mailing list