private void load(String pkg) {
    try {
      URL infourl =
          Application.getRessourceURL(JD_CONTROLLING_RECONNECT_PLUGINS + pkg + "/info.json");
      if (infourl == null) {
        LogController.CL().finer("Could not load Reconnect Plugin " + pkg);
        return;
      }

      ReconnectPluginInfo plgInfo =
          JSonStorage.restoreFromString(
              IO.readURLToString(infourl), new TypeRef<ReconnectPluginInfo>() {}, null);
      if (plgInfo == null) {
        LogController.CL().finer("Could not load Reconnect Plugin (no info.json)" + pkg);
        return;
      }
      Class<?> clazz =
          getClass()
              .getClassLoader()
              .loadClass(
                  JD_CONTROLLING_RECONNECT_PLUGINS.replace("/", ".")
                      + pkg
                      + "."
                      + plgInfo.getClassName());
      for (RouterPlugin plg : plugins) {
        if (plg.getClass() == clazz) {
          LogController.CL().finer("Dupe found: " + pkg);
          return;
        }
      }
      plugins.add((RouterPlugin) clazz.newInstance());
    } catch (Throwable e) {
      LogController.CL().log(e);
    }
  }
Exemplo n.º 2
0
  @Override
  public void run(Storage config, AbstractMyJDClientForDesktopJVM api) throws Exception {
    final String session = config.get("session", "");
    final SessionInfo sessioninfo = JSonStorage.restoreFromString(session, SessionInfo.class);
    api.setSessionInfo(sessioninfo);

    api.reconnect();
    Dialog.getInstance()
        .showMessageDialog(
            "Done. New SessionToken: " + JSonStorage.serializeToJson(api.getSessionInfo()));
  }
Exemplo n.º 3
0
    protected <Typo> Typo call(String command, TypeRef<Typo> type, Object... objects) throws IOException {
        StringBuilder sb = new StringBuilder();

        if (objects != null) {
            for (int i = 0; i < objects.length; i++) {
                sb.append(i == 0 ? "" : "&");

                sb.append(Encoding.urlEncode(JSonStorage.serializeToJson(objects[i])));
            }
        }
        Browser br = new Browser();
        br.setAllowedResponseCodes(200, 503, 500, 400);
        String ret = br.postPageRaw(HTTP_BASE + command, sb.toString());
        if (br.getRequest().getHttpConnection().getResponseCode() == 503) {
            throw new RetryIOException(ret);
        }
        if (br.getRequest().getHttpConnection().getResponseCode() == 400) {
            throw new BadQueryException(ret);
        }
        if (type == null) {
            return null;
        }
        return JSonStorage.restoreFromString(ret, type);
    }