/**
   * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
   */
  @Override
  public void contextInitialized(ServletContextEvent sce) {
    this.context = sce.getServletContext();

    this.context.log("Configuring Program D Core from servlet context listener.");

    // Check for the config parameter.
    String config = this.context.getInitParameter(PARAM_CORE_CONFIG);
    if (config == null || config.length() == 0) {
      this.context.log(
          "No \"" + PARAM_CORE_CONFIG + "\" init-param specified for Program D.  Cannot continue.");
      return;
    }

    // Create the base URL.
    URL baseURL;
    try {
      baseURL = this.context.getResource("/");
    } catch (MalformedURLException e) {
      this.context.log("Error when getting base URL!", e);
      return;
    }

    // Set up the Program D Core.
    Core core = new Core(baseURL, URLTools.contextualize(baseURL, config));
    this.context.setAttribute(KEY_CORE, core);
  }
예제 #2
0
 /**
  * Processes whatever is at the given URL, returning nothing.
  *
  * @param url the URL at which to find whatever is to be processed
  * @throws ProcessorException if there is a problem processing whatever is at the given URL
  */
 public void process(URL url) throws ProcessorException {
   this._logger.info(String.format("Loading \"%s\".", URLTools.unescape(url)));
   processResponse(url);
 }