You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Ivan Filippenko <Iv...@aero.org> on 2002/09/11 08:37:08 UTC

RE: BeanSerializer bug (WAS: rc1 serializes fields with public gettersbutno setters)

Navneet,

Thank you very much.  This is just the tip I needed.

> I believe all you would need to do to decide which fields get serialized
> and which don't is to provide a BeanInfo for the beans you want to 
qualify.
>
> I believe if you do this, the BeanSerializer should 'just work'(TM) and
> leave out the fields omitted from the BeanInfo. I checked the 
BeanSerializer
> code and it seems to do its introspection using the Java Beans 
Introspector
> as I thought it should, so things should work this way. I haven't tested 
this though.

Yes, it does indeed work this way, as my tests demonstrate.
Thanks again!

  -- Ivan





Navneet Joneja <nj...@interwoven.com>
09/10/2002 11:19 AM
Please respond to axis-user

 
        To:     "'axis-user@xml.apache.org'" <ax...@xml.apache.org>
        cc: 
        Subject:        RE: BeanSerializer bug (WAS: rc1 serializes fields with public getters 
butno setters)


Ivan,
Re. your first question, I believe the JAX-RPC specification and tutorial 
says that it should be possible to serialize/deserialize any bean property 
(even those without public mutators), so the fixed behavior would be 
correct.
 
Re. your second question:
Again, speaking from Beta 3 knowledge, so I'm not sure this information is 
up to date.
 
I believe all you would need to do to decide which fields get serialized 
and which don't is to provide a BeanInfo for the beans you want to 
qualify.
 
I believe if you do this, the BeanSerializer should 'just work'(TM) and 
leave out the fields omitted from the BeanInfo. I checked the 
BeanSerializer code and it seems to do its introspection using the Java 
Beans Introspector as I thought it should, so things should work this way. 
I haven't tested this though.
 
I think I read that there's a way to do this in the WSDD as well but I 
can't seem to locate it right now, so perhaps I'm mistaken, in which case 
please excuse my earlier mail that suggested it was possible.
 
- Navneet
 
 
-----Original Message-----
From: Ivan Filippenko [mailto:Ivan.V.Filippenko@aero.org]
Sent: Tuesday, September 10, 2002 8:42 AM
To: axis-user@xml.apache.org
Cc: Navneet Joneja
Subject: RE: BeanSerializer bug (WAS: rc1 serializes fields with public getters 
butno setters)


I tend to agree with your analysis of this situation, Navneet. 
>From this perspective, AXIS rc1 appears actually to have 
*fixed* what used to be a bug as of Beta3, in your opinion -- 
namely, rc1 *does* appear now to serialize/deserialize 
"bean properties" that only have public getters! 

I'd like to hear from the committers what the true specification 
for bean serialization is intended to be ?! 

Finally: 
> I believe that if you want to NOT serialize the field, 
> I believe you could change the wsdd file so that 
> this field does not get serialized. 

How does one do this, exactly? 

Many thanks, 

  -- Ivan 




Navneet Joneja <nj...@interwoven.com> 
09/09/2002 05:29 PM 
Please respond to axis-user 
        
        To:        "'axis-user@xml.apache.org'" <ax...@xml.apache.org> 
        cc:        "'axis-dev@xml.apache.org'" <ax...@xml.apache.org> 
        Subject:        RE: BeanSerializer bug (WAS: rc1 serializes fields 
with public getters but no setters)



Ivan, 
I agree - I think there is a bug in the BeanSerializer, but not quite in 
the way you describe. 
  
First - the solution to your problem - I believe that if you want to NOT 
serialize the field, I believe you could change the wsdd file so that this 
field does not get serialized. 
  
As a matter of fact, I think the fact that the BeanSerializer does not 
deserialize beans (information based off beta 3, so if this has changed, I 
apologise) without a public setter method is a bug. This prevents you from 
making an object immutable AFTER deserialization. Compare the behavior of 
the BeanSerializer with the Java Serialization mechanism which serializes 
EVERYTHING except transient fields. The BeanSerializer should be able to 
do the same. 
  
As an illustrative example, consider the following interface: 
  
public interface AccountService extends java.rmi.Remote { 
    public AccountData getAccountData(); 
    // other methods 
} 
  
class AccountData  { 
    float balance; 
    public float getBalance() { 
        return balance; 
   } 
 
    private void setBalance(float balance) { 
        this.balance=balance; 
    } 
 
    //other bean properties 
} 
  
So basically this interface wants to return all the information about the 
account as a single object to reduce granularity - the AccountData object. 
Now the AccountData should be immutable once deserialized. Setting the 
value of, say, the balance attribute of the bean on the client side will 
have no effect and its presence in the public API would only serve to 
confuse users. 
  
BeanSerializer should be able to handle such classes correctly but alas, 
does not. 
  
- Navneet 
  
 -----Original Message-----
From: Ivan Filippenko [mailto:Ivan.V.Filippenko@aero.org]
Sent: Monday, September 09, 2002 4:23 PM
To: axis-user@xml.apache.org
Subject: rc1 serializes fields with public getters but no setters


This is new and annoying.  If I have a public method getURL() 
but no corresponding setter (and no instance variable, either), 
AXIS rc1 creates a <URL> field in the XML serialization.  But I 
don't want this field, because there are no provisions to deserialize it! 

This is new since Beta3, and looks like a bug, no? 

Thanks, 

 -- Ivan