db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess PersistentFieldIntrospectorImpl.java AbstractPersistentField.java
Date Thu, 10 Jul 2003 00:20:59 GMT
arminw      2003/07/09 17:20:59

  Modified:    src/java/org/apache/ojb/broker/metadata/fieldaccess
                        PersistentFieldIntrospectorImpl.java
                        AbstractPersistentField.java
  Log:
  try to fix bug when using
  PersistentFieldIntrospectorImpl.
  Do not use Field instance when using
  bean introspection.
  
  Revision  Changes    Path
  1.2       +20 -1     db-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldIntrospectorImpl.java
  
  Index: PersistentFieldIntrospectorImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldIntrospectorImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PersistentFieldIntrospectorImpl.java	8 Jul 2003 14:30:07 -0000	1.1
  +++ PersistentFieldIntrospectorImpl.java	10 Jul 2003 00:20:59 -0000	1.2
  @@ -88,6 +88,25 @@
           super(aClass, aPropertyName);
       }
   
  +
  +    /*
  +    need to overwrite these three methods to avoid
  +    building of Field instances
  +    */
  +    public String getName()
  +    {
  +        return this.fieldName;
  +    }
  +    public Class getType()
  +    {
  +        return getPropertyDescriptor().getPropertyType();
  +    }
  +    public Class getDeclaringClass()
  +    {
  +        return this.rootObjectType;
  +    }
  +
  +
       /**
        * Sets aValue for anObject
        */
  
  
  
  1.3       +14 -28    db-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess/AbstractPersistentField.java
  
  Index: AbstractPersistentField.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess/AbstractPersistentField.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractPersistentField.java	8 Jul 2003 14:30:07 -0000	1.2
  +++ AbstractPersistentField.java	10 Jul 2003 00:20:59 -0000	1.3
  @@ -79,9 +79,9 @@
       private static final int NESTED_FIELD = 2;
       private static final Class[] METHOD_TYPES = {Class.class, String.class};
   
  -    private transient Field field;
  -    private String fieldName;
  -    private Class rootObjectType;
  +    protected transient Field field;
  +    protected String fieldName;
  +    protected Class rootObjectType;
       /**
        * 0 - not initialized
        * 1 - normal field
  @@ -295,20 +295,17 @@
                               + name + " in object:" + obj.getClass().getName(), e);
                   }
                   Class type = pField.getType();
  -                if ((value != null) || !type.isPrimitive())
  +                /*
  +                TODO: here we need cast to AbstractPersistentField to execute the doSet-method.
  +                Find better solution without cast?
  +                */
  +                if (pField instanceof AbstractPersistentField)
                   {
  -                    /*
  -                    TODO: here we need cast to AbstractPersistentField to execute the doSet-method.
  -                    Find better solution without cast?
  -                    */
  -                    if(pField instanceof AbstractPersistentField)
  -                    {
  -                        ((AbstractPersistentField) pField).doSet(ProxyHelper.getRealObject(obj),
attrib);
  -                    }
  -                    else
  -                    {
  -                        pField.set(ProxyHelper.getRealObject(obj), attrib);
  -                    }
  +                    ((AbstractPersistentField) pField).doSet(ProxyHelper.getRealObject(obj),
attrib);
  +                }
  +                else
  +                {
  +                    pField.set(ProxyHelper.getRealObject(obj), attrib);
                   }
               }
               String nestedName = fieldName.substring(index + PATH_TOKEN.length());
  @@ -324,17 +321,6 @@
   
       private PersistentField createInternPersistentField(Class fieldType, String fieldName)
       {
  -//        try
  -//        {
  -//            Object[] args = {fieldType, fieldName};
  -//            return (AbstractPersistentField) ClassHelper.newInstance(PERSISTENT_FIELD_IMPL_FOR_NESTED,
METHOD_TYPES, args);
  -//        }
  -//        catch (Exception e)
  -//        {
  -//            throw new MetadataException("Cannot create PersistentField for field '" +
fieldName + "' of class " +
  -//                    fieldType.getName(), e);
  -//        }
  -
           try
           {
               return PersistentFieldFactory.createPersistentField(fieldType, fieldName);
  
  
  

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