db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer RowReaderDefaultImpl.java
Date Fri, 06 Feb 2004 07:58:02 GMT
tomdz       2004/02/05 23:58:02

  Modified:    src/java/org/apache/ojb/broker/accesslayer
                        RowReaderDefaultImpl.java
  Log:
  Now checks whether the factory-method is static, and if not, then creates an instance of
the factory-class to call the factory-method at.
  
  Revision  Changes    Path
  1.27      +17 -2     db-ojb/src/java/org/apache/ojb/broker/accesslayer/RowReaderDefaultImpl.java
  
  Index: RowReaderDefaultImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/RowReaderDefaultImpl.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- RowReaderDefaultImpl.java	11 Dec 2003 00:36:41 -0000	1.26
  +++ RowReaderDefaultImpl.java	6 Feb 2004 07:58:02 -0000	1.27
  @@ -64,6 +64,7 @@
   import java.lang.reflect.Constructor;
   import java.lang.reflect.InvocationTargetException;
   import java.lang.reflect.Method;
  +import java.lang.reflect.Modifier;
   import java.sql.ResultSet;
   import java.sql.SQLException;
   import java.util.Map;
  @@ -244,7 +245,21 @@
               try
               {
                   // 1. create an empty Object by calling the no-parms factory method
  -                result = targetClassDescriptor.getFactoryMethod().invoke(null, null);
  +                Method method = targetClassDescriptor.getFactoryMethod();
  +
  +                if (Modifier.isStatic(method.getModifiers()))
  +                {
  +                    // method is static so call it directly
  +                    result = method.invoke(null, null);
  +                }
  +                else
  +                {
  +                    // method is not static, so create an object of the factory first
  +                    // note that this requires a public no-parameter (default) constructor
  +                    Object factoryInstance = targetClassDescriptor.getFactoryClass().newInstance();
  +
  +                    result = method.invoke(factoryInstance, null);
  +                }
               }
               catch (Exception ex)
               {
  
  
  

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