Example #1
0
  public void init() throws ServletException {
    try {
      // Load configuration (from classpath or WEB-INF root path)
      String webInfPath = getServletContext().getRealPath("/") + "/WEB-INF";
      Config.load(webInfPath);
      Log.init();
      // Start
      Log.info(
          "init() Pushlet Webapp - version="
              + Version.SOFTWARE_VERSION
              + " built="
              + Version.BUILD_DATE);
      // Start session manager
      SessionManager.getInstance().start();
      // Start event Dispatcher
      Dispatcher.getInstance().start();

      if (Config.getBoolProperty(Config.SOURCES_ACTIVATE)) {
        EventSourceManager.start(webInfPath);
      } else {
        Log.info("Not starting local event sources");
      }
    } catch (Throwable t) {
      throw new ServletException("Failed to initialize Pushlet framework " + t, t);
    }
  }
Example #2
0
 private void init() {
   Log.init("BlackList");
   Log.i("Application start init...");
   Context context = getApplicationContext();
   BlackListCache.init(context);
   Log.i("Application init completed.");
 }
Example #3
0
  public static void main(String[] args) {
    Log.init();
    Log.logger.info("Test WebService Start:");
    try {
      String endpoint = "http://localhost:9080/imws/services/ImpactManager";
      // String result="no result!";
      String namespace = "http://imapi.bmc.com/2010/01";

    } catch (Exception e) {
      Log.logger.error(e.getMessage());
    }
  }
