[aerogear-dev] Nested endpoints (cont.)

Summers Pittman supittma at redhat.com
Wed May 1 14:39:06 EDT 2013


So the old thread was getting a bit long windy.

Here are the current issues that are being discussed on nested endpoints 
(and things which we need to discuss before we move ahead on putting 
them in the Pipe spec)

1.  Saving and removing look really weird.
     pipe.remove(2,'/child/3', callback)
         vs
     pipe.remove(2, callback)

    The first removes an element in the child collection with an id 3 of 
parent with id 2.  The second removes the parent with id 2.  This really 
isn't THAT weird but it is a bit ugly.

    pipe.save(new Parent(), callback)
     vs
    pipe.save(new Child(), '2/child', callback)

    The first saves a new parent object but the second saves a new child 
under the parent with an id of 2.

2. The type of Pipe breaks with nested resources as they are.

   In Android Pipe is parameterized with a type which correlates to the 
resource it represents.  This type is serialized into an instance of the 
resource and the serialization mechanism does not change.  For example

    Pipe<Parent> pipe = new RestAdapter<Parent>(URL, Parent.class);
    pipe.read(callback);

    Passes a instance of List<Parent> to the callback.  With nested 
resources

    pipe.read('/child/2', callback);

    SHOULD pass a List<Child> to the callback.  There are two ways to do 
this and both feel quite hackey.

    1) Use reflection to find the type of child and then use that class.
        The obvious problem with this is that a service may not return 
all of the children attached to a Parent if you ask for just the Parent 
(or all of the Parents) but the Parent class on Android would have to 
include it.
    2) Pass a type to the read operation.
         This is LESS hackey and possibly OK, except that we will have 
to add more configuration to the GSONdeserialization.  The side effect 
of this means now we have to include serialization information about 
child types in the configuration of the Parent Pipe.  At this point the 
user might as well just make a Child Pipe.

   The same comments apply for save.

Thoughts?

Summers



More information about the aerogear-dev mailing list