directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 10403 - incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application
Date Thu, 29 Apr 2004 04:27:02 GMT
Author: akarasulu
Date: Wed Apr 28 21:27:01 2004
New Revision: 10403

Modified:
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/ApplicationDAOMonitor.java
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/ApplicationDAOMonitorAdapter.java
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/JeApplicationDAO.java
Log:
Commit changes ...

 o completed JeApplicationDAO.delete() operation
 o passed JeApplicationDAO.delete() unit tests
 o added ApplicationDAO monitor interface methods to cover delete()
 o implemented new monitor methods in no-op monitor adapter



Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/ApplicationDAOMonitor.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/ApplicationDAOMonitor.java
(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/ApplicationDAOMonitor.java
Wed Apr 28 21:27:01 2004
@@ -16,8 +16,6 @@
  */
 package org.apache.rms.je.application ;
 
-import com.sleepycat.je.OperationStatus;
-
 
 /**
  * A monitor for an Application data access object.
@@ -55,5 +53,31 @@
      * @param appName the name of the application
      */ 
     void applicationCreated( ApplicationDAO dao, String appName ) ;
+
+    /**
+     * Monitor callback for events where the dao failed at some operation
+     * on the application because the application did not exist.
+     *
+     * @param dao the data access object that failed
+     * @param info extra implementation specific information
+     * @param op the operation performed by the dao
+     * @param appName the name of the application
+     */
+    void applicationDoesNotExist( ApplicationDAO dao, Object info,
+                                  String op, String appName ) ;
+
+    /**
+     * Monitor callback for events where the dao failed to delete
+     * an application.
+     *
+     * @param dao the data access object that failed
+     * @param info extra implementation specific information
+     * @param appName the name of the application
+     * @param fault the fault that caused the failure
+     */
+    void failedOnDelete( ApplicationDAO dao, Object info, String appName,
+                         Throwable fault ) ;
+
+    void failedOnDelete( ApplicationDAO dao, String appName, Throwable fault ) ;
 
 }

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/ApplicationDAOMonitorAdapter.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/ApplicationDAOMonitorAdapter.java
(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/ApplicationDAOMonitorAdapter.java
Wed Apr 28 21:27:01 2004
@@ -18,8 +18,13 @@
 
 
 /**
- * A no-op application data access object monitor adapter.
- * 
+ * A no-op application data access object monitor adapter.  At a bare minimum
+ * this monitor prints out stack traces of exceptions to stderr.  If you don't
+ * like that then use the logging monitor implementation or create and use a
+ * new one by implementing the ApplicationDAOMonitor interface or extending
+ * this class.  If you extend this class then simply override the mathods with
+ * throwable fault arguments and don't call the super methods.
+ *
  * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
@@ -36,6 +41,10 @@
     public void failedOnHas( ApplicationDAO dao, String appName,
                              Throwable fault )
     {
+        if ( fault != null )
+        {
+            fault.printStackTrace() ;
+        }
     }
 
 
@@ -62,5 +71,56 @@
      */
     public void applicationCreated( ApplicationDAO dao, String appName )
     {
+    }
+
+
+    /**
+     * Monitor callback for events where the dao failed at some operation on
+     * the application because the application did not exist.
+     *
+     * @param dao     the data access object that failed
+     * @param info    extra implementation specific information
+     * @param op      the operation performed by the dao
+     * @param appName the name of the application
+     */
+    public void applicationDoesNotExist( ApplicationDAO dao, Object info,
+                                         String op, String appName )
+    {
+    }
+
+
+    /**
+     * Monitor callback for events where the dao failed to delete
+     * an application.
+     *
+     * @param dao     the data access object that failed
+     * @param info    extra implementation specific information
+     * @param appName the name of the application
+     * @param fault   the fault that caused the failure
+     */
+    public void failedOnDelete( ApplicationDAO dao, Object info,
+                                String appName, Throwable fault )
+    {
+        if ( fault != null )
+        {
+            fault.printStackTrace() ;
+        }
+    }
+
+
+    /**
+     * Monitor callback for events where the dao failed to delete
+     * an application.
+     *
+     * @param dao     the data access object that failed
+     * @param appName the name of the application
+     * @param fault   the fault that caused the failure
+     */
+    public void failedOnDelete( ApplicationDAO dao, String appName, Throwable fault )
+    {
+        if ( fault != null )
+        {
+            fault.printStackTrace() ;
+        }
     }
 }

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/JeApplicationDAO.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/JeApplicationDAO.java
(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/JeApplicationDAO.java
Wed Apr 28 21:27:01 2004
@@ -210,7 +210,36 @@
      */
     public void delete( String appName ) throws RmsException
     {
-        throw new NotImplementedException( "STUB" ) ;
+        DatabaseEntry key ;
+        DatabaseEntry rowId ;
+        OperationStatus status = null ;
+        DatabaseEntry value = new DatabaseEntry() ;
+
+        try
+        {
+            rowId = getRowId( appName );
+        }
+        catch ( JeRmsException e )
+        {
+            monitor.failedOnDelete( this, e.getStatus(), appName, e ) ;
+            throw e ;
+        }
+
+        try
+        {
+            BINDING.objectToEntry( value, appName ) ;
+            status = db.delete( null, rowId ) ;
+        }
+        catch ( IOException e )
+        {
+            monitor.failedOnDelete( this, appName, e ) ;
+            throw new RmsException( e ) ;
+        }
+        catch ( DatabaseException e )
+        {
+            monitor.failedOnDelete( this, appName, e ) ;
+            throw new RmsException( e ) ;
+        }
     }
 
 
@@ -239,5 +268,51 @@
     public Iterator listNames() throws RmsException
     {
         throw new NotImplementedException( "STUB" ) ;
+    }
+
+
+    /**
+     * Gets the rowId entry for an application.
+     *
+     * @param appName the name of the application
+     * @return the rowId (primary key) of the application
+     * @throws RmsException if there is a failure why accessing the db
+     * backing store, or the application does not exist
+     */
+    private DatabaseEntry getRowId( String appName ) throws RmsException
+    {
+        DatabaseEntry key = null ;
+        DatabaseEntry rowId = new DatabaseEntry() ;
+        DatabaseEntry value = new DatabaseEntry() ;
+        OperationStatus status = null ;
+
+        try
+        {
+            key = new DatabaseEntry( appName.getBytes( "UTF-8" ) ) ;
+        }
+        catch ( UnsupportedEncodingException e )
+        {
+            monitor.failedOnHas( this, appName, e ) ;
+            throw new RmsException( e ) ;
+        }
+
+        try
+        {
+            status = byAppName.get( null, key, rowId, value,
+                    LockMode.DEFAULT ) ;
+        }
+        catch ( DatabaseException e )
+        {
+            throw new RmsException( e ) ;
+        }
+
+        if ( status != OperationStatus.SUCCESS )
+        {
+            monitor.applicationDoesNotExist( this, status, "getRowId", appName ) ;
+            throw new JeRmsException( status, "Application " + appName
+                    + " does not exist" ) ;
+        }
+
+        return rowId ;
     }
 }

Mime
View raw message