openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1797251 - in /openwebbeans/trunk: ./ webbeans-impl/src/main/java/org/apache/webbeans/config/ webbeans-impl/src/main/java/org/apache/webbeans/corespi/ webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/ webbeans-impl/src/main/j...
Date Thu, 01 Jun 2017 19:30:26 GMT
Author: rmannibucau
Date: Thu Jun  1 19:30:25 2017
New Revision: 1797251

URL: http://svn.apache.org/viewvc?rev=1797251&view=rev
Log:
OWB-1190 some work around se API - far to be complete and tested

Added:
    openwebbeans/trunk/webbeans-se/
    openwebbeans/trunk/webbeans-se/pom.xml
    openwebbeans/trunk/webbeans-se/src/
    openwebbeans/trunk/webbeans-se/src/main/
    openwebbeans/trunk/webbeans-se/src/main/java/
    openwebbeans/trunk/webbeans-se/src/main/java/org/
    openwebbeans/trunk/webbeans-se/src/main/java/org/apache/
    openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/
    openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/
    openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/CDISeBeanArchiveService.java
    openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/CDISeLoaderService.java
    openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/CDISeScannerService.java
    openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/OWBContainer.java
    openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/OWBInitializer.java
    openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/SeContainerSelector.java
    openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/SeInitializerFacade.java
    openwebbeans/trunk/webbeans-se/src/main/resources/
    openwebbeans/trunk/webbeans-se/src/main/resources/META-INF/
    openwebbeans/trunk/webbeans-se/src/main/resources/META-INF/services/
    openwebbeans/trunk/webbeans-se/src/main/resources/META-INF/services/javax.enterprise.inject.se.SeContainerInitializer
    openwebbeans/trunk/webbeans-se/src/test/
    openwebbeans/trunk/webbeans-se/src/test/java/
    openwebbeans/trunk/webbeans-se/src/test/java/org/
    openwebbeans/trunk/webbeans-se/src/test/java/org/apache/
    openwebbeans/trunk/webbeans-se/src/test/java/org/apache/openwebbeans/
    openwebbeans/trunk/webbeans-se/src/test/java/org/apache/openwebbeans/se/
    openwebbeans/trunk/webbeans-se/src/test/java/org/apache/openwebbeans/se/CDISETest.java
Modified:
    openwebbeans/trunk/pom.xml
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/DefaultSingletonService.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/xbean/CdiArchive.java
    openwebbeans/trunk/webbeans-web/src/test/java/org/apache/webbeans/web/tests/WebBeansTest.java

Modified: openwebbeans/trunk/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/pom.xml?rev=1797251&r1=1797250&r2=1797251&view=diff
==============================================================================
--- openwebbeans/trunk/pom.xml (original)
+++ openwebbeans/trunk/pom.xml Thu Jun  1 19:30:25 2017
@@ -537,6 +537,7 @@
         <module>distribution</module>
         <module>webbeans-maven</module>
         <module>webbeans-gradle</module>
+        <module>webbeans-se</module>
     </modules>
 
     <dependencyManagement>

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java?rev=1797251&r1=1797250&r2=1797251&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java Thu Jun  1 19:30:25 2017
@@ -29,6 +29,7 @@ import org.apache.webbeans.util.WebBeans
  * @version $Rev$ $Date$
  *
  */
+// TODO: we need to rework it to allow to re-set it at runtime (owb-se, openejb, meecrowave, ...) should be able to run sequentially
 public final class WebBeansFinder
 {   
     //How you use singleton provider ,
@@ -45,7 +46,12 @@ public final class WebBeansFinder
     {
         //No action
     }
-    
+
+    public static SingletonService<WebBeansContext> getSingletonService()
+    {
+        return singletonService;
+    }
+
     public static WebBeansContext getSingletonInstance()
     {
         return singletonService.get(WebBeansUtil.getCurrentClassLoader());

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/DefaultSingletonService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/DefaultSingletonService.java?rev=1797251&r1=1797250&r2=1797251&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/DefaultSingletonService.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/DefaultSingletonService.java Thu Jun  1 19:30:25 2017
@@ -60,6 +60,15 @@ public class DefaultSingletonService imp
         }
     }
 
