Author: pete.muir(a)jboss.org
Date: 2009-04-03 08:19:31 -0400 (Fri, 03 Apr 2009)
New Revision: 2294
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/ClassTransformer.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/EjbDescriptorCache.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/NonContextualInjector.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/AnnotationModel.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/BindingTypeModel.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MetaDataCache.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/ScopeModel.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/StereotypeModel.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockXmlEnvironment.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/DefaultResourceLoader.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlEnvironment.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlParser.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SessionBeanElementChecker.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SimpleBeanElementChecker.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/StereotypesTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/NewEnterpriseBeanTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/annotatedItem/ClassAnnotatedItemTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/xml/deploy/BeansXmlParserTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/xml/parser/XmlParserImplTest.java
Log:
tidy up usage of ejb descriptors, start on moving all creation of annotated items to a
single stateful location suitable for exposing via SPI
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java 2009-04-02 21:29:06
UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java 2009-04-03 12:19:31
UTC (rev 2294)
@@ -104,6 +104,7 @@
// The enabled deployment types from web-beans.xml
private transient List<Class<? extends Annotation>>
enabledDeploymentTypes;
+
// The Web Beans event manager
private transient final EventManager eventManager;
@@ -118,25 +119,20 @@
// The registered contexts
private transient final ContextMap contextMap;
+
// The client proxy pool
private transient final ClientProxyProvider clientProxyProvider;
+
// The registered beans
private transient List<Bean<?>> beans;
+
// The registered beans, mapped by implementation class
private transient final Map<Class<?>, EnterpriseBean<?>>
newEnterpriseBeanMap;
private transient final Map<String, RIBean<?>> riBeans;
-
- // The registered decorators
- private transient final Set<Decorator> decorators;
- // The registered interceptors
- private transient final Set<Interceptor> interceptors;
-
- // The EJB resolver provided by the container
+
private transient final ServiceRegistry services;
- private transient final EjbDescriptorCache ejbDescriptorCache;
-
private final transient Map<Bean<?>, Bean<?>> specializedBeans;
private final transient NonContextualInjector nonContextualInjector;
@@ -154,11 +150,8 @@
this.riBeans = new ConcurrentHashMap<String, RIBean<?>>();
this.resolver = new Resolver(this);
this.clientProxyProvider = new ClientProxyProvider();
- this.decorators = new HashSet<Decorator>();
- this.interceptors = new HashSet<Interceptor>();
this.contextMap = new ContextMap();
this.eventManager = new EventManager(this);
- this.ejbDescriptorCache = new EjbDescriptorCache();
this.currentInjectionPoint = new ThreadLocal<Stack<InjectionPoint>>()
{
@Override
@@ -460,8 +453,7 @@
*/
public Manager addDecorator(Decorator decorator)
{
- decorators.add(decorator);
- return this;
+ throw new UnsupportedOperationException("Not yet implemented");
}
/**
@@ -474,8 +466,7 @@
*/
public Manager addInterceptor(Interceptor interceptor)
{
- interceptors.add(interceptor);
- return this;
+ throw new UnsupportedOperationException("Not yet implemented");
}
/**
@@ -874,11 +865,6 @@
return resolver;
}
- public EjbDescriptorCache getEjbDescriptorCache()
- {
- return ejbDescriptorCache;
- }
-
/**
* Gets a string representation
*
@@ -892,8 +878,6 @@
buffer.append("Enabled deployment types: " + getEnabledDeploymentTypes()
+ "\n");
buffer.append("Registered contexts: " + contextMap.keySet() +
"\n");
buffer.append("Registered beans: " + getBeans().size() +
"\n");
- buffer.append("Registered decorators: " + decorators.size() +
"\n");
- buffer.append("Registered interceptors: " + interceptors.size() +
"\n");
buffer.append("Specialized beans: " + specializedBeans.size() +
"\n");
return buffer.toString();
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-04-02
21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -144,7 +144,7 @@
mergedStereotypes = new MergedStereotypes<T,
E>(getAnnotatedItem().getMetaAnnotations(Stereotype.class), manager);
if (isSpecializing())
{
- preSpecialize();
+ preSpecialize(environment);
specialize(environment);
postSpecialize();
}
@@ -348,7 +348,7 @@
manager.getSpecializedBeans().put(getSpecializedBean(), this);
}
- protected void preSpecialize()
+ protected void preSpecialize(BeanDeployerEnvironment environment)
{
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-04-02
21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -277,9 +277,9 @@
}
@Override
- protected void preSpecialize()
+ protected void preSpecialize(BeanDeployerEnvironment environment)
{
- super.preSpecialize();
+ super.preSpecialize(environment);
if (getAnnotatedItem().getSuperclass() == null ||
getAnnotatedItem().getSuperclass().getRawType().equals(Object.class))
{
throw new DefinitionException("Specializing bean must extend another bean
" + toString());
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-04-02
21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -17,6 +17,7 @@
package org.jboss.webbeans.bean;
+import java.beans.BeanDescriptor;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.Arrays;
@@ -41,6 +42,7 @@
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.context.DependentStorageRequest;
+import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.ejb.InternalEjbDescriptor;
import org.jboss.webbeans.ejb.api.SessionObjectReference;
import org.jboss.webbeans.ejb.spi.BusinessInterfaceDescriptor;
@@ -77,9 +79,9 @@
* @param manager the current manager
* @return An Enterprise Web Bean
*/
- public static <T> EnterpriseBean<T> of(AnnotatedClass<T> clazz,
RootManager manager)
+ public static <T> EnterpriseBean<T> of(AnnotatedClass<T> clazz,
RootManager manager, BeanDeployerEnvironment environment)
{
- return new EnterpriseBean<T>(clazz, manager);
+ return new EnterpriseBean<T>(clazz, manager, environment);
}
/**
@@ -88,11 +90,11 @@
* @param type The type of the bean
* @param manager The Web Beans manager
*/
- protected EnterpriseBean(AnnotatedClass<T> type, RootManager manager)
+ protected EnterpriseBean(AnnotatedClass<T> type, RootManager manager,
BeanDeployerEnvironment environment)
{
super(type, manager);
initType();
- Iterable<InternalEjbDescriptor<T>> ejbDescriptors =
manager.getEjbDescriptorCache().get(getType());
+ Iterable<InternalEjbDescriptor<T>> ejbDescriptors =
environment.getEjbDescriptors().get(getType());
if (ejbDescriptors == null)
{
throw new DefinitionException("Not an EJB " + toString());
@@ -189,10 +191,11 @@
/**
* Validates specialization
*/
- protected void preSpecialize()
+ @Override
+ protected void preSpecialize(BeanDeployerEnvironment environment)
{
- super.preSpecialize();
- if
(!manager.getEjbDescriptorCache().containsKey(getAnnotatedItem().getSuperclass().getRawType()))
+ super.preSpecialize(environment);
+ if
(!environment.getEjbDescriptors().containsKey(getAnnotatedItem().getSuperclass().getRawType()))
{
throw new DefinitionException("Annotation defined specializing EJB must
have EJB superclass");
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java 2009-04-02
21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -25,6 +25,7 @@
import javax.inject.Standard;
import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.literal.NewLiteral;
@@ -44,9 +45,9 @@
* @param manager The Web Beans manager
* @return a new NewEnterpriseBean instance
*/
- public static <T> NewEnterpriseBean<T> of(AnnotatedClass<T> clazz,
RootManager manager)
+ public static <T> NewEnterpriseBean<T> of(AnnotatedClass<T> clazz,
RootManager manager, BeanDeployerEnvironment environment)
{
- return new NewEnterpriseBean<T>(clazz, manager);
+ return new NewEnterpriseBean<T>(clazz, manager, environment);
}
/**
@@ -55,9 +56,9 @@
* @param type An annotated class
* @param manager The Web Beans manager
*/
- protected NewEnterpriseBean(AnnotatedClass<T> type, RootManager manager)
+ protected NewEnterpriseBean(AnnotatedClass<T> type, RootManager manager,
BeanDeployerEnvironment environment)
{
- super(type, manager);
+ super(type, manager, environment);
}
/**
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-04-02
21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -248,7 +248,7 @@
}
@Override
- protected void preSpecialize()
+ protected void preSpecialize(BeanDeployerEnvironment environment)
{
if
(declaringBean.getAnnotatedItem().getSuperclass().getDeclaredMethod(getAnnotatedItem().getAnnotatedMethod())
== null)
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-04-02
21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -355,10 +355,10 @@
}
@Override
- protected void preSpecialize()
+ protected void preSpecialize(BeanDeployerEnvironment environment)
{
- super.preSpecialize();
- if
(manager.getEjbDescriptorCache().containsKey(getAnnotatedItem().getSuperclass().getRawType()))
+ super.preSpecialize(environment);
+ if
(environment.getEjbDescriptors().containsKey(getAnnotatedItem().getSuperclass().getRawType()))
{
throw new DefinitionException("Simple bean must specialize a simple
bean");
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-04-02
21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -25,6 +25,7 @@
import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.bean.SimpleBean;
import org.jboss.webbeans.ejb.EJBApiAbstraction;
+import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.event.ObserverFactory;
import org.jboss.webbeans.event.ObserverImpl;
import org.jboss.webbeans.introspector.AnnotatedClass;
@@ -37,6 +38,8 @@
import org.jboss.webbeans.jsf.JSFApiAbstraction;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.resources.ClassTransformer;
+import org.jboss.webbeans.resources.spi.ResourceLoader;
import org.jboss.webbeans.servlet.ServletApiAbstraction;
import org.jboss.webbeans.util.Reflections;
@@ -45,20 +48,23 @@
private static final LogProvider log = Logging.getLogProvider(BeanDeployer.class);
- private final BeanDeployerEnvironment beanDeployerEnvironment;
+ private final BeanDeployerEnvironment environment;
private final Set<AnnotatedClass<?>> classes;
private final RootManager manager;
+ private final ClassTransformer classTransformer;
- public BeanDeployer(RootManager manager)
+
+ public BeanDeployer(RootManager manager, EjbDescriptorCache ejbDescriptors)
{
this.manager = manager;
- this.beanDeployerEnvironment = new BeanDeployerEnvironment();
+ this.environment = new BeanDeployerEnvironment(ejbDescriptors);
this.classes = new HashSet<AnnotatedClass<?>>();
+ this.classTransformer = new ClassTransformer();
}
public <T> BeanDeployer addBean(RIBean<T> bean)
{
- this.beanDeployerEnvironment.addBean(bean);
+ this.environment.addBean(bean);
return this;
}
@@ -66,7 +72,7 @@
{
if (!clazz.isAnnotation() && !clazz.isEnum())
{
- classes.add(AnnotatedClassImpl.of(clazz));
+ classes.add(classTransformer.classForName(clazz));
}
return this;
}
@@ -90,7 +96,7 @@
{
for (AnnotatedClass<?> clazz : classes)
{
- if (manager.getEjbDescriptorCache().containsKey(clazz.getRawType()))
+ if (environment.getEjbDescriptors().containsKey(clazz.getRawType()))
{
createEnterpriseBean(clazz);
}
@@ -104,14 +110,14 @@
public BeanDeployer deploy()
{
- Set<RIBean<?>> beans = beanDeployerEnvironment.getBeans();
+ Set<RIBean<?>> beans = environment.getBeans();
for (RIBean<?> bean : beans)
{
- bean.initialize(beanDeployerEnvironment);
+ bean.initialize(environment);
log.info("Bean: " + bean);
}
manager.setBeans(beans);
- for (ObserverImpl<?> observer : beanDeployerEnvironment.getObservers())
+ for (ObserverImpl<?> observer : environment.getObservers())
{
observer.initialize();
log.info("Observer : " + observer);
@@ -126,8 +132,8 @@
private void checkDisposalMethods() {
- Set<DisposalMethodBean<?>> all = new
HashSet<DisposalMethodBean<?>>(beanDeployerEnvironment.getAllDisposalBeans());
- Set<DisposalMethodBean<?>> resolved = new
HashSet<DisposalMethodBean<?>>(beanDeployerEnvironment.getResolvedDisposalBeans());
+ Set<DisposalMethodBean<?>> all = new
HashSet<DisposalMethodBean<?>>(environment.getAllDisposalBeans());
+ Set<DisposalMethodBean<?>> resolved = new
HashSet<DisposalMethodBean<?>>(environment.getResolvedDisposalBeans());
if(all.size()>0 && !resolved.containsAll(all)) {
StringBuffer buff = new StringBuffer();
buff.append("The following Disposal methods where not resolved\n");
@@ -141,7 +147,7 @@
public BeanDeployerEnvironment getBeanDeployerEnvironment()
{
- return beanDeployerEnvironment;
+ return environment;
}
/**
@@ -186,7 +192,7 @@
for (AnnotatedMethod<?> method :
annotatedClass.getDeclaredMethodsWithAnnotatedParameters(Disposes.class))
{
DisposalMethodBean<?> disposalBean = DisposalMethodBean.of(manager,
method, declaringBean);
- beanDeployerEnvironment.addAllDisposalBean(disposalBean);
+ environment.addAllDisposalBean(disposalBean);
manager.getResolver().addInjectionPoints(disposalBean.getInjectionPoints());
manager.addBean(disposalBean);
}
@@ -247,7 +253,7 @@
private void createObserverMethod(AbstractClassBean<?> declaringBean,
AnnotatedMethod<?> method)
{
ObserverImpl<?> observer = ObserverFactory.create(method, declaringBean,
manager);
- beanDeployerEnvironment.getObservers().add(observer);
+ environment.getObservers().add(observer);
}
private <T> void createSimpleBean(AnnotatedClass<T> annotatedClass)
@@ -260,9 +266,9 @@
private <T> void createEnterpriseBean(AnnotatedClass<T> annotatedClass)
{
// TODO Don't create enterprise bean if it has no local interfaces!
- EnterpriseBean<T> bean = EnterpriseBean.of(annotatedClass, manager);
+ EnterpriseBean<T> bean = EnterpriseBean.of(annotatedClass, manager,
environment);
createBean(bean, annotatedClass);
- addBean(NewEnterpriseBean.of(annotatedClass, manager));
+ addBean(NewEnterpriseBean.of(annotatedClass, manager, environment));
}
/**
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java 2009-04-02
21:29:06 UTC (rev 2293)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -12,6 +12,7 @@
import org.jboss.webbeans.bean.NewBean;
import org.jboss.webbeans.bean.ProducerMethodBean;
import org.jboss.webbeans.bean.RIBean;
+import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.event.ObserverImpl;
import org.jboss.webbeans.injection.resolution.ResolvableAnnotatedClass;
import org.jboss.webbeans.introspector.AnnotatedClass;
@@ -29,8 +30,9 @@
private final Set<ObserverImpl<?>> observers;
private final Set<DisposalMethodBean<?>> allDisposalBeans;
private final Set<DisposalMethodBean<?>> resolvedDisposalBeans;
+ private final EjbDescriptorCache ejbDescriptors;
- public BeanDeployerEnvironment()
+ public BeanDeployerEnvironment(EjbDescriptorCache ejbDescriptors)
{
this.classBeanMap = new HashMap<AnnotatedClass<?>,
AbstractClassBean<?>>();
this.methodBeanMap = new HashMap<AnnotatedMethod<?>,
ProducerMethodBean<?>>();
@@ -38,6 +40,7 @@
this.resolvedDisposalBeans = new HashSet<DisposalMethodBean<?>>();
this.beans = new HashSet<RIBean<?>>();
this.observers = new HashSet<ObserverImpl<?>>();
+ this.ejbDescriptors = ejbDescriptors;
}
public ProducerMethodBean<?> getProducerMethod(AnnotatedMethod<?> method)
@@ -113,5 +116,10 @@
{
return resolvedDisposalBeans;
}
+
+ public EjbDescriptorCache getEjbDescriptors()
+ {
+ return ejbDescriptors;
+ }
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-04-02
21:29:06 UTC (rev 2293)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -47,6 +47,7 @@
import org.jboss.webbeans.conversation.NumericConversationIdGenerator;
import org.jboss.webbeans.conversation.ServletConversationManager;
import org.jboss.webbeans.ejb.EJBApiAbstraction;
+import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.ejb.spi.EjbServices;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.jsf.JSFApiAbstraction;
@@ -55,6 +56,7 @@
import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.metadata.MetaDataCache;
+import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.resources.DefaultNamingContext;
import org.jboss.webbeans.resources.DefaultResourceLoader;
import org.jboss.webbeans.resources.spi.NamingContext;
@@ -120,7 +122,12 @@
getServices().add(EJBApiAbstraction.class, new EJBApiAbstraction(resourceLoader));
getServices().add(JSFApiAbstraction.class, new JSFApiAbstraction(resourceLoader));
getServices().add(ServletApiAbstraction.class, new
ServletApiAbstraction(resourceLoader));
- getServices().add(MetaDataCache.class, new MetaDataCache());
+ // Temporary workaround to provide context for building annotated class
+ // TODO expose AnnotatedClass on SPI and allow container to provide impl of this
via ResourceLoader
+ getServices().add(ClassTransformer.class, new ClassTransformer());
+ getServices().add(MetaDataCache.class, new
MetaDataCache(getServices().get(ClassTransformer.class)));
+
+
}
public RootManager getManager()
@@ -134,9 +141,9 @@
*
* @param classes The classes to register as Web Beans
*/
- protected void registerBeans(Iterable<Class<?>> classes,
Collection<AnnotatedClass<?>> xmlClasses)
+ protected void registerBeans(Iterable<Class<?>> classes,
Collection<AnnotatedClass<?>> xmlClasses, EjbDescriptorCache ejbDescriptors)
{
- BeanDeployer beanDeployer = new BeanDeployer(manager);
+ BeanDeployer beanDeployer = new BeanDeployer(manager, ejbDescriptors);
beanDeployer.addClasses(classes);
beanDeployer.addClasses(xmlClasses);
beanDeployer.addBean(ManagerBean.of(manager));
@@ -170,22 +177,25 @@
beginApplication(getApplicationContext());
BeanStore requestBeanStore = new ConcurrentHashMapBeanStore();
beginDeploy(requestBeanStore);
+ EjbDescriptorCache ejbDescriptors = new EjbDescriptorCache();
if (getServices().contains(EjbServices.class))
{
// Must populate EJB cache first, as we need it to detect whether a
// bean is an EJB!
-
manager.getEjbDescriptorCache().addAll(getServices().get(EjbServices.class).discoverEjbs());
+ ejbDescriptors.addAll(getServices().get(EjbServices.class).discoverEjbs());
}
- XmlEnvironment xmlEnvironmentImpl = new XmlEnvironment(getServices());
+
+ XmlEnvironment xmlEnvironmentImpl = new XmlEnvironment(getServices(),
ejbDescriptors);
XmlParser parser = new XmlParser(xmlEnvironmentImpl);
parser.parse();
+
List<Class<? extends Annotation>> enabledDeploymentTypes =
xmlEnvironmentImpl.getEnabledDeploymentTypes();
if (enabledDeploymentTypes.size() > 0)
{
manager.setEnabledDeploymentTypes(enabledDeploymentTypes);
}
log.info("Deployment types: " + manager.getEnabledDeploymentTypes());
-
registerBeans(getServices().get(WebBeanDiscovery.class).discoverWebBeanClasses(),
xmlEnvironmentImpl.getClasses());
+
registerBeans(getServices().get(WebBeanDiscovery.class).discoverWebBeanClasses(),
xmlEnvironmentImpl.getClasses(), ejbDescriptors);
manager.fireEvent(manager, new InitializedLiteral());
log.info("Web Beans initialized. Validating beans.");
manager.getResolver().resolveInjectionPoints();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/EjbDescriptorCache.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/EjbDescriptorCache.java 2009-04-02
21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/EjbDescriptorCache.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -17,10 +17,9 @@
package org.jboss.webbeans.ejb;
-import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArraySet;
import org.jboss.webbeans.ejb.spi.EjbDescriptor;
@@ -31,22 +30,21 @@
* @author Pete Muir
*
*/
-public class EjbDescriptorCache implements Serializable
+public class EjbDescriptorCache
{
- private static final long serialVersionUID = 1L;
// EJB name -> EJB descriptor map
- private ConcurrentMap<String, InternalEjbDescriptor<?>> ejbsByName;
+ private Map<String, InternalEjbDescriptor<?>> ejbsByName;
// EJB implementation class -> EJB descriptors map
- private ConcurrentMap<Class<?>, Set<InternalEjbDescriptor<?>>>
ejbsByBeanClass;
+ private Map<Class<?>, Set<InternalEjbDescriptor<?>>>
ejbsByBeanClass;
/**
* Constructor
*/
public EjbDescriptorCache()
{
- this.ejbsByName = new ConcurrentHashMap<String,
InternalEjbDescriptor<?>>();
- this.ejbsByBeanClass = new ConcurrentHashMap<Class<?>,
Set<InternalEjbDescriptor<?>>>();
+ this.ejbsByName = new HashMap<String, InternalEjbDescriptor<?>>();
+ this.ejbsByBeanClass = new HashMap<Class<?>,
Set<InternalEjbDescriptor<?>>>();
}
/**
@@ -81,7 +79,10 @@
{
InternalEjbDescriptor<T> internalEjbDescriptor = new
InternalEjbDescriptor<T>(ejbDescriptor);
ejbsByName.put(ejbDescriptor.getEjbName(), internalEjbDescriptor);
- ejbsByBeanClass.putIfAbsent(ejbDescriptor.getType(), new
CopyOnWriteArraySet<InternalEjbDescriptor<?>>());
+ if (!ejbsByBeanClass.containsKey(ejbDescriptor.getType()))
+ {
+ ejbsByBeanClass.put(ejbDescriptor.getType(), new
CopyOnWriteArraySet<InternalEjbDescriptor<?>>());
+ }
ejbsByBeanClass.get(ejbDescriptor.getType()).add(internalEjbDescriptor);
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/NonContextualInjector.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/NonContextualInjector.java 2009-04-02
21:29:06 UTC (rev 2293)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/NonContextualInjector.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -5,6 +5,7 @@
import org.jboss.webbeans.RootManager;
import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
+import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.collections.ConcurrentCache;
@@ -27,7 +28,7 @@
public Set<FieldInjectionPoint<?>> call() throws Exception
{
- return
Beans.getFieldInjectionPoints(AnnotatedClassImpl.of(instance.getClass()), null);
+ return
Beans.getFieldInjectionPoints(manager.getServices().get(ClassTransformer.class).classForName(instance.getClass()),
null);
}
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java 2009-04-02
21:29:06 UTC (rev 2293)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -23,6 +23,7 @@
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.introspector.AnnotatedType;
import org.jboss.webbeans.introspector.AnnotationStore;
+import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.util.Reflections;
/**
@@ -53,14 +54,14 @@
*
* @param annotationMap The annotation map
*/
- public AbstractAnnotatedType(AnnotationStore annotatedItemHelper, Class<T>
rawType, Type type)
+ public AbstractAnnotatedType(AnnotationStore annotatedItemHelper, Class<T>
rawType, Type type, ClassTransformer classTransformer)
{
super(annotatedItemHelper, rawType, type);
this.name = rawType.getName();
this._simpleName = rawType.getSimpleName();
if (rawType.getSuperclass() != null)
{
- this.superclass = AnnotatedClassImpl.of(rawType.getSuperclass());
+ this.superclass = classTransformer.classForName(rawType.getSuperclass());
}
else
{
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java 2009-04-02
21:29:06 UTC (rev 2293)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -29,6 +29,7 @@
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.AnnotationStore;
+import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.util.Strings;
import org.jboss.webbeans.util.collections.ForwardingMap;
@@ -99,9 +100,9 @@
// Cached string representation
private String toString;
- public static <A extends Annotation> AnnotatedAnnotation<A>
of(Class<A> annotationType)
+ public static <A extends Annotation> AnnotatedAnnotation<A>
of(Class<A> annotationType, ClassTransformer classTransformer)
{
- return new AnnotatedAnnotationImpl<A>(annotationType);
+ return new AnnotatedAnnotationImpl<A>(annotationType, classTransformer);
}
/**
@@ -111,9 +112,9 @@
*
* @param annotationType The annotation type
*/
- public AnnotatedAnnotationImpl(Class<T> annotationType)
+ protected AnnotatedAnnotationImpl(Class<T> annotationType, ClassTransformer
classTransformer)
{
- super(AnnotationStore.of(annotationType), annotationType, annotationType);
+ super(AnnotationStore.of(annotationType), annotationType, annotationType,
classTransformer);
this.clazz = annotationType;
members = new HashSet<AnnotatedMethod<?>>();
annotatedMembers = new AnnotatedMemberMap();
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java 2009-04-02
21:29:06 UTC (rev 2293)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -37,6 +37,7 @@
import org.jboss.webbeans.introspector.AnnotationStore;
import org.jboss.webbeans.introspector.ConstructorSignature;
import org.jboss.webbeans.introspector.MethodSignature;
+import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.util.Names;
import org.jboss.webbeans.util.Reflections;
import org.jboss.webbeans.util.Strings;
@@ -262,14 +263,14 @@
private final boolean _enum;
- public static <T> AnnotatedClass<T> of(Class<T> clazz)
+ public static <T> AnnotatedClass<T> of(Class<T> clazz,
ClassTransformer classTransformer)
{
- return new AnnotatedClassImpl<T>(clazz, clazz, clazz.getAnnotations(),
clazz.getDeclaredAnnotations());
+ return new AnnotatedClassImpl<T>(clazz, clazz, clazz.getAnnotations(),
clazz.getDeclaredAnnotations(), classTransformer);
}
- private AnnotatedClassImpl(Class<T> rawType, Type type, Annotation[]
annotations, Annotation[] declaredAnnotations)
+ private AnnotatedClassImpl(Class<T> rawType, Type type, Annotation[]
annotations, Annotation[] declaredAnnotations, ClassTransformer classTransformer)
{
- super(AnnotationStore.of(annotations, declaredAnnotations), rawType, type);
+ super(AnnotationStore.of(annotations, declaredAnnotations), rawType, type,
classTransformer);
this.fields = new HashSet<AnnotatedField<?>>();
this.annotatedFields = new AnnotatedFieldMap();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/AnnotationModel.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/AnnotationModel.java 2009-04-02
21:29:06 UTC (rev 2293)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/AnnotationModel.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -23,6 +23,7 @@
import org.jboss.webbeans.introspector.AnnotatedAnnotation;
import org.jboss.webbeans.introspector.jlr.AnnotatedAnnotationImpl;
+import org.jboss.webbeans.resources.ClassTransformer;
/**
* Abstract representation of an annotation model
@@ -41,9 +42,9 @@
*
* @param type The annotation type
*/
- public AnnotationModel(Class<T> type)
+ public AnnotationModel(Class<T> type, ClassTransformer transformer)
{
- this.annotatedAnnotation = new AnnotatedAnnotationImpl<T>(type);
+ this.annotatedAnnotation = transformer.classForName(type);
init();
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/BindingTypeModel.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/BindingTypeModel.java 2009-04-02
21:29:06 UTC (rev 2293)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/BindingTypeModel.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -27,6 +27,7 @@
import javax.inject.ExecutionException;
import org.jboss.webbeans.introspector.AnnotatedMethod;
+import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.util.Reflections;
/**
@@ -46,9 +47,9 @@
*
* @param type The type
*/
- public BindingTypeModel(Class<T> type)
+ public BindingTypeModel(Class<T> type, ClassTransformer transformer)
{
- super(type);
+ super(type, transformer);
}
/**
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MetaDataCache.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MetaDataCache.java 2009-04-02
21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MetaDataCache.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -21,6 +21,7 @@
import java.util.concurrent.Callable;
import org.jboss.webbeans.bootstrap.api.Service;
+import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.util.collections.ConcurrentCache;
/**
@@ -38,7 +39,14 @@
private ConcurrentCache<Class<? extends Annotation>, ScopeModel<?>>
scopes = new ConcurrentCache<Class<? extends Annotation>,
ScopeModel<?>>();
// The binding type models
private ConcurrentCache<Class<? extends Annotation>,
BindingTypeModel<?>> bindingTypes = new ConcurrentCache<Class<? extends
Annotation>, BindingTypeModel<?>>();
+
+ private final ClassTransformer classTransformer;
+ public MetaDataCache(ClassTransformer classTransformer)
+ {
+ this.classTransformer = classTransformer;
+ }
+
/**
* Gets a stereotype model
*
@@ -55,7 +63,7 @@
public StereotypeModel<T> call() throws Exception
{
- return new StereotypeModel<T>(stereotype);
+ return new StereotypeModel<T>(stereotype, classTransformer);
}
});
}
@@ -76,7 +84,7 @@
public ScopeModel<T> call() throws Exception
{
- return new ScopeModel<T>(scopeType);
+ return new ScopeModel<T>(scopeType, classTransformer);
}
});
@@ -98,7 +106,7 @@
public BindingTypeModel<T> call() throws Exception
{
- return new BindingTypeModel<T>(bindingType);
+ return new BindingTypeModel<T>(bindingType, classTransformer);
}
});
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/ScopeModel.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/ScopeModel.java 2009-04-02
21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/ScopeModel.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -21,6 +21,8 @@
import javax.context.ScopeType;
+import org.jboss.webbeans.resources.ClassTransformer;
+
/**
*
* Model of a scope
@@ -35,9 +37,9 @@
*
* @param scope The scope type
*/
- public ScopeModel(Class<T> scope)
+ public ScopeModel(Class<T> scope, ClassTransformer classTransformer)
{
- super(scope);
+ super(scope, classTransformer);
}
/**
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/StereotypeModel.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/StereotypeModel.java 2009-04-02
21:29:06 UTC (rev 2293)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/StereotypeModel.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -30,6 +30,8 @@
import javax.inject.DeploymentType;
import javax.interceptor.InterceptorBindingType;
+import org.jboss.webbeans.resources.ClassTransformer;
+
/**
* A meta model for a stereotype, allows us to cache a stereotype and to
* validate it
@@ -57,9 +59,9 @@
*
* @param sterotype The stereotype
*/
- public StereotypeModel(Class<T> sterotype)
+ public StereotypeModel(Class<T> sterotype, ClassTransformer transformer)
{
- super(sterotype);
+ super(sterotype, transformer);
initDefaultDeploymentType();
initDefaultScopeType();
initBeanNameDefaulted();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockXmlEnvironment.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockXmlEnvironment.java 2009-04-02
21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockXmlEnvironment.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -4,6 +4,8 @@
import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
import org.jboss.webbeans.bootstrap.api.helpers.SimpleServiceRegistry;
+import org.jboss.webbeans.ejb.EjbDescriptorCache;
+import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.resources.DefaultResourceLoader;
import org.jboss.webbeans.resources.spi.ResourceLoader;
import org.jboss.webbeans.xml.XmlEnvironment;
@@ -17,11 +19,12 @@
{
services = new SimpleServiceRegistry();
services.add(ResourceLoader.class, new DefaultResourceLoader());
+ services.add(ClassTransformer.class, new ClassTransformer());
}
- public MockXmlEnvironment(Iterable<URL> beansXmlUrls)
+ public MockXmlEnvironment(Iterable<URL> beansXmlUrls, EjbDescriptorCache
ejbDescriptors)
{
- super(services, beansXmlUrls);
+ super(services, beansXmlUrls, ejbDescriptors);
}
}
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/ClassTransformer.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/ClassTransformer.java
(rev 0)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/ClassTransformer.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -0,0 +1,24 @@
+package org.jboss.webbeans.resources;
+
+import java.lang.annotation.Annotation;
+
+import org.jboss.webbeans.bootstrap.api.Service;
+import org.jboss.webbeans.introspector.AnnotatedAnnotation;
+import org.jboss.webbeans.introspector.AnnotatedClass;
+import org.jboss.webbeans.introspector.jlr.AnnotatedAnnotationImpl;
+import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
+
+public class ClassTransformer implements Service
+{
+
+ public <T> AnnotatedClass<T> classForName(Class<T> clazz)
+ {
+ return AnnotatedClassImpl.of(clazz, this);
+ }
+
+ public <T extends Annotation> AnnotatedAnnotation<T>
classForName(Class<T> clazz)
+ {
+ return AnnotatedAnnotationImpl.of(clazz, this);
+ }
+
+}
Property changes on:
ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/ClassTransformer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/DefaultResourceLoader.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/DefaultResourceLoader.java 2009-04-02
21:29:06 UTC (rev 2293)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/DefaultResourceLoader.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -19,6 +19,8 @@
import java.io.IOException;
import java.net.URL;
+import org.jboss.webbeans.introspector.AnnotatedClass;
+import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
import org.jboss.webbeans.resources.spi.ResourceLoader;
import org.jboss.webbeans.resources.spi.ResourceLoadingException;
import org.jboss.webbeans.util.EnumerationIterable;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlEnvironment.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlEnvironment.java 2009-04-02
21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlEnvironment.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -7,9 +7,11 @@
import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
+import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.introspector.AnnotatedAnnotation;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
+import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.resources.spi.ResourceLoader;
public class XmlEnvironment
@@ -20,19 +22,21 @@
private final ServiceRegistry serviceRegistry;
private final List<Class<? extends Annotation>> enabledDeploymentTypes;
private final Iterable<URL> beansXmlUrls;
+ private final EjbDescriptorCache ejbDescriptors;
- public XmlEnvironment(ServiceRegistry serviceRegistry)
+ public XmlEnvironment(ServiceRegistry serviceRegistry, EjbDescriptorCache
ejbDescriptors)
{
- this(serviceRegistry,
serviceRegistry.get(WebBeanDiscovery.class).discoverWebBeansXml());
+ this(serviceRegistry,
serviceRegistry.get(WebBeanDiscovery.class).discoverWebBeansXml(), ejbDescriptors);
}
- protected XmlEnvironment(ServiceRegistry serviceRegistry, Iterable<URL>
beanXmlUrls)
+ protected XmlEnvironment(ServiceRegistry serviceRegistry, Iterable<URL>
beanXmlUrls, EjbDescriptorCache ejbDescriptors)
{
this.classes = new ArrayList<AnnotatedClass<?>>();
this.annotations = new ArrayList<AnnotatedAnnotation<?>>();
this.enabledDeploymentTypes = new ArrayList<Class<? extends
Annotation>>();
this.serviceRegistry = serviceRegistry;
this.beansXmlUrls = beanXmlUrls;
+ this.ejbDescriptors = ejbDescriptors;
}
public List<AnnotatedClass<?>> getClasses()
@@ -52,7 +56,7 @@
public <T> AnnotatedClass<? extends T> loadClass(String className,
Class<T> expectedType)
{
- return
AnnotatedClassImpl.of(serviceRegistry.get(ResourceLoader.class).classForName(className).asSubclass(expectedType));
+ return
serviceRegistry.get(ClassTransformer.class).classForName((serviceRegistry.get(ResourceLoader.class).classForName(className).asSubclass(expectedType)));
}
public <T extends Annotation> Class<? extends T> loadAnnotation(String
className, Class<T> expectedType)
@@ -65,6 +69,11 @@
return enabledDeploymentTypes;
}
+ public EjbDescriptorCache getEjbDescriptors()
+ {
+ return ejbDescriptors;
+ }
+
public URL loadFileByUrn(String urn, String fileName)
{
char separator = '/';
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlParser.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlParser.java 2009-04-02 21:29:06
UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlParser.java 2009-04-03 12:19:31
UTC (rev 2294)
@@ -206,8 +206,8 @@
{
beanElementCheckers.add(new JmsResourceElementChecker(new
NotSimpleBeanChildrenChecker(environment, packagesMap)));
beanElementCheckers.add(new ResourceElementChecker(new
NotSimpleBeanChildrenChecker(environment, packagesMap)));
- beanElementCheckers.add(new SessionBeanElementChecker(new
NotSimpleBeanChildrenChecker(environment, packagesMap)));
- beanElementCheckers.add(new SimpleBeanElementChecker(new
SimpleBeanChildrenChecker(environment, packagesMap)));
+ beanElementCheckers.add(new SessionBeanElementChecker(new
NotSimpleBeanChildrenChecker(environment, packagesMap),
environment.getEjbDescriptors()));
+ beanElementCheckers.add(new SimpleBeanElementChecker(new
SimpleBeanChildrenChecker(environment, packagesMap), environment.getEjbDescriptors()));
boolean isValidType = false;
for(BeanElementChecker beanElementChecker : beanElementCheckers)
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SessionBeanElementChecker.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SessionBeanElementChecker.java 2009-04-02
21:29:06 UTC (rev 2293)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SessionBeanElementChecker.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -3,23 +3,29 @@
import org.dom4j.Element;
import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.xml.XmlConstants;
import org.jboss.webbeans.xml.checker.beanchildren.BeanChildrenChecker;
public class SessionBeanElementChecker extends NotSimpleBeanElementChecker
{
- public SessionBeanElementChecker(BeanChildrenChecker childrenChecker)
+
+ private final EjbDescriptorCache ejbDescriptors;
+
+ public SessionBeanElementChecker(BeanChildrenChecker childrenChecker,
EjbDescriptorCache ejbDescriptors)
{
super(childrenChecker);
+ this.ejbDescriptors = ejbDescriptors;
}
public boolean accept(Element beanElement, AnnotatedClass<?> beanClass)
{
- RootManager manager = CurrentManager.rootManager();
- if (manager.getEjbDescriptorCache().containsKey(beanElement.getName()) ||
+ if (ejbDescriptors.containsKey(beanElement.getName()) ||
beanElement.attribute(XmlConstants.EJB_NAME) != null)
+ {
return true;
+ }
return false;
}
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SimpleBeanElementChecker.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SimpleBeanElementChecker.java 2009-04-02
21:29:06 UTC (rev 2293)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SimpleBeanElementChecker.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -7,6 +7,7 @@
import org.dom4j.Element;
import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.xml.ParseXmlHelper;
import org.jboss.webbeans.xml.XmlConstants;
@@ -15,19 +16,24 @@
public class SimpleBeanElementChecker extends BeanElementCheckerImpl
{
- public SimpleBeanElementChecker(BeanChildrenChecker childrenChecker)
+
+ private final EjbDescriptorCache ejbDescriptors;
+
+ public SimpleBeanElementChecker(BeanChildrenChecker childrenChecker,
EjbDescriptorCache ejbDescriptors)
{
super(childrenChecker);
+ this.ejbDescriptors = ejbDescriptors;
}
public boolean accept(Element beanElement, AnnotatedClass<?> beanClass)
{
- RootManager manager = CurrentManager.rootManager();
- boolean isSessionBean =
manager.getEjbDescriptorCache().containsKey(beanElement.getName()) ||
+ boolean isSessionBean = ejbDescriptors.containsKey(beanElement.getName()) ||
beanElement.attribute(XmlConstants.EJB_NAME) !=
null;
if (!beanClass.isAbstract() && !isSessionBean &&
!beanClass.isParameterizedType())
+ {
return true;
+ }
return false;
}
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/StereotypesTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/StereotypesTest.java 2009-04-02
21:29:06 UTC (rev 2293)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/StereotypesTest.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -6,6 +6,7 @@
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.webbeans.metadata.StereotypeModel;
+import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.test.unit.AbstractWebBeansTest;
import org.testng.annotations.Test;
@@ -13,10 +14,12 @@
public class StereotypesTest extends AbstractWebBeansTest
{
+ private final ClassTransformer transformer = new ClassTransformer();
+
@Test
public void testAnimalStereotype()
{
- StereotypeModel<AnimalStereotype> animalStereotype = new
StereotypeModel<AnimalStereotype>(AnimalStereotype.class);
+ StereotypeModel<AnimalStereotype> animalStereotype = new
StereotypeModel<AnimalStereotype>(AnimalStereotype.class, transformer);
assert
animalStereotype.getDefaultScopeType().annotationType().equals(RequestScoped.class);
assert animalStereotype.getInterceptorBindings().size() == 0;
assert animalStereotype.getRequiredTypes().size() == 1;
@@ -29,7 +32,7 @@
@Test
public void testAnimalOrderStereotype()
{
- StereotypeModel<AnimalOrderStereotype> animalStereotype = new
StereotypeModel<AnimalOrderStereotype>(AnimalOrderStereotype.class);
+ StereotypeModel<AnimalOrderStereotype> animalStereotype = new
StereotypeModel<AnimalOrderStereotype>(AnimalOrderStereotype.class, transformer);
assert animalStereotype.getDefaultScopeType() == null;
assert animalStereotype.getInterceptorBindings().size() == 0;
assert animalStereotype.getRequiredTypes().size() == 2;
@@ -43,7 +46,7 @@
@Test
public void testRequestScopedAnimalStereotype()
{
- StereotypeModel<RequestScopedAnimalStereotype> animalStereotype = new
StereotypeModel<RequestScopedAnimalStereotype>(RequestScopedAnimalStereotype.class);
+ StereotypeModel<RequestScopedAnimalStereotype> animalStereotype = new
StereotypeModel<RequestScopedAnimalStereotype>(RequestScopedAnimalStereotype.class,
transformer);
assert animalStereotype.getDefaultScopeType() == null;
assert animalStereotype.getInterceptorBindings().size() == 0;
assert animalStereotype.getRequiredTypes().size() == 1;
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/NewEnterpriseBeanTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/NewEnterpriseBeanTest.java 2009-04-02
21:29:06 UTC (rev 2293)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/NewEnterpriseBeanTest.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -46,14 +46,6 @@
}
@Test(groups = { "new" })
- public void testNewBeanIsEnterpriseWebBeanIfParameterTypeIsEnterpriseWebBean()
- {
- initNewBean();
- assert wrappedEnterpriseBean.getType().equals(newEnterpriseBean.getType());
- assert manager.getEjbDescriptorCache().containsKey(newEnterpriseBean.getType());
- }
-
- @Test(groups = { "new" })
public void testNewBeanHasSameInitializerMethodsAsWrappedBean()
{
initNewBean();
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/annotatedItem/ClassAnnotatedItemTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/annotatedItem/ClassAnnotatedItemTest.java 2009-04-02
21:29:06 UTC (rev 2293)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/annotatedItem/ClassAnnotatedItemTest.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -11,17 +11,20 @@
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
+import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.test.unit.AbstractWebBeansTest;
import org.testng.annotations.Test;
@Artifact
public class ClassAnnotatedItemTest extends AbstractWebBeansTest
{
+
+ private final ClassTransformer transformer = new ClassTransformer();
@Test
public void testDeclaredAnnotations()
{
- AnnotatedClass<Order> annotatedElement = AnnotatedClassImpl.of(Order.class);
+ AnnotatedClass<Order> annotatedElement = AnnotatedClassImpl.of(Order.class,
transformer);
assert annotatedElement.getAnnotationsAsSet().size() == 1;
assert annotatedElement.getAnnotation(Production.class) != null;
assert annotatedElement.getRawType().equals(Order.class);
@@ -30,7 +33,7 @@
@Test
public void testMetaAnnotations()
{
- AnnotatedClass<Order> annotatedElement = AnnotatedClassImpl.of(Order.class);
+ AnnotatedClass<Order> annotatedElement = AnnotatedClassImpl.of(Order.class,
transformer);
Set<Annotation> annotations =
annotatedElement.getMetaAnnotations(DeploymentType.class);
assert annotations.size() == 1;
Iterator<Annotation> it = annotations.iterator();
@@ -41,10 +44,10 @@
@Test
public void testEmpty()
{
- AnnotatedClass<Order> annotatedElement = AnnotatedClassImpl.of(Order.class);
+ AnnotatedClass<Order> annotatedElement = AnnotatedClassImpl.of(Order.class,
transformer);
assert annotatedElement.getAnnotation(Stereotype.class) == null;
assert annotatedElement.getMetaAnnotations(Stereotype.class).size() == 0;
- AnnotatedClass<Antelope> classWithNoAnnotations =
AnnotatedClassImpl.of(Antelope.class);
+ AnnotatedClass<Antelope> classWithNoAnnotations =
AnnotatedClassImpl.of(Antelope.class, transformer);
assert classWithNoAnnotations.getAnnotationsAsSet().size() == 0;
}
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/xml/deploy/BeansXmlParserTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/xml/deploy/BeansXmlParserTest.java 2009-04-02
21:29:06 UTC (rev 2293)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/xml/deploy/BeansXmlParserTest.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -10,6 +10,7 @@
import org.jboss.testharness.impl.packaging.Classes;
import org.jboss.testharness.impl.packaging.Resource;
import org.jboss.testharness.impl.packaging.Resources;
+import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.mock.MockResourceLoader;
import org.jboss.webbeans.mock.MockXmlEnvironment;
import org.jboss.webbeans.resources.spi.ResourceLoader;
@@ -28,8 +29,6 @@
public class BeansXmlParserTest extends AbstractWebBeansTest
{
- private static final ResourceLoader RESOURCE_LOADER = new MockResourceLoader();
-
// Quick unit tests for the parser
@Test
public void testDefaultDeploymentTypes()
@@ -43,7 +42,7 @@
it.next();
}
assert i == 1;
- XmlEnvironment environment = new MockXmlEnvironment(urls);
+ XmlEnvironment environment = new MockXmlEnvironment(urls, new
EjbDescriptorCache());
XmlParser parser = new XmlParser(environment);
parser.parse();
@@ -56,7 +55,7 @@
public void testUserDefinedDeploymentType()
{
Iterable<URL> urls = getResources("user-defined-beans.xml");
- XmlEnvironment environment = new MockXmlEnvironment(urls);
+ XmlEnvironment environment = new MockXmlEnvironment(urls, new
EjbDescriptorCache());
XmlParser parser = new XmlParser(environment);
parser.parse();
assert environment.getEnabledDeploymentTypes().size() == 3;
@@ -72,7 +71,7 @@
public void testDuplicateDeployElement()
{
Iterable<URL> urls =
getResources("duplicate-deployments-beans.xml");
- XmlEnvironment environment = new MockXmlEnvironment(urls);
+ XmlEnvironment environment = new MockXmlEnvironment(urls, new
EjbDescriptorCache());
XmlParser parser = new XmlParser(environment);
parser.parse();
}
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/xml/parser/XmlParserImplTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/xml/parser/XmlParserImplTest.java 2009-04-02
21:29:06 UTC (rev 2293)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/xml/parser/XmlParserImplTest.java 2009-04-03
12:19:31 UTC (rev 2294)
@@ -21,6 +21,7 @@
import org.jboss.testharness.impl.packaging.Classes;
import org.jboss.testharness.impl.packaging.Resource;
import org.jboss.testharness.impl.packaging.Resources;
+import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.mock.MockXmlEnvironment;
@@ -44,7 +45,7 @@
//@Test
public void testParse()
{
- XmlEnvironment parserEnv = new
MockXmlEnvironment(getResources("beans.xml"));
+ XmlEnvironment parserEnv = new
MockXmlEnvironment(getResources("beans.xml"), new EjbDescriptorCache());
AnnotatedClass<?> aClass =
parserEnv.loadClass("org.jboss.webbeans.test.unit.xml.beans.Order",
Order.class);
Set<URL> xmls = new HashSet<URL>();