code: public <T> T executeInApplicationContext(Callable<T> callable) throws Exception {
          ApplicationContext context = (ApplicationContext) getScopedContext(ApplicationScoped.class);
          boolean activatedByUs = false;
          try {
              if (!context.isActive()) {
                  context.activate();
                  activatedByUs = true;
              }
              return callable.call();
          } finally {
              if (activatedByUs && context.isActive()) {
                  context.deactivate();
              }
          }
      }
docs: -------------------------------------------------------------------------------------||