You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ar...@apache.org on 2006/01/08 21:36:10 UTC

svn commit: r367091 - in /db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/fieldaccess: PersistentFieldAutoProxyImpl.java PersistentFieldBase.java PersistentFieldDynaBeanImpl.java

Author: arminw
Date: Sun Jan  8 12:36:03 2006
New Revision: 367091

URL: http://svn.apache.org/viewcvs?rev=367091&view=rev
Log:
improve logging messages

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldAutoProxyImpl.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldBase.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldDynaBeanImpl.java

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldAutoProxyImpl.java
URL: http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldAutoProxyImpl.java?rev=367091&r1=367090&r2=367091&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldAutoProxyImpl.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldAutoProxyImpl.java Sun Jan  8 12:36:03 2006
@@ -19,14 +19,18 @@
 
 import org.apache.ojb.broker.metadata.MetadataException;
 import org.apache.ojb.broker.util.ClassHelper;
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.SystemUtils;
 
 /**
- * PeristentField implementation that attempts to detect the nature of
+ * A {@link PersistentField} implementation that attempts to detect the nature of
  * the field it is persisting.
  * <p>
- * First checks to see if it is a Field, then Property, then DynaBean
- * <p>
+ * First checks to see if it is a bean property, then field, then DynaBean.
+ * <br/>
  * It will match in that order.
+ *
+ * @version $Id: $
  */
 public class PersistentFieldAutoProxyImpl extends PersistentFieldBase
 {
@@ -38,7 +42,8 @@
      * setection order.
      */
     protected Class[] persistentFieldClasses = new Class[]{
-        PersistentFieldDirectImpl.class
+        PersistentFieldCGLibImpl.class
+        , PersistentFieldDirectImpl.class
         , PersistentFieldIntrospectorImpl.class
         , PersistentFieldPrivilegedImpl.class
         , PersistentFieldDynaBeanImpl.class};
@@ -64,8 +69,11 @@
             {
                 index = 0;
                 currentPF = null;
-                throw new AutoDetectException("Can't autodetect valid PersistentField implementation: "
-                        + latestException.message, latestException.exception);
+                String eol = SystemUtils.LINE_SEPARATOR;
+                throw new AutoDetectException(eol + "Can't autodetect valid PersistentField implementation using "
+                        + eol + ArrayUtils.toString(persistentFieldClasses)
+                        + eol + "Last exception message was: "
+                        + eol + latestException.message, latestException.exception);
             }
             try
             {
@@ -101,8 +109,8 @@
             }
             else
             {
-                handleException("Can't extract field value for field " + getName()
-                        + " from object " + (anObject != null ? anObject.getClass() : null), e);
+                handleException("Can't extract field value for field '" + getName()
+                        + "' from object " + (anObject != null ? anObject.getClass() : null) + " using " + getCurrent().getClass(), e);
                 return get(anObject);
             }
         }
@@ -122,8 +130,8 @@
             }
             else
             {
-                handleException("Can't set value for field " + getName()
-                        + " to object " + (obj != null ? obj.getClass() : null), e);
+                handleException("Can't set value for field '" + getName()
+                        + "' to object " + (obj != null ? obj.getClass() : null) + " using " + getCurrent().getClass(), e);
                 set(obj, value);
             }
         }
@@ -143,7 +151,7 @@
             }
             else
             {
-                handleException("Can't identify field type for field " + getName(), null);
+                handleException("Can't identify field type for field '" + getName() + "'", null);
                 return getType();
             }
         }

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldBase.java
URL: http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldBase.java?rev=367091&r1=367090&r2=367091&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldBase.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldBase.java Sun Jan  8 12:36:03 2006
@@ -199,12 +199,12 @@
         StringBuffer buf = new StringBuffer();
         buf
                 .append(eol + "[try to set 'object value' in 'target object'")
-                .append(eol + "target obj class: " + (obj != null ? obj.getClass().getName() : null))
-                .append(eol + "target field name: " + (aField != null ? aField.getName() : null))
-                .append(eol + "target field type: " + (aField != null ? aField.getType() : null))
-                .append(eol + "target field declared in: " + (aField != null ? aField.getDeclaringClass().getName() : null))
-                .append(eol + "object value class: " + (value != null ? value.getClass().getName() : null))
-                .append(eol + "object value: " + (value != null ? value : null))
+                .append(eol + "  target obj class: " + (obj != null ? obj.getClass().getName() : null))
+                .append(eol + "  target field name: " + (aField != null ? aField.getName() : null))
+                .append(eol + "  target field type: " + (aField != null ? aField.getType() : null))
+                .append(eol + "  target field declared in: " + (aField != null ? aField.getDeclaringClass().getName() : null))
+                .append(eol + "  object value class: " + (value != null ? value.getClass().getName() : null))
+                .append(eol + "  object value: " + (value != null ? value : null))
                 .append(eol + "]");
         return buf.toString();
     }
@@ -218,10 +218,10 @@
         StringBuffer buf = new StringBuffer();
         buf
                 .append(eol + "[try to read from source object")
-                .append(eol + "source obj class: " + (obj != null ? obj.getClass().getName() : null))
-                .append(eol + "target field name: " + (aField != null ? aField.getName() : null))
-                .append(eol + "target field type: " + (aField != null ? aField.getType() : null))
-                .append(eol + "target field declared in: " + (aField != null ? aField.getDeclaringClass().getName() : null))
+                .append(eol + "  source obj class: " + (obj != null ? obj.getClass().getName() : null))
+                .append(eol + "  target field name: " + (aField != null ? aField.getName() : null))
+                .append(eol + "  target field type: " + (aField != null ? aField.getType() : null))
+                .append(eol + "  target field declared in: " + (aField != null ? aField.getDeclaringClass().getName() : null))
                 .append(eol + "]");
         return buf.toString();
     }
