示例#1
0
  /**
   * This method initializes the class, by loading properties, texts and setting the endpoint.
   *
   * @throws IOException
   */
  public void initialize() throws IOException {

    // load properties
    InputStream inputStream = this.getClass().getResourceAsStream(PROPERTIES_FILE_LOCATION);
    if (inputStream == null) {
      throw new IllegalArgumentException(
          "Could not load properties from classpath (" + PROPERTIES_FILE_LOCATION + ")");
    }
    props.load(inputStream);

    // load text
    InputStream languageStream = null;

    // try to get language form property file
    if (props.containsKey("Language")) {
      languageStream =
          this.getClass()
              .getResourceAsStream("/props/ALEClient_" + props.getProperty("Language") + ".lang");
    }

    // try system default language
    if (languageStream == null) {
      languageStream =
          this.getClass()
              .getResourceAsStream(
                  "/props/ALEClient_" + SYSTEM_DEFAULT_LOCALE.getLanguage() + ".lang");
    }

    // try default language
    if (languageStream == null) {
      languageStream =
          this.getClass()
              .getResourceAsStream("/props/ALEClient_" + DEFAULT_LOCALE.getLanguage() + ".lang");
    }

    if (languageStream == null) {
      throw new IllegalArgumentException(
          "Could not load language package from classpath (" + DEFAULT_LOCALE + ")");
    }
    guiText = new PropertyResourceBundle(languageStream);

    // set endpoint
    aleProxy.setEndpoint(props.getProperty("EndPoint"));

    initializeGUI();
  }