blob: 4865d3af1dca9515bfc891f8ff87130ffb011896 [file] [log] [blame]
// Copyright 2019 Xinge Gao
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package test;
import com.alibaba.com.caucho.hessian.io.Hessian2Input;
import com.alibaba.com.caucho.hessian.io.Hessian2Output;
import com.caucho.hessian.test.TestHessian2Servlet;
import java.lang.reflect.Method;
public class Hessian {
public static void main(String[] args) throws Exception {
if (args[0].startsWith("reply")) {
Method method = TestHessian2Servlet.class.getMethod(args[0]);
TestHessian2Servlet servlet = new TestHessian2Servlet();
Object object = method.invoke(servlet);
Hessian2Output output = new Hessian2Output(System.out);
output.writeObject(object);
output.flush();
} else if (args[0].startsWith("customReply")) {
Method method = TestCustomReply.class.getMethod(args[0]);
TestCustomReply testCustomReply = new TestCustomReply(System.out);
method.invoke(testCustomReply);
} else if (args[0].startsWith("arg")) {
Hessian2Input input = new Hessian2Input(System.in);
Object o = input.readObject();
Method method = TestHessian2Servlet.class.getMethod(args[0], Object.class);
TestHessian2Servlet servlet = new TestHessian2Servlet();
System.out.print(method.invoke(servlet, o));
} else if (args[0].startsWith("customArg")) {
Method method = TestCustomDecode.class.getMethod(args[0]);
TestCustomDecode testCustomDecode = new TestCustomDecode(System.in);
System.out.print(method.invoke(testCustomDecode));
} else if (args[0].startsWith("throw_")) {
Method method = method = TestThrowable.class.getMethod(args[0]);
TestHessian2Servlet servlet = new TestHessian2Servlet();
Object object = method.invoke(servlet);
Hessian2Output output = new Hessian2Output(System.out);
output.writeObject(object);
output.flush();
}
}
}