Hi,
is it somehow possible to declare a mapping for an abstract class in my
mapping.xml file? When reading this mapping, castor complains that he
cannot find a public noargs consturctor. However, there is one.
In fact, I do not want to create an instance of the abstract class at any
time. I only (un)marshal objects, that extend the abstract class
type. It's very convenient to define all common fields in this class
instead of repeating them in every sub-type.
I found a workaround by simply commenting out two lines in
org.exolab.mapping.xml.loader.Types.isConstructable. My patched version
looks like this:
public static boolean isConstructable( Class type )
{
try {
if ( ( type.getModifiers() & Modifier.PUBLIC ) == 0 )
return false;
// if ( ( type.getModifiers() & ( Modifier.ABSTRACT |
Modifier.INTERFACE ) ) != 0 )
// return false;
if ( ( type.getConstructor( new Class[0] ).getModifiers() &
Modifier.PUBLIC ) != 0 )
return true;
} catch ( NoSuchMethodException except ) {
} catch ( SecurityException except ) {
}
return false;
}
A more elegant solution would be, to define another attribute
"abstract" in the mapping.xml schema, to let castor know, that it is ok,
that a class is not constructable.
As I have to (un)marshal an existing class library to/from xml, it's an
abosulte need for me to have abstract classes supported somehow. Is there
any chance that you will add support, perhaps similar to the way I
proposed, or do you have other plans.
ciao Sebastian
PS: I want to thank all you guys for the good work, you've already done.
Sebastian Kanthak
Technichal University of Darmstadt, Germany
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev