From 05b6eb6fd9a934a96a1c920720f8c5cbde41271d Mon Sep 17 00:00:00 2001 From: mdb Date: Mon, 8 Oct 2007 23:58:40 +0000 Subject: [PATCH] Add a default handleFailure() implementation like PersistingUnit. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2232 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../com/samskivert/jdbc/RepositoryUnit.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/java/com/samskivert/jdbc/RepositoryUnit.java b/src/java/com/samskivert/jdbc/RepositoryUnit.java index 1f09af91..2a9c425c 100644 --- a/src/java/com/samskivert/jdbc/RepositoryUnit.java +++ b/src/java/com/samskivert/jdbc/RepositoryUnit.java @@ -20,6 +20,9 @@ package com.samskivert.jdbc; +import java.util.logging.Level; + +import com.samskivert.Log; import com.samskivert.io.PersistenceException; import com.samskivert.util.Invoker; @@ -77,9 +80,21 @@ public abstract class RepositoryUnit extends Invoker.Unit /** * Called if our persistent actions failed, back on the non-invoker thread. Note that this may * be either an {@link Exception} thrown by {@link #invokePersist} or a {@link - * RuntimeException} thrown by same. + * RuntimeException} thrown by same. The default implementation logs an error message and a + * stack trace. */ - public abstract void handleFailure (Exception pe); + public void handleFailure (Exception pe) + { + Log.log.log(Level.WARNING, getFailureMessage(), pe); + } + + /** + * Returns the error message to be logged if {@link #invokePersist} throws an exception. + */ + protected String getFailureMessage () + { + return this + " failed."; + } protected Exception _error; }