openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1728163 [2/2] - in /openwebbeans/branches/cdi-2.0: ./ webbeans-doc/src/docbkx/userguide/ webbeans-ee/src/main/java/org/apache/webbeans/ee/event/ webbeans-impl/src/main/java/org/apache/webbeans/component/ webbeans-impl/src/main/java/org/apa...
Date Tue, 02 Feb 2016 17:48:15 GMT
Modified: openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultApplicationBoundaryService.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultApplicationBoundaryService.java?rev=1728163&r1=1728162&r2=1728163&view=diff
==============================================================================
--- openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultApplicationBoundaryService.java
(original)
+++ openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultApplicationBoundaryService.java
Tue Feb  2 17:48:14 2016
@@ -18,33 +18,97 @@
  */
 package org.apache.webbeans.corespi.se;
 
-import javax.enterprise.inject.spi.BeanManager;
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
 
+import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.spi.ApplicationBoundaryService;
 
 /**
  * Really simple default impl of the ApplicationBoundaryService.
  * Assumes that there is a pretty easy ClassLoader structure in place.
+ * If a proxy should get created for a class further outside of the
+ * {@link #applicationClassLoader} then the {@link #applicationClassLoader}
+ * itself will get used to prevent mem leaks.
  */
-public class DefaultApplicationBoundaryService implements ApplicationBoundaryService
+public class DefaultApplicationBoundaryService implements ApplicationBoundaryService, Closeable
 {
-    private final ClassLoader appCL = BeanManager.class.getClassLoader();
+    /**
+     * The outermost ClassLoader of the appliction. E.g. the EAR classloader
+     */
+    private ClassLoader applicationClassLoader;
+
+    /**
+     * All ClassLoaders further outside of the {@link #applicationClassLoader}.
+     */
+    private Set<ClassLoader> parentClassLoaders;
+
+    public DefaultApplicationBoundaryService()
+    {
+        init();
+    }
+
+    protected void init()
+    {
+        applicationClassLoader = BeanManagerImpl.class.getClassLoader();
+        parentClassLoaders = new HashSet<ClassLoader>();
+        ClassLoader cl = applicationClassLoader;
+        while (cl.getParent() != null)
+        {
+            cl = cl.getParent();
+            parentClassLoaders.add(cl);
+        }
+
+    }
 
     @Override
     public ClassLoader getApplicationClassLoader()
     {
-        return appCL;
+        return applicationClassLoader;
     }
 
     @Override
     public ClassLoader getBoundaryClassLoader(Class classToProxy)
     {
-        ClassLoader classLoader = classToProxy.getClassLoader();
-        if (classLoader == null && classToProxy.isInterface())
+        ClassLoader appCl = getApplicationClassLoader();
+
+        ClassLoader classToProxyCl = classToProxy.getClassLoader();
+
+        if (classToProxyCl == null)
         {
-            return getApplicationClassLoader();
+            // Some JVMs return null for the bootstrap CL
+            return appCl;
         }
-        return classLoader;
+
+        if (classToProxyCl == appCl)
+        {
+            // this mainly happens in a 'flat CL' environment
+            return appCl;
+        }
+
+        if (isOutsideOfApplicationClassLoader(classToProxyCl))
+        {
+            // note: this logic only works if you have a hieararchic ClassLoader scenario
+            // It doesn't work for e.g. OSGi environments where the CLs are spread out
+            // with very limited visibility
+            return appCl;
+        }
+
+        return classToProxyCl;
+    }
+
+    protected boolean isOutsideOfApplicationClassLoader(ClassLoader classToProxyCl)
+    {
+
+        return parentClassLoaders.contains(classToProxyCl);
     }
 
+    @Override
+    public void close() throws IOException
+    {
+        // we store ClassLoaders so we MUST free them at shutdown!
+        parentClassLoaders.clear();
+    }
 }

Modified: openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java?rev=1728163&r1=1728162&r2=1728163&view=diff
==============================================================================
--- openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
(original)
+++ openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
Tue Feb  2 17:48:14 2016
@@ -531,7 +531,7 @@ public final class NotificationManager
             if(checkEventTypeParameterForExtensions(beanClass, actualArgs[0])
                     && (secondParam == null || actualArgs.length == 1
                             || checkEventTypeParameterForExtensions(secondParam, actualArgs[1])
-                            || GenericsUtil.isAssignableFrom(false, false, secondParam, actualArgs[1])))
+                            || GenericsUtil.isAssignableFrom(false, false, actualArgs[1],
secondParam)))
             {
                 addToMatching(type, matching);   
             }

