GenericType and proxy issue

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

GenericType and proxy issue

Cem Koc
Hi,

I would like to create a proxy client implementation in order to create client code of the the resource at runtime on the fly. In my projects I observed that client codes of the projects are pretty same. However the cost of the sync of the client codes and resource codes are very expensive for me.

I prefer proxy client codes over static client codes. In order to provide this, I use interface as resource and the created proxy and restful web services are based on this interface. In this way I can provide a contract between my client code and restful web services.

However I have a pretty difficult situtation now regarding type erasure.

I have such a resource

      @POST
      @Path("list")
      public List<SchoolBean> postSchool(String entity) {
         ArrayList<SchoolBean> l = generateData();
         return  l;
      }



I mean without static compilation I would like to generate client code like this:

     Method method = getResourceMethod();
     WebResource r = client.resource(getUri().path("test/list").build());
     ClientResponse cr = r.post(ClientResponse.class, "POST");
    // this is working as I expected
    // cr.getEntity(String.class)

At this point I would like to create entity, in this case "List<SchoolBean>". How I would do this? Note that I have just method information at that point.

What trick should I use to get this information?

cr.getEntity(???????)
Reply | Threaded
Open this post in threaded view
|

Re: GenericType and proxy issue

Cem Koc
new GenericType(method.getGenericReturnType())

solved my problem

thanks.