示例#1
0
    @Override
    protected XmlRpcHandlerMapping newXmlRpcHandlerMapping() throws XmlRpcException {
      PropertyHandlerMapping phm = new PropertyHandlerMapping();
      phm.addHandler("acma", WebService.class);
      XmlRpcSystemImpl.addSystemHandler(phm);

      return phm;
    }
示例#2
0
  /**
   * Starts the server
   *
   * @throws Exception
   */
  public XMLRPCServer() throws Exception {
    if (LocalSettings.hasProperty(LocalSettings.SERVER_PORT)) {
      port = Integer.valueOf(LocalSettings.getProperty(LocalSettings.SERVER_PORT));
    }
    webServer = new WebServer(getPort());
    XmlRpcServer xmlRpcServer = webServer.getXmlRpcServer();
    ((XmlRpcStreamServer) xmlRpcServer)
        .setErrorLogger(
            new XmlRpcErrorLogger() {

              @Override
              public void log(java.lang.String pMessage) {
                Log.Debug(this, pMessage);
              }

              @Override
              public void log(java.lang.String pMessage, java.lang.Throwable pThrowable) {
                Log.Debug(this, pMessage);
                Log.Debug(pThrowable);
              }
            });

    PropertyHandlerMapping phm = new XPropertyHandlerMapping();
    //        ArrayList<Context> cx = Context.getImportableContexts();
    //        for (int i = 0; i < cx.size(); i++) {
    //            Context context = cx.get(i);
    //        }
    phm.addHandler("remote", XMLRPCHandler.class);

    xmlRpcServer.setHandlerMapping(phm);

    XmlRpcServerConfigImpl serverConfig = (XmlRpcServerConfigImpl) xmlRpcServer.getConfig();
    serverConfig.setEnabledForExtensions(true);
    serverConfig.setContentLengthOptional(false);

    PropertyHandlerMapping mapping =
        (PropertyHandlerMapping) ((XmlRpcStreamServer) xmlRpcServer).getHandlerMapping();
    XmlRpcSystemImpl.addSystemHandler(mapping);

    webServer.start();
    Log.Debug(this, "XML RPC Server started! Listening port: " + port);

    if (Log.getLoglevel() == Log.LOGLEVEL_DEBUG) {
      Log.Debug(this, "XML RPC Server handler: ");
      String[] lm = phm.getListMethods();
      for (int i = 0; i < lm.length; i++) {
        String string = lm[i];
        Log.Debug(this, string);
      }
    }
  }