db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r521385 - in /db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer: ChainingIterator.java OJBIterator.java PagingIterator.java RsIterator.java
Date Thu, 22 Mar 2007 18:02:19 GMT
Author: arminw
Date: Thu Mar 22 11:02:18 2007
New Revision: 521385

URL: http://svn.apache.org/viewvc?view=rev&rev=521385
Log:
rename (deprecate) method OJBIterator.releaseDbResources() to OJBIterator.close()

Modified:
    db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/ChainingIterator.java
    db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/OJBIterator.java
    db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/PagingIterator.java
    db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/ChainingIterator.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/ChainingIterator.java?view=diff&rev=521385&r1=521384&r2=521385
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/ChainingIterator.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/ChainingIterator.java Thu Mar
22 11:02:18 2007
@@ -98,11 +98,16 @@
      */
     public void setAutoRelease(boolean autoRelease)
     {
+        setAutoClose(autoRelease);
+    }
+
+    public void setAutoClose(boolean autoClose)
+    {
         checkOpen();
         Iterator it = m_rsIterators.iterator();
         while (it.hasNext())
         {
-            ((OJBIterator) it.next()).setAutoRelease(autoRelease);
+            ((OJBIterator) it.next()).setAutoClose(autoClose);
         }
     }
 
@@ -391,18 +396,19 @@
         return retval;
     }
 
-    /**
-     * delegate to each contained OJBIterator and release
-     * its resources.
-     */
     public void releaseDbResources()
     {
+        close();
+    }
+
+    public void close()
+    {
         if(m_rsIterators == null) return;
 
         Iterator it = m_rsIterators.iterator();
         while (it.hasNext())
         {
-            ((OJBIterator) it.next()).releaseDbResources();
+            ((OJBIterator) it.next()).close();
         }
         m_rsIterators = null;
     }

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/OJBIterator.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/OJBIterator.java?view=diff&rev=521385&r1=521384&r2=521385
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/OJBIterator.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/OJBIterator.java Thu Mar 22 11:02:18
2007
@@ -20,22 +20,22 @@
 import org.apache.ojb.broker.PersistenceBrokerException;
 
 /**
- * A {@link Iterator} extension internaly used by OJB to handle query results.
+ * A {@link Iterator} extension internally used by OJB to handle query results.
  *
  * <p>
- * NOTE: OJB is very strict in handling <em>OJBIterator</em> instances. The <em>OJBIterator</em>
is
+ * NOTE: OJB is very strict in handling <tt>OJBIterator</tt> instances. <tt>OJBIterator</tt>
is
  * bound very closely to the used {@link org.apache.ojb.broker.PersistenceBroker} instance.
  * Thus if you do a
  * <br/> - {@link org.apache.ojb.broker.PersistenceBroker#close}
  * <br/> - {@link org.apache.ojb.broker.PersistenceBroker#commitTransaction}
  * <br/> - {@link org.apache.ojb.broker.PersistenceBroker#abortTransaction}
  * <br/>
- * call, the current <em>OJBIterator</em> instance resources will be cleaned
up automatic
- * and invalidate current instance by implicit {@link #releaseDbResources()} call.
+ * call, the current <tt>OJBIterator</tt> instance resources will be cleaned
up automatic
+ * and invalidate current instance.
  * </p>
  * <p>
- * Except user explicitly call {@link #setAutoRelease(boolean) setAutoRelease(false)}, then
the
- * user is responsible for release resource call.
+ * Except user explicitly call {@link #setAutoClose(boolean) setAutoClose(false)}, then the
+ * user is responsible for the release resource call.
  * </p>
  *
  * @version $Id$
@@ -87,40 +87,86 @@
     boolean relative(int row) throws PersistenceBrokerException;
 
     /**
-     * Release all internally used Database resources of the iterator.
-     * Clients must call this methods explicitely if the iterator is not
-     * exhausted by the client application. If the Iterator is exhauseted
-     * this method will be called implicitely.
+     * Release all internally used database resources of this iterator.
+     * Clients must call this method explicitly for <strong>immediate release of resources</strong>
+     * if the iterator is not exhausted by the client, else the resources will be
+     * released on {@link org.apache.ojb.broker.PersistenceBroker#close PB.close()},
+     * {@link org.apache.ojb.broker.PersistenceBroker#commitTransaction PB.commitTransaction()}
+     * or {@link org.apache.ojb.broker.PersistenceBroker#abortTransaction() PB.abortTransaction()}.
+     * <p>
+     * If the Iterator is exhauseted this method will be called implicit after return of
the
+     * last iterator object.
+     * </p>
      *
+     * @deprecated please use {@link #close()}
      * @see #setAutoRelease(boolean)
      */
     public void releaseDbResources();
 
     /**
+     * Release all internally used database resources of this iterator.
+     * Clients must call this method explicitly for <strong>immediate release of resources</strong>
+     * if the iterator is not exhausted by the client, else the resources will be
+     * released on {@link org.apache.ojb.broker.PersistenceBroker#close PB.close()},
+     * {@link org.apache.ojb.broker.PersistenceBroker#commitTransaction PB.commitTransaction()}
+     * or {@link org.apache.ojb.broker.PersistenceBroker#abortTransaction() PB.abortTransaction()}.
+     * <p>
+     * If the Iterator is exhauseted this method will be called implicit after return of
the
+     * last iterator object.
+     * </p>
+     *
+     * @see #setAutoClose(boolean)
+     */
+    public void close();
+
+    /**
      * Allows user to switch off/on automatic resource cleanup.
      * Set <em>false</em> to take responsibility of resource cleanup
      * for this class, means after use it's mandatory to call
-     * {@link #releaseDbResources}.
+     * {@link #close()}.
      * <br/> By default it's <em>true</em> and resource cleanup is done
      * automatic.
      * <p/>
      * <strong>NOTE</strong>: Be carefully when set to <em>false</em>
and the {@link org.apache.ojb.broker.PersistenceBroker}
-     * instance which create this instance was closed. Closing of broker instance release
all used connection resources,
+     * instance which create this instance is closed. Closing of broker instance release
all used connection resources
+     * (expect the resources used by this instance - because of the <em>false</em>
setting),
      * thus the connection used by this instance maybe reused by another thread and can cause
unexpected side-effects.
-     * So we strongly recommend to do a {@link #releaseDbResources()} before close the used
broker instance or use default
+     * So we strongly recommend to do a {@link #close()} call before close the used broker
instance or use default
      * setting of this class with automatic cleanup.
      * </p>
      *
      * @param autoRelease Flag to set resource cleanup behavior.
      * @see #releaseDbResources()
+     * @deprecated please use {@link #setAutoClose(boolean)}
      */
     void setAutoRelease(boolean autoRelease);
 
     /**
+     * Allows user to switch off/on automatic resource cleanup.
+     * Set <em>false</em> to take responsibility of resource cleanup
+     * for this class, means after use it's mandatory to call
+     * {@link #close()}.
+     * <br/> By default it's <em>true</em> and resource cleanup is done
+     * automatic.
+     * <p/>
+     * <strong>NOTE</strong>: Be carefully when set to <em>false</em>
and the {@link org.apache.ojb.broker.PersistenceBroker}
+     * instance which create this instance is closed. Closing of broker instance release
all used connection resources
+     * (expect the resources used by this instance - because of the <em>false</em>
setting),
+     * thus the connection used by this instance maybe reused by another thread and can cause
unexpected side-effects.
+     * So we strongly recommend to do a {@link #close()} call before close the used broker
instance or use default
+     * setting of this class with automatic cleanup.
+     * </p>
+     *
+     * @param autoClose Flag to set resource cleanup behavior.
+     * @see #close()
+     */
+    void setAutoClose(boolean autoClose);
+
+    /**
      * Returns <em>true</em> if this class was closed and all resources are released.
      *
      * @return The state of the iterator.
-     * @see #releaseDbResources()
+     * @see #close()
      */
     boolean isClosed();
     
