Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-746

Generated services Iface/Client inner classes do not derive from base classes

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.2
    • 0.3
    • Java - Compiler
    • None
    • All

    Description

      When defining a service in Thrift, the generated code looks like

      public class Service {
      public interface Iface

      { ... }

      public static class Client

      { ... }

      }

      This makes it quite hard to create generic classes which accept any kind of Client or Iface as a parameter. One such use case is the pooling of Client objects.

      One way to circumvent this is to create a top level thrift service and have all other services extend it, but then there will be no coherency across the thrift community.

      What about introducing a TService class:

      public class TService {
      public interface Iface {}
      public static class Client {
      public Client(TProtocol prot)

      { this(prot,prot); }

      public Client(TProtocol iprot, TProtocol oprot) {}
      }
      }

      and have generated services inherit from it:

      public class Service {
      public interface Iface extends TService.Iface {
      }
      public static class Client extends TService.Client {
      }
      }

      As a bonus I'll contribute the pooling mechanism I've created for Bibale (based on GenericObjectPool).

      Attachments

        1. TService.patch
          2 kB
          Mathias Herberts
        2. TServiceClient.patch
          2 kB
          Mathias Herberts
        3. TServiceClient.patch-2
          2 kB
          Mathias Herberts
        4. TServiceClient-r930531.patch
          4 kB
          Mathias Herberts

        Activity

          People

            herberts Mathias Herberts
            herberts Mathias Herberts
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: