[webbeans-commits] Webbeans SVN: r1182 - ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean and 9 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Thu Jan 22 19:31:15 EST 2009
Author: pete.muir at jboss.org
Date: 2009-01-22 19:31:15 -0500 (Thu, 22 Jan 2009)
New Revision: 1182
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BeanValidator.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Beans.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/Waste.java
Removed:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanValidation.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/Waste.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractFacadeBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedItem.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotationStore.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedItem.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Proxies.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/tck/ContainersImpl.java
tck/trunk/impl/pom.xml
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/Building.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/BuildingInterface.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/EnterpriseBeanSpecializationTest.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/FarmYard_Broken.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/Office.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/simple/Building.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/simple/FarmYard_Broken.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/simple/Office.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/simple/SimpleBeanSpecializationTest.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/simple/Waste.java
tck/trunk/pom.xml
Log:
Specialization and tests
Copied: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BeanValidator.java (from rev 1180, ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanValidation.java)
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BeanValidator.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -0,0 +1,141 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Set;
+
+import javax.webbeans.AmbiguousDependencyException;
+import javax.webbeans.DefinitionException;
+import javax.webbeans.InconsistentSpecializationException;
+import javax.webbeans.InjectionPoint;
+import javax.webbeans.New;
+import javax.webbeans.NullableDependencyException;
+import javax.webbeans.UnproxyableDependencyException;
+import javax.webbeans.UnsatisfiedDependencyException;
+import javax.webbeans.UnserializableDependencyException;
+import javax.webbeans.manager.Bean;
+
+import org.jboss.webbeans.bean.AbstractBean;
+import org.jboss.webbeans.bean.NewEnterpriseBean;
+import org.jboss.webbeans.bean.NewSimpleBean;
+import org.jboss.webbeans.util.Beans;
+import org.jboss.webbeans.util.ListComparator;
+import org.jboss.webbeans.util.Proxies;
+import org.jboss.webbeans.util.Reflections;
+
+/**
+ * Checks a list of beans for DeploymentExceptions and their subclasses
+ *
+ * @author Nicklas Karlsson
+ *
+ */
+public class BeanValidator
+{
+
+ private final ManagerImpl manager;
+
+ public BeanValidator(ManagerImpl manager)
+ {
+ this.manager = manager;
+ }
+
+ /**
+ * Validates the beans
+ *
+ * @param beans The beans to validate
+ */
+ public void validate(List<Bean<?>> beans)
+ {
+ final List<Bean<?>> specializedBeans = new ArrayList<Bean<?>>();
+ for (Bean<?> bean : beans)
+ {
+ for (InjectionPoint injectionPoint : bean.getInjectionPoints())
+ {
+ if (injectionPoint.getType() instanceof Class)
+ {
+ Class<?> type = (Class<?>) injectionPoint.getType();
+ if (injectionPoint.getAnnotation(New.class) != null && injectionPoint.getBindings().size() > 1)
+ {
+ throw new DefinitionException("The injection point " + injectionPoint + " is annotated with @New which cannot be combined with other binding types");
+ }
+ Annotation[] bindings = injectionPoint.getBindings().toArray(new Annotation[0]);
+ Set<?> resolvedBeans = manager.resolveByType(type, bindings);
+ if (resolvedBeans.isEmpty())
+ {
+ throw new UnsatisfiedDependencyException("The injection point " + injectionPoint + " has unsatisfied dependencies for type " + type + " and binding types " + bindings + " in " + bean);
+ }
+ if (resolvedBeans.size() > 1)
+ {
+ throw new AmbiguousDependencyException("The injection point " + injectionPoint + " has ambiguos dependencies for type " + type + " and binding types " + bindings + " in " + bean);
+ }
+ Bean<?> resolvedBean = (Bean<?>) resolvedBeans.iterator().next();
+ if (MetaDataCache.instance().getScopeModel(resolvedBean.getScopeType()).isNormal() && !Proxies.isClassProxyable(type))
+ {
+ throw new UnproxyableDependencyException("The injection point " + injectionPoint + " has non-proxyable dependencies");
+ }
+ if (Reflections.isPrimitive((Class<?>) injectionPoint.getType()) && resolvedBean.isNullable())
+ {
+ throw new NullableDependencyException("The injection point " + injectionPoint + " has nullable dependencies");
+ }
+ }
+ else
+ {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+ }
+ if (bean instanceof AbstractBean && !(bean instanceof NewSimpleBean) && !(bean instanceof NewEnterpriseBean))
+ {
+ AbstractBean<?, ?> abstractBean = (AbstractBean<?, ?>) bean;
+ if (abstractBean.isSpecializing())
+ {
+ if (!hasHigherPrecedence(bean.getDeploymentType(), abstractBean.getSpecializedBean().getDeploymentType()))
+ {
+ throw new InconsistentSpecializationException("Specializing bean must have a higher precedence deployment type than the specialized bean");
+ }
+ if (specializedBeans.contains(abstractBean.getSpecializedBean()))
+ {
+ throw new InconsistentSpecializationException("Two beans cannot specialize the same bean");
+ }
+ specializedBeans.add(abstractBean.getSpecializedBean());
+ }
+ }
+ if (Beans.isPassivatingBean(bean) && !bean.isSerializable())
+ {
+ throw new UnserializableDependencyException("The bean " + bean + " declares a passivating scopes but has non-serializable dependencies");
+ }
+ boolean normalScoped = MetaDataCache.instance().getScopeModel(bean.getScopeType()).isNormal();
+ if (normalScoped && !Beans.isBeanProxyable(bean))
+ {
+ throw new UnproxyableDependencyException("Normal scoped bean " + bean + " is not proxyable");
+ }
+ }
+
+ }
+
+
+ private boolean hasHigherPrecedence(Class<? extends Annotation> deploymentType, Class<? extends Annotation> otherDeploymentType)
+ {
+ Comparator<Class<? extends Annotation>> comparator = new ListComparator<Class<? extends Annotation>>(manager.getEnabledDeploymentTypes());
+ return comparator.compare(deploymentType, otherDeploymentType) > 0;
+ }
+
+
+}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -64,7 +64,7 @@
import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
import org.jboss.webbeans.resources.spi.NamingContext;
import org.jboss.webbeans.resources.spi.ResourceLoader;
-import org.jboss.webbeans.util.Proxies;
+import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.Reflections;
/**
@@ -623,7 +623,7 @@
}
Bean<T> bean = beans.iterator().next();
boolean normalScoped = MetaDataCache.instance().getScopeModel(bean.getScopeType()).isNormal();
- if (normalScoped && !Proxies.isBeanProxyable(bean))
+ if (normalScoped && !Beans.isBeanProxyable(bean))
{
throw new UnproxyableDependencyException("Normal scoped bean " + bean + " is not proxyable");
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -43,7 +43,7 @@
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.model.MergedStereotypes;
-import org.jboss.webbeans.util.Proxies;
+import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.Reflections;
/**
@@ -139,6 +139,12 @@
initTypes();
initProxyable();
checkRequiredTypesImplemented();
+ if (isSpecializing())
+ {
+ preCheckSpecialization();
+ initSpecialization();
+ postCheckSpecialization();
+ }
}
/**
@@ -157,6 +163,10 @@
{
this.bindingTypes = new HashSet<Annotation>();
this.bindingTypes.addAll(getAnnotatedItem().getMetaAnnotations(BindingType.class));
+ if (isSpecializing())
+ {
+ this.bindingTypes.addAll(getSpecializedBean().getBindings());
+ }
if (bindingTypes.size() == 0)
{
log.trace("Adding default @Current binding type");
@@ -213,7 +223,11 @@
return;
}
}
-
+ else if (isSpecializing())
+ {
+ this.name = getSpecializedBean().getName();
+ return;
+ }
if (beanNameDefaulted || getMergedStereotypes().isBeanNameDefaulted())
{
@@ -224,7 +238,7 @@
protected void initProxyable()
{
- proxyable = Proxies.apiTypesAreProxyable(getTypes());
+ proxyable = Beans.apiTypesAreProxyable(getTypes());
}
/**
@@ -309,6 +323,24 @@
}
}
}
+
+ protected void postCheckSpecialization()
+ {
+ if (getAnnotatedItem().isAnnotationPresent(Named.class) && getSpecializedBean().getAnnotatedItem().isAnnotationPresent(Named.class))
+ {
+ throw new DefinitionException("Cannot put name on specializing and specialized class");
+ }
+ }
+
+ protected void preCheckSpecialization()
+ {
+
+ }
+
+ protected void initSpecialization()
+ {
+
+ }
/**
* Binds the decorators to the proxy
@@ -373,6 +405,10 @@
* @return The default name
*/
protected abstract String getDefaultName();
+
+ public abstract AbstractBean<?, ?> getSpecializedBean();
+
+ public abstract boolean isSpecializing();
/**
* Gets the deployment type of the bean
@@ -520,4 +556,18 @@
{
return proxyable;
}
+
+ @Override
+ public boolean equals(Object other)
+ {
+ if (other instanceof AbstractBean)
+ {
+ AbstractBean<?, ?> that = (AbstractBean<?, ?>) other;
+ return this.getTypes().equals(that.getTypes()) && this.getBindings().equals(that.getBindings());
+ }
+ else
+ {
+ return false;
+ }
+ }
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -70,11 +70,11 @@
* @param type The type
* @param manager The Web Beans manager
*/
- public AbstractClassBean(AnnotatedClass<T> type, ManagerImpl manager)
+ protected AbstractClassBean(AnnotatedClass<T> type, ManagerImpl manager)
{
super(manager);
this.annotatedItem = type;
- dependentInstancesStore = new DependentInstancesStore();
+ this.dependentInstancesStore = new DependentInstancesStore();
}
/**
@@ -270,6 +270,22 @@
throw new DefinitionException("Web Bean implementation class " + type + " cannot be declared abstract");
}
}
+
+ @Override
+ protected void preCheckSpecialization()
+ {
+ super.preCheckSpecialization();
+ if (getAnnotatedItem().getSuperclass() == null || getAnnotatedItem().getSuperclass().getType().equals(Object.class))
+ {
+ throw new DefinitionException("Specializing bean must extend another bean");
+ }
+ }
+
+ @Override
+ public boolean isSpecializing()
+ {
+ return getAnnotatedItem().isAnnotationPresent(Specializes.class);
+ }
/**
* Gets the annotated item
@@ -290,22 +306,10 @@
@Override
protected String getDefaultName()
{
- String name = Strings.decapitalize(getSpecializedType().getSimpleName());
+ String name = Strings.decapitalize(getAnnotatedItem().getSimpleName());
log.trace("Default name of " + type + " is " + name);
return name;
}
-
- private AnnotatedClass<?> getSpecializedType()
- {
- if (annotatedItem.isAnnotationPresent(Specializes.class))
- {
- return annotatedItem.getSuperclass();
- }
- else
- {
- return annotatedItem;
- }
- }
/**
* Gets the injectable fields
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractFacadeBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractFacadeBean.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractFacadeBean.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -159,5 +159,17 @@
{
return "FacadeBean " + getName() + " for " + annotatedItem;
}
+
+ @Override
+ public AbstractBean<?, ?> getSpecializedBean()
+ {
+ return null;
+ }
+
+ @Override
+ public boolean isSpecializing()
+ {
+ return false;
+ }
}
\ No newline at end of file
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -37,6 +37,7 @@
import org.jboss.webbeans.injection.InjectionPointImpl;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.Names;
import org.jboss.webbeans.util.Reflections;
@@ -176,7 +177,7 @@
{
return;
}
- if (dependent && Reflections.isPassivatingBean(injectionPoint.getBean()))
+ if (dependent && Beans.isPassivatingBean(injectionPoint.getBean()))
{
if (injectionPoint.isField())
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -59,6 +59,8 @@
private InternalEjbDescriptor<T> ejbDescriptor;
private Class<T> proxyClass;
+
+ private EnterpriseBean<?> specializedBean;
/**
* Creates a simple, annotation defined Enterprise Web Bean
@@ -87,6 +89,10 @@
protected EnterpriseBean(AnnotatedClass<T> type, ManagerImpl manager)
{
super(type, manager);
+ if (type.isAnnotationPresent(Specializes.class))
+ {
+ this.specializedBean = EnterpriseBean.of(type.getSuperclass(), manager);
+ }
init();
}
@@ -119,7 +125,6 @@
checkEnterpriseBeanTypeAllowed();
checkEnterpriseScopeAllowed();
checkConflictingRoles();
- checkSpecialization();
}
/**
@@ -185,18 +190,20 @@
/**
* Validates specialization
*/
- private void checkSpecialization()
+ protected void preCheckSpecialization()
{
- if (!getType().isAnnotationPresent(Specializes.class))
+ super.preCheckSpecialization();
+ if (!manager.getEjbDescriptorCache().containsKey(getAnnotatedItem().getSuperclass().getType()))
{
- return;
- }
- // TODO Should also check the bean type it does contain!
- if (!manager.getEjbDescriptorCache().containsKey(getType().getSuperclass()))
- {
throw new DefinitionException("Annotation defined specializing EJB must have EJB superclass");
}
}
+
+ @Override
+ protected void initSpecialization()
+ {
+ this.specializedBean = EnterpriseBean.of(getAnnotatedItem().getSuperclass(), manager);
+ }
/**
* Creates an instance of the bean
@@ -341,5 +348,11 @@
{
return getEjbDescriptor().isStateful() && Dependent.class.equals(getScopeType());
}
+
+ @Override
+ public AbstractBean<?, ?> getSpecializedBean()
+ {
+ return specializedBean;
+ }
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -128,5 +128,17 @@
buffer.append(" API types " + getTypes() + ", binding types " + getBindings() + "\n");
return buffer.toString();
}
+
+ @Override
+ public AbstractBean<?, ?> getSpecializedBean()
+ {
+ return null;
+ }
+
+ @Override
+ public boolean isSpecializing()
+ {
+ return false;
+ }
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -45,6 +45,8 @@
private AnnotatedMethod<T> method;
private AnnotatedMethod<?> disposalMethod;
+
+ private ProducerMethodBean<?> specializedBean;
/**
* Creates a producer method Web Bean
@@ -63,14 +65,7 @@
{
return of(AnnotatedMethodImpl.<T>of(method, declaringBean.getAnnotatedItem()), declaringBean, manager);
}
-
- /**
- * Constructor
- *
- * @param method The producer method abstraction
- * @param declaringBean The declaring bean
- * @param manager The Web Beans manager
- */
+
protected ProducerMethodBean(AnnotatedMethod<T> method, AbstractClassBean<?> declaringBean, ManagerImpl manager)
{
super(declaringBean, manager);
@@ -210,5 +205,18 @@
}
return true;
}
+
+ @Override
+ public AbstractBean<?, ?> getSpecializedBean()
+ {
+ return specializedBean;
+ }
+
+ @Override
+ public boolean isSpecializing()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -30,6 +30,7 @@
import javax.webbeans.ExecutionException;
import javax.webbeans.Initializer;
import javax.webbeans.InjectionPoint;
+import javax.webbeans.Specializes;
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.MetaDataCache;
@@ -66,6 +67,8 @@
private AnnotatedMethod<?> postConstruct;
// The pre-destroy method
private AnnotatedMethod<?> preDestroy;
+
+ private SimpleBean<?> specializedBean;
/**
* Creates a simple, annotation defined Web Bean
@@ -102,6 +105,10 @@
protected SimpleBean(AnnotatedClass<T> type, ManagerImpl manager)
{
super(type, manager);
+ if (type.isAnnotationPresent(Specializes.class))
+ {
+ this.specializedBean = SimpleBean.of(type.getSuperclass(), manager);
+ }
init();
}
@@ -340,6 +347,22 @@
}
}
}
+
+ @Override
+ protected void preCheckSpecialization()
+ {
+ super.preCheckSpecialization();
+ if (manager.getEjbDescriptorCache().containsKey(getSpecializedBean().getType()))
+ {
+ throw new DefinitionException("Simple bean must specialize a simple bean");
+ }
+ }
+
+ @Override
+ protected void initSpecialization()
+ {
+ this.specializedBean = SimpleBean.of(getAnnotatedItem().getSuperclass(), manager);
+ }
/**
* Initializes the constructor
@@ -496,5 +519,11 @@
return injectionPointsAreSerializable();
}
}
+
+ @Override
+ public SimpleBean<?> getSpecializedBean()
+ {
+ return specializedBean;
+ }
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -12,12 +12,10 @@
import javax.webbeans.DeploymentType;
import javax.webbeans.Fires;
import javax.webbeans.Initializer;
-import javax.webbeans.Named;
import javax.webbeans.Observes;
import javax.webbeans.Obtains;
import javax.webbeans.Produces;
import javax.webbeans.Realizes;
-import javax.webbeans.Specializes;
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bean.AbstractBean;
@@ -36,7 +34,6 @@
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.AnnotatedMethod;
-import org.jboss.webbeans.introspector.WrappedAnnotatedClass;
import org.jboss.webbeans.introspector.WrappedAnnotatedField;
import org.jboss.webbeans.introspector.WrappedAnnotatedMethod;
import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
@@ -54,41 +51,25 @@
private static final Set<Annotation> EMPTY_BINDINGS = Collections.emptySet();
private final Set<AbstractBean<?, ?>> beans;
+ private final Set<AnnotatedClass<?>> deferredClasses;
private final ManagerImpl manager;
public BeanDeployer(ManagerImpl manager)
{
- this.beans = new HashSet<AbstractBean<?,?>>();
this.manager = manager;
+ this.beans = new HashSet<AbstractBean<?,?>>();
+ this.deferredClasses = new HashSet<AnnotatedClass<?>>();
}
+
public void addBean(AbstractBean<?, ?> bean)
{
this.beans.add(bean);
}
- public void addBeans(Set<AbstractBean<?, ?>> beans)
- {
- this.beans.addAll(beans);
- }
-
public void addClass(Class<?> clazz)
{
- AnnotatedClass<?> annotatedClass = AnnotatedClassImpl.of(clazz);
- if (annotatedClass.isAnnotationPresent(Specializes.class))
- {
- annotatedClass = specializeClass(annotatedClass);
- }
- if (manager.getEjbDescriptorCache().containsKey(clazz))
- {
- createBean(EnterpriseBean.of(annotatedClass, manager), annotatedClass);
- beans.add(NewEnterpriseBean.of(annotatedClass, manager));
- }
- else if (isTypeSimpleWebBean(clazz))
- {
- createBean(SimpleBean.of(annotatedClass, manager), annotatedClass);
- beans.add(NewSimpleBean.of(annotatedClass, manager));
- }
+ deferredClasses.add(AnnotatedClassImpl.of(clazz));
}
public void addClasses(Iterable<Class<?>> classes)
@@ -101,6 +82,17 @@
public void deploy()
{
+ for (AnnotatedClass<?> clazz : deferredClasses)
+ {
+ if (manager.getEjbDescriptorCache().containsKey(clazz.getType()))
+ {
+ createEnterpriseBean(clazz);
+ }
+ else if (isTypeSimpleWebBean(clazz.getType()))
+ {
+ createSimpleBean(clazz);
+ }
+ }
manager.setBeans(beans);
}
@@ -203,6 +195,20 @@
ObserverImpl<?> observer = ObserverImpl.of(method, declaringBean, manager);
manager.addObserver(observer);
}
+
+ private void createSimpleBean(AnnotatedClass<?> annotatedClass)
+ {
+ SimpleBean<?> bean = SimpleBean.of(annotatedClass, manager);
+ createBean(bean, annotatedClass);
+ beans.add(NewSimpleBean.of(annotatedClass, manager));
+ }
+
+ private void createEnterpriseBean(AnnotatedClass<?> annotatedClass)
+ {
+ EnterpriseBean<?> bean = EnterpriseBean.of(annotatedClass, manager);
+ createBean(bean, annotatedClass);
+ beans.add(NewEnterpriseBean.of(annotatedClass, manager));
+ }
private void createFacades(Set<AnnotatedItem<?, ?>> injectionPoints)
{
@@ -340,13 +346,4 @@
};
}
- private static <T> AnnotatedClass<T> specializeClass(final AnnotatedClass<T> clazz)
- {
- Set<Annotation> extraAnnotations = new HashSet<Annotation>();
- extraAnnotations.addAll(clazz.getSuperclass().getDeclaredMetaAnnotations(BindingType.class));
- extraAnnotations.add(clazz.getSuperclass().getAnnotation(Named.class));
- Set<Annotation> extraDeclaredAnnotations = Collections.emptySet();
- return new WrappedAnnotatedClass<T>(clazz, extraAnnotations, extraDeclaredAnnotations);
- }
-
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -19,6 +19,7 @@
import java.util.Collections;
+import org.jboss.webbeans.BeanValidator;
import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bean.SimpleBean;
@@ -34,7 +35,6 @@
import org.jboss.webbeans.resources.spi.NamingContext;
import org.jboss.webbeans.resources.spi.ResourceLoader;
import org.jboss.webbeans.transaction.Transaction;
-import org.jboss.webbeans.util.BeanValidation;
/**
* Common bootstrapping functionality that is run at application startup and
@@ -155,7 +155,7 @@
getManager().fireEvent(getManager(), new InitializedLiteral());
log.info("Web Beans initialized. Validating beans.");
getManager().getResolver().resolveInjectionPoints();
- BeanValidation.validate(getManager().getBeans());
+ new BeanValidator(manager).validate(manager.getBeans());
getManager().fireEvent(getManager(), new DeployedLiteral());
}
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedItem.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedItem.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedItem.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -111,6 +111,14 @@
* @return True if present, false if not
*/
public boolean isAnnotationPresent(Class<? extends Annotation> annotationType);
+
+ /**
+ * Indicates if an annotation type specified is present
+ *
+ * @param annotationType The annotation to match
+ * @return True if present, false if not
+ */
+ public boolean isDeclaredAnnotationPresent(Class<? extends Annotation> annotationType);
/**
* Gets the type of the element
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotationStore.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotationStore.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotationStore.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -302,6 +302,11 @@
return annotationMap.containsKey(annotationType);
}
+ public boolean isDeclaredAnnotationPresent(Class<? extends Annotation> annotationType)
+ {
+ return declaredAnnotationMap.containsKey(annotationType);
+ }
+
AnnotationMap getAnnotationMap()
{
return annotationMap;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedItem.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedItem.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedItem.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -208,5 +208,10 @@
{
return delegate().getAnnotationStore();
}
+
+ public boolean isDeclaredAnnotationPresent(Class<? extends Annotation> annotationType)
+ {
+ return delegate().isDeclaredAnnotationPresent(annotationType);
+ }
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -248,5 +248,10 @@
}
public abstract S getDelegate();
+
+ public boolean isDeclaredAnnotationPresent(Class<? extends Annotation> annotationType)
+ {
+ return getAnnotationStore().isDeclaredAnnotationPresent(annotationType);
+ }
}
\ No newline at end of file
Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanValidation.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanValidation.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanValidation.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -1,97 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.webbeans.util;
-
-import java.lang.annotation.Annotation;
-import java.util.List;
-import java.util.Set;
-
-import javax.webbeans.AmbiguousDependencyException;
-import javax.webbeans.DefinitionException;
-import javax.webbeans.InjectionPoint;
-import javax.webbeans.New;
-import javax.webbeans.NullableDependencyException;
-import javax.webbeans.UnproxyableDependencyException;
-import javax.webbeans.UnsatisfiedDependencyException;
-import javax.webbeans.UnserializableDependencyException;
-import javax.webbeans.manager.Bean;
-
-import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.MetaDataCache;
-
-/**
- * Checks a list of beans for DeploymentExceptions and their subclasses
- *
- * @author Nicklas Karlsson
- *
- */
-public class BeanValidation
-{
-
- /**
- * Validates the beans
- *
- * @param beans The beans to validate
- */
- // TODO THIS SHOULD NOT BE A STATIC UTITLITY CLASS
- @Deprecated
- public static void validate(List<Bean<?>> beans)
- {
- for (Bean<?> bean : beans)
- {
- for (InjectionPoint injectionPoint : bean.getInjectionPoints())
- {
- Class<?> type = (Class<?>) injectionPoint.getType();
- if (injectionPoint.getAnnotation(New.class) != null && injectionPoint.getBindings().size() > 1)
- {
- throw new DefinitionException("The injection point " + injectionPoint + " is annotated with @New which cannot be combined with other binding types");
- }
- Annotation[] bindingTypes = injectionPoint.getBindings().toArray(new Annotation[0]);
- Set<?> resolvedBeans = CurrentManager.rootManager().resolveByType(type, bindingTypes);
- if (resolvedBeans.isEmpty())
- {
- throw new UnsatisfiedDependencyException("The injection point " + injectionPoint + " has unsatisfied dependencies for type " + type + " and binding types " + bindingTypes + " in " + bean);
- }
- if (resolvedBeans.size() > 1)
- {
- throw new AmbiguousDependencyException("The injection point " + injectionPoint + " has ambiguos dependencies for type " + type + " and binding types " + bindingTypes + " in " + bean);
- }
- Bean<?> resolvedBean = (Bean<?>) resolvedBeans.iterator().next();
- if (MetaDataCache.instance().getScopeModel(resolvedBean.getScopeType()).isNormal() && !Proxies.isClassProxyable(type))
- {
- throw new UnproxyableDependencyException("The injection point " + injectionPoint + " has non-proxyable dependencies");
- }
- if (Reflections.isPrimitive((Class<?>) injectionPoint.getType()) && resolvedBean.isNullable())
- {
- throw new NullableDependencyException("The injection point " + injectionPoint + " has nullable dependencies");
- }
- // Specialization checks
- }
- if (Reflections.isPassivatingBean(bean) && !bean.isSerializable())
- {
- throw new UnserializableDependencyException("The bean " + bean + " declares a passivating scopes but has non-serializable dependencies");
- }
- boolean normalScoped = MetaDataCache.instance().getScopeModel(bean.getScopeType()).isNormal();
- if (normalScoped && !Proxies.isBeanProxyable(bean))
- {
- throw new UnproxyableDependencyException("Normal scoped bean " + bean + " is not proxyable");
- }
- }
-
- }
-
-}
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Beans.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Beans.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Beans.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -0,0 +1,68 @@
+package org.jboss.webbeans.util;
+
+import java.lang.reflect.Type;
+import java.util.Set;
+
+import javax.webbeans.manager.Bean;
+
+import org.jboss.webbeans.MetaDataCache;
+import org.jboss.webbeans.bean.AbstractBean;
+import org.jboss.webbeans.bean.EnterpriseBean;
+
+public class Beans
+{
+
+ public static boolean isPassivatingBean(Bean<?> bean)
+ {
+ if (bean instanceof EnterpriseBean)
+ {
+ return ((EnterpriseBean<?>) bean).getEjbDescriptor().isStateful();
+ }
+ else
+ {
+ return MetaDataCache.instance().getScopeModel(bean.getScopeType()).isPassivating();
+ }
+ }
+
+ /**
+ * Indicates if a bean is proxyable
+ *
+ * @param bean The bean to test
+ * @return True if proxyable, false otherwise
+ */
+ public static boolean isBeanProxyable(Bean<?> bean)
+ {
+ if (bean instanceof AbstractBean)
+ {
+ return ((AbstractBean<?, ?>) bean).isProxyable();
+ }
+ else
+ {
+ return Beans.apiTypesAreProxyable(bean.getTypes());
+ }
+ }
+
+ /**
+ * Indicates if a set of types are all proxyable
+ *
+ * @param types The types to test
+ * @return True if proxyable, false otherwise
+ */
+ public static boolean apiTypesAreProxyable(Set<Type> types)
+ {
+ for (Type apiType : types)
+ {
+ if (Object.class.equals(apiType))
+ {
+ continue;
+ }
+ boolean isClass = !((Class<?>) apiType).isInterface();
+ if (isClass && !Proxies.isClassProxyable((Class<?>) apiType))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
Property changes on: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Beans.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Proxies.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Proxies.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Proxies.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -23,9 +23,7 @@
import javassist.util.proxy.ProxyFactory;
-import javax.webbeans.manager.Bean;
-import org.jboss.webbeans.bean.AbstractBean;
/**
* Utilties for working with Javassist proxies
@@ -167,45 +165,4 @@
}
}
- /**
- * Indicates if a bean is proxyable
- *
- * @param bean The bean to test
- * @return True if proxyable, false otherwise
- */
- public static boolean isBeanProxyable(Bean<?> bean)
- {
- if (bean instanceof AbstractBean)
- {
- return ((AbstractBean<?, ?>) bean).isProxyable();
- }
- else
- {
- return apiTypesAreProxyable(bean.getTypes());
- }
- }
-
- /**
- * Indicates if a set of types are all proxyable
- *
- * @param types The types to test
- * @return True if proxyable, false otherwise
- */
- public static boolean apiTypesAreProxyable(Set<Type> types)
- {
- for (Type apiType : types)
- {
- if (Object.class.equals(apiType))
- {
- continue;
- }
- boolean isClass = !((Class<?>) apiType).isInterface();
- if (isClass && !isClassProxyable((Class<?>) apiType))
- {
- return false;
- }
- }
- return true;
- }
-
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -36,10 +36,7 @@
import javax.webbeans.BindingType;
import javax.webbeans.ExecutionException;
-import javax.webbeans.manager.Bean;
-import org.jboss.webbeans.MetaDataCache;
-import org.jboss.webbeans.bean.EnterpriseBean;
/**
* Utility class for static reflection-type operations
@@ -75,18 +72,6 @@
}
- public static boolean isPassivatingBean(Bean<?> bean)
- {
- if (bean instanceof EnterpriseBean)
- {
- return ((EnterpriseBean<?>) bean).getEjbDescriptor().isStateful();
- }
- else
- {
- return MetaDataCache.instance().getScopeModel(bean.getScopeType()).isPassivating();
- }
- }
-
/**
* Checks if class is final
*
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/tck/ContainersImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/tck/ContainersImpl.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/tck/ContainersImpl.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -18,13 +18,13 @@
public Manager deploy(List<Class<? extends Annotation>> enabledDeploymentTypes, Class<?>... classes)
{
MockBootstrap bootstrap = new MockBootstrap();
- bootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(classes));
- bootstrap.boot();
ManagerImpl manager = bootstrap.getManager();
if (enabledDeploymentTypes != null)
{
manager.setEnabledDeploymentTypes(enabledDeploymentTypes);
}
+ bootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(classes));
+ bootstrap.boot();
return manager;
}
Modified: tck/trunk/impl/pom.xml
===================================================================
--- tck/trunk/impl/pom.xml 2009-01-22 18:08:43 UTC (rev 1181)
+++ tck/trunk/impl/pom.xml 2009-01-23 00:31:15 UTC (rev 1182)
@@ -83,6 +83,10 @@
<groupId>org.hibernate</groupId>
<artifactId>tck-utils</artifactId>
</dependency>
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ </dependency>
</dependencies>
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/Building.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/Building.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/Building.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -10,7 +10,12 @@
@Produces
public Waste getWaste()
{
- return new Waste();
+ return new Waste(getClassName());
}
+ public String getClassName()
+ {
+ return Building.class.getName();
+ }
+
}
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/BuildingInterface.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/BuildingInterface.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/BuildingInterface.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -3,7 +3,9 @@
import javax.ejb.Local;
@Local
-interface BuildingInterface
+public interface BuildingInterface
{
+ String getClassName();
+
}
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/EnterpriseBeanSpecializationTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/EnterpriseBeanSpecializationTest.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/EnterpriseBeanSpecializationTest.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -51,52 +51,71 @@
assert manager.resolveByType(Farmer.class, LANDOWNER_LITERAL).iterator().next().getName().equals("farmer");
}
- @Test(groups="broken", expectedExceptions=DefinitionException.class) @SpecAssertion(section = "4.3.1")
+ @Test(expectedExceptions=DefinitionException.class) @SpecAssertion(section = "4.3.1")
public void testSpecializingAndSpecializedBeanHasName()
{
- //deployBeans(FarmYard_Broken.class);
+ deployBeans(FarmYard_Broken.class);
}
@Test(groups="broken") @SpecAssertion(section={"4.3.1", "3.2.7"})
- public void testSpecializedBeanNotInstantiated()
+ public void testSpecializedBeanNotInstantiated() throws Exception
{
deployBeans(LazyFarmer.class, Farmer.class);
- Farmer farmer = manager.getInstanceByType(Farmer.class, LANDOWNER_LITERAL);
- assert farmer.getClassName().equals(LazyFarmer.class.getName());
+ new RunInDependentContext()
+ {
+
+ @Override
+ protected void execute() throws Exception
+ {
+ Farmer farmer = manager.getInstanceByType(Farmer.class, LANDOWNER_LITERAL);
+ assert farmer.getClassName().equals(LazyFarmer.class.getName());
+ }
+
+ }.run();
}
- @Test(groups="broken", expectedExceptions=InconsistentSpecializationException.class) @SpecAssertion(section="4.3.1")
+ @Test(expectedExceptions=InconsistentSpecializationException.class) @SpecAssertion(section="4.3.1")
public void testSpecializingBeanDoesNotHaveHigherPrecedenceThanSpecializedBean()
{
- deployBeans(OrganicFarmer_Broken.class);
+ deployBeans(Farmer.class, OrganicFarmer_Broken.class);
}
@Test(groups="broken") @SpecAssertion(section="4.3.1")
- public void testProducerMethodOnSpecializedBeanCalledOnSpecializingBean()
+ public void testProducerMethodOnSpecializedBeanCalledOnSpecializingBean() throws Exception
{
- //deployBeans(Office.class, Building.class);
- //assert manager.resolveByType(Waste.class).size() == 0;
+ deployBeans(Office.class, Building.class);
+ new RunInDependentContext()
+ {
+
+ @Override
+ protected void execute() throws Exception
+ {
+ assert manager.resolveByType(Waste.class).size() == 1;
+ assert manager.getInstanceByType(Waste.class).getFrom().equals(Office.class.getName());
+ }
+
+ }.run();
}
- @Test(groups="broken", expectedExceptions=InconsistentSpecializationException.class) @SpecAssertion(section="4.3.1")
+ @Test(expectedExceptions=InconsistentSpecializationException.class) @SpecAssertion(section="4.3.1")
public void testTwoBeansSpecializeTheSameBean()
{
- deployBeans(SheepFarmer_Broken.class, FishFarmer_Broken.class);
+ deployBeans(Farmer.class, SheepFarmer_Broken.class, FishFarmer_Broken.class);
}
- @Test(groups={"broken", "specialization"},expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.2.7")
+ @Test(groups={"specialization"},expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.2.7")
public void testSpecializingClassDirectlyExtendsSimpleBean()
{
deployBeans(Tractor_Broken.class);
}
- @Test(groups={"broken", "specialization"},expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.2.7")
+ @Test(groups={"specialization"},expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.2.7")
public void testSpecializingClassDirectlyExtendsNothing()
{
deployBeans(Cow_Broken.class);
}
- @Test(groups={"broken", "specialization"},expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.2.7")
+ @Test(groups={"specialization"},expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.2.7")
public void testSpecializingClassImplementsInterfaceAndExtendsNothing()
{
deployBeans(Donkey_Broken.class);
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/FarmYard_Broken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/FarmYard_Broken.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/FarmYard_Broken.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -1,11 +1,13 @@
package org.jboss.webbeans.tck.unit.inheritance.specialization.enterprise;
import javax.ejb.Stateful;
+import javax.webbeans.Named;
import javax.webbeans.Specializes;
@Specializes
@AnotherDeploymentType
@Stateful
+ at Named
class FarmYard_Broken extends Yard
{
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/Office.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/Office.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/Office.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -9,4 +9,10 @@
class Office extends Building
{
+ @Override
+ public String getClassName()
+ {
+ return Office.class.getName();
+ }
+
}
Deleted: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/Waste.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/Waste.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/Waste.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -1,6 +0,0 @@
-package org.jboss.webbeans.tck.unit.inheritance.specialization.enterprise;
-
-class Waste
-{
-
-}
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/Waste.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/Waste.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/enterprise/Waste.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -0,0 +1,19 @@
+package org.jboss.webbeans.tck.unit.inheritance.specialization.enterprise;
+
+class Waste
+{
+
+ private String from;
+
+ public String getFrom()
+ {
+ return from;
+ }
+
+ public Waste(String from)
+ {
+ super();
+ this.from = from;
+ }
+
+}
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/simple/Building.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/simple/Building.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/simple/Building.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -5,10 +5,15 @@
class Building
{
+ protected String getClassName()
+ {
+ return Building.class.getName();
+ }
+
@Produces
public Waste getWaste()
{
- return new Waste();
+ return new Waste(getClassName());
}
}
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/simple/FarmYard_Broken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/simple/FarmYard_Broken.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/simple/FarmYard_Broken.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -1,9 +1,11 @@
package org.jboss.webbeans.tck.unit.inheritance.specialization.simple;
+import javax.webbeans.Named;
import javax.webbeans.Specializes;
@Specializes
@AnotherDeploymentType
+ at Named
class FarmYard_Broken extends Yard
{
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/simple/Office.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/simple/Office.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/simple/Office.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -6,4 +6,10 @@
class Office extends Building
{
+ @Override
+ protected String getClassName()
+ {
+ return Office.class.getName();
+ }
+
}
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/simple/SimpleBeanSpecializationTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/simple/SimpleBeanSpecializationTest.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/simple/SimpleBeanSpecializationTest.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -51,52 +51,71 @@
assert manager.resolveByType(Farmer.class, LANDOWNER_LITERAL).iterator().next().getName().equals("farmer");
}
- @Test(groups="broken", expectedExceptions=DefinitionException.class) @SpecAssertion(section = "4.3.1")
+ @Test(expectedExceptions=DefinitionException.class) @SpecAssertion(section = "4.3.1")
public void testSpecializingAndSpecializedBeanHasName()
{
- //deployBeans(FarmYard_Broken.class);
+ deployBeans(FarmYard_Broken.class);
}
- @Test(groups="broken") @SpecAssertion(section={"4.3.1", "3.3.7"})
- public void testSpecializedBeanNotInstantiated()
+ @Test @SpecAssertion(section={"4.3.1", "3.3.7"})
+ public void testSpecializedBeanNotInstantiated() throws Exception
{
deployBeans(LazyFarmer.class, Farmer.class);
- Farmer farmer = manager.getInstanceByType(Farmer.class, LANDOWNER_LITERAL);
- assert farmer.getClassName().equals(LazyFarmer.class.getName());
+ new RunInDependentContext()
+ {
+
+ @Override
+ protected void execute() throws Exception
+ {
+ Farmer farmer = manager.getInstanceByType(Farmer.class, LANDOWNER_LITERAL);
+ assert farmer.getClassName().equals(LazyFarmer.class.getName());
+ }
+
+ }.run();
}
- @Test(groups="broken", expectedExceptions=InconsistentSpecializationException.class) @SpecAssertion(section="4.3.1")
+ @Test(expectedExceptions=InconsistentSpecializationException.class) @SpecAssertion(section="4.3.1")
public void testSpecializingBeanDoesNotHaveHigherPrecedenceThanSpecializedBean()
{
deployBeans(OrganicFarmer_Broken.class);
}
@Test(groups="broken") @SpecAssertion(section="4.3.1")
- public void testProducerMethodOnSpecializedBeanCalledOnSpecializingBean()
+ public void testProducerMethodOnSpecializedBeanCalledOnSpecializingBean() throws Exception
{
- //deployBeans(Office.class, Building.class);
- //assert manager.resolveByType(Waste.class).size() == 0;
+ deployBeans(Office.class, Building.class);
+ new RunInDependentContext()
+ {
+
+ @Override
+ protected void execute() throws Exception
+ {
+ assert manager.resolveByType(Waste.class).size() == 1;
+ assert manager.getInstanceByType(Waste.class).getFrom().equals(Office.class.getName());
+ }
+
+ }.run();
}
- @Test(groups="broken", expectedExceptions=InconsistentSpecializationException.class) @SpecAssertion(section="4.3.1")
+ @Test(expectedExceptions=InconsistentSpecializationException.class) @SpecAssertion(section="4.3.1")
public void testTwoBeansSpecializeTheSameBean()
{
deployBeans(SheepFarmer_Broken.class, FishFarmer_Broken.class);
}
- @Test(groups={"broken", "specialization"},expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.3.7")
+ @Test(groups={"specialization"},expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.3.7")
public void testSpecializingClassDirectlyExtendsEnterpriseBean()
{
- deployBeans(Tractor_Broken.class);
+ deployBeans(FarmEquipment.class, Tractor_Broken.class);
}
- @Test(groups={"broken", "specialization"},expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.3.7")
+ @Test(groups={"specialization"},expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.3.7")
public void testSpecializingClassDirectlyExtendsNothing()
{
deployBeans(Cow_Broken.class);
}
- @Test(groups={"broken", "specialization"},expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.3.7")
+ @Test(groups={"specialization"},expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.3.7")
public void testSpecializingClassImplementsInterfaceAndExtendsNothing()
{
deployBeans(Donkey_Broken.class);
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/simple/Waste.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/simple/Waste.java 2009-01-22 18:08:43 UTC (rev 1181)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/specialization/simple/Waste.java 2009-01-23 00:31:15 UTC (rev 1182)
@@ -3,4 +3,17 @@
class Waste
{
+ private String from;
+
+ public String getFrom()
+ {
+ return from;
+ }
+
+ public Waste(String from)
+ {
+ super();
+ this.from = from;
+ }
+
}
Modified: tck/trunk/pom.xml
===================================================================
--- tck/trunk/pom.xml 2009-01-22 18:08:43 UTC (rev 1181)
+++ tck/trunk/pom.xml 2009-01-23 00:31:15 UTC (rev 1182)
@@ -126,6 +126,11 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>1.0</version>
+ </dependency>
</dependencies>
More information about the weld-commits
mailing list