Example #4
0
  public static void main(String[] args) {
    Log.init();
    Log.logger.info("事件查询开始");
    String url = null;
    String tokenurl = null;
    String username = null;
    String password = null;
    String jsonpath = null;
    Properties prop = new Properties();
    try {
      InputStream propin = new BufferedInputStream(new FileInputStream("searchEvent.properties"));
      prop.load(propin);
      url = prop.getProperty("SearchUrl");
      tokenurl = prop.getProperty("TokenUrl");
      username = prop.getProperty("username");
      password = prop.getProperty("password");
      jsonpath = prop.getProperty("json-path");
    } catch (Exception e) {
      Log.logger.error(e.getMessage());
    }

    AuthToken token = new AuthToken(username, password, tokenurl);
    String codeToken = token.getToken();
    StringBuffer jsonfile = new StringBuffer();
    File config = new File(jsonpath);
    InputStream in = null;
    try {
      in = new FileInputStream(config);
      int tempbyte;
      while ((tempbyte = in.read()) != -1) {
        jsonfile.append((char) tempbyte);
      }
      // System.out.print(testfile.toString());
      in.close();
    } catch (Exception e) {
      Log.logger.error(e.getMessage());
    }
    EventSearch event = new EventSearch(jsonfile.toString(), url, codeToken);
    event.POST();
  }
  @Override
  public void onLoad() {
    instance = this; // Set the instance
    log = getLogger(); // Set the logger

    version =
        new TRVersion(
            getDescription().getVersion().equals("1.2") ? "1.20" : getDescription().getVersion());
    Log.init();

    // #################### load Config ####################
    saveDefaultConfig(false); // Copy config files

    config = this.getConfigx(); // Load the configuration files
    double configVer = config.getDouble(ConfigFile.General, "ConfigVersion", 0.9);
    if (configVer < 1.1) UpdateConfigFiles.v09(); // 0 --> newest
    else if (configVer < 1.5) { // Upgrade to 1.8
      AdvancedConfig.upgradeFile();
      DatabaseConfig.upgradeFile();
      GeneralConfig.upgradeFile();
      HackDupeConfig.upgradeOldHackFile();
      ModModificationsConfig.upgradeFile();
      SafeZonesConfig.upgradeFile();
      TPerformanceConfig.upgradeFile();
      LoggingConfig.upgradeFile();
      if (linkEEPatch()) EEPatchConfig.upgradeFile();
      reloadConfig();
    } else if (configVer < 1.6) { // Upgrade to 1.8
      GeneralConfig.upgradeFile();
      DatabaseConfig.upgradeFile();
      LoggingConfig.upgradeFile();
      if (linkEEPatch()) EEPatchConfig.upgradeFile();
      reloadConfig();
    } else if (configVer < 1.7) { // upgrade to 1.8
      GeneralConfig.upgradeFile();
      DatabaseConfig.upgradeFile();
      LoggingConfig.upgradeFile();
      if (linkEEPatch()) EEPatchConfig.upgradeFile();
      reloadConfig();
    } else if (configVer < 1.8) { // upgrade to 1.8
      GeneralConfig.upgradeFile();
      DatabaseConfig.upgradeFile();
      reloadConfig();
    }

    try { // Load all settings
      load(); // TODO loading eepatch
    } catch (Exception ex) {
      Warning.load("An error occurred: Unable to load settings!", true);
      Log.Exception(ex, true);
    }
    // #####################################################

    // ##################### load SQL ######################

    log.info("[DB] Loading Database...");
    if (!TRDB.loadDB()) {
      Warning.dbAndLoad("[DB] Failed to load Database!", true);
    } else {
      if (dbtype == DBType.SQLite) {
        if (TRDB.initSQLite()) log.info("[SQLite] SQLite Database loaded!");
        else {
          Warning.dbAndLoad("[SQLite] Failed to load SQLite Database!", true);
        }
      } else if (dbtype == DBType.MySQL) {
        if (TRDB.initMySQL()) {
          log.info("[MySQL] Database connection established!");
        } else {
          Warning.dbAndLoad("[MySQL] Failed to connect to MySQL Database!", true);
        }
      } else {
        Warning.dbAndLoad("[DB] Unknown Database type set!", true);
      }
    }
    // #####################################################

    // ###################### RPTimer ######################
    if (config.getBoolean2(ConfigFile.General, "UseAutoRPTimer", false)) {
      try {
        double value = config.getDouble(ConfigFile.ModModifications, "RPTimerMin", 0.2d);
        int ticks = (int) Math.round((value - 0.1d) * 20d);
        RedPowerLogic.minInterval = ticks; // set minimum interval for logic timers...
        log.info("Set the RedPower Timer Min interval to " + value + " seconds.");
      } catch (Exception e) {
        Warning.load("Setting the RedPower Timer failed!", false);
      }
    }
    // #####################################################

    // ###################### Patch CC #####################
    if (config.getBoolean2(ConfigFile.General, "PatchComputerCraft", true)) {
      PatchCC.start();
    }
    // #####################################################

    // BlockBreaker anti-dupe
    try {
      ArrayList<Block> miningLaser = new ArrayList<Block>();

      for (Block block : EntityMiningLaser.unmineableBlocks) {
        miningLaser.add(block);
      }
      miningLaser.add(Block.byId[194]);
      EntityMiningLaser.unmineableBlocks = miningLaser.toArray(new Block[miningLaser.size()]);
      log.fine("Patched Mining Laser + Auto Crafting Table MK II dupe.");
    } catch (Exception ex) {
      Warning.load("Unable to patch Mining Laser + Auto Crafting Table MK II dupe!", false);
    }

    try {
      RedPowerMachine.breakerBlacklist.add(Integer.valueOf(-1 << 15 | 194));

      RedPowerMachine.deployerBlacklist.add(Integer.valueOf(0 << 15 | 6362)); // REP
      RedPowerMachine.deployerBlacklist.add(Integer.valueOf(0 << 15 | 6359)); // Wireless sniffer
      RedPowerMachine.deployerBlacklist.add(Integer.valueOf(0 << 15 | 6363)); // Private sniffer
      RedPowerMachine.deployerBlacklist.add(Integer.valueOf(0 << 15 | 27562)); // Alcbag
      RedPowerMachine.deployerBlacklist.add(Integer.valueOf(0 << 15 | 27585)); // Divining ROd
      RedPowerMachine.deployerBlacklist.add(Integer.valueOf(0 << 15 | 30122)); // Cropnalyser
      RedPowerMachine.deployerBlacklist.add(Integer.valueOf(0 << 15 | 30104)); // Debug item

      RedPowerMachine.deployerBlacklist.add(Integer.valueOf(0 << 15 | 27592)); // transtablet
      RedPowerMachine.deployerBlacklist.add(Integer.valueOf(0 << 15 | 7493)); // Ender pouch
      log.fine("Patched BlockBreaker + Auto Crafting Table MK II dupe.");
      log.fine("Patched most Deployer Crash Bugs.");
    } catch (Exception ex) {
      Warning.load("Unable to patch BlockBreaker + Auto Crafting Table MK II dupe!", false);
      Warning.load("Unable to patch Deployer Crash Bugs!", false);
    }

    try {
      Ic2Recipes.addMaceratorRecipe(new ItemStack(135, 1, 2), new ItemStack(30254, 4, 0));
      Ic2Recipes.addMaceratorRecipe(new ItemStack(135, 1, 3), new ItemStack(30255, 4, 0));
      log.fine("Added Missing Nether Ores recipes.");
    } catch (Exception ex) {
      Warning.load("Unable to add missing Nether Ore recipes.", false);
    }
  }