db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/util ProxyHelper.java
Date Sat, 08 Nov 2003 20:41:51 GMT
brj         2003/11/08 12:41:51

  Modified:    src/java/org/apache/ojb/broker/util ProxyHelper.java
  Log:
  improved error reporting
  
  Revision  Changes    Path
  1.19      +37 -14    db-ojb/src/java/org/apache/ojb/broker/util/ProxyHelper.java
  
  Index: ProxyHelper.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/ProxyHelper.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- ProxyHelper.java	8 Nov 2003 17:33:02 -0000	1.18
  +++ ProxyHelper.java	8 Nov 2003 20:41:51 -0000	1.19
  @@ -62,6 +62,7 @@
   import com.develop.java.lang.reflect.InvocationHandler;
   */
   //#endif
  +
   import java.lang.reflect.Constructor;
   
   import java.util.List;
  @@ -130,7 +131,7 @@
                       collectionProxyClass+"] defined in configuration", e);
           }
       }
  -
  +  
       /**
        * Get the real Object
        *
  @@ -147,6 +148,8 @@
           */
           if ((objectOrProxy instanceof Proxy) && Proxy.isProxyClass(objectOrProxy.getClass()))
           {
  +            String msg;
  +            
               try
               {
                   handler = (IndirectionHandler) Proxy.getInvocationHandler(objectOrProxy);
  @@ -154,17 +157,19 @@
               }
               catch (ClassCastException e)
               {
  -                log.error("The InvocationHandler for the provided Proxy was not an instance
of org.apache.ojb.broker.accesslayer.IndirectionHandler.");
  -                throw new PersistenceBrokerException("The InvocationHandler for the provided
Proxy was not an instance of org.apache.ojb.broker.accesslayer.IndirectionHandler.", e);
  +                msg = "The InvocationHandler for the provided Proxy was not an instance
of " + IndirectionHandler.class.getName();
  +                log.error(msg);
  +                throw new PersistenceBrokerException(msg, e);
               }
               catch (IllegalArgumentException e)
               {
  -                log.error("Could not retrieve real object for given Proxy: "+objectOrProxy);
  -                throw new PersistenceBrokerException(e);
  +                msg = "Could not retrieve real object for given Proxy: " + objectOrProxy;
  +                log.error(msg);
  +                throw new PersistenceBrokerException(msg, e);
               }
               catch (PersistenceBrokerException e)
               {
  -                log.error("Could not retrieve real object for given Proxy: "+objectOrProxy);
  +                log.error("Could not retrieve real object for given Proxy: " + objectOrProxy);
                   throw e;
               }
           }
  @@ -176,7 +181,7 @@
               }
               catch (PersistenceBrokerException e)
               {
  -                log.error("Could not retrieve real object for VirtualProxy: "+objectOrProxy);
  +                log.error("Could not retrieve real object for VirtualProxy: " + objectOrProxy);
                   throw e;
               }
           }
  @@ -202,6 +207,8 @@
           */
           if ((objectOrProxy instanceof Proxy) && Proxy.isProxyClass(objectOrProxy.getClass()))
           {
  +            String msg;
  +            
               try
               {
                   handler = (IndirectionHandler) Proxy.getInvocationHandler(objectOrProxy);
  @@ -214,14 +221,21 @@
                       return null;
                   }
               }
  +            catch (ClassCastException e)
  +            {
  +                msg = "The InvocationHandler for the provided Proxy was not an instance
of " + IndirectionHandler.class.getName();
  +                log.error(msg);
  +                throw new PersistenceBrokerException(msg, e);
  +            }
               catch (IllegalArgumentException e)
               {
  -                log.error("Could not retrieve real object for given Proxy: "+objectOrProxy);
  -                throw new PersistenceBrokerException(e);
  +                msg = "Could not retrieve real object for given Proxy: " + objectOrProxy;
  +                log.error(msg);
  +                throw new PersistenceBrokerException(msg, e);
               }
               catch (PersistenceBrokerException e)
               {
  -                log.error("Could not retrieve real object for given Proxy: "+objectOrProxy);
  +                log.error("Could not retrieve real object for given Proxy: " + objectOrProxy);
                   throw e;
               }
           }
  @@ -241,7 +255,7 @@
               }
               catch (PersistenceBrokerException e)
               {
  -                log.error("Could not retrieve real object for VirtualProxy: "+objectOrProxy);
  +                log.error("Could not retrieve real object for VirtualProxy: " + objectOrProxy);
                   throw e;
               }
           }
  @@ -268,6 +282,8 @@
           */
           if ((objectOrProxy instanceof Proxy) && Proxy.isProxyClass(objectOrProxy.getClass()))
           {
  +            String msg;
  +            
               try
               {
                   handler = (IndirectionHandler) Proxy.getInvocationHandler(objectOrProxy);
  @@ -278,10 +294,17 @@
                   // return handler.getIdentity().getObjectsTopLevelClass();
                   return handler.getIdentity().getObjectsRealClass();
               }
  +            catch (ClassCastException e)
  +            {
  +                msg = "The InvocationHandler for the provided Proxy was not an instance
of " + IndirectionHandler.class.getName();
  +                log.error(msg);
  +                throw new PersistenceBrokerException(msg, e);
  +            }
               catch (IllegalArgumentException e)
               {
  -                log.error("Could not retrieve real Class for Proxy: "+objectOrProxy);
  -                throw e;
  +                msg = "Could not retrieve real object for given Proxy: " + objectOrProxy;
  +                log.error(msg);
  +                throw new PersistenceBrokerException(msg, e);
               }
           }
           else if (objectOrProxy instanceof VirtualProxy)
  
  
  

---------------------------------------------------------------------
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