Package org.jboss.arquillian.container.impl

Examples of org.jboss.arquillian.container.impl.LocalContainerRegistry


   @Inject
   private Instance<ServiceLoader> loader;

   public void createRegistry(@Observes ArquillianDescriptor event)
   {
      LocalContainerRegistry reg = new LocalContainerRegistry();
      ServiceLoader serviceLoader = loader.get();

      validateConfiguration(event);

      String activeConfiguration = getActivatedConfiguration();
      for(ContainerDef container : event.getContainers())
      {
         if(
               (activeConfiguration != null && activeConfiguration.equals(container.getContainerName())) ||
               (activeConfiguration == null && container.isDefault()))
         {
            reg.create(container, serviceLoader);           
         }
      }
      for(GroupDef group : event.getGroups())
      {
         if(
               (activeConfiguration != null && activeConfiguration.equals(group.getGroupName())) ||
               (activeConfiguration == null && group.isGroupDefault()))
         {
            for(ContainerDef container : group.getGroupContainers())
            {
               reg.create(container, serviceLoader);
            }
         }
      }
      if(activeConfiguration == null && reg.getContainers().size() == 0)
      {
         try
         {
            DeployableContainer<?> deployableContainer = serviceLoader.onlyOne(DeployableContainer.class);
            if(deployableContainer != null)
            {
               reg.create(new ContainerDefImpl("arquillian.xml").setContainerName("default"), serviceLoader);
            }
         }
         catch (Exception e)
         {
            // ignore
View Full Code Here


   @Inject
   private Instance<ServiceLoader> loader;

   public void createRegistry(@Observes ArquillianDescriptor event)
   {
      LocalContainerRegistry reg = new LocalContainerRegistry(injector.get());
      ServiceLoader serviceLoader = loader.get();

      validateConfiguration(event);

      String activeConfiguration = getActivatedConfiguration();
      for(ContainerDef container : event.getContainers())
      {
         if(
               (activeConfiguration != null && activeConfiguration.equals(container.getContainerName())) ||
               (activeConfiguration == null && container.isDefault()))
         {
            reg.create(container, serviceLoader);           
         }
      }
      for(GroupDef group : event.getGroups())
      {
         if(
               (activeConfiguration != null && activeConfiguration.equals(group.getGroupName())) ||
               (activeConfiguration == null && group.isGroupDefault()))
         {
            for(ContainerDef container : group.getGroupContainers())
            {
               reg.create(container, serviceLoader);
            }
         }
      }
      if(activeConfiguration == null && reg.getContainers().size() == 0)
      {
         DeployableContainer<?> deployableContainer = null;
         try
         {
            // 'check' if there are any DeployableContainers on CP
            deployableContainer = serviceLoader.onlyOne(DeployableContainer.class);
         }
         catch (IllegalStateException e)
         {
            throw new IllegalStateException(
                  "Could not add a default container to registry because multipe " +
                           DeployableContainer.class.getName() + " found on classpath", e);
         }
         catch (Exception e)
         {
            throw new IllegalStateException("Could not create the default container instance", e);
         }
         if(deployableContainer != null)
         {
            reg.create(new ContainerDefImpl("arquillian.xml").setContainerName("default"), serviceLoader);
         }
      }
      else if (activeConfiguration != null && reg.getContainers().size() == 0)
      {
         throw new IllegalArgumentException("No container or group found that match given qualifier: " + activeConfiguration);
      }

      // export
View Full Code Here

   @Inject
   private Instance<ServiceLoader> loader;

   public void createRegistry(@Observes ArquillianDescriptor event)
   {
      LocalContainerRegistry reg = new LocalContainerRegistry(injector.get());
      ServiceLoader serviceLoader = loader.get();

      validateConfiguration(event);

      String activeConfiguration = getActivatedConfiguration();
      for(ContainerDef container : event.getContainers())
      {
         if(
               (activeConfiguration != null && activeConfiguration.equals(container.getContainerName())) ||
               (activeConfiguration == null && container.isDefault()))
         {
            reg.create(container, serviceLoader);           
         }
      }
      for(GroupDef group : event.getGroups())
      {
         if(
               (activeConfiguration != null && activeConfiguration.equals(group.getGroupName())) ||
               (activeConfiguration == null && group.isGroupDefault()))
         {
            for(ContainerDef container : group.getGroupContainers())
            {
               reg.create(container, serviceLoader);
            }
         }
      }
      if(activeConfiguration == null && reg.getContainers().size() == 0)
      {
         DeployableContainer<?> deployableContainer = null;
         try
         {
            // 'check' if there are any DeployableContainers on CP
            deployableContainer = serviceLoader.onlyOne(DeployableContainer.class);
         }
         catch (IllegalStateException e)
         {
            throw new IllegalStateException(
                  "Could not add a default container to registry because multipe " +
                           DeployableContainer.class.getName() + " found on classpath", e);
         }
         catch (Exception e)
         {
            throw new IllegalStateException("Could not create the default container instance", e);
         }
         if(deployableContainer != null)
         {
            reg.create(new ContainerDefImpl("arquillian.xml").setContainerName("default"), serviceLoader);
         }
      }
      else if (activeConfiguration != null && reg.getContainers().size() == 0)
      {
         throw new IllegalArgumentException("No container or group found that match given qualifier: " + activeConfiguration);
      }

      // export
View Full Code Here

      when(container2.getMode()).thenReturn("suite");
      when(container3.getMode()).thenReturn("class");
      when(container4.getMode()).thenReturn("class");
      when(container5.getMode()).thenReturn("custom");

      registry = new LocalContainerRegistry(injector.get());

      bind(ApplicationScoped.class, ContainerRegistry.class, registry);
   }
View Full Code Here

            new DeploymentDescription(DEPLOYMENT_4_NAME, Descriptors.create(BeansDescriptor.class))
               .setTarget(new TargetDescription(CONTAINER_1_NAME))
               .setOrder(4)
               .shouldBeManaged(true));
     
      registry = new LocalContainerRegistry(injector.get());
     
      bind(ApplicationScoped.class, ContainerRegistry.class, registry);
      bind(ApplicationScoped.class, DeploymentScenario.class, scenario);
     
   }
View Full Code Here

   @Inject
   private Instance<ServiceLoader> loader;

   public void createRegistry(@Observes ArquillianDescriptor event)
   {
      LocalContainerRegistry reg = new LocalContainerRegistry(injector.get());
      ServiceLoader serviceLoader = loader.get();

      validateConfiguration(event);

      String activeConfiguration = getActivatedConfiguration();
      for(ContainerDef container : event.getContainers())
      {
         if(
               (activeConfiguration != null && activeConfiguration.equals(container.getContainerName())) ||
               (activeConfiguration == null && container.isDefault()))
         {
            reg.create(container, serviceLoader);           
         }
      }
      for(GroupDef group : event.getGroups())
      {
         if(
               (activeConfiguration != null && activeConfiguration.equals(group.getGroupName())) ||
               (activeConfiguration == null && group.isGroupDefault()))
         {
            for(ContainerDef container : group.getGroupContainers())
            {
               reg.create(container, serviceLoader);
            }
         }
      }
      if(activeConfiguration == null && reg.getContainers().size() == 0)
      {
         DeployableContainer<?> deployableContainer = null;
         try
         {
            // 'check' if there are any DeployableContainers on CP
            deployableContainer = serviceLoader.onlyOne(DeployableContainer.class);
         }
         catch (IllegalStateException e)
         {
            StringBuilder stringBuilder = new StringBuilder()
               .append("Could not add a default container to registry because multiple instances of ")
               .append(DeployableContainer.class.getName())
               .append(" found on classpath (candidates are: ");
            String separator = "";
            for (DeployableContainer s : serviceLoader.all(DeployableContainer.class)) {
               stringBuilder.append(separator)
                  .append(s.getConfigurationClass().getName());
               separator = ", ";
            }
            stringBuilder.append(")");
            throw new IllegalStateException(stringBuilder.toString());        
         }
         catch (Exception e)
         {
            throw new IllegalStateException("Could not create the default container instance", e);
         }
         if(deployableContainer != null)
         {
            reg.create(new ContainerDefImpl("arquillian.xml").setContainerName("default"), serviceLoader);
         }
      }
      else if (activeConfiguration != null && reg.getContainers().size() == 0)
      {
         throw new IllegalArgumentException("No container or group found that match given qualifier: " + activeConfiguration);
      }

      // export
View Full Code Here

   @Inject
   private Instance<ServiceLoader> loader;

   public void createRegistry(@Observes ArquillianDescriptor event)
   {
      LocalContainerRegistry reg = new LocalContainerRegistry(injector.get());
      ServiceLoader serviceLoader = loader.get();

      validateConfiguration(event);

      String activeConfiguration = getActivatedConfiguration();
      for(ContainerDef container : event.getContainers())
      {
         if(
               (activeConfiguration != null && activeConfiguration.equals(container.getContainerName())) ||
               (activeConfiguration == null && container.isDefault()))
         {
            reg.create(container, serviceLoader);           
         }
      }
      for(GroupDef group : event.getGroups())
      {
         if(
               (activeConfiguration != null && activeConfiguration.equals(group.getGroupName())) ||
               (activeConfiguration == null && group.isGroupDefault()))
         {
            for(ContainerDef container : group.getGroupContainers())
            {
               reg.create(container, serviceLoader);
            }
         }
      }
      if(activeConfiguration == null && reg.getContainers().size() == 0)
      {
         try
         {
            DeployableContainer<?> deployableContainer = serviceLoader.onlyOne(DeployableContainer.class);
            if(deployableContainer != null)
            {
               reg.create(new ContainerDefImpl("arquillian.xml").setContainerName("default"), serviceLoader);
            }
         }
         catch (Exception e)
         {
            // ignore
View Full Code Here

   @Inject
   private Instance<ServiceLoader> loader;

   public void createRegistry(@Observes ArquillianDescriptor event)
   {
      LocalContainerRegistry reg = new LocalContainerRegistry(injector.get());
      ServiceLoader serviceLoader = loader.get();

      validateConfiguration(event);

      String activeConfiguration = getActivatedConfiguration();
      for(ContainerDef container : event.getContainers())
      {
         if(
               (activeConfiguration != null && activeConfiguration.equals(container.getContainerName())) ||
               (activeConfiguration == null && container.isDefault()))
         {
            reg.create(container, serviceLoader);           
         }
      }
      for(GroupDef group : event.getGroups())
      {
         if(
               (activeConfiguration != null && activeConfiguration.equals(group.getGroupName())) ||
               (activeConfiguration == null && group.isGroupDefault()))
         {
            for(ContainerDef container : group.getGroupContainers())
            {
               reg.create(container, serviceLoader);
            }
         }
      }
      if(activeConfiguration == null && reg.getContainers().size() == 0)
      {
         DeployableContainer<?> deployableContainer = null;
         try
         {
            // 'check' if there are any DeployableContainers on CP
            deployableContainer = serviceLoader.onlyOne(DeployableContainer.class);
         }
         catch (IllegalStateException e)
         {
            StringBuilder stringBuilder = new StringBuilder()
               .append("Could not add a default container to registry because multiple instances of ")
               .append(DeployableContainer.class.getName())
               .append(" found on classpath (candidates are: ");
            String separator = "";
            for (DeployableContainer s : serviceLoader.all(DeployableContainer.class)) {
               stringBuilder.append(separator)
                  .append(s.getConfigurationClass().getName());
               separator = ", ";
            }
            stringBuilder.append(")");
            throw new IllegalStateException(stringBuilder.toString());        
         }
         catch (Exception e)
         {
            throw new IllegalStateException("Could not create the default container instance", e);
         }
         if(deployableContainer != null)
         {
            reg.create(new ContainerDefImpl("arquillian.xml").setContainerName("default"), serviceLoader);
         }
      }
      else if (activeConfiguration != null && reg.getContainers().size() == 0)
      {
         throw new IllegalArgumentException("No container or group found that match given qualifier: " + activeConfiguration);
      }

      // export
View Full Code Here

   @Inject
   private Instance<ServiceLoader> loader;

   public void createRegistry(@Observes ArquillianDescriptor event)
   {
      LocalContainerRegistry reg = new LocalContainerRegistry();
      ServiceLoader serviceLoader = loader.get();

      String activeConfiguration = getActivatedConfiguration();
      for(ContainerDef container : event.getContainers())
      {
         if(
               (activeConfiguration != null && activeConfiguration.equals(container.getContainerName())) ||
               (activeConfiguration == null && container.isDefault()))
         {
            reg.create(container, serviceLoader);           
         }
      }
      if(activeConfiguration != null)
      {
         for(GroupDef group : event.getGroups())
         {
            if(activeConfiguration.equals(group.getGroupName()))
            {
               for(ContainerDef container : group.getGroupContainers())
               {
                  reg.create(container, serviceLoader);
               }
            }
         }
      }
      else if(reg.getContainers().size() == 0)
      {
         try
         {
            DeployableContainer<?> deployableContainer = serviceLoader.onlyOne(DeployableContainer.class);
            if(deployableContainer != null)
            {
               reg.create(new ContainerDefImpl("arquillian.xml").setContainerName("default"), serviceLoader);
            }
         }
         catch (Exception e)
         {
            // ignore
View Full Code Here

   private DeployableContainer deployableContainer;

   @Before
   public void createSetup()
   {
      registry = new LocalContainerRegistry(injector.get());
      when(serviceLoader.onlyOne(eq(DeployableContainer.class))).thenReturn(deployableContainer);

      ContainerDef suiteContainerDef = mock(ContainerDef.class);
      when(suiteContainerDef.getContainerName()).thenReturn(MANAGED_SERVER_NAME);
      when(suiteContainerDef.getMode()).thenReturn("suite");
View Full Code Here

TOP

Related Classes of org.jboss.arquillian.container.impl.LocalContainerRegistry

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.