jersey
  1. jersey
  2. JERSEY-1251

Interface based resources and clients

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-m05
    • Fix Version/s: 1.13, 2.0-m06, 2.0
    • Component/s: None
    • Labels:
      None

      Description

      I am not sure is it right place to share my opinions but I could not be successful to be subscribe to mailing list. I have tried to read latest draft but I could not find something useful.

      We would like to decrease the amount of coding and bottlenecks. What I would like to offer you is interface based clients and resources. I have done a primitive proxy client implementation and with the help of spring resources to provide greatly eliminated client codes. ( If I remember correctly, Jeanfrancois Arcand has done something similar.)

      Shortly,

      We have divided our modules to 3 main part.

      • API
      • Client
      • Server

      API has interfaces like this:

      @Path("service")
      public interface CampaignPersonalResource  {
      
         @GET
         @Path("active/user")
         public Object getActiveUsersCampaigns() ;
      
      }
      
      

      Client is providing a connection to API

       public void testActiveUsers(){
              CampaignPersonalResource resource = new ProxyClientBuilder()
                      .client(c)
                      .port(3131)
                      .context("test")
                      .build(CampaignPersonalResource.class);
           
           // to use 
           resource.getActiveUsersCampaigns();    
       }
      

      Server side is an implementation of the interface. Hope that I have shared this in right place. If it is already discussed, please point me necessary links.

      As a result of these improvements client and server side codes will be type safety and the amount of coding for client codes will be eliminated.

      Thanks

        Activity

        Hide
        Martin Matula added a comment -

        We have this in Jersey 2.0.

        Please look at my blog and let me know if it covers what you suggest: http://blog.alutam.com/2012/05/04/proxy-client-on-top-of-jax-rs-2-0-client-api/

        In this sprint I will be moving it from the incubator to the main workspace.

        Btw, this is for Jersey 2.0 - currently we are not planning to provide this on top of Jersey 1.x (although it is quite easy to do).

        Show
        Martin Matula added a comment - We have this in Jersey 2.0. Please look at my blog and let me know if it covers what you suggest: http://blog.alutam.com/2012/05/04/proxy-client-on-top-of-jax-rs-2-0-client-api/ In this sprint I will be moving it from the incubator to the main workspace. Btw, this is for Jersey 2.0 - currently we are not planning to provide this on top of Jersey 1.x (although it is quite easy to do).
        Hide
        Martin Matula added a comment -

        And you can subscribe to the mailing lists here: http://java.net/projects/jersey/lists (you have to be logged into java.net to see the "Subscribe" buttons)

        Show
        Martin Matula added a comment - And you can subscribe to the mailing lists here: http://java.net/projects/jersey/lists (you have to be logged into java.net to see the "Subscribe" buttons)
        Hide
        cemokoc added a comment -

        Thanks Martin for clarification. You made my day. I could not subscribe the jsr339 mailing list. I thought that it was more suitable for there.

        Btw why this is not supported by Jersey 1.x too? It seems that we will need to wait quite long for finalizing JSR-339 and I am sure it might be utilized by a lot of people easily by 1.x.

        I will ask other questions at Jersey Mailing List,

        thanks.

        Show
        cemokoc added a comment - Thanks Martin for clarification. You made my day. I could not subscribe the jsr339 mailing list. I thought that it was more suitable for there. Btw why this is not supported by Jersey 1.x too? It seems that we will need to wait quite long for finalizing JSR-339 and I am sure it might be utilized by a lot of people easily by 1.x. I will ask other questions at Jersey Mailing List, thanks.
        Hide
        Martin Matula added a comment -

        Well, maybe I will add it as a contrib module to Jersey 1.x as well - it is simple to do, so should be feasible to back-port from Jersey 2.0 in one day.

        If you want to subscribe to jsr339 mailing list, you can do that as well - all the expert group messages get replicated to the users list that is open to all. You can subscribe here: http://java.net/projects/jax-rs-spec/lists

        Show
        Martin Matula added a comment - Well, maybe I will add it as a contrib module to Jersey 1.x as well - it is simple to do, so should be feasible to back-port from Jersey 2.0 in one day. If you want to subscribe to jsr339 mailing list, you can do that as well - all the expert group messages get replicated to the users list that is open to all. You can subscribe here: http://java.net/projects/jax-rs-spec/lists
        Hide
        cemokoc added a comment -

        Martin, how do you handle for javax.ws.rs.core.Response return types? Because at client side Response type at resources are changing to ClientResponse. And ClientResponse is not sharing a common super class with Response Type at resource.

        Show
        cemokoc added a comment - Martin, how do you handle for javax.ws.rs.core.Response return types? Because at client side Response type at resources are changing to ClientResponse. And ClientResponse is not sharing a common super class with Response Type at resource.
        Hide
        Martin Matula added a comment -

        OK, now it is there as an experimental module in Jersey 1.x workspace: http://java.net/projects/jersey/sources/svn/show/trunk/jersey/experimental/proxy-client

        I dealt with the Response issue by creating ClientResponseWrapper that extends Response and has getClientResponse() method you can call to access the original client response. The usage can be seen in the proxy-client test.

        Show
        Martin Matula added a comment - OK, now it is there as an experimental module in Jersey 1.x workspace: http://java.net/projects/jersey/sources/svn/show/trunk/jersey/experimental/proxy-client I dealt with the Response issue by creating ClientResponseWrapper that extends Response and has getClientResponse() method you can call to access the original client response. The usage can be seen in the proxy-client test.
        Hide
        Martin Matula added a comment -

        Keeping this open until I move proxy client from the incubator to the main workspace in Jersey 2.0.

        Show
        Martin Matula added a comment - Keeping this open until I move proxy client from the incubator to the main workspace in Jersey 2.0.
        Hide
        Martin Matula added a comment -

        Proxy client is now in jersey/ext.

        Show
        Martin Matula added a comment - Proxy client is now in jersey/ext.

          People

          • Assignee:
            Martin Matula
            Reporter:
            cemokoc
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: