2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
22 import org.apache.thrift.*;
23 import org.apache.thrift.protocol.*;
24 import org.apache.thrift.transport.*;
25 import org.apache.thrift.server.*;
26 import org.apache.thrift.meta_data.*;
28 import thrift.test.*; // generated code
33 public static function Execute(args : Arguments) : Void
38 var transport : TServerTransport = null;
39 switch( args.transport) {
41 trace("- socket port "+args.port);
42 transport = new TServerSocket( args.port);
46 throw "HTTP server not implemented yet";
47 //transport = new THttpServer( targetHost);
49 transport = new TWrappingServerTransport(
51 new TFileStream("php://input", Read),
52 new TFileStream("php://output", Append)
58 throw "Unhandled transport";
61 // optional: layered transport
62 var transfactory : TTransportFactory = null;
64 trace("- framed transport");
65 transfactory = new TFramedTransportFactory();
68 trace("- buffered transport");
69 transfactory = new TBufferedTransportFactory();
73 var protfactory : TProtocolFactory = null;
74 switch( args.protocol)
77 trace("- binary protocol");
78 protfactory = new TBinaryProtocolFactory();
80 trace("- json protocol");
81 protfactory = new TJSONProtocolFactory();
83 trace("- compact protocol");
84 protfactory = new TCompactProtocolFactory();
89 var handler = new TestServerHandler();
90 var processor = new ThriftTestProcessor(handler);
93 var server : TServer = null;
94 switch( args.servertype)
97 var simpleServer = new TSimpleServer( processor, transport, transfactory, protfactory);
99 simpleServer.runOnce = true;
101 server = simpleServer;
104 throw "Unhandled server type";
109 // Server event handler
110 if( args.serverEvents) {
111 var events = new TestServerEventHandler();
112 server.setEventHandler(serverEvents);
113 handler.server = serverEngine;
122 catch (x : TException)
124 trace('$x ${x.errorID} ${x.errorMsg}');