JDK-6179657 : RFE: Classes should be able to provide PersistenceDelegates for their encoding
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-10-15
  • Updated: 2011-03-11
  • Resolved: 2010-10-08
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
A DESCRIPTION OF THE REQUEST :
I propose adding a new interface with a meaning similar to Serializable. Any class implementing XMLEncodable would have to implement getPersistenceDelegate() and return a persistence delegate to encode itself.

There would be three ways of encoding classes using XMLEncoder:

1) Beans, they don't need a persistence delegate.
2) Non-beans that do not implement XMLEncodable would have to associate a PersistenceDelegate with the XMLEncoder for the class
3) Non-beans that implement XMLEncoder and provide getPersistenceDelegate().

In all of the above cases, users can still override these delegates by calling XMLEncoder.setPersistenceDelegate() and providing a custom delegate.

Methods 1 and 2 are currently supported by XMLEncoder. I am simply requesting we add method 3.

JUSTIFICATION :
Reduced overhead: As more and more non-bean core classes are supported under-the-hood by XMLEncoder for encoding, the internal Map of [Class, PersistenceDelegate] will grow. This new method will reduce the overhead of storing such a map.

Increased ease-of-use: No need to associate PersistenceDelegates with classes that implement XMLEncodable. This would apply to 3rd-party classes, core classes, etc.

Backwards compatibility is maintained
###@###.### 10/15/04 02:58 GMT

Comments
EVALUATION I would prefer to use annotations rather than interfaces.
08-10-2010

EVALUATION We need to consider this opportunity. ###@###.### 10/20/04 09:17 GMT
20-10-2004