3 Replies Latest reply on May 19, 2006 10:20 AM by shane.bryzak

    WebRemote method serialization with interfaces

      We have a Remoting method in a Service that returns an interface A. Interface A extends Interface B. When the javascript interface is generated by the InterfaceGenerator, it does not generate metadata for Interface B. This means that the object is not fully serialized/deserialized.

      Is there a way to get the full hierarchy generated for interfaces?

      Thanks.

        • 1. Re: WebRemote method serialization with interfaces
          shane.bryzak

          I'll have a look at this over the next few days, it shouldn't be difficult to traverse the inheritence chain and include inherited fields.

          • 2. Re: WebRemote method serialization with interfaces

            Here's another interesting related problem, when the server serializes the return object, it serializes the class. Because the WebRemote method returns an interface, the javascript client does not know that that class actually implements that interface.

            Hypothetical Example:

            
            @Name("service")
            public class Service
            {
             @WebRemote public InterfaceA getA()
             {
             return new ClassA();
             }
            }
            
            public interface InterfaceA
            {
             public String getText();
            }
            
            class ClassA implements InterfaceA
            {
             public String getText()
             {
             return "HelloWorld";
             }
            }
            


            I'm not sure how one would get this to work correctly.

            Is there a way to force remote interface generation for ClassA?

            Could the BeanWrapper also output the names of the interfaces in the block?

            For instance,
            <bean type="ClassA" interfaces="InterfaceA">....</bean>
            



            • 3. Re: WebRemote method serialization with interfaces
              shane.bryzak

              Hmm... I can see how this could be a problem. ClassA would not be defined by the client stub so the client would not know how to deal with it when it is returned. Your idea of including a list of interfaces inside the serialized block sounds good. I'll think about it for a couple of days (its the last day of JavaOne so I won't have time today)