Author: pete.muir(a)jboss.org
Date: 2010-06-05 16:33:48 -0400 (Sat, 05 Jun 2010)
New Revision: 6408
Added:
core/trunk/impl/src/main/java/org/jboss/weld/manager/EnabledClasses.java
Removed:
core/trunk/impl/src/main/java/org/jboss/weld/xml/EnabledClasses.java
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployment.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java
core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeDecoratorResolver.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeInterceptorResolver.java
core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java
core/trunk/impl/src/main/java/org/jboss/weld/xml/BeansXmlParser.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/bootstrap/xml/BeansXmlTest.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/nonTransitiveResolution/TransitiveResolutionTest.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/resolution/AccessibleManagerResolutionTest.java
Log:
use EnabledClasses throughout Weld to simplify BeanManagerImpl
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployment.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployment.java 2010-06-05
19:11:46 UTC (rev 6407)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployment.java 2010-06-05
20:33:48 UTC (rev 6408)
@@ -71,9 +71,9 @@
services.addAll(deploymentServices.entrySet());
services.addAll(beanDeploymentArchive.getServices().entrySet());
this.beanManager = BeanManagerImpl.newManager(deploymentManager,
beanDeploymentArchive.getId(), services, new
BeansXmlParser(services.get(ResourceLoader.class),
beanDeploymentArchive.getBeansXml()).parse());
- log.debug(ENABLED_ALTERNATIVES, this.beanManager,
beanManager.getEnabledAlternativeClasses(),
beanManager.getEnabledAlternativeStereotypes());
- log.debug(ENABLED_DECORATORS, this.beanManager,
beanManager.getEnabledDecoratorClasses());
- log.debug(ENABLED_INTERCEPTORS, this.beanManager,
beanManager.getEnabledInterceptorClasses());
+ log.debug(ENABLED_ALTERNATIVES, this.beanManager,
beanManager.getEnabledClasses().getAlternativeClasses(),
beanManager.getEnabledClasses().getAlternativeStereotypes());
+ log.debug(ENABLED_DECORATORS, this.beanManager,
beanManager.getEnabledClasses().getDecorators());
+ log.debug(ENABLED_INTERCEPTORS, this.beanManager,
beanManager.getEnabledClasses().getInterceptors());
if (beanManager.getServices().contains(EjbServices.class))
{
// Must populate EJB cache first, as we need it to detect whether a
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java 2010-06-05
19:11:46 UTC (rev 6407)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java 2010-06-05
20:33:48 UTC (rev 6408)
@@ -18,7 +18,6 @@
import static org.jboss.weld.logging.Category.BOOTSTRAP;
import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
-import static
org.jboss.weld.logging.messages.ValidatorMessage.SCOPE_ANNOTATION_ON_INJECTION_POINT;
import static
org.jboss.weld.logging.messages.ValidatorMessage.ALTERNATIVE_BEAN_CLASS_NOT_ANNOTATED;
import static
org.jboss.weld.logging.messages.ValidatorMessage.ALTERNATIVE_BEAN_CLASS_SPECIFIED_MULTIPLE_TIMES;
import static
org.jboss.weld.logging.messages.ValidatorMessage.ALTERNATIVE_STEREOTYPE_NOT_ANNOTATED;
@@ -52,6 +51,7 @@
import static
org.jboss.weld.logging.messages.ValidatorMessage.NON_SERIALIZABLE_BEAN_INJECTED_INTO_PASSIVATING_BEAN;
import static
org.jboss.weld.logging.messages.ValidatorMessage.PASSIVATING_BEAN_WITH_NONSERIALIZABLE_DECORATOR;
import static
org.jboss.weld.logging.messages.ValidatorMessage.PASSIVATING_BEAN_WITH_NONSERIALIZABLE_INTERCEPTOR;
+import static
org.jboss.weld.logging.messages.ValidatorMessage.SCOPE_ANNOTATION_ON_INJECTION_POINT;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
@@ -471,9 +471,9 @@
{
interceptorBeanClasses.add(interceptor.getBeanClass());
}
- for (Class<?> enabledInterceptorClass :
beanManager.getEnabledInterceptorClasses())
+ for (Class<?> enabledInterceptorClass :
beanManager.getEnabledClasses().getInterceptors())
{
- if (beanManager.getEnabledInterceptorClasses().indexOf(enabledInterceptorClass)
< beanManager.getEnabledInterceptorClasses().lastIndexOf(enabledInterceptorClass))
+ if
(beanManager.getEnabledClasses().getInterceptors().indexOf(enabledInterceptorClass) <
beanManager.getEnabledClasses().getInterceptors().lastIndexOf(enabledInterceptorClass))
{
throw new DeploymentException(INTERCEPTOR_SPECIFIED_TWICE,
enabledInterceptorClass + " specified twice");
}
@@ -492,9 +492,9 @@
{
decoratorBeanClasses.add(bean.getBeanClass());
}
- for (Class<?> clazz : beanManager.getEnabledDecoratorClasses())
+ for (Class<?> clazz : beanManager.getEnabledClasses().getDecorators())
{
- if (beanManager.getEnabledDecoratorClasses().indexOf(clazz) <
beanManager.getEnabledDecoratorClasses().lastIndexOf(clazz))
+ if (beanManager.getEnabledClasses().getDecorators().indexOf(clazz) <
beanManager.getEnabledClasses().getDecorators().lastIndexOf(clazz))
{
throw new DeploymentException(DECORATOR_SPECIFIED_TWICE, clazz);
}
@@ -508,7 +508,7 @@
private void validateEnabledAlternatives(BeanManagerImpl beanManager)
{
List<Class<?>> seenAlternatives = new
ArrayList<Class<?>>();
- for (Class<? extends Annotation> stereotype :
beanManager.getEnabledAlternativeStereotypes())
+ for (Class<? extends Annotation> stereotype :
beanManager.getEnabledClasses().getAlternativeStereotypes())
{
if (!stereotype.isAnnotationPresent(Alternative.class))
{
@@ -520,7 +520,7 @@
}
seenAlternatives.add(stereotype);
}
- for (Class<?> clazz : beanManager.getEnabledAlternativeClasses())
+ for (Class<?> clazz :
beanManager.getEnabledClasses().getAlternativeClasses())
{
if (!clazz.isAnnotationPresent(Alternative.class))
{
@@ -571,7 +571,7 @@
{
if (ij.getBean() instanceof Decorator<?>)
{
- if
(beanManager.getEnabledDecoratorClasses().contains(ij.getBean().getBeanClass()))
+ if
(beanManager.getEnabledClasses().getDecorators().contains(ij.getBean().getBeanClass()))
{
return resolvedBeans.size() > 0;
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java 2010-06-05
19:11:46 UTC (rev 6407)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java 2010-06-05
20:33:48 UTC (rev 6408)
@@ -78,6 +78,7 @@
import org.jboss.weld.jsf.JsfApiAbstraction;
import org.jboss.weld.logging.messages.VersionMessage;
import org.jboss.weld.manager.BeanManagerImpl;
+import org.jboss.weld.manager.EnabledClasses;
import org.jboss.weld.metadata.TypeStore;
import org.jboss.weld.metadata.cache.MetaAnnotationStore;
import org.jboss.weld.persistence.PersistenceApiAbstraction;
@@ -98,7 +99,6 @@
import org.jboss.weld.util.serviceProvider.DefaultServiceLoaderFactory;
import org.jboss.weld.util.serviceProvider.ServiceLoaderFactory;
import org.jboss.weld.ws.WSApiAbstraction;
-import org.jboss.weld.xml.EnabledClasses;
import org.slf4j.cal10n.LocLogger;
/**
Modified: core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java 2010-06-05
19:11:46 UTC (rev 6407)
+++ core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java 2010-06-05
20:33:48 UTC (rev 6408)
@@ -116,7 +116,6 @@
import org.jboss.weld.util.collections.IterableToIteratorFunction;
import org.jboss.weld.util.reflection.HierarchyDiscovery;
import org.jboss.weld.util.reflection.Reflections;
-import org.jboss.weld.xml.EnabledClasses;
import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
@@ -466,43 +465,24 @@
*/
public Collection<Class<?>> getEnabledAlternativeClasses()
{
- return getEnabledClasses().getEnabledAlternativeClasses();
+ return getEnabledClasses().getAlternativeClasses();
}
/**
- * @return the enabled alternative stereotypes
+ * Enabled Alternatives, Interceptors and Decorators
+ *
+ * @return
*/
- public Collection<Class<? extends Annotation>>
getEnabledAlternativeStereotypes()
+ public EnabledClasses getEnabledClasses()
{
- return getEnabledClasses().getEnabledAlternativeStereotypes();
- }
-
- private EnabledClasses getEnabledClasses()
- {
return enabledClasses;
}
public boolean isBeanEnabled(Bean<?> bean)
{
- return Beans.isBeanEnabled(bean, getEnabledAlternativeClasses(),
getEnabledAlternativeStereotypes());
+ return Beans.isBeanEnabled(bean, getEnabledClasses().getAlternativeClasses(),
getEnabledClasses().getAlternativeStereotypes());
}
-
- /**
- * @return the enabledDecoratorClasses
- */
- public List<Class<?>> getEnabledDecoratorClasses()
- {
- return getEnabledClasses().getEnabledDecoratorClasses();
- }
- /**
- * @return the enabledInterceptorClasses
- */
- public List<Class<?>> getEnabledInterceptorClasses()
- {
- return getEnabledClasses().getEnabledInterceptorClasses();
- }
-
public Set<Bean<?>> getBeans(Type beanType, Annotation... qualifiers)
{
return beanResolver.resolve(new
ResolvableBuilder(beanType).addQualifiers(qualifiers).create());
@@ -860,7 +840,7 @@
{
StringBuilder buffer = new StringBuilder();
buffer.append("Manager\n");
- buffer.append("Enabled alternatives: " + getEnabledAlternativeClasses() +
" " + getEnabledAlternativeStereotypes() + "\n");
+ buffer.append("Enabled alternatives: " +
getEnabledClasses().getAlternativeClasses() + " " +
getEnabledClasses().getAlternativeStereotypes() + "\n");
buffer.append("Registered contexts: " + contexts.keySet() +
"\n");
buffer.append("Registered beans: " + getBeans().size() +
"\n");
buffer.append("Specialized beans: " + specializedBeans.size() +
"\n");
Copied: core/trunk/impl/src/main/java/org/jboss/weld/manager/EnabledClasses.java (from rev
6407, core/trunk/impl/src/main/java/org/jboss/weld/xml/EnabledClasses.java)
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/manager/EnabledClasses.java
(rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/manager/EnabledClasses.java 2010-06-05
20:33:48 UTC (rev 6408)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat, Inc., 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.weld.manager;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ *
+ * @author Nicklas Karlsson
+ *
+ */
+public class EnabledClasses
+{
+
+ private final List<Class<? extends Annotation>> alternativeStereotypes;
+ private final List<Class<?>> alternativeClasses;
+ private final List<Class<?>> decorators;
+ private final List<Class<?>> interceptors;
+
+ public EnabledClasses()
+ {
+ this.alternativeClasses = Collections.emptyList();
+ this.alternativeStereotypes = Collections.emptyList();
+ this.decorators = Collections.emptyList();
+ this.interceptors = Collections.emptyList();
+ }
+
+ public EnabledClasses(List<Class<? extends Annotation>>
alternativeStereotypes, List<Class<?>> alternativeClasses,
List<Class<?>> decorators, List<Class<?>> interceptors)
+ {
+ this.alternativeStereotypes = new ArrayList<Class<? extends
Annotation>>(alternativeStereotypes);
+ this.alternativeClasses = new ArrayList<Class<?>>(alternativeClasses);
+ this.decorators = new ArrayList<Class<?>>(decorators);
+ this.interceptors = new ArrayList<Class<?>>(interceptors);
+ }
+
+ public List<Class<? extends Annotation>> getAlternativeStereotypes()
+ {
+ return Collections.unmodifiableList(alternativeStereotypes);
+ }
+
+ public List<Class<?>> getAlternativeClasses()
+ {
+ return Collections.unmodifiableList(alternativeClasses);
+ }
+
+ public List<Class<?>> getDecorators()
+ {
+ return Collections.unmodifiableList(decorators);
+ }
+
+ public List<Class<?>> getInterceptors()
+ {
+ return Collections.unmodifiableList(interceptors);
+ }
+}
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeDecoratorResolver.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeDecoratorResolver.java 2010-06-05
19:11:46 UTC (rev 6407)
+++
core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeDecoratorResolver.java 2010-06-05
20:33:48 UTC (rev 6408)
@@ -45,7 +45,7 @@
{
return Reflections.matches(Collections.singleton(bean.getDelegateType()),
resolvable.getTypes())
&& Beans.containsAllBindings(bean.getDelegateQualifiers(),
resolvable.getQualifiers(), getBeanManager())
- &&
getBeanManager().getEnabledDecoratorClasses().contains(bean.getBeanClass());
+ &&
getBeanManager().getEnabledClasses().getDecorators().contains(bean.getBeanClass());
}
@Override
@@ -56,7 +56,7 @@
public int compare(Decorator<?> o1, Decorator<?> o2)
{
- List<Class<?>> enabledDecorators =
getBeanManager().getEnabledDecoratorClasses();
+ List<Class<?>> enabledDecorators =
getBeanManager().getEnabledClasses().getDecorators();
int p1 = enabledDecorators.indexOf(((Decorator<?>)
o1).getBeanClass());
int p2 = enabledDecorators.indexOf(((Decorator<?>)
o2).getBeanClass());
return p1 - p2;
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeInterceptorResolver.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeInterceptorResolver.java 2010-06-05
19:11:46 UTC (rev 6407)
+++
core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeInterceptorResolver.java 2010-06-05
20:33:48 UTC (rev 6408)
@@ -18,7 +18,6 @@
package org.jboss.weld.resolution;
import java.util.Comparator;
-import java.util.List;
import java.util.Set;
import java.util.TreeSet;
@@ -45,7 +44,7 @@
@Override
protected boolean matches(InterceptorResolvable resolvable, Interceptor<?>
bean)
{
- return bean.intercepts(resolvable.getInterceptionType()) &&
bean.getInterceptorBindings().size() > 0 &&
Beans.containsAllInterceptionBindings(bean.getInterceptorBindings(),
resolvable.getQualifiers(), getManager()) &&
getManager().getEnabledInterceptorClasses().contains(bean.getBeanClass());
+ return bean.intercepts(resolvable.getInterceptionType()) &&
bean.getInterceptorBindings().size() > 0 &&
Beans.containsAllInterceptionBindings(bean.getInterceptorBindings(),
resolvable.getQualifiers(), getManager()) &&
getManager().getEnabledClasses().getInterceptors().contains(bean.getBeanClass());
}
@Override
@@ -56,9 +55,8 @@
public int compare(Interceptor<?> o1, Interceptor<?> o2)
{
- List<Class<?>> enabledInterceptors =
getManager().getEnabledInterceptorClasses();
- int p1 = enabledInterceptors.indexOf(((InterceptorImpl<?>)
o1).getType());
- int p2 = enabledInterceptors.indexOf(((InterceptorImpl<?>)
o2).getType());
+ int p1 =
getManager().getEnabledClasses().getInterceptors().indexOf(((InterceptorImpl<?>)
o1).getType());
+ int p2 =
getManager().getEnabledClasses().getInterceptors().indexOf(((InterceptorImpl<?>)
o2).getType());
return p1 - p2;
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java 2010-06-05 19:11:46 UTC
(rev 6407)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java 2010-06-05 20:33:48 UTC
(rev 6408)
@@ -591,7 +591,7 @@
Set<T> result = new HashSet<T>();
for (T bean : beans)
{
- if (isBeanEnabled(bean, beanManager.getEnabledAlternativeClasses(),
beanManager.getEnabledAlternativeStereotypes()) && !isSpecialized(bean, beans,
beanManager))
+ if (isBeanEnabled(bean,
beanManager.getEnabledClasses().getAlternativeClasses(),
beanManager.getEnabledClasses().getAlternativeStereotypes()) &&
!isSpecialized(bean, beans, beanManager))
{
result.add(bean);
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/xml/BeansXmlParser.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/xml/BeansXmlParser.java 2010-06-05
19:11:46 UTC (rev 6407)
+++ core/trunk/impl/src/main/java/org/jboss/weld/xml/BeansXmlParser.java 2010-06-05
20:33:48 UTC (rev 6408)
@@ -22,12 +22,16 @@
import java.io.IOException;
import java.io.InputStream;
+import java.lang.annotation.Annotation;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import org.jboss.weld.manager.EnabledClasses;
import org.jboss.weld.resources.spi.ResourceLoader;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
@@ -73,7 +77,33 @@
}
}
- return new EnabledClasses(resourceLoader, mergedElements);
+ List<Class<?>> enabledAlternativeClasses = new
ArrayList<Class<?>>();
+ List<Class<? extends Annotation>> enabledAlternativeStereotypes = new
ArrayList<Class<? extends Annotation>>();
+ List<Class<?>> enabledDecoratorClasses = new
ArrayList<Class<?>>();
+ List<Class<?>> enabledInterceptorClasses = new
ArrayList<Class<?>>();
+ for (BeansXmlElement element : mergedElements.getAlternativesElements())
+ {
+ for (Class<?> clazz : element.getClasses(resourceLoader))
+ {
+ if (clazz.isAnnotation())
+ {
+ enabledAlternativeStereotypes.add(clazz.asSubclass(Annotation.class));
+ }
+ else
+ {
+ enabledAlternativeClasses.add(clazz);
+ }
+ }
+ }
+ for (BeansXmlElement element : mergedElements.getDecoratorsElements())
+ {
+ enabledDecoratorClasses.addAll(element.getClasses(resourceLoader));
+ }
+ for (BeansXmlElement element : mergedElements.getInterceptorsElements())
+ {
+ enabledInterceptorClasses.addAll(element.getClasses(resourceLoader));
+ }
+ return new EnabledClasses(enabledAlternativeStereotypes, enabledAlternativeClasses,
enabledDecoratorClasses, enabledInterceptorClasses);
}
private Document loadDocument(DocumentBuilder documentBuilder, URL beansXml)
Deleted: core/trunk/impl/src/main/java/org/jboss/weld/xml/EnabledClasses.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/xml/EnabledClasses.java 2010-06-05
19:11:46 UTC (rev 6407)
+++ core/trunk/impl/src/main/java/org/jboss/weld/xml/EnabledClasses.java 2010-06-05
20:33:48 UTC (rev 6408)
@@ -1,93 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat, Inc., 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.weld.xml;
-
-import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.jboss.weld.resources.spi.ResourceLoader;
-
-/**
- *
- * @author Nicklas Karlsson
- *
- */
-public class EnabledClasses
-{
-
- private final List<Class<? extends Annotation>>
enabledAlternativeStereotypes;
- private final List<Class<?>> enabledAlternativeClasses;
- private final List<Class<?>> enabledDecoratorClasses;
- private final List<Class<?>> enabledInterceptorClasses;
-
- public EnabledClasses()
- {
- this.enabledAlternativeClasses = new ArrayList<Class<?>>();
- this.enabledAlternativeStereotypes = new ArrayList<Class<? extends
Annotation>>();
- this.enabledDecoratorClasses = new ArrayList<Class<?>>();
- this.enabledInterceptorClasses = new ArrayList<Class<?>>();
- }
-
- EnabledClasses(ResourceLoader resourceLoader, MergedElements beanXmlElements)
- {
- this();
- for (BeansXmlElement element : beanXmlElements.getAlternativesElements())
- {
- for (Class<?> clazz : element.getClasses(resourceLoader))
- {
- if (clazz.isAnnotation())
- {
-
this.enabledAlternativeStereotypes.add(clazz.asSubclass(Annotation.class));
- }
- else
- {
- this.enabledAlternativeClasses.add(clazz);
- }
- }
- }
- for (BeansXmlElement element : beanXmlElements.getDecoratorsElements())
- {
- this.enabledDecoratorClasses.addAll(element.getClasses(resourceLoader));
- }
- for (BeansXmlElement element : beanXmlElements.getInterceptorsElements())
- {
- this.enabledInterceptorClasses.addAll(element.getClasses(resourceLoader));
- }
- }
-
- public List<Class<? extends Annotation>>
getEnabledAlternativeStereotypes()
- {
- return Collections.unmodifiableList(enabledAlternativeStereotypes);
- }
-
- public List<Class<?>> getEnabledAlternativeClasses()
- {
- return Collections.unmodifiableList(enabledAlternativeClasses);
- }
-
- public List<Class<?>> getEnabledDecoratorClasses()
- {
- return Collections.unmodifiableList(enabledDecoratorClasses);
- }
-
- public List<Class<?>> getEnabledInterceptorClasses()
- {
- return Collections.unmodifiableList(enabledInterceptorClasses);
- }
-}
Modified:
core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/bootstrap/xml/BeansXmlTest.java
===================================================================
---
core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/bootstrap/xml/BeansXmlTest.java 2010-06-05
19:11:46 UTC (rev 6407)
+++
core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/bootstrap/xml/BeansXmlTest.java 2010-06-05
20:33:48 UTC (rev 6408)
@@ -110,8 +110,8 @@
List<Class<?>> beans = Arrays.asList(Alt.class, Dec.class, Int.class,
IntBind.class, Plain.class);
List<URL> beansXmls =
Arrays.asList(getClass().getResource("alternative.xml"));
TestContainer container = new TestContainer(new MockEELifecycle(), beans,
beansXmls).startContainer().ensureRequestActive();
- assert container.getBeanManager().getEnabledAlternativeClasses().size() == 1;
- assert container.getBeanManager().getEnabledAlternativeClasses().iterator().next()
== Alt.class;
+ assert
container.getBeanManager().getEnabledClasses().getAlternativeClasses().size() == 1;
+ assert
container.getBeanManager().getEnabledClasses().getAlternativeClasses().iterator().next()
== Alt.class;
container.stopContainer();
}
@@ -121,8 +121,8 @@
List<Class<?>> beans = Arrays.asList(Alt.class, Dec.class, Int.class,
IntBind.class, Plain.class);
List<URL> beansXmls =
Arrays.asList(getClass().getResource("decorator.xml"));
TestContainer container = new TestContainer(new MockEELifecycle(), beans,
beansXmls).startContainer().ensureRequestActive();
- assert container.getBeanManager().getEnabledDecoratorClasses().size() == 1;
- assert container.getBeanManager().getEnabledDecoratorClasses().iterator().next() ==
Dec.class;
+ assert container.getBeanManager().getEnabledClasses().getDecorators().size() == 1;
+ assert
container.getBeanManager().getEnabledClasses().getDecorators().iterator().next() ==
Dec.class;
container.stopContainer();
}
@@ -132,8 +132,8 @@
List<Class<?>> beans = Arrays.asList(Alt.class, Dec.class, Int.class,
IntBind.class, Plain.class);
List<URL> beansXmls =
Arrays.asList(getClass().getResource("interceptor.xml"));
TestContainer container = new TestContainer(new MockEELifecycle(), beans,
beansXmls).startContainer().ensureRequestActive();
- assert container.getBeanManager().getEnabledInterceptorClasses().size() == 1;
- assert container.getBeanManager().getEnabledInterceptorClasses().iterator().next()
== Int.class;
+ assert container.getBeanManager().getEnabledClasses().getInterceptors().size() ==
1;
+ assert
container.getBeanManager().getEnabledClasses().getInterceptors().iterator().next() ==
Int.class;
container.stopContainer();
}
@@ -143,12 +143,12 @@
List<Class<?>> beans = Arrays.asList(Alt.class, Dec.class, Int.class,
IntBind.class, Plain.class);
List<URL> beansXmls =
Arrays.asList(getClass().getResource("alternative.xml"),
getClass().getResource("decorator.xml"),
getClass().getResource("interceptor.xml"));
TestContainer container = new TestContainer(new MockEELifecycle(), beans,
beansXmls).startContainer().ensureRequestActive();
- assert container.getBeanManager().getEnabledAlternativeClasses().size() == 1;
- assert container.getBeanManager().getEnabledAlternativeClasses().iterator().next()
== Alt.class;
- assert container.getBeanManager().getEnabledInterceptorClasses().size() == 1;
- assert container.getBeanManager().getEnabledInterceptorClasses().iterator().next()
== Int.class;
- assert container.getBeanManager().getEnabledDecoratorClasses().size() == 1;
- assert container.getBeanManager().getEnabledDecoratorClasses().iterator().next() ==
Dec.class;
+ assert
container.getBeanManager().getEnabledClasses().getAlternativeClasses().size() == 1;
+ assert
container.getBeanManager().getEnabledClasses().getAlternativeClasses().iterator().next()
== Alt.class;
+ assert container.getBeanManager().getEnabledClasses().getInterceptors().size() ==
1;
+ assert
container.getBeanManager().getEnabledClasses().getInterceptors().iterator().next() ==
Int.class;
+ assert container.getBeanManager().getEnabledClasses().getDecorators().size() == 1;
+ assert
container.getBeanManager().getEnabledClasses().getDecorators().iterator().next() ==
Dec.class;
container.stopContainer();
}
@@ -165,8 +165,8 @@
List<Class<?>> beans = Arrays.asList(Alt.class, Dec.class, Int.class,
IntBind.class, Plain.class);
List<URL> beansXmls =
Arrays.asList(getClass().getResource("namespaced.xml"));
TestContainer container = new TestContainer(new MockEELifecycle(), beans,
beansXmls).startContainer().ensureRequestActive();
- assert container.getBeanManager().getEnabledAlternativeClasses().size() == 1;
- assert container.getBeanManager().getEnabledAlternativeClasses().iterator().next()
== Alt.class;
+ assert
container.getBeanManager().getEnabledClasses().getAlternativeClasses().size() == 1;
+ assert
container.getBeanManager().getEnabledClasses().getAlternativeClasses().iterator().next()
== Alt.class;
container.stopContainer();
}
@@ -177,8 +177,8 @@
List<Class<?>> beans = Arrays.asList(Alt.class, Dec.class, Int.class,
IntBind.class, Plain.class);
List<URL> beansXmls =
Arrays.asList(getClass().getResource("nonDefaultNamespaced.xml"));
TestContainer container = new TestContainer(new MockEELifecycle(), beans,
beansXmls).startContainer().ensureRequestActive();
- assert container.getBeanManager().getEnabledAlternativeClasses().size() == 1;
- assert container.getBeanManager().getEnabledAlternativeClasses().iterator().next()
== Alt.class;
+ assert
container.getBeanManager().getEnabledClasses().getAlternativeClasses().size() == 1;
+ assert
container.getBeanManager().getEnabledClasses().getAlternativeClasses().iterator().next()
== Alt.class;
container.stopContainer();
}
@@ -191,8 +191,8 @@
List<Class<?>> beans = Arrays.asList(Alt.class, Dec.class, Int.class,
IntBind.class, Plain.class);
List<URL> beansXmls =
Arrays.asList(getClass().getResource("nonPrettyPrinted.xml"));
TestContainer container = new TestContainer(new MockEELifecycle(), beans,
beansXmls).startContainer().ensureRequestActive();
- assert container.getBeanManager().getEnabledAlternativeClasses().size() == 1;
- assert container.getBeanManager().getEnabledAlternativeClasses().iterator().next()
== Alt.class;
+ assert
container.getBeanManager().getEnabledClasses().getAlternativeClasses().size() == 1;
+ assert
container.getBeanManager().getEnabledClasses().getAlternativeClasses().iterator().next()
== Alt.class;
container.stopContainer();
}
Modified:
core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/nonTransitiveResolution/TransitiveResolutionTest.java
===================================================================
---
core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/nonTransitiveResolution/TransitiveResolutionTest.java 2010-06-05
19:11:46 UTC (rev 6407)
+++
core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/nonTransitiveResolution/TransitiveResolutionTest.java 2010-06-05
20:33:48 UTC (rev 6408)
@@ -49,9 +49,9 @@
BeanManagerImpl warBeanManager = container.getBeanManager();
BeanManagerImpl jar1BeanManager =
container.getLifecycle().getBootstrap().getManager(jar1);
BeanManagerImpl jar2BeanManager =
container.getLifecycle().getBootstrap().getManager(jar2);
- assert warBeanManager.getEnabledAlternativeClasses().isEmpty();
- assert !jar1BeanManager.getEnabledAlternativeClasses().isEmpty();
- assert jar2BeanManager.getEnabledAlternativeClasses().isEmpty();
+ assert warBeanManager.getEnabledClasses().getAlternativeClasses().isEmpty();
+ assert !jar1BeanManager.getEnabledClasses().getAlternativeClasses().isEmpty();
+ assert jar2BeanManager.getEnabledClasses().getAlternativeClasses().isEmpty();
}
finally
{
@@ -82,9 +82,9 @@
BeanManagerImpl warBeanManager = container.getBeanManager();
BeanManagerImpl jar1BeanManager =
container.getLifecycle().getBootstrap().getManager(jar1);
BeanManagerImpl jar2BeanManager =
container.getLifecycle().getBootstrap().getManager(jar2);
- assert warBeanManager.getEnabledAlternativeClasses().isEmpty();
- assert !jar1BeanManager.getEnabledAlternativeClasses().isEmpty();
- assert !jar2BeanManager.getEnabledAlternativeClasses().isEmpty();
+ assert warBeanManager.getEnabledClasses().getAlternativeClasses().isEmpty();
+ assert !jar1BeanManager.getEnabledClasses().getAlternativeClasses().isEmpty();
+ assert !jar2BeanManager.getEnabledClasses().getAlternativeClasses().isEmpty();
}
finally
{
Modified:
core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/resolution/AccessibleManagerResolutionTest.java
===================================================================
---
core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/resolution/AccessibleManagerResolutionTest.java 2010-06-05
19:11:46 UTC (rev 6407)
+++
core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/resolution/AccessibleManagerResolutionTest.java 2010-06-05
20:33:48 UTC (rev 6408)
@@ -31,12 +31,12 @@
import org.jboss.weld.introspector.WeldClass;
import org.jboss.weld.introspector.jlr.WeldClassImpl;
import org.jboss.weld.manager.BeanManagerImpl;
+import org.jboss.weld.manager.EnabledClasses;
import org.jboss.weld.metadata.TypeStore;
import org.jboss.weld.metadata.cache.MetaAnnotationStore;
import org.jboss.weld.resources.ClassTransformer;
import org.jboss.weld.serialization.ContextualStoreImpl;
import org.jboss.weld.serialization.spi.ContextualStore;
-import org.jboss.weld.xml.EnabledClasses;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;