Ejemplo n.º 1
0
  public void init() {

    try {

      server = new XmlRpcServletServer();

      mapping = new PropertyHandlerMapping();

      cl = Thread.currentThread().getContextClassLoader();

      // Here we load the property handler file

      mapping.load(cl, (propertyFilePath + propertyFile));

      server.setHandlerMapping(mapping);

      serverConfig = (XmlRpcServerConfigImpl) server.getConfig();

      serverConfig.setEnabledForExceptions(true);

      serverConfig.setEnabledForExtensions(true);

      server.setConfig(serverConfig);

    } catch (XmlRpcException e) {

      e.getMessage();

    } catch (IOException e) {

      e.getMessage();
    }
  }
Ejemplo n.º 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);
      }
    }
  }