axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Roder <>
Subject Issue - hard to subclass BeanSerializer
Date Wed, 19 Dec 2001 21:37:51 GMT

I am trying to create a subclass of BeanSerializer.  I am working on a
UpperCaseBeanSerializer that will encode attributes to start with uppercase
instead of lowercase. ie.
instead of
 Note: I am doing the
client side soap app that hits a 3rd party soap service that I can not

In just trying to do a rename the class type operation to get it into my
package space I am seeing a couple of issues.

1)There is no easy way to get getDeserializer(Class cls) in a subclass
without a lot of copy/paste of the code.  My complete subclass is included.
Ideas on how to clean this up?  

2)  The following code happens in two locations.  
                    pd =
                    pd = sortPropertyDescriptors(pd, cls);
In doing my subclass, the first line is where I am going to have to change
the behavior for my subclass. I will modify the case of the properties that
the normal BeanInfo gives back.  One of these is expected in the getPd
method, but one is in the getDeserializer() method.   I would just replace
the call in getDeserializer() with getPd, but getPd has the side affect of
setting the enumSerializer.  Ideas on how to clean this up?

Couple of questions.  

Why does BeanSerializer sneak in a EnumSerializer if it thinks it needs it?
Shouldn't the class just be registered with a EnumSerializer instead of a

I am having a hard time reading and understanding the getDeserializer code
and how the factory is working and what the local Hashtable cache is good
for.  It seems it might be missing a static on the hashtable?  Or is is an
instance of the factory going to have getDeserializer called on it that many
times? A new factory instance is returned each time getFactory.  

I don't have much time to wrap my head around this today, so if someone can
throw out pointers, that would be great!




public class UpperCaseBeanSerializer extends BeanSerializer
    implements Serializer, Serializable
    static Category LOG =

     * Default constructor.
    public UpperCaseBeanSerializer() {

     * Constructor that takes a class.  Provided only for convenience.
     * Equivalent to calling setCls(cls) on a new instance.
    public UpperCaseBeanSerializer(Class cls) {

    public static DeserializerFactory getFactory()
      return new UpperCaseBeanSerFactory();

     * UpperCaseBeanSerializer Factory that creates instances with the
     * class.  Caches the PropertyDescriptor
    public static class UpperCaseBeanSerFactory implements
DeserializerFactory {
        private Hashtable propertyDescriptors = new Hashtable();
        public Deserializer getDeserializer(Class cls) {
            PropertyDescriptor [] pd =
                  (PropertyDescriptor [])propertyDescriptors.get(cls);
            if (pd == null) {
                try {
                    pd =
                    pd = sortPropertyDescriptors(pd, cls);
                } catch (IntrospectionException e) {
                    return null;
                propertyDescriptors.put(cls, pd);

            // If an enum class.  Return the Deserializer for Enumeration
            if (isEnumClass(cls)) {
                return EnumSerializer.getFactory().getDeserializer(cls);

            UpperCaseBeanSerializer bs = new UpperCaseBeanSerializer();

            try {
            } catch (Exception e) {
                // I'm not allowed to throw much, so I throw what I can!
                throw new NullPointerException(e.toString());

            return bs;


I won't have time to look into this  of the   

View raw message