コード例 #1
0
ファイル: WebServiceEngine.java プロジェクト: eowyn36/A-CMAv2
    @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);
      }
    }
  }
コード例 #3
0
  protected XmlRpcHandlerMapping newXmlRpcHandlerMapping() throws XmlRpcException {
    PropertyHandlerMapping mapping = (PropertyHandlerMapping) this;
    AbstractReflectiveHandlerMapping.AuthenticationHandler handler =
        new AbstractReflectiveHandlerMapping.AuthenticationHandler() {

          @Override
          public boolean isAuthorized(XmlRpcRequest pRequest) {
            XmlRpcHttpRequestConfig config = (XmlRpcHttpRequestConfig) pRequest.getConfig();
            return isAuthenticated(config.getBasicUserName(), config.getBasicPassword());
          }
        };
    mapping.setAuthenticationHandler(handler);
    return mapping;
  }
コード例 #4
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();
    }
  }