Пример #1
0
  public void contextInitialized(ServletContextEvent sce) {
    // Setting a dependency provider with the right bean manager
    BeanManager bm;
    try {
      bm = (BeanManager) new InitialContext().lookup("java:comp/BeanManager");
    } catch (NamingException e) {
      throw new RuntimeException(e);
    }
    registeredDependencyProvider = new BeanManagerDependencyProvider(bm);
    D.register(registeredDependencyProvider);

    sce.getServletContext().setAttribute(BEAN_MANAGER, bm);

    // warn about dev mode
    if (System.getProperty(ResourceResolver.ASAMAL_DEV_DIR) != null) {
      System.out.println("****************************");
      System.out.println("****************************");
      System.out.println("*    Running in DEV mode   *");
      System.out.println("* DO NOT use on production *");
      System.out.println("****************************");
      System.out.println("****************************");
    }
  }
Пример #2
0
 public void contextDestroyed(ServletContextEvent sce) {
   // Clearing up
   if (registeredDependencyProvider != null) {
     D.unregister(registeredDependencyProvider);
   }
 }