public void contextInitialized(ServletContextEvent event) {
   ServletContext context = event.getServletContext();
   String dogBreed = context.getInitParameter("breed");
   Dog dog = new Dog(dogBreed);
   context.setAttribute("dog", dog);
   System.out.println("Context initialized");
 }
Esempio n. 2
0
  /** @param e */
  @Override
  public void contextInitialized(ServletContextEvent e) {
    ServletContext context = e.getServletContext();

    // retrieve jyro.home
    String dirName = context.getInitParameter(Jyro.JYRO_HOME);
    if (dirName == null) {
      dirName = System.getProperty(Jyro.JYRO_HOME);
      if (dirName == null) {
        throw new IllegalStateException(
            Jyro.JYRO_HOME + " not specified in servlet or context paramter, system property");
      }
    }

    // resolve relative path
    File dir = new File(dirName);
    if (!dir.isAbsolute()) {
      dirName = context.getRealPath(dirName);
      dir = new File(dirName);
    }
    logger.info(Jyro.JYRO_HOME + "=" + dirName);

    // build and startup Jyro
    String contextPath = context.getContextPath();
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    try {
      platform = new JyroPlatform(contextPath, dir, loader, null);
      platform.startup();
    } catch (Exception ex) {
      throw new IllegalStateException(ex);
    }
  }
Esempio n. 3
0
  @Override
  public void contextInitialized(ServletContextEvent sce) {
    try {
      final ServletContext context = sce.getServletContext();
      System.out.println("Servlet context initialized...");

      if (context == null) {
        throw new RuntimeException("Failed to initialize context. Visallo is not running.");
      }
      VisalloLoggerFactory.setProcessType("web");

      final Configuration config =
          ConfigurationLoader.load(
              context.getInitParameter(APP_CONFIG_LOADER), getInitParametersAsMap(context));
      config.setDefaults(WebConfiguration.DEFAULTS);
      LOGGER = VisalloLoggerFactory.getLogger(ApplicationBootstrap.class);
      LOGGER.info("Running application with configuration:\n%s", config);

      setupInjector(context, config);
      verifyGraphVersion();
      setupGraphAuthorizations();
      setupWebApp(context, config);

      Iterable<ApplicationBootstrapInitializer> initializers =
          ServiceLoaderUtil.load(ApplicationBootstrapInitializer.class, config);
      for (ApplicationBootstrapInitializer initializer : initializers) {
        initializer.initialize();
      }
    } catch (Throwable ex) {
      LOGGER.error("Could not startup context", ex);
      throw new VisalloException("Could not startup context", ex);
    }
  }
  /**
   * Context initialized.
   *
   * @param sce the sce
   */
  @Override
  public void contextInitialized(ServletContextEvent sce) {

    ServletContext context = sce.getServletContext();
    context.setAttribute("locales", LocaleManager.INSTANCE.getLocales());

    Locale.setDefault(Locale.ENGLISH);
  }
Esempio n. 5
0
 @Override
 public void contextDestroyed(ServletContextEvent sce) {
   log.info("Destroying Web application");
   WebApplicationContext ac =
       WebApplicationContextUtils.getRequiredWebApplicationContext(sce.getServletContext());
   AnnotationConfigWebApplicationContext gwac = (AnnotationConfigWebApplicationContext) ac;
   gwac.close();
   log.debug("Web application destroyed");
 }
Esempio n. 6
0
  @Override
  public void contextInitialized(ServletContextEvent sce) {
    ServletContext servletContext = sce.getServletContext();
    log.info("Web application configuration");

    log.debug("Configuring Spring root application context");
    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(ApplicationConfiguration.class);
    rootContext.refresh();

    servletContext.setAttribute(
        WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, rootContext);

    log.debug("Configuring Spring Web application context");
    AnnotationConfigWebApplicationContext dispatcherServletConfig =
        new AnnotationConfigWebApplicationContext();
    dispatcherServletConfig.setParent(rootContext);
    dispatcherServletConfig.register(DispatcherServletConfig.class);

    log.debug("Registering Spring MVC Servlet");
    ServletRegistration.Dynamic dispatcherServlet =
        servletContext.addServlet("dispatcher", new DispatcherServlet(dispatcherServletConfig));
    dispatcherServlet.addMapping("/tatami/*");
    dispatcherServlet.setLoadOnStartup(2);

    log.debug("Registering Meteor Servlet for online users");

    ServletRegistration.Dynamic meteorServlet =
        servletContext.addServlet("atmosphereServlet", new MeteorServlet());

    meteorServlet.setAsyncSupported(true);
    meteorServlet.addMapping("/realtime/*");
    meteorServlet.setLoadOnStartup(3);

    meteorServlet.setInitParameter(
        "org.atmosphere.servlet", "fr.ippon.tatami.web.atmosphere.users.OnlineUsersServlet");

    meteorServlet.setInitParameter(
        "org.atmosphere.cpr.broadcasterCacheClass", "org.atmosphere.cache.HeaderBroadcasterCache");

    meteorServlet.setInitParameter(
        "org.atmosphere.cpr.broadcastFilterClasses",
        "org.atmosphere.client.TrackMessageSizeFilter");

    meteorServlet.setInitParameter("org.atmosphere.useNative", "true");

    log.debug("Registering Spring Security Filter");
    FilterRegistration.Dynamic springSecurityFilter =
        servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy());
    EnumSet<DispatcherType> disps =
        EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC);
    springSecurityFilter.addMappingForServletNames(disps, true, "dispatcher", "atmosphereServlet");

    log.debug("Web application fully configured");
  }
Esempio n. 7
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));
      }
    }
  @Override
  public void contextInitialized(ServletContextEvent event) {

    /* clasa Gestiune pentru retinerea evidentei cartilor  */
    model.Gestiune g = new model.Gestiune();

    /* clasa DataBorrowedBook pentru retinerea cartilor imprumutate si returnate de client */
    model.DataBorrowedBook d = new model.DataBorrowedBook();

    ServletContext ctx = event.getServletContext();

    ctx.setAttribute("gestiune", g);
    ctx.setAttribute("tableUser", d);
  }
Esempio n. 9
0
 public void contextInitialized(ServletContextEvent event) {
   /*
    * From latest servlet specification:
    * All ServletContextListeners are notified of context initialization
    * before any filters or servlets in the web application are initialized.
    *
    * The servlet specification of Version 2.3 only provide the description
    * "Notification that the web application is ready to process requests.",
    * the order of initialization of listeners and servlets
    * may not guaranteed in older servlet version.
    *
    * @since 6.0.1
    */
   final ServletContext ctx = event.getServletContext();
   if (WebManager.getWebManagerIfAny(ctx) == null) {
     _webman = new WebManager(ctx, "/zkau");
     _webmanCreated = true;
   }
 }
 @Override
 public void contextInitialized(ServletContextEvent sce) {
   initJetWebEngine(sce.getServletContext());
 }
Esempio n. 11
0
 /**
  * Receives notification that the web application initialization process is starting.
  *
  * @param sce The servlet context event
  */
 public void contextInitialized(ServletContextEvent sce) {
   sce.getServletContext().setInitParameter("aaa", "bbb");
 }