+    public void register(final ClassLoader key, final WebBeansContext context)
+    {
+        if (singletonMap.containsKey(key))
+        {
+            throw new IllegalArgumentException(key + " is already registered");
+        }
+        singletonMap.putIfAbsent(key, context);
+    }
+
     /**
      * Clear all deployment instances when the application is undeployed.
      * @param classLoader of the deployment

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java?rev=1797251&r1=1797250&r2=1797251&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java Thu Jun  1 19:30:25 2017
@@ -35,6 +35,7 @@ import org.apache.webbeans.util.UrlSet;
 import org.apache.webbeans.util.WebBeansUtil;
 import org.apache.xbean.finder.AnnotationFinder;
 import org.apache.xbean.finder.ClassLoaders;
+import org.apache.xbean.finder.archive.Archive;
 import org.apache.xbean.finder.filter.Filter;
 
 import java.io.IOException;
@@ -92,13 +93,7 @@ public abstract class AbstractMetaDataDi
     protected OwbAnnotationFinder finder;
     protected boolean isBDAScannerEnabled = false;
     protected BDABeansXmlScanner bdaBeansXmlScanner;
-    protected final WebBeansContext webBeansContext;
-
-
-    protected AbstractMetaDataDiscovery()
-    {
-        webBeansContext = WebBeansContext.getInstance();
-    }
+    protected WebBeansContext webBeansContext;
 
     protected AnnotationFinder initFinder()
     {
@@ -109,16 +104,21 @@ public abstract class AbstractMetaDataDi
 
         if (beanArchiveService == null)
         {
-            beanArchiveService = webBeansContext.getBeanArchiveService();
+            beanArchiveService = webBeansContext().getBeanArchiveService();
         }
 
-        final Filter userFilter = webBeansContext.getService(Filter.class);
-        archive = new CdiArchive(beanArchiveService, WebBeansUtil.getCurrentClassLoader(), getBeanDeploymentUrls(), userFilter);
+        final Filter userFilter = webBeansContext().getService(Filter.class);
+        archive = new CdiArchive(beanArchiveService, WebBeansUtil.getCurrentClassLoader(), getBeanDeploymentUrls(), userFilter, getAdditionalArchive());
         finder = new OwbAnnotationFinder(archive);
 
         return finder;
     }
 
+    protected Archive getAdditionalArchive()
+    {
+        return null;
+    }
+
     /**
      * @return list of beans.xml locations or implicit bean archives
      * @deprecated just here for backward compat reasons
@@ -206,7 +206,7 @@ public abstract class AbstractMetaDataDi
                 }
             }
 
-            boolean onlyBeansXmlJars = webBeansContext.getOpenWebBeansConfiguration().scanOnlyBeansXmlJars();
+            boolean onlyBeansXmlJars = webBeansContext().getOpenWebBeansConfiguration().scanOnlyBeansXmlJars();
             if (!onlyBeansXmlJars)
             {
                 // third step: remove all jars we know they do not contain any CDI beans
@@ -358,7 +358,7 @@ public abstract class AbstractMetaDataDi
         if (beanArchiveService == null)
         {
 
-            beanArchiveService = webBeansContext.getBeanArchiveService();
+            beanArchiveService = webBeansContext().getBeanArchiveService();
         }
 
         // just to trigger the creation
@@ -463,8 +463,8 @@ public abstract class AbstractMetaDataDi
         try
         {
             Class<? extends Annotation> annotationType = (Class<? extends Annotation>) WebBeansUtil.getCurrentClassLoader().loadClass(annotationName);
-            boolean isBeanAnnotation = webBeansContext.getBeanManagerImpl().isScope(annotationType);
-            isBeanAnnotation = isBeanAnnotation || webBeansContext.getBeanManagerImpl().isStereotype(annotationType);
+            boolean isBeanAnnotation = webBeansContext().getBeanManagerImpl().isScope(annotationType);
+            isBeanAnnotation = isBeanAnnotation || webBeansContext().getBeanManagerImpl().isStereotype(annotationType);
 
             return isBeanAnnotation;
         }
@@ -492,4 +492,13 @@ public abstract class AbstractMetaDataDi
     {
         return isBDAScannerEnabled;
     }
+
+    protected WebBeansContext webBeansContext()
+    {
+        if (webBeansContext == null)
+        {
+            webBeansContext = WebBeansContext.getInstance();
+        }
+        return WebBeansContext.getInstance();
+    }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/xbean/CdiArchive.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/xbean/CdiArchive.java?rev=1797251&r1=1797250&r2=1797251&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/xbean/CdiArchive.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/xbean/CdiArchive.java Thu Jun  1 19:30:25 2017
@@ -53,15 +53,20 @@ public class CdiArchive implements Archi
     private final Archive delegate;
 
     public CdiArchive(BeanArchiveService beanArchiveService, final ClassLoader loader, final Map<String, URL> urls,
-                      final Filter userFilter)
+                      final Filter userFilter, final Archive customArchive)
     {
         final Collection<Archive> archives = new ArrayList<Archive>();
+        if (customArchive != null)
+        {
+            archives.add(userFilter != null ? new FilteredArchive(customArchive, userFilter) : customArchive);
+        }
         for (final URL url : urls.values())
         {
             final List<String> urlClasses = new ArrayList<String>();
 
             BeanArchiveInformation beanArchiveInfo = beanArchiveService.getBeanArchiveInformation(url);
-            final Archive archive = new FilteredArchive(ClasspathArchive.archive(loader, url),
+            final Archive archive = new FilteredArchive(
+                    "openwebbeans".equals(url.getProtocol()) ? customArchive : ClasspathArchive.archive(loader, url),
                     new BeanArchiveFilter(beanArchiveInfo, urlClasses, userFilter));
 
             classesByUrl.put(url.toExternalForm(), new FoundClasses(url, urlClasses, beanArchiveInfo));

Added: openwebbeans/trunk/webbeans-se/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-se/pom.xml?rev=1797251&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-se/pom.xml (added)
+++ openwebbeans/trunk/webbeans-se/pom.xml Thu Jun  1 19:30:25 2017
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements. See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version
+    2.0 (the "License"); you may not use this file except in compliance
+    with the License. You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+    applicable law or agreed to in writing, software distributed under the
+    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+    CONDITIONS OF ANY KIND, either express or implied. See the License for
+    the specific language governing permissions and limitations under the
+    License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="
+            http://maven.apache.org/POM/4.0.0
+            http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>openwebbeans</artifactId>
+    <groupId>org.apache.openwebbeans</groupId>
+    <version>2.0.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>openwebbeans-se</artifactId>
+  <name>Apache OpenWebBeans CDI Java SE Implementation</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-jcdi_2.0_spec</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-el_2.2_spec</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-annotation_1.3_spec</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-atinject_1.0_spec</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-interceptor_1.2_spec</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>openwebbeans-impl</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file

Added: openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/CDISeBeanArchiveService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/CDISeBeanArchiveService.java?rev=1797251&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/CDISeBeanArchiveService.java (added)
+++ openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/CDISeBeanArchiveService.java Thu Jun  1 19:30:25 2017
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openwebbeans.se;
+
+import org.apache.webbeans.xml.DefaultBeanArchiveInformation;
+import org.apache.webbeans.xml.DefaultBeanArchiveService;
+
+import java.net.URL;
+
+public class CDISeBeanArchiveService extends DefaultBeanArchiveService
+{
+    public static final String EMBEDDED_URL = "cdi-standalone";
+
+    private final DefaultBeanArchiveInformation embeddedBai;
+
+    public CDISeBeanArchiveService(final DefaultBeanArchiveInformation bai)
+    {
+        embeddedBai = bai;
+    }
+
+    @Override
+    public BeanArchiveInformation getBeanArchiveInformation(final URL beanArchiveUrl)
+    {
+        if ("openwebbeans".equals(beanArchiveUrl.getProtocol()))
+        {
+            return embeddedBai;
+        }
+        return super.getBeanArchiveInformation(beanArchiveUrl);
+    }
+}

Added: openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/CDISeLoaderService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/CDISeLoaderService.java?rev=1797251&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/CDISeLoaderService.java (added)
+++ openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/CDISeLoaderService.java Thu Jun  1 19:30:25 2017
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openwebbeans.se;
+
+import org.apache.webbeans.service.DefaultLoaderService;
+
+import javax.enterprise.inject.spi.Extension;
+import java.util.Collection;
+import java.util.List;
+
+public class CDISeLoaderService extends DefaultLoaderService
+{
+    private final Collection<Extension> extensions;
+    private final ClassLoader loader;
+
+    public CDISeLoaderService(final Collection<Extension> extensions, final ClassLoader loader)
+    {
+        this.extensions = extensions;
+        this.loader = loader;
+    }
+
+    @Override
+    public <T> List<T> load(final Class<T> serviceType)
+    {
+        return load(serviceType, loader);
+    }
+
+    @Override
+    public <T> List<T> load(final Class<T> serviceType, final ClassLoader classLoader)
+    {
+        final List<T> loaded = super.load(serviceType, classLoader);
+        if (Extension.class == serviceType)
+        {
+            loaded.addAll(Collection.class.cast(extensions));
+        }
+        return loaded;
+    }
+}

Added: openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/CDISeScannerService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/CDISeScannerService.java?rev=1797251&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/CDISeScannerService.java (added)
+++ openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/CDISeScannerService.java Thu Jun  1 19:30:25 2017
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openwebbeans.se;
+
+import org.apache.webbeans.corespi.scanner.AbstractMetaDataDiscovery;
+import org.apache.xbean.finder.archive.Archive;
+import org.apache.xbean.finder.archive.ClassesArchive;
+import org.apache.xbean.finder.archive.FileArchive;
+import org.apache.xbean.finder.archive.FilteredArchive;
+import org.apache.xbean.finder.archive.JarArchive;
+import org.apache.xbean.finder.filter.Filter;
+import org.apache.xbean.finder.util.Files;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
+
+import static java.util.Arrays.asList;
+
+public class CDISeScannerService extends AbstractMetaDataDiscovery
+{
+    private boolean autoScanning;
+    private final Collection<Class<?>> classes = new ArrayList<>();
+
+    public void loader(final ClassLoader loader)
+    {
+        this.loader = loader;
+    }
+
+    public void classes(final Class<?>[] classes)
+    {
+        this.classes.addAll(asList(classes));
+    }
+
+    public void packages(final boolean recursive, final Class<?>[] markers)
+    {
+        Stream.of(markers)
+                .forEach(c -> this.addPackages(recursive, c.getName().replace('.', '/') + ".class", c.getPackage().getName()));
+    }
+
+    public void packages(final boolean recursive, final Package[] packages)
+    {
+        Stream.of(packages)
+                .forEach(p -> this.addPackages(recursive, p.getName().replace('.', '/'), p.getName()));
+    }
+
+    public void disableAutoScanning()
+    {
+        autoScanning = false;
+    }
+
+    @Override
+    protected void configure()
+    {
+        if (autoScanning)
+        {
+            registerBeanArchives(loader);
+        }
+
+        if (!classes.isEmpty())
+        {
+            try
+            {
+                addDeploymentUrl(CDISeBeanArchiveService.EMBEDDED_URL, new URL("openwebbeans", null, 0, "cdise", new URLStreamHandler()
+                {
+                    @Override
+                    protected URLConnection openConnection(final URL u) throws IOException
+                    {
+                        return null;
+                    }
+                }));
+            }
+            catch (final MalformedURLException e)
+            {
+                throw new IllegalArgumentException(e); // quite unlikely
+            }
+        }
+    }
+
+    @Override
+    protected Archive getAdditionalArchive()
+    {
+        return classes.isEmpty() ? null : new ClassesArchive(classes);
+    }
+
+    // not sure why it is in the spec, no way to make it portable
+    private void addPackages(final boolean recursive, final String resource, final String pack)
+    {
+        try
+        {
+            final Enumeration<URL> urls = loader.getResources(resource);
+            if (!urls.hasMoreElements())
+            {
+                throw new IllegalArgumentException("No matching jar for '" + resource + "'");
+            }
+            while (urls.hasMoreElements())
+            {
+                final URL url = urls.nextElement();
+                final CaptureClasses capturedClasses = new CaptureClasses(pack, classes, recursive, loader);
+                switch (url.getProtocol())
+                {
+                    case "jar":
+                        consume(new FilteredArchive(new JarArchive(loader, url), capturedClasses));
+                        break;
+                    case "file":
+                        File file = Files.toFile(url);
+                        if (!file.exists())
+                        {
+                            throw new IllegalArgumentException(file + " doesn't exist (from url" + url + ")");
+                        }
+
+                        for (int i = 0; i < pack.chars().filter(c -> c == '.').count(); i++)
+                        {
+                            file = file.getParentFile();
+                        }
+                        if (resource.contains("/"))
+                        {
+                            file = file.getParentFile();
+                        }
+                        if (resource.endsWith(".class"))
+                        {
+                            file = file.getParentFile();
+                        }
+
+                        consume(new FilteredArchive(new FileArchive(loader, file), capturedClasses));
+                        break;
+                    default:
+                        throw new IllegalArgumentException("Unsupported resource: " + url + " for resource '" + resource + "'");
+                }
+            }
+        }
+        catch (IOException e)
+        {
+            throw new IllegalArgumentException(e);
+        }
+    }
+
+    private void consume(final FilteredArchive entries)
+    {
+        StreamSupport.stream(entries.spliterator(), false).forEach(e ->
+        {
+        });
+    }
+
+    private static final class CaptureClasses implements Filter
+    {
+        private final Collection<Class<?>> classes;
+        private final String prefix;
+        private final boolean recursive;
+        private final long prefixSegments;
+        private final ClassLoader loader;
+
+        private CaptureClasses(final String prefix, final Collection<Class<?>> classes, final boolean recursive, final ClassLoader loader)
+        {
+            this.prefix = prefix == null ? "" : prefix;
+            this.prefixSegments = this.prefix.chars().filter(c -> c == '.').count();
+            this.classes = classes;
+            this.recursive = recursive;
+            this.loader = loader;
+        }
+
+        @Override
+        public boolean accept(final String name)
+        {
+            final boolean accepts = name.startsWith(prefix) && (recursive || name.chars().filter(c -> c == '.').count() == prefixSegments + 1);
+            if (accepts)
+            {
+                try
+                {
+                    classes.add(loader.loadClass(name));
+                }
+                catch (final ClassNotFoundException e)
+                {
+                    logger.warning(e.getMessage());
+                }
+            }
+            return accepts;
+        }
+    }
+}

Added: openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/OWBContainer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/OWBContainer.java?rev=1797251&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/OWBContainer.java (added)
+++ openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/OWBContainer.java Thu Jun  1 19:30:25 2017
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openwebbeans.se;
+
+import org.apache.webbeans.annotation.DefaultLiteral;
+import org.apache.webbeans.component.InstanceBean;
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.container.InjectableBeanManager;
+import org.apache.webbeans.context.creational.CreationalContextImpl;
+import org.apache.webbeans.inject.instance.InstanceImpl;
+import org.apache.webbeans.spi.ContainerLifecycle;
+
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.se.SeContainer;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.util.TypeLiteral;
+import java.lang.annotation.Annotation;
+import java.util.Iterator;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+public class OWBContainer implements SeContainer
+{
+    private final WebBeansContext context;
+    private final Object startEvent;
+    private AtomicBoolean running = new AtomicBoolean(true);
+
+    // let's it be public in case we extend it
+    public OWBContainer(final WebBeansContext context, final Object startObj)
+    {
+        this.context = context;
+        this.startEvent = startObj;
+    }
+
+    @Override
+    public void close()
+    {
+        if (running.compareAndSet(true, false))
+        {
+            context.getService(ContainerLifecycle.class).stopApplication(startEvent);
+        }
+    }
+
+    @Override
+    public boolean isRunning()
+    {
+        return running.get();
+    }
+
+    @Override
+    public BeanManager getBeanManager()
+    {
+        return new InjectableBeanManager(context.getBeanManagerImpl());
+    }
+
+    @Override
+    public Instance<Object> select(final Annotation... qualifiers)
+    {
+        return instance().select(qualifiers);
+    }
+
+    @Override
+    public boolean isUnsatisfied()
+    {
+        return instance().isUnsatisfied();
+    }
+
+    @Override
+    public boolean isAmbiguous()
+    {
+        return instance().isAmbiguous();
+    }
+
+    @Override
+    public void destroy(final Object instance) // not sure it is the right impl
+    {
+        InstanceImpl.class.cast(instance).destroy(instance);
+    }
+
+    @Override
+    public <U extends Object> Instance<U> select(final TypeLiteral<U> subtype, final Annotation... qualifiers)
+    {
+        return instance().select(subtype, qualifiers);
+    }
+
+    @Override
+    public <U extends Object> Instance<U> select(final Class<U> subtype, final Annotation... qualifiers)
+    {
+        return instance().select(subtype, qualifiers);
+    }
+
+    @Override
+    public Iterator<Object> iterator()
+    {
+        return instance().iterator();
+    }
+
+    @Override
+    public Object get()
+    {
+        return instance().get();
+    }
+
+    private Instance<Object> instance()
+    {
+        final BeanManagerImpl bm = context.getBeanManagerImpl();
+        final CreationalContextImpl<Instance<Object>> creationalContext = bm.createCreationalContext(null);
+        return new InstanceBean<>(context).create(creationalContext).select(DefaultLiteral.INSTANCE);
+    }
+}

Added: openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/OWBInitializer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/OWBInitializer.java?rev=1797251&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/OWBInitializer.java (added)
+++ openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/OWBInitializer.java Thu Jun  1 19:30:25 2017
@@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openwebbeans.se;
+
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.config.WebBeansFinder;
+import org.apache.webbeans.corespi.DefaultSingletonService;
+import org.apache.webbeans.spi.BeanArchiveService;
+import org.apache.webbeans.spi.ContainerLifecycle;
+import org.apache.webbeans.spi.LoaderService;
+import org.apache.webbeans.spi.ScannerService;
+import org.apache.webbeans.spi.SingletonService;
+import org.apache.webbeans.xml.DefaultBeanArchiveInformation;
+
+import javax.enterprise.inject.se.SeContainer;
+import javax.enterprise.inject.se.SeContainerInitializer;
+import javax.enterprise.inject.spi.Extension;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.stream.Stream;
+
+import static java.util.Arrays.asList;
+import static java.util.stream.Collectors.toList;
+import static java.util.stream.Collectors.toMap;
+
+public class OWBInitializer extends SeContainerInitializer
+{
+    private final CDISeScannerService scannerService = new CDISeScannerService();
+    private final Properties properties = new Properties();
+    private final Map<String, Object> services = new HashMap<>();
+    private final Collection<Extension> extensions = new ArrayList<>();
+    private final DefaultBeanArchiveInformation bai = new DefaultBeanArchiveInformation(CDISeBeanArchiveService.EMBEDDED_URL);
+    private ClassLoader loader = Thread.currentThread().getContextClassLoader();
+
+    public OWBInitializer()
+    {
+        scannerService.loader(loader);
+    }
+
+    @Override
+    public SeContainer initialize()
+    {
+        final Thread thread = Thread.currentThread();
+        final ClassLoader old = thread.getContextClassLoader();
+        thread.setContextClassLoader(loader);
+        try
+        {
+            services.putIfAbsent(ScannerService.class.getName(), scannerService);
+            services.putIfAbsent(LoaderService.class.getName(), new CDISeLoaderService(extensions, loader));
+            services.putIfAbsent(BeanArchiveService.class.getName(), new CDISeBeanArchiveService(bai));
+            final Map<Class<?>, Object> preparedServices = services.entrySet().stream()
+                    .collect(toMap(e ->
+                    {
+                        try
+                        {
+                            return loader.loadClass(e.getKey());
+                        }
+                        catch (final ClassNotFoundException e1)
+                        {
+                            throw new IllegalArgumentException(e1);
+                        }
+                    }, Map.Entry::getValue));
+
+            final WebBeansContext context = new WebBeansContext(preparedServices, properties);
+
+            final SingletonService<WebBeansContext> singletonInstance = WebBeansFinder.getSingletonService();
+            DefaultSingletonService.class.cast(singletonInstance).register(loader, context);
+
+            final Object startObj = new Object();
+            context.getService(ContainerLifecycle.class).startApplication(startObj);
+            return new OWBContainer(context, startObj);
+        }
+        finally
+        {
+            thread.setContextClassLoader(old);
+        }
+    }
+
+    @Override
+    public SeContainerInitializer addBeanClasses(final Class<?>... classes)
+    {
+        scannerService.classes(classes);
+        return this;
+    }
+
+    @Override
+    public SeContainerInitializer addPackages(final Package... packages)
+    {
+        return addPackages(false, packages);
+    }
+
+    @Override
+    public SeContainerInitializer addPackages(final boolean scanRecursively, final Package... packages)
+    {
+        scannerService.packages(scanRecursively, packages);
+        return this;
+    }
+
+    @Override
+    public SeContainerInitializer addPackages(final Class<?>... packageClasses)
+    {
+        return addPackages(false, packageClasses);
+    }
+
+    @Override
+    public SeContainerInitializer addPackages(final boolean scanRecursively, final Class<?>... packageClasses)
+    {
+        scannerService.packages(scanRecursively, packageClasses);
+        return this;
+    }
+
+    @Override
+    public SeContainerInitializer enableInterceptors(final Class<?>... interceptorClasses)
+    {
+        bai.getInterceptors().addAll(Stream.of(interceptorClasses).map(Class::getName).collect(toList()));
+        return this;
+    }
+
+    @Override
+    public SeContainerInitializer enableDecorators(final Class<?>... decoratorClasses)
+    {
+        bai.getDecorators().addAll(Stream.of(decoratorClasses).map(Class::getName).collect(toList()));
+        return this;
+    }
+
+    @Override
+    public SeContainerInitializer selectAlternatives(final Class<?>... alternativeClasses)
+    {
+        bai.getAlternativeClasses().addAll(Stream.of(alternativeClasses).map(Class::getName).collect(toList()));
+        return this;
+    }
+
+    @Override
+    public SeContainerInitializer selectAlternativeStereotypes(final Class<? extends Annotation>... alternativeStereotypeClasses)
+    {
+        bai.getAlternativeStereotypes().addAll(Stream.of(alternativeStereotypeClasses).map(Class::getName).collect(toList()));
+        return this;
+    }
+
+    @Override
+    public SeContainerInitializer addExtensions(final Extension... extensions)
+    {
+        this.extensions.addAll(asList(extensions));
+        return this;
+    }
+
+    @Override
+    public SeContainerInitializer addExtensions(final Class<? extends Extension>... extensions)
+    {
+        this.extensions.addAll(Stream.of(extensions).map(e ->
+        {
+            try
+            {
+                return e.getConstructor().newInstance();
+            }
+            catch (final InstantiationException | IllegalAccessException | NoSuchMethodException e1)
+            {
+                throw new IllegalArgumentException(e1);
+            }
+            catch (final InvocationTargetException e1)
+            {
+                throw new IllegalArgumentException(e1.getCause());
+            }
+        }).collect(toList()));
+        return this;
+    }
+
+    @Override
+    public SeContainerInitializer addProperty(final String key, final Object value)
+    {
+        if (String.class.isInstance(value))
+        {
+            properties.put(key, value);
+        }
+        else
+        {
+            services.put(key, value);
+        }
+        return this;
+    }
+
+    @Override
+    public SeContainerInitializer setProperties(final Map<String, Object> properties)
+    {
+        properties.forEach(this::addProperty);
+        return this;
+    }
+
+    @Override
+    public SeContainerInitializer disableDiscovery()
+    {
+        scannerService.disableAutoScanning();
+        return this;
+    }
+
+    @Override
+    public SeContainerInitializer setClassLoader(final ClassLoader classLoader)
+    {
+        loader = classLoader;
+        scannerService.loader(loader);
+        return this;
+    }
+}

Added: openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/SeContainerSelector.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/SeContainerSelector.java?rev=1797251&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/SeContainerSelector.java (added)
+++ openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/SeContainerSelector.java Thu Jun  1 19:30:25 2017
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openwebbeans.se;
+
+import javax.enterprise.inject.se.SeContainerInitializer;
+
+public interface SeContainerSelector
+{
+    SeContainerInitializer find();
+}

Added: openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/SeInitializerFacade.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/SeInitializerFacade.java?rev=1797251&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/SeInitializerFacade.java (added)
+++ openwebbeans/trunk/webbeans-se/src/main/java/org/apache/openwebbeans/se/SeInitializerFacade.java Thu Jun  1 19:30:25 2017
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openwebbeans.se;
+
+import javax.enterprise.inject.se.SeContainer;
+import javax.enterprise.inject.se.SeContainerInitializer;
+import javax.enterprise.inject.spi.Extension;
+import java.lang.annotation.Annotation;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Optional;
+import java.util.ServiceLoader;
+
+// will allow to plug other impl but reusing most of our logic
+public class SeInitializerFacade extends SeContainerInitializer
+{
+    private final SeContainerInitializer delegate;
+
+    public SeInitializerFacade()
+    {
+        delegate = Optional.of(ServiceLoader.load(SeContainerSelector.class).iterator())
+                .filter(Iterator::hasNext)
+                .map(Iterator::next)
+                .map(SeContainerSelector::find)
+                .orElseGet(OWBInitializer::new);
+    }
+
+    @Override
+    public SeContainerInitializer addBeanClasses(final Class<?>... classes)
+    {
+        return delegate.addBeanClasses(classes);
+    }
+
+    @Override
+    public SeContainerInitializer addPackages(final Class<?>... packageClasses)
+    {
+        return delegate.addPackages(packageClasses);
+    }
+
+    @Override
+    public SeContainerInitializer addPackages(final boolean scanRecursively, final Class<?>... packageClasses)
+    {
+        return delegate.addPackages(scanRecursively, packageClasses);
+    }
+
+    @Override
+    public SeContainerInitializer addPackages(final Package... packages)
+    {
+        return delegate.addPackages(packages);
+    }
+
+    @Override
+    public SeContainerInitializer addPackages(final boolean scanRecursively, final Package... packages)
+    {
+        return delegate.addPackages(scanRecursively, packages);
+    }
+
+    @Override
+    public SeContainerInitializer addExtensions(final Extension... extensions)
+    {
+        return delegate.addExtensions(extensions);
+    }
+
+    @Override
+    public SeContainerInitializer addExtensions(final Class<? extends Extension>... extensions)
+    {
+        return delegate.addExtensions(extensions);
+    }
+
+    @Override
+    public SeContainerInitializer enableInterceptors(final Class<?>... interceptorClasses)
+    {
+        return delegate.enableInterceptors(interceptorClasses);
+    }
+
+    @Override
+    public SeContainerInitializer enableDecorators(final Class<?>... decoratorClasses)
+    {
+        return delegate.enableDecorators(decoratorClasses);
+    }
+
+    @Override
+    public SeContainerInitializer selectAlternatives(final Class<?>... alternativeClasses)
+    {
+        return delegate.selectAlternatives(alternativeClasses);
+    }
+
+    @Override
+    public SeContainerInitializer selectAlternativeStereotypes(final Class<? extends Annotation>... alternativeStereotypeClasses)
+    {
+        return delegate.selectAlternativeStereotypes(alternativeStereotypeClasses);
+    }
+
+    @Override
+    public SeContainerInitializer addProperty(final String key, final Object value)
+    {
+        return delegate.addProperty(key, value);
+    }
+
+    @Override
+    public SeContainerInitializer setProperties(final Map<String, Object> properties)
+    {
+        return delegate.setProperties(properties);
+    }
+
+    @Override
+    public SeContainerInitializer disableDiscovery()
+    {
+        return delegate.disableDiscovery();
+    }
+
+    @Override
+    public SeContainerInitializer setClassLoader(final ClassLoader classLoader)
+    {
+        return delegate.setClassLoader(classLoader);
+    }
+
+    @Override
+    public SeContainer initialize()
+    {
+        return delegate.initialize();
+    }
+}

Added: openwebbeans/trunk/webbeans-se/src/main/resources/META-INF/services/javax.enterprise.inject.se.SeContainerInitializer
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-se/src/main/resources/META-INF/services/javax.enterprise.inject.se.SeContainerInitializer?rev=1797251&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-se/src/main/resources/META-INF/services/javax.enterprise.inject.se.SeContainerInitializer (added)
+++ openwebbeans/trunk/webbeans-se/src/main/resources/META-INF/services/javax.enterprise.inject.se.SeContainerInitializer Thu Jun  1 19:30:25 2017
@@ -0,0 +1,17 @@
+#Licensed to the Apache Software Foundation (ASF) under one
+#or more contributor license agreements.  See the NOTICE file
+#distributed with this work for additional information
+#regarding copyright ownership.  The ASF licenses this file
+#to you under the Apache License, Version 2.0 (the
+#"License"); you may not use this file except in compliance
+#with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+#Unless required by applicable law or agreed to in writing,
+#software distributed under the License is distributed on an
+#"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#KIND, either express or implied.  See the License for the
+#specific language governing permissions and limitations
+#under the License.
+org.apache.openwebbeans.se.SeInitializerFacade

Added: openwebbeans/trunk/webbeans-se/src/test/java/org/apache/openwebbeans/se/CDISETest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-se/src/test/java/org/apache/openwebbeans/se/CDISETest.java?rev=1797251&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-se/src/test/java/org/apache/openwebbeans/se/CDISETest.java (added)
+++ openwebbeans/trunk/webbeans-se/src/test/java/org/apache/openwebbeans/se/CDISETest.java Thu Jun  1 19:30:25 2017
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openwebbeans.se;
+
+import org.junit.Test;
+
+import javax.enterprise.inject.se.SeContainer;
+import javax.enterprise.inject.se.SeContainerInitializer;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class CDISETest
+{
+    @Test
+    public void scanning()
+    {
+        // no scanning
+        try (final SeContainer container = SeContainerInitializer.newInstance().disableDiscovery().initialize())
+        {
+            assertTrue(container.isRunning());
+            assertTrue(container.select(ImNotScanned.class).isUnsatisfied());
+        }
+        // class
+        try (final SeContainer container = SeContainerInitializer.newInstance()
+                .disableDiscovery()
+                .addBeanClasses(ImNotScanned.class)
+                .initialize())
+        {
+            assertNotNull(container.select(ImNotScanned.class).get());
+        }
+        // from package
+        try (final SeContainer container = SeContainerInitializer.newInstance()
+                .disableDiscovery()
+                .addPackages(ImNotScanned.class.getPackage())
+                .initialize())
+        {
+            assertNotNull(container.select(ImNotScanned.class).get());
+        }
+        // from package based on a class
+        try (final SeContainer container = SeContainerInitializer.newInstance()
+                .disableDiscovery()
+                .addPackages(ImNotScanned.class)
+                .initialize())
+        {
+            assertNotNull(container.select(ImNotScanned.class).get());
+        }
+    }
+
+    public static class ImNotScanned {
+
+    }
+}

Modified: openwebbeans/trunk/webbeans-web/src/test/java/org/apache/webbeans/web/tests/WebBeansTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-web/src/test/java/org/apache/webbeans/web/tests/WebBeansTest.java?rev=1797251&r1=1797250&r2=1797251&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-web/src/test/java/org/apache/webbeans/web/tests/WebBeansTest.java (original)
+++ openwebbeans/trunk/webbeans-web/src/test/java/org/apache/webbeans/web/tests/WebBeansTest.java Thu Jun  1 19:30:25 2017
@@ -79,7 +79,7 @@ public class WebBeansTest {
         @Override
         public void scan()
         {
-            archive = new CdiArchive(new DefaultBeanArchiveService(), Thread.currentThread().getContextClassLoader(), new HashMap<String, URL>(), null);
+            archive = new CdiArchive(new DefaultBeanArchiveService(), Thread.currentThread().getContextClassLoader(), new HashMap<String, URL>(), null, null);
             finder = new OwbAnnotationFinder(new ClassesArchive());
         }
     }



Mime
View raw message