Package org.jboss.arquillian.core.spi.context

Examples of org.jboss.arquillian.core.spi.context.ApplicationContext


      handledThrowables.get().clear();
     
      List<ObserverMethod> observers = resolveObservers(event.getClass());
      List<ObserverMethod> interceptorObservers = resolveInterceptorObservers(event.getClass());
     
      ApplicationContext context = (ApplicationContext)getScopedContext(ApplicationScoped.class);
      // We need to know if we were to the one to Activate it to avoid:
      // * nested ApplicationContexts
      // * ending the scope to soon (to low in the stack)
      boolean activatedApplicationContext = false;
      try
      {
         if(!context.isActive()) {
            context.activate();
            activatedApplicationContext = true;
         }
         new EventContextImpl<T>(this, interceptorObservers, observers, nonManagedObserver, event).proceed();
      }
      catch (Exception e)
      {
         Throwable fireException = e;
         if(fireException instanceof InvocationException)
         {
            fireException = fireException.getCause();
         }
         if(handledThrowables.get().contains(fireException.getClass()))
         {
            UncheckedThrow.throwUnchecked(fireException);
         }
         else
         {
            fireException(fireException);
         }
      }
      finally
      {
         debug(event, false);
         if(activatedApplicationContext && context.isActive()) {
            context.deactivate();
         }
      }
   }
View Full Code Here


   //-------------------------------------------------------------------------------------||
   // Exposed Convenience Impl Methods ---------------------------------------------------||
   //-------------------------------------------------------------------------------------||

   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();
           }
       }
   }
View Full Code Here

      return created;
   }

   private void createBuiltInServices() throws Exception
   {   
      final ApplicationContext context = new ApplicationContextImpl();
      contexts.add(context);
      executeInApplicationContext(new Callable<Object>() {
          @Override
          public Object call() throws Exception {
              ManagerImpl.this.bind(
View Full Code Here

   private void addContextsToApplicationScope() throws Exception
   {
      executeInApplicationContext(new Callable<Void>() {
         @Override
         public Void call() throws Exception {
            ApplicationContext appContext = getContext(ApplicationContext.class);
            ObjectStore store = appContext.getObjectStore();

            for(Context context : contexts)
            {
               store.add((Class<Context>)context.getClass().getInterfaces()[0], context);
            }
View Full Code Here

   /**
    *
    */
   private void createApplicationContextAndActivate()
   {   
      ApplicationContext context = new ApplicationContextImpl();
      context.activate();
      context.getObjectStore().add(Injector.class, InjectorImpl.of(this));
      contexts.add(context);
   }
View Full Code Here

    * @param objectStore
    */
   @SuppressWarnings("unchecked")
   private void addContextsToApplicationScope()
   {
      ApplicationContext appContext = getContext(ApplicationContext.class);
      ObjectStore store = appContext.getObjectStore();
     
      for(Context context : contexts)
      {
         store.add((Class<Context>)context.getClass().getInterfaces()[0], context);
      }
View Full Code Here

   /**
    *
    */
   private void createApplicationContextAndActivate()
   {   
      ApplicationContext context = new ApplicationContextImpl();
      context.activate();
      context.getObjectStore().add(Injector.class, InjectorImpl.of(this));
      contexts.add(context);
   }
View Full Code Here

    * @param objectStore
    */
   @SuppressWarnings("unchecked")
   private void addContextsToApplicationScope()
   {
      ApplicationContext appContext = getContext(ApplicationContext.class);
      ObjectStore store = appContext.getObjectStore();
     
      for(Context context : contexts)
      {
         store.add((Class<Context>)context.getClass().getInterfaces()[0], context);
      }
View Full Code Here

   /**
    *
    */
   private void createApplicationContextAndActivate()
   {   
      ApplicationContext context = new ApplicationContextImpl();
      context.activate();
      context.getObjectStore().add(Injector.class, InjectorImpl.of(this));
      contexts.add(context);
   }
View Full Code Here

    * @param objectStore
    */
   @SuppressWarnings("unchecked")
   private void addContextsToApplicationScope()
   {
      ApplicationContext appContext = getContext(ApplicationContext.class);
      ObjectStore store = appContext.getObjectStore();
     
      for(Context context : contexts)
      {
         store.add((Class<Context>)context.getClass().getInterfaces()[0], context);
      }
View Full Code Here

TOP

Related Classes of org.jboss.arquillian.core.spi.context.ApplicationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.