You are viewing a plain text version of this content. The canonical link for it is here.
Posted to graffito-dev@incubator.apache.org by "Dan Connelly (JIRA)" <ji...@apache.org> on 2006/09/13 14:06:22 UTC

[jira] Created: (GRFT-101) Allow developer to supply "newInstace" method in subclass of ObjectConverterImpl

Allow developer to supply "newInstace" method in subclass of ObjectConverterImpl
--------------------------------------------------------------------------------

                 Key: GRFT-101
                 URL: http://issues.apache.org/jira/browse/GRFT-101
             Project: Graffito
          Issue Type: Improvement
    Affects Versions: 1.0-a1-dev
         Environment: JCR Mapping
            Reporter: Dan Connelly


I used a simple change in ObjectConverterImpl.   This allows me to use a Factory class (in place of JavaBean constructors) in my object model.

I added the following method to ObjectConverterImpl.:

   protected Object newInstance(String className) {
       return ReflectionUtils.newInstance(className);
   }


Elsewhere in ObjectConverterImpl, it will now invoke

           this.newInstance(classDescriptor.getClassName());

every where that is previously invoked

           ReflectionUtils.newInstance(classDescriptor.getClassName());

Now I can over-ride the newInstance method in MyObjectConverterImpl (which subclasses ObjectConverterImpl).   This allows me to construct objects for my model using its Factory class.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (GRFT-101) Allow developer to supply "newInstace" method in subclass of ObjectConverterImpl

Posted by "Dan Connelly (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/GRFT-101?page=comments#action_12436668 ] 
            
Dan Connelly commented on GRFT-101:
-----------------------------------

A proper patch just for this issue would take more] time than I have because I have other changes in this code, particularly an implementation of REFERENCE fields.    I can within a few days submit a patch for the combined issues if that is needed.

Actually for this JIRA, the code change is easy.   No need to wait for a grand patch.    No new JUnits needed for this change.

Add the following methods to ObjectConverterImpl:

	protected Object newInstance(String className) {
		return ReflectionUtils.newInstance(className);
	}
	
	protected void setNestedProperty(Object object, String fieldName, Object value) {
		ReflectionUtils.setNestedProperty(object, fieldName, value);
	}


Then modify ALL invocations of ReflectionUtils.newInstance and ReflectionUtils.setNestedProperty in the code.

Make those invocations this.newInstance and this.setNestedProperty, respectively.




> Allow developer to supply "newInstace" method in subclass of ObjectConverterImpl
> --------------------------------------------------------------------------------
>
>                 Key: GRFT-101
>                 URL: http://issues.apache.org/jira/browse/GRFT-101
>             Project: Graffito
>          Issue Type: Improvement
>    Affects Versions: 1.0-a1-dev
>         Environment: JCR Mapping
>            Reporter: Dan Connelly
>
> I used a simple change in ObjectConverterImpl.   This allows me to use a Factory class (in place of JavaBean constructors) in my object model.
> I added the following method to ObjectConverterImpl.:
>    protected Object newInstance(String className) {
>        return ReflectionUtils.newInstance(className);
>    }
> Elsewhere in ObjectConverterImpl, it will now invoke
>            this.newInstance(classDescriptor.getClassName());
> every where that is previously invoked
>            ReflectionUtils.newInstance(classDescriptor.getClassName());
> Now I can over-ride the newInstance method in MyObjectConverterImpl (which subclasses ObjectConverterImpl).   This allows me to construct objects for my model using its Factory class.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (GRFT-101) Allow developer to supply "newInstace" method in subclass of ObjectConverterImpl

Posted by "Dan Connelly (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/GRFT-101?page=comments#action_12434654 ] 
            
Dan Connelly commented on GRFT-101:
-----------------------------------

Also, since collection may be an immutable (where collection cannot be set in an object, but items in the existing collection can be aded and removed), a similar hook in ObjectConverterImpl is needed to support an escape from having ReflectionUtils attempt to forace a NEW collection instance into the object:

	
	protected void setCollection(Object object, String fieldName, ManageableCollection collection) {
		ReflectionUtils.setNestedProperty(object, fieldName, collection);
	}


