1 Reply Latest reply: Jun 28, 2012 10:17 AM by Jonathan Fuerth RSS

Marshalling discovery need to be revised

Anton Kuranov Newbie

Hi,

 

I think that Errai marshalling discovery needs more intelligence to detect portable types automatically. The main problem of current implementation is that unlike GWT-RPC it does not support inheritance of classes. This means that every bean must be explicitly annotated with @Portable. In my project I have a rather big and complex hierarchy of "portable" classes including an abstract ones. And I need to annotate every non-abstract final subclass with @Portable while logically it will be sufficient to mark only superclasses as @Portable. Another problem is that inner classes of a portable class automatically marked as portable. There is no reason for it while usually inner classes may be facades or builders or used internally. Non-static inner classes must be excluded from marshalling because Errai can not initiate them via no-args constructor.

 

I expect that marshalling system can work something like this:

- Every class, abstract class or interface may be marked as @Portable.

- Every class that inherits portable class or interface automatically becomes portable.

- Now we can create a "Portable" marker interface (like Serializable) and mark our classes via inheritance.

- Every class found in set of fields of a portable class (except transient and static) must become portable (including subclasses).

- Every classes discovered in methods of an interface marked as @Remote becomes portable

- Static inner classes of a portable class by default must not be portable.

- It will be good to add support for non-static inner classes. Currently none of GWT serializers support them.

 

Anton

  • 1. Re: Marshalling discovery need to be revised
    Jonathan Fuerth Master

    Hi Anton,

     

    Thanks for this feedback. I agree with you on many points, and I disagree on a few:

     

    - Every class, abstract class or interface may be marked as @Portable.

    - Every class that inherits portable class or interface automatically becomes portable.

    - Now we can create a "Portable" marker interface (like Serializable) and mark our classes via inheritance.

     

    This behaviour makes sense to me, and I think it's a pretty low-risk change in behaviour.

     

    - Every class found in set of fields of a portable class (except transient and static) must become portable (including subclasses).

    - Every classes discovered in methods of an interface marked as @Remote becomes portable

     

    I disagree on these two points. The requirement to explicitly mark types as @Portable has benefits:

     

    1. It prevents accidentally sending large amounts of data over the wire

    2. It is a safety mechanism that prevents sending instances of secret "server only" types over the wire

    3. It advertises to other developers that instances of the type will be serialized, so they need to keep in mind some design constraints

     

    - Static inner classes of a portable class by default must not be portable.

     

    I totally agree. I fought for this default behaviour, but I lost. Unfortunately, you will have to mark each static nested class with @NonPortable (which is newly available in Errai 2.0.1).

     

    - It will be good to add support for non-static inner classes. Currently none of GWT serializers support them.

     

    That's a very good idea. Can you open an issue for this at issues.jboss.org?

     

    -Jonathan