@@ -253,31 +253,31 @@
         buf
             .append(eol + "["
                     + (msg == null ? "try to handle " + type + " property call" : type + " property call: " + msg))
-            .append(eol + "Declaring class [" + getDeclaringClass().getName() + "]")
-            .append(eol + "Property Name [" + getName() + "]")
-            .append(eol + "Property Type ["
+            .append(eol + "  Declaring class [" + getDeclaringClass().getName() + "]")
+            .append(eol + "  Property Name [" + getName() + "]")
+            .append(eol + "  Property Type ["
                     + (returnOrArgumentType != null ? returnOrArgumentType.getName() : "not available") + "]");
 
         if (anObject != null)
         {
             //buf.append("the " + (isSetter ? "target" : "source") + " object was [" + anObject + "]");
-            buf.append(eol + "the "
+            buf.append(eol + "  the "
                     + (isSetter ? "target" : "source") + " object type was [" + anObject.getClass().getName() + "]");
         }
         else
         {
-            buf.append(eol + "the " + (isSetter ? "target" : "source") + " object was 'null'");
+            buf.append(eol + "  the " + (isSetter ? "target" : "source") + " object was 'null'");
         }
         if(isSetter)
         {
             if (aValue != null)
             {
-                buf.append(eol + "the value was [" + aValue + "]");
-                buf.append(eol + "the value type was [" + aValue.getClass().getName() + "]");
+                buf.append(eol + "  the value was [" + aValue + "]");
+                buf.append(eol + "  the value type was [" + aValue.getClass().getName() + "]");
             }
             else
             {
-                buf.append(eol + "the value was 'null'");
+                buf.append(eol + "  the value was 'null'");
             }
         }
         return buf.toString();

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldDynaBeanImpl.java
URL: http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldDynaBeanImpl.java?rev=367091&r1=367090&r2=367091&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldDynaBeanImpl.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldDynaBeanImpl.java Sun Jan  8 12:36:03 2006
@@ -16,6 +16,7 @@
  */
 
 import org.apache.commons.beanutils.DynaBean;
+import org.apache.commons.lang.SystemUtils;
 import org.apache.ojb.broker.PersistenceBrokerException;
 import org.apache.ojb.broker.metadata.MetadataException;
 import org.apache.ojb.broker.util.logging.Logger;
@@ -130,26 +131,28 @@
      */
     protected void logSetProblem(Object anObject, Object aValue, String msg)
     {
-        Logger logger = LoggerFactory.getDefaultLogger();
-        logger.error("Error in operation [set] of object [" + this.getClass().getName() + "], " + msg);
-        logger.error("Property Name [" + getName() + "]");
+        String eol = SystemUtils.LINE_SEPARATOR;
+        StringBuffer buf = new StringBuffer();
+        buf.append("Error in [set] operation: " + msg);
+        buf.append(eol + "  Property Name [" + getName() + "]");
         if (anObject instanceof DynaBean)
         {
             DynaBean dynaBean = (DynaBean) anObject;
-            logger.error("anObject was DynaClass [" + dynaBean.getDynaClass().getName() + "]");
+            buf.append(eol + "  the target object is a DynaClass [" + dynaBean.getDynaClass().getName() + "]");
         }
         else if (anObject != null)
         {
-            logger.error("anObject was class [" + anObject.getClass().getName() + "]");
+            buf.append(eol + "  the target object type is [" + anObject.getClass().getName() + "]");
         }
         else
         {
-            logger.error("anObject was null");
+            buf.append(eol + "  the target object is 'null'");
         }
         if (aValue != null)
-            logger.error("aValue was class [" + aValue.getClass().getName() + "]");
+            buf.append(eol + "  the value type is [" + aValue.getClass().getName() + "]");
         else
-            logger.error("aValue was null");
+            buf.append(eol + "  the value is 'null'");
+        getLog().error(buf.toString());
     }
 
     /**
@@ -157,21 +160,23 @@
      */
     protected void logGetProblem(Object anObject, String msg)
     {
-        Logger logger = LoggerFactory.getDefaultLogger();
-        logger.error("Error in operation [get of object [" + this.getClass().getName() + "], " + msg);
-        logger.error("Property Name [" + getName() + "]");
+        String eol = SystemUtils.LINE_SEPARATOR;
+        StringBuffer buf = new StringBuffer();
+        buf.append("Error in [get] operation: " + msg);
+        buf.append(eol + "  Property Name [" + getName() + "]");
         if (anObject instanceof DynaBean)
         {
             DynaBean dynaBean = (DynaBean) anObject;
-            logger.error("anObject was DynaClass [" + dynaBean.getDynaClass().getName() + "]");
+            buf.append(eol + "  the object to read is a DynaClass [" + dynaBean.getDynaClass().getName() + "]");
         }
         else if (anObject != null)
         {
-            logger.error("anObject was class [" + anObject.getClass().getName() + "]");
+            buf.append(eol + "  the type of object to read is [" + anObject.getClass().getName() + "]");
         }
         else
         {
-            logger.error("anObject was null");
+            buf.append(eol + "  the object to read is 'null'");
         }
+        getLog().error(buf.toString());
     }
 }



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