MCPcopy Create free account
hub / github.com/apache/thrift / main

Method main

tutorial/java/src/JavaClient.java:33–71  ·  view source on GitHub ↗
(String [] args)

Source from the content-addressed store, hash-verified

31
32public class JavaClient {
33 public static void main(String [] args) {
34
35 if (args.length != 1) {
36 System.out.println("Please enter 'simple' or 'secure'");
37 System.exit(0);
38 }
39
40 try {
41 TTransport transport;
42 if (args[0].contains("simple")) {
43 transport = new TSocket("localhost", 9090);
44 transport.open();
45 }
46 else {
47 /*
48 * Similar to the server, you can use the parameters to setup client parameters or
49 * use the default settings. On the client side, you will need a TrustStore which
50 * contains the trusted certificate along with the public key.
51 * For this example it's a self-signed cert.
52 */
53 TSSLTransportParameters params = new TSSLTransportParameters();
54 params.setTrustStore("../../lib/java/test/resources/.truststore", "thrift", "SunX509", "JKS");
55 /*
56 * Get a client transport instead of a server transport. The connection is opened on
57 * invocation of the factory method, no need to specifically call open()
58 */
59 transport = TSSLTransportFactory.getClientSocket("localhost", 9091, 0, params);
60 }
61
62 TProtocol protocol = new TBinaryProtocol(transport);
63 Calculator.Client client = new Calculator.Client(protocol);
64
65 perform(client);
66
67 transport.close();
68 } catch (TException x) {
69 x.printStackTrace();
70 }
71 }
72
73 private static void perform(Calculator.Client client) throws TException
74 {

Callers

nothing calls this directly

Calls 5

openMethod · 0.95
setTrustStoreMethod · 0.95
getClientSocketMethod · 0.95
performMethod · 0.95
closeMethod · 0.95

Tested by

no test coverage detected