0
我想从一个servlet集成XLLoop并尝试通过HTTP协议运行。下面是我的代码:如何将Xlloop集成到JAVA Web服务器中?
XlloopServlet.java
@WebServlet(value = "/FunctionServer", name = "FunctionServer", asyncSupported = true)
public class XlloopServlet extends FunctionServlet {
private static final long serialVersionUID = -3845895326255874126L;
@Override
public void init(final ServletConfig config) throws ServletException {
// Create a function information handler to register our functions
FunctionInformationHandler infoHandler = new FunctionInformationHandler();
// Create a reflection function handler and add the required methods
FunctionHandler handler = new FunctionHandler();
infoHandler.add(handler.getFunctions());
// Set the handlers
CompositeFunctionHandler compositeHandler = new CompositeFunctionHandler();
compositeHandler.add(handler);
compositeHandler.add(infoHandler);
// Setting the function handler in the parent servlet
setHandler(compositeHandler);
}
和我FunctionHandler类注册功能:
public class FunctionHandler implements IFunctionHandler, FunctionProvider {
private ReflectFunctionHandler rfh;
public FunctionHandler() {
// Create a reflection function handler and add the Math methods
rfh = new ReflectFunctionHandler();
rfh.addMethods("Math.", Math.class);
rfh.addMethods("Math.", Maths.class);
rfh.addMethods("CSV.", CSV.class);
rfh.addMethods("Reflect.", Reflect.class);
}
@Override
public XLoper execute(IFunctionContext arg0, String arg1, XLoper[] arg2) throws RequestException {
return rfh.execute(arg0, arg1, arg2);
}
@Override
public boolean hasFunction(String arg0) {
return rfh.hasFunction(arg0);
}
@Override
public FunctionInformation[] getFunctions() {
return rfh.getFunctions();
}
public ReflectFunctionHandler getReflectFunctionHandler() {
return rfh;
}
}
我XLLoop ini文件是如下:
protocol=http
url=http://localhost:8080/MyApp/FunctionServer
现在,当我尝试从我的excel中调用一个函数时,我会在servlet类中接收一个调用并且永远执行的东西,但函数没有得到执行的Excel文件。
任何人有任何想法如何将XLLoop插件整合到像tomcat这样的网络服务器上?