/** * @param clientClass * @param url * @param token * @return * @throws TTransportException */ <T> T createStoreClient(Class<T> clientClass, String url, String token) throws TTransportException { THttpClient transport = new THttpClient(url); transport.setCustomHeader(USER_AGENT_KEY, generateUserAgent()); if (customHeaders != null) { for (Map.Entry<String, String> header : customHeaders.entrySet()) { transport.setCustomHeader(header.getKey(), header.getValue()); } } TProtocol protocol = new TBinaryProtocol(transport); try { return clientClass.getDeclaredConstructor(TProtocol.class, TProtocol.class, String.class).newInstance(protocol, protocol, token); } catch (Throwable e) { throw new RuntimeException("Couldn't create " + clientClass.getName() + " due to the error.", e); } }
/** * @param clientClass * @param url * @param token * @return * @throws TTransportException */ <T> T createStoreClient(Class<T> clientClass, String url, String token) throws TTransportException { THttpClient transport = new THttpClient(url); transport.setCustomHeader(USER_AGENT_KEY, generateUserAgent()); if (customHeaders != null) { for (Map.Entry<String, String> header : customHeaders.entrySet()) { transport.setCustomHeader(header.getKey(), header.getValue()); } } TProtocol protocol = new TBinaryProtocol(transport); try { return clientClass.getDeclaredConstructor(TProtocol.class, TProtocol.class, String.class).newInstance(protocol, protocol, token); } catch (Throwable e) { throw new RuntimeException("Couldn't create " + clientClass.getName() + " due to the error.", e); } }