Author: struberg
Date: Wed Jun 4 07:49:55 2014
New Revision: 1599956
URL: http://svn.apache.org/r1599956
Log:
OWB-958 improve @Specializes handling
* we now do sort out 'disabled' beans already before the beans get scanned.
* that way we can signifficantly easy the BeanManager#resolve() code
Added:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SpecializationUtil.java
(with props)
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/disposes/StaticProducerTest.java
Modified:
openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianScannerService.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/logger/ISomeLogger.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/logger/SystemLogger.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/disposes/beans/AppScopedBean.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/specializes/logger/LoggerSpecializationTest.java
openwebbeans/trunk/webbeans-tck/standalone-suite.xml
Modified:
openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianScannerService.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianScannerService.java?rev=1599956&r1=1599955&r2=1599956&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianScannerService.java
(original)
+++
openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianScannerService.java
Wed Jun 4 07:49:55 2014
@@ -48,7 +48,7 @@ public class OwbArquillianScannerService
private final static String WEB_INF_CLASS_FOLDER = "/WEB-INF/classes/";
- private boolean beansXmlBdaScanningEnabled;
+ private final boolean beansXmlBdaScanningEnabled;
private Archive archive;
private UrlSet beansXmls = new UrlSet();
@@ -82,6 +82,7 @@ public class OwbArquillianScannerService
{
if (archive == null)
{
+ this.archive = null;
return;
}
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java?rev=1599956&r1=1599955&r2=1599956&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java
Wed Jun 4 07:49:55 2014
@@ -437,7 +437,10 @@ public abstract class BeanAttributesBuil
this.name = name;
}
}
-
+
+ /**
+ * @return the AnnotatedType of the next non-Specialized superclass
+ */
protected abstract Annotated getSuperAnnotated();
protected abstract void defineNullable();
@@ -517,15 +520,21 @@ public abstract class BeanAttributesBuil
{
if (getAnnotated().isAnnotationPresent(Specializes.class))
{
- Class<? super C> classToSpecialize =
getAnnotated().getJavaClass().getSuperclass();
+ AnnotatedType<? super C> annotatedToSpecialize =
getAnnotated();
- while
(classToSpecialize.isAnnotationPresent(Specializes.class))
+ do
{
- classToSpecialize = classToSpecialize.getSuperclass();
- }
+ Class<? super C> superclass =
annotatedToSpecialize.getJavaClass().getSuperclass();
+ if (superclass.equals(Object.class))
+ {
+ throw new DefinitionException("@Specialized Class : "
+ getAnnotated().getJavaClass().getName()
+ + " must not directly extend Object.class");
+ }
+ annotatedToSpecialize =
webBeansContext.getAnnotatedElementFactory().newAnnotatedType(superclass);
+ } while(annotatedToSpecialize.getAnnotation(Specializes.class)
!= null);
+
- AnnotatedType<? super C> annotatedToSpecialize =
webBeansContext.getAnnotatedElementFactory().newAnnotatedType(classToSpecialize);
- defineName(annotatedToSpecialize,
WebBeansUtil.getManagedBeanDefaultName(classToSpecialize.getSimpleName()));
+ defineName(annotatedToSpecialize,
WebBeansUtil.getManagedBeanDefaultName(annotatedToSpecialize.getJavaClass().getSimpleName()));
}
if (name == null)
{
@@ -551,12 +560,19 @@ public abstract class BeanAttributesBuil
@Override
protected AnnotatedType<? super C> getSuperAnnotated()
{
- Class<? super C> superclass =
getAnnotated().getJavaClass().getSuperclass();
- if (superclass == null)
+ AnnotatedType<? super C> annotatedType = getAnnotated();
+ do
{
- return null;
- }
- return
webBeansContext.getAnnotatedElementFactory().newAnnotatedType(superclass);
+ Class<? super C> superclass =
annotatedType.getJavaClass().getSuperclass();
+ if (superclass == null || superclass.equals(Object.class))
+ {
+ return null;
+ }
+ annotatedType =
webBeansContext.getAnnotatedElementFactory().newAnnotatedType(superclass);
+
+ } while (annotatedType.getAnnotation(Specializes.class) != null);
+
+ return annotatedType;
}
}
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=1599956&r1=1599955&r2=1599956&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
Wed Jun 4 07:49:55 2014
@@ -51,7 +51,6 @@ import javax.annotation.Priority;
import javax.enterprise.inject.Alternative;
import javax.enterprise.inject.spi.DefinitionException;
import javax.enterprise.inject.spi.DeploymentException;
-import
org.apache.webbeans.exception.inject.InconsistentSpecializationException;
import org.apache.webbeans.inject.AlternativesManager;
import org.apache.webbeans.intercept.InterceptorsManager;
import org.apache.webbeans.logger.WebBeansLoggerFacade;
@@ -74,13 +73,12 @@ import org.apache.webbeans.util.Annotati
import org.apache.webbeans.util.ClassUtil;
import org.apache.webbeans.util.ExceptionUtil;
import org.apache.webbeans.util.InjectionExceptionUtil;
+import org.apache.webbeans.util.SpecializationUtil;
import org.apache.webbeans.util.WebBeansConstants;
import org.apache.webbeans.util.WebBeansUtil;
-import javax.enterprise.context.NormalScope;
import javax.enterprise.inject.AmbiguousResolutionException;
import javax.enterprise.inject.Model;
-import javax.enterprise.inject.Specializes;
import javax.enterprise.inject.UnproxyableResolutionException;
import javax.enterprise.inject.UnsatisfiedResolutionException;
import javax.enterprise.inject.spi.AnnotatedField;
@@ -207,22 +205,26 @@ public class BeansDeployer
fireAfterTypeDiscoveryEvent();
+ // Handle Specialization
+ removeSpecializedTypes(annotatedTypes);
+
// create beans from the discovered AnnotatedTypes
deployFromAnnotatedTypes(annotatedTypes);
-
- //Check Specialization
- processSpecializations(scanner);
+ //X TODO configure specialized producer beans.
+
webBeansContext.getWebBeansUtil().configureProducerMethodSpecializations();
+
+ // all beans which got 'overridden' by a Specialized version
can be removed now
removeDisabledBeans();
- //Fire Event
+ // We are finally done with our bean discovery
fireAfterBeanDiscoveryEvent();
- //Validate injection Points
+ // Validate injection Points
validateInjectionPoints();
- //Fire Event
+ // fire event
fireAfterDeploymentValidationEvent();
@@ -794,12 +796,8 @@ public class BeansDeployer
final WebBeansUtil webBeansUtil = webBeansContext.getWebBeansUtil();
// done separately to be able to swallow the logging when not relevant
and avoid to pollute logs
- if (!webBeansUtil.isConstructorOk(beanClass))
+ if (!webBeansUtil.isConstructorOk(type))
{
- if (isNormalScoped(type))
- {
- logger.info("Bean implementation class : " +
beanClass.getName() + " must define at least one Constructor");
- } // else not an issue
return false;
}
@@ -818,24 +816,6 @@ public class BeansDeployer
return true;
}
- private static boolean isNormalScoped(final AnnotatedType<?> type)
- {
- final Set<Annotation> annotations = type.getAnnotations();
- if (annotations != null)
- {
- for (final Annotation a : annotations)
- {
- if
(AnnotationUtil.hasMetaAnnotation(a.annotationType().getAnnotations(),
NormalScope.class)
- ||
AnnotationUtil.hasAnnotation(a.annotationType().getAnnotations(),
NormalScope.class))
- {
- return true;
- }
- }
- }
-
- return false;
- }
-
/**
* Discovers and deploys alternatives, interceptors and decorators from
XML.
*
@@ -1015,52 +995,17 @@ public class BeansDeployer
}
/**
- * TODO this has to be changed to use AnnotatedTypes instead of
scanner.getBeanClasses()!
- * Checks specialization.
- * @param scanner scanner instance
+ * 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.
*/
- protected void processSpecializations(ScannerService scanner)
+ private void removeSpecializedTypes(List<AnnotatedType<?>> annotatedTypes)
{
logger.fine("Checking Specialization constraints has started.");
try
{
- Set<Class<?>> beanClasses = scanner.getBeanClasses();
- if (beanClasses != null && beanClasses.size() > 0)
- {
- //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
- //specialize Car.
- Class<?> superClass;
- ArrayList<Class<?>> superClassList = new ArrayList<Class<?>>();
- ArrayList<Class<?>> specialClassList = new
ArrayList<Class<?>>();
- for(Class<?> specialClass : beanClasses)
- {
- if(AnnotationUtil.hasClassAnnotation(specialClass,
Specializes.class))
- {
- superClass = specialClass.getSuperclass();
- if(superClass.equals(Object.class))
- {
- throw new
WebBeansConfigurationException(WebBeansLoggerFacade.getTokenString(OWBLogConst.EXCEPT_0003)
+ specialClass.getName()
- +
WebBeansLoggerFacade.getTokenString(OWBLogConst.EXCEPT_0004));
- }
- if (superClassList.contains(superClass))
- {
- // since CDI 1.1 we have to wrap this in a
DeploymentException
- InconsistentSpecializationException exception
- = new
InconsistentSpecializationException(WebBeansLoggerFacade.getTokenString(OWBLogConst.EXCEPT_0005)
+ superClass.getName());
- throw new WebBeansDeploymentException(exception);
- }
- superClassList.add(superClass);
- specialClassList.add(specialClass);
- }
- }
-
webBeansContext.getWebBeansUtil().configureSpecializations(specialClassList);
- }
-
-
- //configure specialized producer beans.
-
webBeansContext.getWebBeansUtil().configureProducerMethodSpecializations();
+ SpecializationUtil specializationUtil = new
SpecializationUtil(webBeansContext);
+ specializationUtil.removeDisabledTypes(annotatedTypes);
}
catch (DefinitionException e)
{
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java?rev=1599956&r1=1599955&r2=1599956&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
Wed Jun 4 07:49:55 2014
@@ -25,7 +25,6 @@ import java.lang.reflect.ParameterizedTy
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -86,42 +85,6 @@ public final class NotificationManager
addObserver(observer, typeLiteral.getType());
}
- /**
- * <p>This method shall only be called for subclasses.
- * It will disable all observer methods which are overridden
- * in the given subclass.</p>
- */
- public void disableOverriddenObservers(Class<?> subClass)
- {
- for (Set<ObserverMethod<?>> observerMethods: observers.values())
- {
- for (Iterator<ObserverMethod<?>> i = observerMethods.iterator();
i.hasNext();)
- {
- ObserverMethod<?> observer = i.next();
- if (observer instanceof ObserverMethodImpl)
- {
- AnnotatedMethod<?> observerMethod =
((ObserverMethodImpl<?>)observer).getObserverMethod();
-
- //needs to be a subtype and not the class itself
(otherwise all observer-methods get removed)
- if
(subClass.isAssignableFrom(observerMethod.getJavaMember().getDeclaringClass())
&&
-
!subClass.equals(observerMethod.getJavaMember().getDeclaringClass()))
- {
- try
- {
-
subClass.getMethod(observerMethod.getJavaMember().getName(),
observerMethod.getJavaMember().getParameterTypes());
- i.remove();
- }
- catch(NoSuchMethodException nsme)
- {
- // that's perfectly fine.
- // it means that we don't need to remove anything
because the
- // observer method didn't get overridden.
- }
- }
- }
- }
- }
- }
public <T> Set<ObserverMethod<? super T>> resolveObservers(T event,
EventMetadata metadata)
{
Added:
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=1599956&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SpecializationUtil.java
(added)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SpecializationUtil.java
Wed Jun 4 07:49:55 2014
@@ -0,0 +1,208 @@
+/*
+ * 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.webbeans.util;
+
+import javax.enterprise.inject.Alternative;
+import javax.enterprise.inject.Specializes;
+import javax.enterprise.inject.Typed;
+import javax.enterprise.inject.spi.AnnotatedType;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.webbeans.config.OWBLogConst;
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.exception.WebBeansDeploymentException;
+import
org.apache.webbeans.exception.inject.InconsistentSpecializationException;
+import org.apache.webbeans.inject.AlternativesManager;
+import org.apache.webbeans.logger.WebBeansLoggerFacade;
+
+/**
+ * This class contains a few helpers for handling
+ * @Specializes.
+ */
+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(List<AnnotatedType<?>> annotatedTypes)
+ {
+ if (annotatedTypes != null && !annotatedTypes.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
+ // specialize Car.
+ // see spec section 5.1.3
+ Set<Class<?>> superClassList = new HashSet<Class<?>>();
+
+ // first let's find all superclasses of Specialized types
+ Set<Class<?>> disabledClasses = new HashSet<Class<?>>();
+ for(AnnotatedType<?> annotatedType : annotatedTypes)
+ {
+ if(annotatedType.getAnnotation(Specializes.class) != null &&
isEnabled(annotatedType))
+ {
+ Class<?> specialClass = annotatedType.getJavaClass();
+ Class<?> superClass = specialClass.getSuperclass();
+
+ if(superClass.equals(Object.class))
+ {
+ throw new WebBeansDeploymentException(new
WebBeansConfigurationException(WebBeansLoggerFacade.getTokenString(OWBLogConst.EXCEPT_0003)
+ + specialClass.getName() +
WebBeansLoggerFacade.getTokenString(OWBLogConst.EXCEPT_0004)));
+ }
+ if (superClassList.contains(superClass))
+ {
+ // since CDI 1.1 we have to wrap this in a
DeploymentException
+ throw new WebBeansDeploymentException(new
InconsistentSpecializationException(WebBeansLoggerFacade.getTokenString(OWBLogConst.EXCEPT_0005)
+
+
superClass.getName()));
+ }
+ if (!containsAllSuperclassTypes(annotatedType, superClass,
annotatedTypes))
+ {
+ throw new WebBeansDeploymentException(new
InconsistentSpecializationException("@Specialized Class : " +
specialClass.getName()
+ + "
must have all bean types of its super class"));
+ }
+
+ AnnotatedType<?> superType =
getAnnotatedTypeForClass(annotatedTypes, superClass);
+
+ if (!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);
+
+ while (!superClass.equals(Object.class))
+ {
+ disabledClasses.add(superClass);
+ superClass = superClass.getSuperclass();
+ }
+ }
+ }
+
+ // and now remove all AnnotatedTypes of those collected
disabledClasses
+ if (!disabledClasses.isEmpty())
+ {
+ Iterator<AnnotatedType<?>> annotatedTypeIterator =
annotatedTypes.iterator();
+ while (annotatedTypeIterator.hasNext())
+ {
+ AnnotatedType<?> annotatedType =
annotatedTypeIterator.next();
+ if (disabledClasses.contains(annotatedType.getJavaClass()))
+ {
+ annotatedTypeIterator.remove();
+ }
+ }
+ }
+ }
+ }
+
+ private boolean containsAllSuperclassTypes(AnnotatedType<?> annotatedType,
Class<?> superClass, List<AnnotatedType<?>> annotatedTypes)
+ {
+ Typed typed = annotatedType.getAnnotation(Typed.class);
+ if (typed != null)
+ {
+ List<Class<?>> typeList = Arrays.asList(typed.value());
+ AnnotatedType<?> superType =
getAnnotatedTypeForClass(annotatedTypes, superClass);
+ if (superType != null)
+ {
+ Typed superClassTyped = superType.getAnnotation(Typed.class);
+ Set<Type> superClassTypes;
+ if (superClassTyped != null)
+ {
+ superClassTypes = new
HashSet<Type>(Arrays.asList(superClassTyped.value()));
+ }
+ else
+ {
+ superClassTypes = superType.getTypeClosure();
+
+ // we can ignore Object.class in this case
+ superClassTypes.remove(Object.class);
+ }
+
+ return typeList.containsAll(superClassTypes);
+ }
+ }
+ return true;
+ }
+
+ private AnnotatedType<?> getAnnotatedTypeForClass(List<AnnotatedType<?>>
annotatedTypes, Class<?> clazz)
+ {
+ for (AnnotatedType<?> annotatedType : annotatedTypes)
+ {
+ if (annotatedType.getJavaClass().equals(clazz))
+ {
+ return annotatedType;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @return false if the AnnotatedType is for a not enabled Alternative
+ */
+ private boolean isEnabled(AnnotatedType<?> annotatedType)
+ {
+ return annotatedType.getAnnotation(Alternative.class) == null ||
+
alternativesManager.isAlternative(annotatedType.getJavaClass(),
getAnnotationClasses(annotatedType));
+ }
+
+ private Set<Class<? extends Annotation>>
getAnnotationClasses(AnnotatedType<?> annotatedType)
+ {
+ Set<Annotation> annotations = annotatedType.getAnnotations();
+ if (annotations != null && !annotations.isEmpty())
+ {
+ Set<Class<? extends Annotation>> annotationClasses = new
HashSet<Class<? extends Annotation>>(annotations.size());
+ for (Annotation annotation : annotations)
+ {
+ annotationClasses.add(annotation.annotationType());
+ }
+
+ return annotationClasses;
+ }
+ return Collections.EMPTY_SET;
+ }
+}
Propchange:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SpecializationUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=1599956&r1=1599955&r2=1599956&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Wed Jun 4 07:49:55 2014
@@ -37,7 +37,6 @@ import org.apache.webbeans.component.Ins
import org.apache.webbeans.component.InterceptedOrDecoratedBeanMetadataBean;
import org.apache.webbeans.component.InterceptorMetadataBean;
import org.apache.webbeans.component.ManagedBean;
-import org.apache.webbeans.component.NewBean;
import org.apache.webbeans.component.NewManagedBean;
import org.apache.webbeans.component.OwbBean;
import org.apache.webbeans.component.ProducerFieldBean;
@@ -52,18 +51,16 @@ import org.apache.webbeans.component.cre
import org.apache.webbeans.component.creation.ProducerMethodBeansBuilder;
import org.apache.webbeans.config.WebBeansContext;
import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.container.ExternalScope;
import org.apache.webbeans.container.InjectionResolver;
import org.apache.webbeans.exception.WebBeansConfigurationException;
-import org.apache.webbeans.exception.WebBeansDeploymentException;
-import javax.enterprise.inject.spi.DefinitionException;
-import
org.apache.webbeans.exception.inject.InconsistentSpecializationException;
import org.apache.webbeans.inject.AlternativesManager;
+import org.apache.webbeans.logger.WebBeansLoggerFacade;
import org.apache.webbeans.plugins.PluginLoader;
import org.apache.webbeans.portable.AbstractProducer;
import org.apache.webbeans.portable.InjectionTargetImpl;
-import org.apache.webbeans.portable.ProducerMethodProducer;
import org.apache.webbeans.portable.events.discovery.ErrorStack;
import org.apache.webbeans.portable.events.generics.GProcessAnnotatedType;
import org.apache.webbeans.portable.events.generics.GProcessBean;
@@ -79,35 +76,13 @@ import org.apache.webbeans.spi.plugins.O
import javax.decorator.Decorator;
import javax.enterprise.context.Dependent;
+import javax.enterprise.context.NormalScope;
import javax.enterprise.context.spi.Contextual;
import javax.enterprise.inject.Alternative;
import javax.enterprise.inject.IllegalProductException;
import javax.enterprise.inject.Instance;
import javax.enterprise.inject.Specializes;
-import javax.enterprise.inject.spi.AfterBeanDiscovery;
-import javax.enterprise.inject.spi.AfterDeploymentValidation;
-import javax.enterprise.inject.spi.AnnotatedField;
-import javax.enterprise.inject.spi.AnnotatedMember;
-import javax.enterprise.inject.spi.AnnotatedMethod;
-import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.BeforeBeanDiscovery;
-import javax.enterprise.inject.spi.BeforeShutdown;
-import javax.enterprise.inject.spi.Extension;
-import javax.enterprise.inject.spi.InjectionPoint;
-import javax.enterprise.inject.spi.ObserverMethod;
-import javax.enterprise.inject.spi.PassivationCapable;
-import javax.enterprise.inject.spi.ProcessAnnotatedType;
-import javax.enterprise.inject.spi.ProcessBean;
-import javax.enterprise.inject.spi.ProcessInjectionTarget;
-import javax.enterprise.inject.spi.ProcessManagedBean;
-import javax.enterprise.inject.spi.ProcessObserverMethod;
-import javax.enterprise.inject.spi.ProcessProducer;
-import javax.enterprise.inject.spi.ProcessProducerField;
-import javax.enterprise.inject.spi.ProcessProducerMethod;
-import javax.enterprise.inject.spi.ProcessSessionBean;
-import javax.enterprise.inject.spi.Producer;
+import javax.enterprise.inject.spi.*;
import javax.inject.Inject;
import javax.inject.Named;
@@ -125,12 +100,11 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.EnumSet;
-import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.logging.Logger;
/**
* Contains some utility methods used in the all project.
@@ -138,6 +112,8 @@ import java.util.Set;
@SuppressWarnings("unchecked")
public final class WebBeansUtil
{
+ private static final Logger logger =
WebBeansLoggerFacade.getLogger(WebBeansUtil.class);
+
private final WebBeansContext webBeansContext;
public WebBeansUtil(WebBeansContext webBeansContext)
@@ -189,7 +165,7 @@ public final class WebBeansUtil
{
Asserts.assertNotNull(bean,"Bean is null");
- Type type = null;
+ Type type;
if(bean instanceof ProducerMethodBean)
{
@@ -362,32 +338,64 @@ public final class WebBeansUtil
/**
* Check that simple web beans class has compatible constructor.
- * @param clazz web beans simple class
+ * @param annotatedType web beans annotatedType
* @throws WebBeansConfigurationException if the web beans has incompatible
* constructor
*/
- public boolean isConstructorOk(Class<?> clazz) throws
WebBeansConfigurationException
+ public boolean isConstructorOk(AnnotatedType<?> annotatedType) throws
WebBeansConfigurationException
{
- Asserts.nullCheckForClass(clazz);
+ Class<?> clazz = annotatedType.getJavaClass();
if (getNoArgConstructor(clazz) != null)
{
+ // if we have a default ct, then all is fine in any case
return true;
}
- Constructor<?>[] constructors =
webBeansContext.getSecurityService().doPrivilegedGetDeclaredConstructors(clazz);
+ if (isNormalScoped(annotatedType))
+ {
+ logger.info("Bean implementation class : " + clazz.getName() + "
must define at least one Constructor");
+ return false;
+ } // else not an issue
- for (Constructor<?> constructor : constructors)
+ Set<? extends AnnotatedConstructor<?>> constructors =
annotatedType.getConstructors();
+ for (AnnotatedConstructor<?> constructor : constructors)
{
if (constructor.getAnnotation(Inject.class) != null)
{
return true;
}
}
+ return false;
+ }
+
+ private boolean isNormalScoped(final AnnotatedType<?> type)
+ {
+ final Set<Annotation> annotations = type.getAnnotations();
+ BeanManagerImpl beanManager = webBeansContext.getBeanManagerImpl();
+ if (annotations != null)
+ {
+ for (final Annotation a : annotations)
+ {
+ if
(AnnotationUtil.hasMetaAnnotation(a.annotationType().getAnnotations(),
NormalScope.class)
+ ||
AnnotationUtil.hasAnnotation(a.annotationType().getAnnotations(),
NormalScope.class))
+ {
+ return true;
+ }
+ for (ExternalScope externalScope :
beanManager.getAdditionalScopes())
+ {
+ if (externalScope.isNormal() &&
externalScope.getScope().equals(a))
+ {
+ return true;
+ }
+ }
+ }
+ }
return false;
}
+
public <T> Bean<T> createNewComponent(Class<T> type)
{
Asserts.nullCheckForClass(type);
@@ -585,249 +593,6 @@ public final class WebBeansUtil
}
}
- /**
- * Return true if a list of beans are directly specialized/extended each
other.
- *
- * @param beans, a set of specialized beans.
- *
- * @return
- */
- protected static boolean isDirectlySpecializedBeanSet(Set<Bean<?>> beans)
- {
-
- ArrayList<AbstractOwbBean<?>> beanList = new
ArrayList<AbstractOwbBean<?>>();
-
- for(Bean<?> bb : beans)
- {
- AbstractOwbBean<?>bean = (AbstractOwbBean<?>)bb;
- beanList.add(bean);
- }
-
- java.util.Collections.sort(beanList, new java.util.Comparator()
- {
- @Override
- public int compare(Object o1, Object o2)
- {
- AbstractOwbBean<?> b1 = (AbstractOwbBean<?>)o1;
- AbstractOwbBean<?> b2 = (AbstractOwbBean<?>)o2;
- Class c1 = b1.getReturnType();
- Class c2 = b2.getReturnType();
- if (c2.isAssignableFrom(c1))
- {
- return 1;
- }
-
- if (c1.isAssignableFrom(c2))
- {
- return -1;
- }
-
- throw new InconsistentSpecializationException(c1 + " and " +
c2 + "are not assignable to each other." );
- }
- });
-
- for(int i=0; i<beanList.size() - 1; i++)
- {
- if
(!beanList.get(i).getReturnType().equals(beanList.get(i+1).getReturnType().getSuperclass()))
- {
- return false;
- }
- }
- return true;
- }
-
- public void configureSpecializations(List<Class<?>> beanClasses)
- {
- for(Class<?> clazz : beanClasses)
- {
- configureSpecializations(clazz, beanClasses);
- }
- }
-
- /**
- * Configures the bean specializations.
- * <p>
- * Specialized beans inherit the <code>name</code> property
- * from their parents. Specialized bean deployment priority
- * must be higher than its super class related bean.
- * </p>
- *
- * <p>from the spec:<br/>
- * "If Y has a name and X declares a name explicitly, using @Named,
- * the container automatically detects the problem and treats it as a
definition error.</p>
- *
- * @param specializedClass specialized class
- * @param beanClasses all Classes which are either @Specializes or
specialized.
- * @throws DefinitionException if name is defined
- * @throws InconsistentSpecializationException related with priority
- * @throws WebBeansConfigurationException any other exception
- *
- * TODO: this method needs to get changed to use AnnotatedTypes
- */
- protected void configureSpecializations(Class<?> specializedClass,
List<Class<?>> beanClasses)
- {
- Asserts.nullCheckForClass(specializedClass);
-
- Bean<?> superBean = null;
- Bean<?> specialized;
- Set<Bean<?>> resolvers = isConfiguredWebBeans(specializedClass, true);
- AlternativesManager altManager =
webBeansContext.getAlternativesManager();
-
- if (resolvers != null && !resolvers.isEmpty())
- {
- specialized = resolvers.iterator().next();
-
- if(resolvers.size() > 1)
- {
- if (!isDirectlySpecializedBeanSet(resolvers))
- {
- throw new InconsistentSpecializationException("More than
one specialized bean for class : "
- + specializedClass + " is enabled in the
deployment.");
- }
- // find the widest bean which satisfies the specializedClass
- for( Bean<?> sp : resolvers)
- {
- if (sp == specialized)
- {
- continue;
- }
-
- if (sp.getTypes().size() > specialized.getTypes().size()
&& sp.getTypes().containsAll(specialized.getTypes()))
- {
- specialized = sp;
- }
- }
- }
-
- Class<?> superClass = specializedClass.getSuperclass();
-
- resolvers = isConfiguredWebBeans(superClass,false);
-
- for(Bean<?> candidates : resolvers)
- {
- AbstractOwbBean<?> candidate = (AbstractOwbBean<?>)candidates;
-
- if(!(candidate instanceof NewBean))
- {
- if(candidate.getReturnType().equals(superClass))
- {
- superBean = candidates;
- break;
- }
- }
- }
-
- if (superBean != null)
- {
- for (Class<?> beanClass: beanClasses)
- {
- if (beanClass.equals(specializedClass))
- {
- continue;
- }
- if (beanClass.getSuperclass().equals(superClass))
- {
- InconsistentSpecializationException exception = new
InconsistentSpecializationException(superClass.getName()
- + " is @Specialized by two classes: " +
beanClass.getName() + " and " + specializedClass.getName());
- throw new WebBeansDeploymentException(exception);
- }
- }
- if (!specialized.getTypes().containsAll(superBean.getTypes()))
- {
- throw new DefinitionException("@Specialized Class : " +
specializedClass.getName()
- + " must have all bean types of its super class");
- }
-
webBeansContext.getBeanManagerImpl().getNotificationManager().disableOverriddenObservers(specializedClass);
-
- // Recursively configure super class first if super class is
also a special bean.
- // So the name and bean meta data could be populated to this
beanclass.
- if (beanClasses.contains(superClass) &&
((AbstractOwbBean<?>)superBean).isEnabled())
- {
- configureSpecializations(superClass, beanClasses);
- }
-
- if (!AnnotationUtil.hasClassAnnotation(specializedClass,
Alternative.class))
- {
- //disable superbean if the current bean is not an
alternative
- ((AbstractOwbBean<?>)superBean).setEnabled(false);
- }
- else if(altManager.isAlternative(specialized))
- {
- //disable superbean if the current bean is an enabled
alternative
- ((AbstractOwbBean<?>)superBean).setEnabled(false);
- }
-
- AbstractOwbBean<?> comp = (AbstractOwbBean<?>)specialized;
- if (comp.isSpecializedBean())
- {
- // This comp is already configured in previous invocation
- // return directly, else Exception might be fired when set
- // bean name again.
- return;
- }
-
- //Check types of the beans
- if(comp.getClass() != superBean.getClass())
- {
- throw new
InconsistentSpecializationException("@Specialized Class : " +
specializedClass.getName()
- + " and its super class may be the same type of
bean,i.e, ManagedBean, SessionBean etc.");
- }
-
- if(superBean.getName() != null)
- {
- if (!superBean.getName().equals(comp.getName()))
- {
- throw new
InconsistentSpecializationException("@Specialized Class : " +
specializedClass.getName()
- + " may not explicitly declare a bean name");
- }
-
- }
- comp.setSpecializedBean(true);
-
- final Map<Class<?>, ProducerMethodBean<?>> parentProducers =
new HashMap<Class<?>, ProducerMethodBean<?>>();
- final Map<Class<?>, ProducerMethodBean<?>> beanProducers = new
HashMap<Class<?>, ProducerMethodBean<?>>();
- for (Bean<?> bean:
webBeansContext.getBeanManagerImpl().getComponents())
- {
- if (bean instanceof ProducerMethodBean)
- {
- final ProducerMethodBean<?> producerBean =
(ProducerMethodBean<?>)bean;
- final Class<?> returnType =
producerBean.getReturnType();
- if (producerBean.getBeanClass() ==
superBean.getBeanClass() && producerBean.getProducer() instanceof
ProducerMethodProducer)
- {
- final ProducerMethodProducer<?, ?> producer =
(ProducerMethodProducer<?, ?>) producerBean.getProducer();
- producer.specializeBy((Bean) comp);
-
- if (beanProducers.keySet().contains(returnType))
- {
-
beanProducers.get(returnType).setSpecializedBean(true);
- }
- else
- {
- parentProducers.put(returnType, producerBean);
- }
- }
- else if (specializedClass == bean.getBeanClass())
- {
- if (parentProducers.keySet().contains(returnType))
- {
- producerBean.setSpecializedBean(true);
- }
- else
- {
- beanProducers.put(returnType, producerBean);
- }
- }
- }
- }
- }
- else
- {
- throw new DefinitionException("WebBean component class : " +
specializedClass.getName()
- + " is not enabled for specialized by the " +
specializedClass + " class");
- }
- }
-
- }
/**
* Configure a list of producer method beans, which override the same
method
@@ -1012,41 +777,6 @@ public final class WebBeansUtil
}
- public Set<Bean<?>> isConfiguredWebBeans(Class<?> clazz,boolean annotate)
- {
- Asserts.nullCheckForClass(clazz);
-
- Set<Bean<?>> beans = new HashSet<Bean<?>>();
-
- Set<Bean<?>> components =
webBeansContext.getBeanManagerImpl().getComponents();
- Iterator<Bean<?>> it = components.iterator();
-
- while (it.hasNext())
- {
- AbstractOwbBean<?> bean = (AbstractOwbBean<?>)it.next();
-
- if (bean.getTypes().contains(clazz)
- || (EnterpriseBeanMarker.class.isInstance(bean) &&
bean.getBeanClass().isAssignableFrom(clazz)))
- {
- if(annotate)
- {
-
if(bean.getReturnType().isAnnotationPresent(Specializes.class))
- {
- if(!(bean instanceof NewBean))
- {
- beans.add(bean);
- }
- }
- }
- else
- {
- beans.add(bean);
- }
- }
- }
-
- return beans;
- }
public <T> Constructor<T> getNoArgConstructor(Class<T> clazz)
{
@@ -1264,8 +994,8 @@ public final class WebBeansUtil
Annotation[] annotationsFromSet =
AnnotationUtil.asArray(bean.getQualifiers());
Method disposal =
annotationManager.getDisposalWithGivenAnnotatedMethod(annotatedType,
bean.getReturnType(), annotationsFromSet);
- AnnotatedMethod<?> disposalAnnotated = null;
- GProcessProducerMethod processProducerMethodEvent = null;
+ AnnotatedMethod<?> disposalAnnotated;
+ GProcessProducerMethod processProducerMethodEvent;
if(disposal != null)
{
disposalAnnotated =
webBeansContext.getAnnotatedElementFactory().newAnnotatedMethod(disposal,
annotatedType);
@@ -1661,25 +1391,6 @@ public final class WebBeansUtil
return
annotatedType.isAnnotationPresent(javax.interceptor.Interceptor.class);
}
- public <T> ManagedBean<T> defineManagedBean(AnnotatedType<T> type)
- {
- BeanAttributesImpl<T> beanAttributes =
BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(type).build();
- ManagedBeanBuilder<T, ManagedBean<T>> managedBeanCreator = new
ManagedBeanBuilder<T, ManagedBean<T>>(webBeansContext, type, beanAttributes);
-
- //Check for Enabled via Alternative
- ManagedBean<T> managedBean = managedBeanCreator.getBean();
- new ProducerMethodBeansBuilder(managedBean.getWebBeansContext(),
managedBean.getAnnotatedType()).defineProducerMethods(managedBean);
- new ProducerFieldBeansBuilder(managedBean.getWebBeansContext(),
managedBean.getAnnotatedType()).defineProducerFields(managedBean);
- new ObserverMethodsBuilder<T, InjectionTargetBean<T>>(webBeansContext,
managedBean.getAnnotatedType()).defineObserverMethods(managedBean);
-
- if (managedBean.getProducer() instanceof AbstractProducer)
- {
- AbstractProducer<T> producer =
(AbstractProducer<T>)managedBean.getProducer();
- producer.defineInterceptorStack(managedBean,
managedBean.getAnnotatedType(), webBeansContext);
- }
- return managedBean;
- }
-
/**
* Checks the implementation class for checking conditions.
*
Modified:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/logger/ISomeLogger.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/logger/ISomeLogger.java?rev=1599956&r1=1599955&r2=1599956&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/logger/ISomeLogger.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/logger/ISomeLogger.java
Wed Jun 4 07:49:55 2014
@@ -22,4 +22,6 @@ public interface ISomeLogger
{
public void printError(String errorMessage);
+ public Class<?> getRealClass();
+
}
Modified:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/logger/SystemLogger.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/logger/SystemLogger.java?rev=1599956&r1=1599955&r2=1599956&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/logger/SystemLogger.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/logger/SystemLogger.java
Wed Jun 4 07:49:55 2014
@@ -34,4 +34,10 @@ public class SystemLogger implements ISo
{
return this.message;
}
+
+ @Override
+ public Class<?> getRealClass()
+ {
+ return getClass();
+ }
}
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/disposes/StaticProducerTest.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/disposes/StaticProducerTest.java?rev=1599956&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/disposes/StaticProducerTest.java
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/disposes/StaticProducerTest.java
Wed Jun 4 07:49:55 2014
@@ -0,0 +1,96 @@
+/*
+ * 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.webbeans.test.disposes;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.Typed;
+
+import junit.framework.Assert;
+
+import org.apache.webbeans.test.AbstractUnitTest;
+import org.junit.Test;
+
+/**
+ * Test if static producer methods and disposal methods do work
+ */
+public class StaticProducerTest extends AbstractUnitTest
+{
+
+ @Test
+ public void testStaticProducer() throws Exception
+ {
+ startContainer(ProducerOwner.class);
+
+ ProducerOwner.destroyed = null;
+
+ MyBean myBean = getInstance(MyBean.class);
+ Assert.assertEquals("testval", myBean.getVal());
+ Assert.assertNotNull(myBean);
+ Assert.assertEquals(Boolean.FALSE, ProducerOwner.destroyed);
+
+ getLifecycle().getContextService().endContext(RequestScoped.class,
null);
+
+ // now the bean should be destroyed
+ Assert.assertEquals(Boolean.TRUE, ProducerOwner.destroyed);
+
+ }
+
+
+ public static class ProducerOwner
+ {
+ public static Boolean destroyed = null;
+
+ @Produces
+ @RequestScoped
+ public static MyBean createVal()
+ {
+ destroyed = Boolean.FALSE;
+ return new MyBean("testval");
+ }
+
+ public static void destroyIt(@Disposes MyBean val)
+ {
+ destroyed = Boolean.TRUE;
+ }
+
+ }
+
+
+ @Typed()
+ public static class MyBean
+ {
+ private String val;
+
+ public MyBean()
+ {
+ }
+
+ public MyBean(String val)
+ {
+ this.val = val;
+ }
+
+ public String getVal()
+ {
+ return val;
+ }
+ }
+}
Modified:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/disposes/beans/AppScopedBean.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/disposes/beans/AppScopedBean.java?rev=1599956&r1=1599955&r2=1599956&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/disposes/beans/AppScopedBean.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/disposes/beans/AppScopedBean.java
Wed Jun 4 07:49:55 2014
@@ -48,6 +48,8 @@ public class AppScopedBean
producedModel = model;
}
System.out.println("produced DependentModel=" + model);
+ OK = false;
+
return model;
}
Modified:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/specializes/logger/LoggerSpecializationTest.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/specializes/logger/LoggerSpecializationTest.java?rev=1599956&r1=1599955&r2=1599956&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/specializes/logger/LoggerSpecializationTest.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/specializes/logger/LoggerSpecializationTest.java
Wed Jun 4 07:49:55 2014
@@ -39,6 +39,9 @@ public class LoggerSpecializationTest ex
SpecializedInjector injector = getInstance(SpecializedInjector.class);
ISomeLogger logger = injector.logger();
Assert.assertTrue(logger instanceof SystemLogger);
+
+ Assert.assertEquals(SystemLogger.class, logger.getRealClass());
+
logger.printError("Hello World");
SystemLogger sysLogger = (SystemLogger)logger;
Assert.assertEquals("Hello World", sysLogger.getMessage());
@@ -54,6 +57,8 @@ public class LoggerSpecializationTest ex
ISomeLogger logger = injector.logger();
Assert.assertTrue(logger instanceof MockSpecializedLogger);
+ Assert.assertEquals(MockSpecializedLogger.class,
logger.getRealClass());
+
logger.printError("Hello World");
MockSpecializedLogger sysLogger = (MockSpecializedLogger)logger;
Assert.assertEquals("Hello World", sysLogger.getMessage());
Modified: openwebbeans/trunk/webbeans-tck/standalone-suite.xml
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tck/standalone-suite.xml?rev=1599956&r1=1599955&r2=1599956&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tck/standalone-suite.xml (original)
+++ openwebbeans/trunk/webbeans-tck/standalone-suite.xml Wed Jun 4 07:49:55
2014
@@ -26,6 +26,10 @@
<packages>
<package name="org.jboss.cdi.tck.tests.*">
+ <!-- CHALLENGED TCK TESTS: clarifying this in the EG -->
+ <exclude
name="org.jboss.cdi.tck.tests.inheritance.specialization.simple"/>
+
+
<!-- the following tests are excluded because we just have not
yet implemented this features -->
<exclude
name="org.jboss.cdi.tck.tests.inheritance.specialization.producer.method.broken.twobeans"
/>
<exclude
name="org.jboss.cdi.tck.tests.implementation.producer.field.definition.broken.interceptor"
/>