package org.jboss.webbeans.tck;

import java.lang.annotation.Annotation;
import java.util.Arrays;
import java.util.List;

import javax.inject.manager.Manager;

import org.jboss.jsr299.tck.api.DeploymentException;
import org.jboss.jsr299.tck.spi.StandaloneContainers;
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.mock.MockBootstrap;
import org.jboss.webbeans.mock.MockWebBeanDiscovery;

public class StandaloneContainersImpl implements StandaloneContainers
{
   
   public Manager deploy(List<Class<? extends Annotation>> enabledDeploymentTypes, Class<?>... classes) throws DeploymentException
   {
      try
      {
         MockBootstrap bootstrap = new MockBootstrap();
         ManagerImpl manager = bootstrap.getManager();
         if (enabledDeploymentTypes != null)
         {
            manager.setEnabledDeploymentTypes(enabledDeploymentTypes);
         }
         MockWebBeanDiscovery discovery = new MockWebBeanDiscovery();
         discovery.setWebBeanClasses(Arrays.asList(classes));
         bootstrap.setWebBeanDiscovery(discovery);
         bootstrap.boot();
         return manager;
      }
      catch (Exception e) 
      {
         throw new DeploymentException("Error deploying beans", e);
      }
   }
   
   public Manager deploy(java.lang.Class<?>... classes) throws DeploymentException
   {
      return deploy(null, classes);
   }
   
}

package org.jboss.webbeans.tck;

import java.lang.annotation.Annotation;
import java.net.URL;
import java.util.List;

import org.jboss.jsr299.tck.api.DeploymentException;
import org.jboss.jsr299.tck.spi.StandaloneContainers;
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.mock.MockBootstrap;
import org.jboss.webbeans.mock.MockWebBeanDiscovery;

public class StandaloneContainersImpl implements StandaloneContainers
{
   
   public void deploy(List<Class<? extends Annotation>> enabledDeploymentTypes, Iterable<Class<?>> classes) throws DeploymentException
   {
      deploy(enabledDeploymentTypes, classes, null);
   }
   
   public void deploy(List<Class<? extends Annotation>> enabledDeploymentTypes, Iterable<Class<?>> classes, Iterable<URL> beansXml) throws DeploymentException
   {
      try
      {
         MockBootstrap bootstrap = new MockBootstrap();
         ManagerImpl manager = bootstrap.getManager();
         if (enabledDeploymentTypes != null)
         {
            manager.setEnabledDeploymentTypes(enabledDeploymentTypes);
         }
         MockWebBeanDiscovery discovery = new MockWebBeanDiscovery();
         discovery.setWebBeanClasses(classes);
         if (beansXml != null)
         {
            discovery.setWebBeansXmlFiles(beansXml);
         }
         bootstrap.setWebBeanDiscovery(discovery);
         bootstrap.boot();
      }
      catch (Exception e) 
      {
         throw new DeploymentException("Error deploying beans", e);
      }
   }
   
   public void deploy(Iterable<Class<?>> classes) throws DeploymentException
   {
      deploy(null, classes, null);
   }
   
   public void deploy(Iterable<Class<?>> classes, Iterable<URL> beansXml) throws DeploymentException
   {
      deploy(null, classes, beansXml);
   }
   
}

Support for reading deployment types from beans.xml
Support for reading deployment types from beans.xml

git-svn-id: 811cd8a17a8c3c0c263af499002feedd54a892d0@1531 1c488680-804c-0410-94cd-c6b725194a0e