Modified: openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java?rev=1728163&r1=1728162&r2=1728163&view=diff
==============================================================================
--- openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
(original)
+++ openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
Tue Feb  2 17:48:14 2016
@@ -31,7 +31,6 @@ import org.apache.webbeans.config.WebBea
 import org.apache.webbeans.config.WebBeansFinder;
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.container.InjectableBeanManager;
-import org.apache.webbeans.container.InjectionResolver;
 import org.apache.webbeans.portable.events.discovery.BeforeShutdownImpl;
 import org.apache.webbeans.spi.ContainerLifecycle;
 import org.apache.webbeans.spi.ContextsService;
@@ -172,14 +171,6 @@ public abstract class AbstractLifeCycle
             //Clear extensions
             webBeansContext.getExtensionLoader().clear();
             
-            //Delete Resolutions Cache
-            InjectionResolver injectionResolver = webBeansContext.getBeanManagerImpl().getInjectionResolver();
-
-            injectionResolver.clearCaches();
-            
-            //Delete AnnotateTypeCache
-            webBeansContext.getAnnotatedElementFactory().clear();
-            
             //After Stop
             afterStopApplication(endObject);
 

Modified: openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java?rev=1728163&r1=1728162&r2=1728163&view=diff
==============================================================================
--- openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
(original)
+++ openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
Tue Feb  2 17:48:14 2016
@@ -540,7 +540,7 @@ public final class ClassUtil
     
 
     /**
-     * Returna true if the class is not abstract and interface.
+     * Return true if the class is not abstract and interface.
      *     
      * @param clazz class type
      * @return true if the class is not abstract and interface

Modified: openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/util/OwbCustomObjectInputStream.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/util/OwbCustomObjectInputStream.java?rev=1728163&r1=1728162&r2=1728163&view=diff
==============================================================================
--- openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/util/OwbCustomObjectInputStream.java
(original)
+++ openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/util/OwbCustomObjectInputStream.java
Tue Feb  2 17:48:14 2016
@@ -26,6 +26,12 @@ import java.lang.reflect.Proxy;
 
 public class OwbCustomObjectInputStream extends ObjectInputStream
 {
+    public static final BlacklistClassResolver BLACKLIST_CLASSES = new BlacklistClassResolver(
+        toArray(System.getProperty(
+            "openwebbeans.serialization.class.blacklist",
+            "org.codehaus.groovy.runtime.,org.apache.commons.collections.functors.,org.apache.xalan")),
+        toArray(System.getProperty("openwebbeans.serialization.class.whitelist")));
+
     private ClassLoader classLoader;
 
     public OwbCustomObjectInputStream(InputStream in, ClassLoader classLoader) throws IOException
@@ -37,7 +43,7 @@ public class OwbCustomObjectInputStream
     @Override
     protected Class<?> resolveClass(ObjectStreamClass desc) throws ClassNotFoundException
     {
-        return Class.forName(desc.getName(), false, classLoader);
+        return Class.forName(BLACKLIST_CLASSES.check(desc.getName()), false, classLoader);
     }
 
     @Override
@@ -58,4 +64,50 @@ public class OwbCustomObjectInputStream
             throw new ClassNotFoundException(null, e);
         }
     }
+
+    private static String[] toArray(final String property)
+    {
+        return property == null ? null : property.split(" *, *");
+    }
+
+    private static class BlacklistClassResolver
+    {
+        private final String[] blacklist;
+        private final String[] whitelist;
+
+        protected BlacklistClassResolver(final String[] blacklist, final String[] whitelist)
+        {
+            this.whitelist = whitelist;
+            this.blacklist = blacklist;
+        }
+
+        protected boolean isBlacklisted(final String name)
+        {
+            return (whitelist != null && !contains(whitelist, name)) || contains(blacklist,
name);
+        }
+
+        public final String check(final String name)
+        {
+            if (isBlacklisted(name))
+            {
+                throw new SecurityException(name + " is not whitelisted as deserialisable,
prevented before loading.");
+            }
+            return name;
+        }
+
+        private static boolean contains(final String[] list, String name)
+        {
+            if (list != null)
+            {
+                for (final String white : list)
+                {
+                    if (name.startsWith(white))
+                    {
+                        return true;
+                    }
+                }
+            }
+            return false;
+        }
+    }
 }

Modified: openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/util/SpecializationUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/util/SpecializationUtil.java?rev=1728163&r1=1728162&r2=1728163&view=diff
==============================================================================
--- openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/util/SpecializationUtil.java
(original)
+++ openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/util/SpecializationUtil.java
Tue Feb  2 17:48:14 2016
@@ -31,6 +31,7 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.apache.webbeans.config.OWBLogConst;
@@ -40,6 +41,7 @@ import org.apache.webbeans.exception.Web
 import org.apache.webbeans.exception.InconsistentSpecializationException;
 import org.apache.webbeans.inject.AlternativesManager;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
+import org.apache.webbeans.spi.BeanArchiveService;
 import org.apache.webbeans.spi.plugins.OpenWebBeansEjbPlugin;
 
 /**
@@ -63,15 +65,17 @@ public class SpecializationUtil
 
     /**
      *
-     * @param annotatedTypes all annotatypes
+     * @param annotatedTypesPerBda all annotatypes sliced by BDA
      * @param attributeProvider if not null provides bean attributes to be able to validate
types contains superclass
      * @param notSpecializationOnly first pass/2nd pass. First one removes only root beans,
second one handles inheritance even in @Spe
      */
-    public void removeDisabledTypes(Collection<AnnotatedType<?>> annotatedTypes,
+    public void removeDisabledTypes( Map<BeanArchiveService.BeanArchiveInformation, List<AnnotatedType<?>>>
annotatedTypesPerBda,
                                     BeanAttributesProvider attributeProvider,
                                     boolean notSpecializationOnly)
     {
-        if (annotatedTypes != null && !annotatedTypes.isEmpty())
+        Set<AnnotatedType<?>> allAnnotatedTypes = getAllAnnotatedTypes(annotatedTypesPerBda);
+
+        if (allAnnotatedTypes != null && !allAnnotatedTypes.isEmpty())
         {
             // superClassList is used to handle the case: Car, CarToyota, Bus, SchoolBus,
CarFord
             // for which case OWB should throw exception that both CarToyota and CarFord
are
@@ -81,7 +85,7 @@ public class SpecializationUtil
 
             // first let's find all superclasses of Specialized types
             Set<Class<?>> disabledClasses = new HashSet<Class<?>>();
-            for(AnnotatedType<?> annotatedType : annotatedTypes)
+            for(AnnotatedType<?> annotatedType : allAnnotatedTypes)
             {
                 if(annotatedType.getAnnotation(Specializes.class) != null && isEnabled(annotatedType))
                 {
@@ -113,19 +117,21 @@ public class SpecializationUtil
                         throw new WebBeansDeploymentException(new InconsistentSpecializationException(WebBeansLoggerFacade.getTokenString(OWBLogConst.EXCEPT_0005)
+
                                                                        superClass.getName()));
                     }
-                    if (!containsAllSuperclassTypes(annotatedType, superClass, annotatedTypes))
+                    if (!containsAllSuperclassTypes(annotatedType, superClass, allAnnotatedTypes))
                     {
                         throw new WebBeansDeploymentException(new InconsistentSpecializationException("@Specialized
Class : " + specialClass.getName()
                                                                           + " must have all
bean types of its super class"));
                     }
 
-                    AnnotatedType<?> superType = getAnnotatedTypeForClass(annotatedTypes,
superClass);
+                    AnnotatedType<?> superType = getAnnotatedTypeForClass(allAnnotatedTypes,
superClass);
                     if (notSpecializationOnly)
                     {
+                        /*X TODO remove?
                         if (superType != null && superType.getAnnotation(Specializes.class)
!= null)
                         {
                             continue;
                         }
+                        */
 
                         if ((superType == null && !webBeansContext.findMissingAnnotatedType(superClass))
|| (superType != null && !webBeansUtil.isConstructorOk(superType)))
                         {
@@ -156,21 +162,36 @@ public class SpecializationUtil
             }
 
             // and now remove all AnnotatedTypes of those collected disabledClasses
-            if (!disabledClasses.isEmpty())
+            removeAllDisabledClasses(annotatedTypesPerBda, disabledClasses);
+        }
+    }
+
+    private void removeAllDisabledClasses(Map<BeanArchiveService.BeanArchiveInformation,
List<AnnotatedType<?>>> annotatedTypesPerBda, Set<Class<?>> disabledClasses)
+    {
+        for (List<AnnotatedType<?>> annotatedTypes : annotatedTypesPerBda.values())
+        {
+            Iterator<AnnotatedType<?>> annotatedTypeIterator = annotatedTypes.iterator();
+            while (annotatedTypeIterator.hasNext())
             {
-                Iterator<AnnotatedType<?>> annotatedTypeIterator = annotatedTypes.iterator();
-                while (annotatedTypeIterator.hasNext())
+                AnnotatedType<?> annotatedType = annotatedTypeIterator.next();
+                if (disabledClasses.contains(annotatedType.getJavaClass()))
                 {
-                    AnnotatedType<?> annotatedType = annotatedTypeIterator.next();
-                    if (disabledClasses.contains(annotatedType.getJavaClass()))
-                    {
-                        annotatedTypeIterator.remove();
-                    }
+                    annotatedTypeIterator.remove();
                 }
             }
         }
     }
 
+    private Set<AnnotatedType<?>> getAllAnnotatedTypes(Map<BeanArchiveService.BeanArchiveInformation,
List<AnnotatedType<?>>> annotatedTypesPerBda)
+    {
+        Set<AnnotatedType<?>> allAnnotatedTypes = new HashSet<AnnotatedType<?>>(annotatedTypesPerBda.size()*50);
+        for (List<AnnotatedType<?>> annotatedTypes : annotatedTypesPerBda.values())
+        {
+            allAnnotatedTypes.addAll(annotatedTypes);
+        }
+        return allAnnotatedTypes;
+    }
+
     private boolean containsAllSuperclassTypes(AnnotatedType<?> annotatedType, Class<?>
superClass, Collection<AnnotatedType<?>> annotatedTypes)
     {
         Typed typed = annotatedType.getAnnotation(Typed.class);
@@ -214,11 +235,11 @@ public class SpecializationUtil
     }
 
     /**
-     * @return false if the AnnotatedType is for a not enabled Alternative
+     * @return true if the AnnotatedType is an enabled Alternative or no alternative at all
      */
     private boolean isEnabled(AnnotatedType<?> annotatedType)
     {
-        return  annotatedType.getAnnotation(Alternative.class) == null ||
+        return annotatedType.getAnnotation(Alternative.class) == null ||
                 alternativesManager.isAlternative(annotatedType.getJavaClass(), getAnnotationClasses(annotatedType));
     }
 

Modified: openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansConstants.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansConstants.java?rev=1728163&r1=1728162&r2=1728163&view=diff
==============================================================================
--- openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansConstants.java
(original)
+++ openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansConstants.java
Tue Feb  2 17:48:14 2016
@@ -40,8 +40,11 @@ public final class WebBeansConstants
     
     public static final String WEB_BEANS_XML_INTERCEPTORS_ELEMENT = "interceptors";
     public static final String WEB_BEANS_XML_DECORATORS_ELEMENT = "decorators";
+    public static final String WEB_BEANS_XML_ALLOW_PROXYING_ELEMENT = "allowProxying";
     public static final String WEB_BEANS_XML_ALTERNATIVES_ELEMENT = "alternatives";
     public static final String WEB_BEANS_XML_SCAN_ELEMENT = "scan";
+    /** Having this tag in beans.xml fordes bean-discovery-mode="scoped" in a backward compat
way */
+    public static final String WEB_BEANS_XML_SCOPED_BEANS_ONLY_ELEMENT = "scopedBeansOnly";
 
     public static final String WEB_BEANS_XML_CLASS = "class";
     public static final String WEB_BEANS_XML_STEREOTYPE = "stereotype";

Modified: openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveInformation.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveInformation.java?rev=1728163&r1=1728162&r2=1728163&view=diff
==============================================================================
--- openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveInformation.java
(original)
+++ openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveInformation.java
Tue Feb  2 17:48:14 2016
@@ -38,7 +38,7 @@ public class DefaultBeanArchiveInformati
 
     /** Exclude all subpackages (exclude= .**) */
     private List<String> excludedPackages = null;
-
+    private List<String> allowProxyingClasses = new ArrayList<String>();
 
 
     @Override
@@ -188,4 +188,11 @@ public class DefaultBeanArchiveInformati
     {
         this.excludedPackages = excludedPackages;
     }
+
+    @Override
+    public List<String> getAllowProxyingClasses()
+    {
+        return allowProxyingClasses;
+    }
+
 }

Modified: openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveService.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveService.java?rev=1728163&r1=1728162&r2=1728163&view=diff
==============================================================================
--- openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveService.java
(original)
+++ openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveService.java
Tue Feb  2 17:48:14 2016
@@ -149,6 +149,8 @@ public class DefaultBeanArchiveService i
         mergedBdaInfo.getAlternativeClasses().addAll(mergeLists(bdaWebClasses.getAlternativeClasses(),
bdaWebInf.getAlternativeClasses()));
         mergedBdaInfo.getAlternativeStereotypes().addAll(mergeLists(bdaWebClasses.getAlternativeStereotypes(),
bdaWebInf.getAlternativeStereotypes()));
 
+        // we do NOT merge the allowProxying as they just stack up anyway
+
         return mergedBdaInfo;
     }
 
@@ -212,7 +214,7 @@ public class DefaultBeanArchiveService i
         {
             xmlStream = beansXmlUrl.openStream();
 
-            return readBeansXml(xmlStream);
+            return readBeansXml(xmlStream, beansXmlUrl.toExternalForm());
 
         }
         catch (Exception e)
@@ -255,7 +257,7 @@ public class DefaultBeanArchiveService i
      * Read the information from the given beans.xml and fill it into a
      * BeanArchiveInformation instance.
      */
-    protected BeanArchiveInformation readBeansXml(InputStream xmlStreamIn) throws IOException
+    protected BeanArchiveInformation readBeansXml(InputStream xmlStreamIn, String beansXmlLocation)
throws IOException
     {
         DefaultBeanArchiveInformation bdaInfo = createBeanArchiveInformation();
 
@@ -285,7 +287,8 @@ public class DefaultBeanArchiveService i
                 {
                     if (!"beans".equalsIgnoreCase(webBeansRoot.getLocalName()))
                     {
-                        throw new WebBeansConfigurationException("beans.xml must have a <beans>
root element, but has: " + webBeansRoot.getLocalName());
+                        throw new WebBeansConfigurationException("beans.xml must have a <beans>
root element, but has: " + webBeansRoot.getLocalName() +
+                                                                 " in " + beansXmlLocation);
                     }
 
                     bdaInfo.setVersion(getTrimmedAttribute(webBeansRoot, "version"));
@@ -293,13 +296,13 @@ public class DefaultBeanArchiveService i
                     String beanDiscoveryMode = getTrimmedAttribute(webBeansRoot, "bean-discovery-mode");
                     bdaInfo.setBeanDiscoveryMode(beanDiscoveryMode != null ? BeanDiscoveryMode.valueOf(beanDiscoveryMode.toUpperCase())
: null);
 
-                    readBeanChildren(bdaInfo, webBeansRoot);
+                    readBeanChildren(bdaInfo, webBeansRoot, beansXmlLocation);
                 }
 
 
                 if (bdaInfo.getVersion() != null && !"1.0".equals(bdaInfo.getVersion())
&& bdaInfo.getBeanDiscoveryMode() == null)
                 {
-                    throw new WebBeansConfigurationException("beans.xml with version 1.1
and higher must declare a bean-discovery-mode!");
+                    throw new WebBeansConfigurationException("beans.xml with version 1.1
and higher must declare a bean-discovery-mode! url=" + beansXmlLocation);
                 }
 
 
@@ -320,7 +323,7 @@ public class DefaultBeanArchiveService i
         return bdaInfo;
     }
 
-    private void readBeanChildren(DefaultBeanArchiveInformation bdaInfo, Element webBeansRoot)
+    private void readBeanChildren(DefaultBeanArchiveInformation bdaInfo, Element webBeansRoot,
String beansXmlLocation)
     {
         ElementIterator elit = new ElementIterator(webBeansRoot);
         while (elit.hasNext())
@@ -343,6 +346,15 @@ public class DefaultBeanArchiveService i
             {
                 fillExcludes(bdaInfo, child);
             }
+            else if (WebBeansConstants.WEB_BEANS_XML_ALLOW_PROXYING_ELEMENT.equalsIgnoreCase(child.getLocalName()))
+            {
+                fillAllowProxying(bdaInfo, child);
+            }
+            else if (WebBeansConstants.WEB_BEANS_XML_SCOPED_BEANS_ONLY_ELEMENT.equalsIgnoreCase(child.getLocalName()))
+            {
+                logger.info("OWB specific feature detected: force bean-discovery-mode=\"scopex\"
for " + beansXmlLocation);
+                bdaInfo.setBeanDiscoveryMode(BeanDiscoveryMode.SCOPED);
+            }
         }
     }
 
@@ -489,6 +501,26 @@ public class DefaultBeanArchiveService i
         }
     }
 
+    private void fillAllowProxying(DefaultBeanArchiveInformation bdaInfo, Element allowProxyingElement)
+    {
+        ElementIterator elit = new ElementIterator(allowProxyingElement);
+        while (elit.hasNext())
+        {
+            Element child = elit.next();
+            if (WebBeansConstants.WEB_BEANS_XML_CLASS.equalsIgnoreCase(child.getLocalName()))
+            {
+                String clazz = child.getTextContent().trim();
+                if (clazz.isEmpty())
+                {
+                    throw new WebBeansConfigurationException("allowProxying <class>
element must not be empty!");
+                }
+                bdaInfo.getAllowProxyingClasses().add(clazz);
+            }
+        }
+    }
+
+
+
     private static boolean isClassAvailable(final ClassLoader loader, final String name)
     {
         try

Modified: openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
URL: http://svn.apache.org/viewvc/openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties?rev=1728163&r1=1728162&r2=1728163&view=diff
==============================================================================
--- openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
(original)
+++ openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
Tue Feb  2 17:48:14 2016
@@ -19,13 +19,13 @@
 #
 # The default configuration is intended for a JDK and a simple ServletContainer
 # like jetty, resin or tomcat.
-#
+# 
 #---------------------------------------------------------------
 
 
 ################################################################################################
 ################################### DEFAULT SPI CONFIGURATION SECTION ##########################
-################################################################################################
+################################################################################################

 
 # this is the basic configuration, thus it has a very low ordinal of 10
 configuration.ordinal=10
@@ -75,7 +75,7 @@ org.apache.webbeans.spi.SecurityService=
 # Service which encapsulates the Service-Loader of Java 1.6+ to allow custom implementations
to support Java 1.5
 org.apache.webbeans.spi.LoaderService=org.apache.webbeans.service.DefaultLoaderService
 
-################################################################################################
+################################################################################################

 #################################### SEVERAL CONFIGURATION PARAMETERS ##########################
 ################################################################################################
 
@@ -95,7 +95,7 @@ org.apache.webbeans.spi.deployer.useEjbM
 
 ################################## OWB Specific Injection ######################################
 #If false, uses spec. defined injection with @Inject. Not recommended use as true.
-#It will be removed in future development.
+#It will be removed in future development. 
 org.apache.webbeans.fieldInjection.useOwbSpecificInjection=false
 ################################################################################################
 
@@ -152,10 +152,12 @@ org.apache.webbeans.generator.javaVersio
 
 ######################### Bean Scanning ########################################################
 # A list of known JARs/paths which should not be scanned for beans
+# if they don't have an explicit META-INF/beans.xml
 org.apache.webbeans.scanExclusionPaths=/jre/lib, \
         /Contents/Home/, \
         /dt.jar, \
         /tools.jar, \
+        /bootstrap.jar, \
         /asm, \
         /javassist, \
         /xbean-, \
@@ -218,3 +220,15 @@ org.apache.webbeans.scanExclusionPaths=/
         /jetty-, \
         /plexus-
 ################################################################################################
+
+
+######################### Bean Scanning ########################################################
+# A list of known classes which might contain final methods but should be proxyable nonetheless
+# Some of those classes are from the JDK and have been proxyable in older versions.
+# This setting can be overridden as jvm param via -Djavax.enterprise.inject.allowProxying.classes=...
+# or an environment key with the name JAVAX_ENTERPRISE_INJECT_ALLOWPROXYING_CLASSES=...
+javax.enterprise.inject.allowProxying.classes=\
+        java.util.HashMap, \
+        java.util.Calendar
+################################################################################################
+

Modified: openwebbeans/branches/cdi-2.0/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/BeanCacheKeyUnitTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/cdi-2.0/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/BeanCacheKeyUnitTest.java?rev=1728163&r1=1728162&r2=1728163&view=diff
==============================================================================
--- openwebbeans/branches/cdi-2.0/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/BeanCacheKeyUnitTest.java
(original)
+++ openwebbeans/branches/cdi-2.0/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/BeanCacheKeyUnitTest.java
Tue Feb  2 17:48:14 2016
@@ -175,7 +175,6 @@ public class BeanCacheKeyUnitTest
         BeanCacheKey a = new BeanCacheKey(true, String.class, null, a1);
         BeanCacheKey b = new BeanCacheKey(true, String.class, null, a2);
         Assert.assertFalse(a.equals(b));
-        Assert.assertFalse(a.hashCode() == b.hashCode());
     }
 
     @Test
@@ -230,7 +229,6 @@ public class BeanCacheKeyUnitTest
         BeanCacheKey a = new BeanCacheKey(true, String.class, null, a4);
         BeanCacheKey b = new BeanCacheKey(true, String.class, null, a5);
         Assert.assertFalse(a.equals(b));
-        Assert.assertFalse(a.hashCode() == b.hashCode());
     }
 
     @Test
@@ -257,7 +255,6 @@ public class BeanCacheKeyUnitTest
         BeanCacheKey a = new BeanCacheKey(true, String.class, null, a7);
         BeanCacheKey b = new BeanCacheKey(true, String.class, null, a8);
         Assert.assertFalse(a.equals(b));
-        Assert.assertFalse(a.hashCode() == b.hashCode());
     }
 
     @Test
@@ -266,7 +263,6 @@ public class BeanCacheKeyUnitTest
         BeanCacheKey a = new BeanCacheKey(true, String.class, null, a9);
         BeanCacheKey b = new BeanCacheKey(true, String.class, null, aa);
         Assert.assertFalse(a.equals(b));
-        Assert.assertFalse(a.hashCode() == b.hashCode());
     }
 
     @Test
@@ -275,7 +271,6 @@ public class BeanCacheKeyUnitTest
         BeanCacheKey a = new BeanCacheKey(true, String.class, null, ab);
         BeanCacheKey b = new BeanCacheKey(true, String.class, null, ac);
         Assert.assertFalse(a.equals(b));
-        Assert.assertFalse(a.hashCode() == b.hashCode());
     }
 
     @Test

Modified: openwebbeans/branches/cdi-2.0/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/BeanArchiveServiceTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/cdi-2.0/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/BeanArchiveServiceTest.java?rev=1728163&r1=1728162&r2=1728163&view=diff
==============================================================================
--- openwebbeans/branches/cdi-2.0/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/BeanArchiveServiceTest.java
(original)
+++ openwebbeans/branches/cdi-2.0/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/BeanArchiveServiceTest.java
Tue Feb  2 17:48:14 2016
@@ -131,6 +131,28 @@ public class BeanArchiveServiceTest
     }
 
     @Test
+    public void testCdi11_discovery_scoped() throws Exception
+    {
+        BeanArchiveInformation bai = scanBeansXml("cdi11_discovery_scoped.xml");
+        Assert.assertEquals(BeanDiscoveryMode.SCOPED, bai.getBeanDiscoveryMode());
+        Assert.assertTrue(bai.getAlternativeClasses().isEmpty());
+        Assert.assertTrue(bai.getAlternativeStereotypes().isEmpty());
+        Assert.assertTrue(bai.getDecorators().isEmpty());
+        Assert.assertTrue(bai.getInterceptors().isEmpty());
+    }
+
+    @Test
+    public void testCdi11_discovery_scopedBeansOnly() throws Exception
+    {
+        BeanArchiveInformation bai = scanBeansXml("cdi11_discovery_scopedBeansOnly.xml");
+        Assert.assertEquals(BeanDiscoveryMode.SCOPED, bai.getBeanDiscoveryMode());
+        Assert.assertTrue(bai.getAlternativeClasses().isEmpty());
+        Assert.assertTrue(bai.getAlternativeStereotypes().isEmpty());
+        Assert.assertTrue(bai.getDecorators().isEmpty());
+        Assert.assertTrue(bai.getInterceptors().isEmpty());
+    }
+
+    @Test
     public void testExclude() throws Exception
     {
         BeanArchiveInformation bai = scanBeansXml("cdi11_exclude.xml");

Modified: openwebbeans/branches/cdi-2.0/webbeans-jsf/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
URL: http://svn.apache.org/viewvc/openwebbeans/branches/cdi-2.0/webbeans-jsf/src/main/resources/META-INF/openwebbeans/openwebbeans.properties?rev=1728163&r1=1728162&r2=1728163&view=diff
==============================================================================
--- openwebbeans/branches/cdi-2.0/webbeans-jsf/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
(original)
+++ openwebbeans/branches/cdi-2.0/webbeans-jsf/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
Tue Feb  2 17:48:14 2016
@@ -25,8 +25,8 @@
 configuration.ordinal=12
 
 #################################### Conversation Context Removal Thread Delay##################
-#Converation contexts are removed when idle timeout > timeout. Default timeout is 30 mins.
-org.apache.webbeans.conversation.Conversation.periodicDelay=1800000
+#Converation contexts are removed when the conversation is not used for > timeout. Default
timeout is 30 mins.
+org.apache.webbeans.conversation.Conversation.timeoutInterval=1800000
 ################################################################################################
 
 ################################### Default Conversation Service ###############################


Modified: openwebbeans/branches/cdi-2.0/webbeans-jsf12/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
URL: http://svn.apache.org/viewvc/openwebbeans/branches/cdi-2.0/webbeans-jsf12/src/main/resources/META-INF/openwebbeans/openwebbeans.properties?rev=1728163&r1=1728162&r2=1728163&view=diff
==============================================================================
--- openwebbeans/branches/cdi-2.0/webbeans-jsf12/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
(original)
+++ openwebbeans/branches/cdi-2.0/webbeans-jsf12/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
Tue Feb  2 17:48:14 2016
@@ -26,8 +26,8 @@ configuration.ordinal= 12
 
 
 #################################### Conversation Context Removal Thread Delay##################
-#Converation contexts are removed when idle timeout > timeout. Default timeout is 30 mins.
-org.apache.webbeans.conversation.Conversation.periodicDelay=1800000
+#Converation contexts are removed when the conversation is not used for > timeout. Default
timeout is 30 mins.
+org.apache.webbeans.conversation.Conversation.timeoutInterval=1800000
 ################################################################################################
 
 ################################### Default Conversation Service ###############################


Modified: openwebbeans/branches/cdi-2.0/webbeans-spi/src/main/java/org/apache/webbeans/spi/ApplicationBoundaryService.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/cdi-2.0/webbeans-spi/src/main/java/org/apache/webbeans/spi/ApplicationBoundaryService.java?rev=1728163&r1=1728162&r2=1728163&view=diff
==============================================================================
--- openwebbeans/branches/cdi-2.0/webbeans-spi/src/main/java/org/apache/webbeans/spi/ApplicationBoundaryService.java
(original)
+++ openwebbeans/branches/cdi-2.0/webbeans-spi/src/main/java/org/apache/webbeans/spi/ApplicationBoundaryService.java
Tue Feb  2 17:48:14 2016
@@ -29,7 +29,8 @@ package org.apache.webbeans.spi;
 public interface ApplicationBoundaryService
 {
     /**
-     *
+     * Please note that the ApplicationClassLoader always have to 'see' the internal OWB
classes
+     * like BeanManagerImpl or the proxy marker interfaces (
      * @return The 'outermost' ClassLoader of that Application
      */
     ClassLoader getApplicationClassLoader();

Modified: openwebbeans/branches/cdi-2.0/webbeans-spi/src/main/java/org/apache/webbeans/spi/BeanArchiveService.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/cdi-2.0/webbeans-spi/src/main/java/org/apache/webbeans/spi/BeanArchiveService.java?rev=1728163&r1=1728162&r2=1728163&view=diff
==============================================================================
--- openwebbeans/branches/cdi-2.0/webbeans-spi/src/main/java/org/apache/webbeans/spi/BeanArchiveService.java
(original)
+++ openwebbeans/branches/cdi-2.0/webbeans-spi/src/main/java/org/apache/webbeans/spi/BeanArchiveService.java
Tue Feb  2 17:48:14 2016
@@ -48,6 +48,20 @@ public interface BeanArchiveService
         ALL(10),
 
         /**
+         * Pick up all classes (like with {@link #ALL} and fire the
+         * ProcessAnnotatedType event for them.
+         * But <b>only</b> pick up the scanned class as CDI bean:
+         * <ul>
+         * <li>if they have an explicit CDI scope annotation, or</li>
+         * <li>if they are an Interceptor or Decorator</li>
+         * <li>if they are a JavaEE managed bean</li>
+         * </ul>
+         * Contrary to the {@link #ALL} mode beans without any scope will
+         * <i>not</i> get picked up as &#064;Dependent scoped beans!
+         */
+        SCOPED(8),
+
+        /**
          * Only classes with a 'bean defining annotation' will get
          * picked up as CDI beans.
          * A 'bean defining annotation' is any CDI or atinject Scope annotation
@@ -154,6 +168,7 @@ public interface BeanArchiveService
 
         List<String> getExcludedClasses();
         List<String> getExcludedPackages();
+        List<String> getAllowProxyingClasses();
     }
 
 

Modified: openwebbeans/branches/cdi-2.0/webbeans-spi/src/main/java/org/apache/webbeans/spi/ScannerService.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/cdi-2.0/webbeans-spi/src/main/java/org/apache/webbeans/spi/ScannerService.java?rev=1728163&r1=1728162&r2=1728163&view=diff
==============================================================================
--- openwebbeans/branches/cdi-2.0/webbeans-spi/src/main/java/org/apache/webbeans/spi/ScannerService.java
(original)
+++ openwebbeans/branches/cdi-2.0/webbeans-spi/src/main/java/org/apache/webbeans/spi/ScannerService.java
Tue Feb  2 17:48:14 2016
@@ -68,7 +68,9 @@ public interface ScannerService
     
     /**
      * Gets beans classes that are found in the
-     * deployment archives. 
+     * deployment archives.
+     * Attention: if the ScannerService is a BdaScannerService then
+     * these classes will only get added to the 'default' BDA
      * @return bean classes
      */
     Set<Class<?>> getBeanClasses();




Mime
View raw message