Search code examples
javaandroidserverthrift

Create thrift service


We have a some mobile service, google maps based (mobile applications for iOS and Android). So, the server part is a Java application, which accepts connection from clients.

In one moment, without me, server was moved (relocated) to another one, and they not moved the Thrift service on the new server. Server works fine, but Android app works only via Apache Thrift. So, the Android developer provided to me the .thrift file.

Can I create service with this data? How? What do I need to read?

The part of .thrift file:

namespace cpp gb65.HelpMeService
namespace csharp gb65.HelpMeService
namespace java com.gb65.HelpMeService
namespace php com.gb65.HelpMeService

//Version
const i32       SERVICE_API_MAJOR_VERSION = 1;
const i32       SERVICE_API_MINOR_VERSION = 0;

enum Res
{
    SUCCESS                             = 0,
    EMAIL_AND_PASSWORD_NOT_FOUND        = 1,
    EMAIL_NOT_UNIQUE                    = 2,
    EMAIL_VALUE_WRONG                   = 3,
    CELLPHONE_NOT_UNIQUE                = 4,
    CELLPHONE_VALUE_WRONG               = 5,
    FIRST_NAME_VALUE_WRONG              = 6,
    LAST_NAME_VALUE_WRONG               = 7,
    PASSWORD_VALUE_WRONG                = 8,
    PHOTO_IS_TOO_LARGE                  = 9,
    SESSION_NOT_FOUND                   = 10,
    TASK_NOT_FOUND                      = 11,
    PHOTO_NOT_FOUND                     = 12,
    USER_NOT_FOUND                      = 13,
    OTHER                               = 14,
    MESSAGE_NOT_FOUND                   = 15,
    OFFER_NOT_FOUND                     = 16,
    ALREADY_FRIENDS                     = 17,
    FRIENDSHIP_OFFER_NOT_FOUND          = 18,   
    _LAST                               = 19
}

If needed, I can provide all of the .thrift file code.


Solution

  • Like CORBA, Thrift has developped a neutral language.
    As shown in this tutorial, you have to compile the .thrift file with

    thrift -r --gen java YourFile.Thrift
    

    After that you have to implement the client calls.