예제 #1
0
    public void contextInitialized(ServletContextEvent sce) {
      final ServletContext app = sce.getServletContext();
      final Configuration conf = NutchConfiguration.get(app);

      LOG.info("creating new bean");
      NutchBean bean = null;
      try {
        bean = new NutchBean(conf);
        app.setAttribute(KEY, bean);
      } catch (final IOException ex) {
        LOG.error(StringUtils.stringifyException(ex));
      }
    }
예제 #2
0
 /**
  * Returns the cached instance in the servlet context.
  *
  * @see NutchBeanConstructor
  */
 public static NutchBean get(ServletContext app, Configuration conf) throws IOException {
   final NutchBean bean = (NutchBean) app.getAttribute(KEY);
   return bean;
 }