Then change collection setter in retrieveCollectionField method to:

		this.setCollection(object, collectionDescriptor.getFieldName(), collection);

> Allow developer to supply "newInstace" method in subclass of ObjectConverterImpl
> --------------------------------------------------------------------------------
>
>                 Key: GRFT-101
>                 URL: http://issues.apache.org/jira/browse/GRFT-101
>             Project: Graffito
>          Issue Type: Improvement
>    Affects Versions: 1.0-a1-dev
>         Environment: JCR Mapping
>            Reporter: Dan Connelly
>
> I used a simple change in ObjectConverterImpl.   This allows me to use a Factory class (in place of JavaBean constructors) in my object model.
> I added the following method to ObjectConverterImpl.:
>    protected Object newInstance(String className) {
>        return ReflectionUtils.newInstance(className);
>    }
> Elsewhere in ObjectConverterImpl, it will now invoke
>            this.newInstance(classDescriptor.getClassName());
> every where that is previously invoked
>            ReflectionUtils.newInstance(classDescriptor.getClassName());
> Now I can over-ride the newInstance method in MyObjectConverterImpl (which subclasses ObjectConverterImpl).   This allows me to construct objects for my model using its Factory class.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (GRFT-101) Allow developer to supply "newInstace" method in subclass of ObjectConverterImpl

Posted by "Christophe Lombart (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/GRFT-101?page=comments#action_12436645 ] 
            
Christophe Lombart commented on GRFT-101:
-----------------------------------------

Dan, 

Can you provide a patch for this issue ? 

> Allow developer to supply "newInstace" method in subclass of ObjectConverterImpl
> --------------------------------------------------------------------------------
>
>                 Key: GRFT-101
>                 URL: http://issues.apache.org/jira/browse/GRFT-101
>             Project: Graffito
>          Issue Type: Improvement
>    Affects Versions: 1.0-a1-dev
>         Environment: JCR Mapping
>            Reporter: Dan Connelly
>
> I used a simple change in ObjectConverterImpl.   This allows me to use a Factory class (in place of JavaBean constructors) in my object model.
> I added the following method to ObjectConverterImpl.:
>    protected Object newInstance(String className) {
>        return ReflectionUtils.newInstance(className);
>    }
> Elsewhere in ObjectConverterImpl, it will now invoke
>            this.newInstance(classDescriptor.getClassName());
> every where that is previously invoked
>            ReflectionUtils.newInstance(classDescriptor.getClassName());
> Now I can over-ride the newInstance method in MyObjectConverterImpl (which subclasses ObjectConverterImpl).   This allows me to construct objects for my model using its Factory class.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (GRFT-101) Allow developer to supply "newInstace" method in subclass of ObjectConverterImpl

Posted by "Dan Connelly (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/GRFT-101?page=comments#action_12436669 ] 
            
Dan Connelly commented on GRFT-101:
-----------------------------------

The setCollection method in a previous comment is not necessary.   Its the same as the setNestedProperty method.

> Allow developer to supply "newInstace" method in subclass of ObjectConverterImpl
> --------------------------------------------------------------------------------
>
>                 Key: GRFT-101
>                 URL: http://issues.apache.org/jira/browse/GRFT-101
>             Project: Graffito
>          Issue Type: Improvement
>    Affects Versions: 1.0-a1-dev
>         Environment: JCR Mapping
>            Reporter: Dan Connelly
>
> I used a simple change in ObjectConverterImpl.   This allows me to use a Factory class (in place of JavaBean constructors) in my object model.
> I added the following method to ObjectConverterImpl.:
>    protected Object newInstance(String className) {
>        return ReflectionUtils.newInstance(className);
>    }
> Elsewhere in ObjectConverterImpl, it will now invoke
>            this.newInstance(classDescriptor.getClassName());
> every where that is previously invoked
>            ReflectionUtils.newInstance(classDescriptor.getClassName());
> Now I can over-ride the newInstance method in MyObjectConverterImpl (which subclasses ObjectConverterImpl).   This allows me to construct objects for my model using its Factory class.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira