Return-Path: X-Original-To: apmail-openwebbeans-commits-archive@www.apache.org Delivered-To: apmail-openwebbeans-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0EF3110771 for ; Mon, 22 Dec 2014 17:25:21 +0000 (UTC) Received: (qmail 11525 invoked by uid 500); 22 Dec 2014 17:25:21 -0000 Delivered-To: apmail-openwebbeans-commits-archive@openwebbeans.apache.org Received: (qmail 11500 invoked by uid 500); 22 Dec 2014 17:25:21 -0000 Mailing-List: contact commits-help@openwebbeans.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openwebbeans.apache.org Delivered-To: mailing list commits@openwebbeans.apache.org Received: (qmail 11488 invoked by uid 99); 22 Dec 2014 17:25:20 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Dec 2014 17:25:20 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id CCF02AC094D; Mon, 22 Dec 2014 17:25:20 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1647355 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: config/BeansDeployer.java util/SpecializationUtil.java Date: Mon, 22 Dec 2014 17:25:20 -0000 To: commits@openwebbeans.apache.org From: rmannibucau@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20141222172520.CCF02AC094D@hades.apache.org> Author: rmannibucau Date: Mon Dec 22 17:25:20 2014 New Revision: 1647355 URL: http://svn.apache.org/r1647355 Log: no ProcessBeanAttribute for specialized beans Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SpecializationUtil.java Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java?rev=1647355&r1=1647354&r2=1647355&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java Mon Dec 22 17:25:20 2014 @@ -233,6 +233,10 @@ public class BeansDeployer addAdditionalAnnotatedTypes(fireAfterTypeDiscoveryEvent(), annotatedTypes); + SpecializationUtil specializationUtil = new SpecializationUtil(webBeansContext); + + specializationUtil.removeDisabledTypes(annotatedTypes, true); + Map, AnnotatedTypeData> annotatedTypePreProcessing = getBeanAttributes(annotatedTypes); annotatedTypes.clear(); // shouldn't be used anymore, view is now annotatedTypePreProcessing @@ -243,7 +247,7 @@ public class BeansDeployer checkStereoTypes(scanner); // Handle Specialization - removeSpecializedTypes(annotatedTypePreProcessing.keySet()); + specializationUtil.removeDisabledTypes(annotatedTypePreProcessing.keySet(), false); // create beans from the discovered AnnotatedTypes deployFromAnnotatedTypes(annotatedTypePreProcessing); @@ -1326,36 +1330,6 @@ public class BeansDeployer return "WebBeans configuration defined in " + bdaLocation.toExternalForm() + " did fail. Reason is : "; } - /** - * Checks specialization on classes and remove any AnnotatedType which got 'disabled' by having a sub-class with @Specializes. - * @param annotatedTypes the annotatedTypes which got picked up during scanning. All 'disabled' annotatedTypes will be removed. - */ - private void removeSpecializedTypes(Collection> annotatedTypes) - { - logger.fine("Checking Specialization constraints has started."); - - try - { - SpecializationUtil specializationUtil = new SpecializationUtil(webBeansContext); - specializationUtil.removeDisabledTypes(annotatedTypes); - } - catch (DefinitionException e) - { - throw e; - } - catch (DeploymentException e) - { - throw e; - } - catch (Exception e) - { - throw new WebBeansDeploymentException(e); - } - - - logger.fine("Checking Specialization constraints has ended."); - } - /** * Check passivations. Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SpecializationUtil.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SpecializationUtil.java?rev=1647355&r1=1647354&r2=1647355&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SpecializationUtil.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SpecializationUtil.java Mon Dec 22 17:25:20 2014 @@ -46,20 +46,22 @@ import org.apache.webbeans.logger.WebBea */ public class SpecializationUtil { - private final WebBeansContext webBeansContext; private final AlternativesManager alternativesManager; private final WebBeansUtil webBeansUtil; public SpecializationUtil(WebBeansContext webBeansContext) { - this.webBeansContext = webBeansContext; this.alternativesManager = webBeansContext.getAlternativesManager(); this.webBeansUtil = webBeansContext.getWebBeansUtil(); } - - public void removeDisabledTypes(Collection> annotatedTypes) + /** + * + * @param annotatedTypes all annotatypes + * @param notSpecializationOnly first pass/2nd pass. First one removes only root beans, second one handles inheritance even in @Spe + */ + public void removeDisabledTypes(Collection> annotatedTypes, boolean notSpecializationOnly) { if (annotatedTypes != null && !annotatedTypes.isEmpty()) { @@ -96,22 +98,29 @@ public class SpecializationUtil } AnnotatedType superType = getAnnotatedTypeForClass(annotatedTypes, superClass); - - if (superType == null || !webBeansUtil.isConstructorOk(superType)) - { - throw new WebBeansDeploymentException(new InconsistentSpecializationException("@Specializes class " + specialClass.getName() - + " does not extend a bean with a valid bean constructor")); - } - - try - { - webBeansUtil.checkManagedBean(specialClass); - } - catch (WebBeansConfigurationException illegalBeanTypeException) + if (notSpecializationOnly) { - // this Exception gets thrown if the given class is not a valid bean type - throw new WebBeansDeploymentException(new InconsistentSpecializationException("@Specializes class " + specialClass.getName() - + " does not extend a valid bean type", illegalBeanTypeException)); + if (superType != null && superType.getAnnotation(Specializes.class) != null) + { + continue; + } + + if (superType == null || !webBeansUtil.isConstructorOk(superType)) + { + throw new WebBeansDeploymentException(new InconsistentSpecializationException("@Specializes class " + specialClass.getName() + + " does not extend a bean with a valid bean constructor")); + } + + try + { + webBeansUtil.checkManagedBean(specialClass); + } + catch (WebBeansConfigurationException illegalBeanTypeException) + { + // this Exception gets thrown if the given class is not a valid bean type + throw new WebBeansDeploymentException(new InconsistentSpecializationException("@Specializes class " + specialClass.getName() + + " does not extend a valid bean type", illegalBeanTypeException)); + } } superClassList.add(superClass); @@ -204,6 +213,6 @@ public class SpecializationUtil return annotationClasses; } - return Collections.EMPTY_SET; + return Collections.emptySet(); } }