@@ -156,6 +202,10 @@
         {
         }
 
+        public void close()
+        {
+        }
+
         public int size() throws PersistenceBrokerException
         {
             return 0;
@@ -177,7 +227,11 @@
 
         public boolean isClosed()
         {
-            return false;
+            return true;
+        }
+
+        public void setAutoClose(boolean autoRelease)
+        {
         }
 
         public void setAutoRelease(boolean autoRelease)

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/PagingIterator.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/PagingIterator.java?view=diff&rev=521385&r1=521384&r2=521385
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/PagingIterator.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/PagingIterator.java Thu Mar 22
11:02:18 2007
@@ -67,7 +67,7 @@
             m_iterator = OJBIterator.EMPTY_ITERATOR;
             m_rowLimitSize = 0;
             m_fullSize = 0;
-            anIterator.releaseDbResources();
+            anIterator.close();
         }
         else
         {
@@ -81,12 +81,14 @@
         return m_iterator.isClosed();
     }
 
-    /**
-     * @see OJBIterator#setAutoRelease(boolean)
-     */
     public void setAutoRelease(boolean autoRelease)
     {
-        m_iterator.setAutoRelease(autoRelease);
+        setAutoClose(autoRelease);
+    }
+
+    public void setAutoClose(boolean autoClose)
+    {
+        m_iterator.setAutoClose(autoClose);
     }
 
     /**
@@ -172,7 +174,12 @@
 	 */
     public void releaseDbResources()
     {
-        m_iterator.releaseDbResources();
+        close();
+    }
+
+    public void close()
+    {
+        m_iterator.close();
     }
 
     /**

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java?view=diff&rev=521385&r1=521384&r2=521385
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java Thu Mar 22 11:02:18
2007
@@ -139,7 +139,7 @@
      * Flag that indicates if the automatic resource cleanup should be
      * done or not. Default is <tt>true</tt>.
      */
-    private boolean autoRelease = true;
+    private boolean autoClose = true;
     private ResourceWrapper resourceListener;
 
     /** if true do not fire PBLifeCycleEvent. */
@@ -784,17 +784,16 @@
         return retval;
     }
 
-    /**
-     * Release all internally used Database resources of the iterator. Clients
-     * must call this methods explicitely if the iterator is not exhausted by
-     * the client application. If the Iterator is exhauseted this method will
-     * be called implicitely.
-     */
     public void releaseDbResources()
     {
         release(true);
     }
 
+    public void close()
+    {
+        release(true);
+    }
+
     void release(boolean removeResourceListener)
     {
         if (!isInBatchedMode()) // resources are reused in batched mode
@@ -851,22 +850,24 @@
      */
     protected void autoReleaseDbResources()
     {
-        if(autoRelease)
+        if(autoClose)
         {
             releaseDbResources();
         }
     }
 
-    /**
-     * @see OJBIterator#setAutoRelease(boolean)
-     */
     public void setAutoRelease(boolean autoRelease)
     {
-        if(resourcesReleased && !autoRelease)
+        setAutoClose(autoRelease);
+    }
+
+    public void setAutoClose(boolean autoClose)
+    {
+        if(resourcesReleased && !autoClose)
         {
             logger.info(INFO_MSG);
         }
-        this.autoRelease = autoRelease;
+        this.autoClose = autoClose;
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message