You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by rm...@apache.org on 2014/12/22 18:25:20 UTC
svn commit: r1647355 - in
/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans:
config/BeansDeployer.java util/SpecializationUtil.java
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<AnnotatedType<?>, 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<AnnotatedType<?>> 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<AnnotatedType<?>> 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<AnnotatedType<?>> 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();
}
}