Skip to content

Commit

Permalink
Remove realization, remove stereotype requirements, impl BeforeBeanDi…
Browse files Browse the repository at this point in the history
…scovery

git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@2914 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Jun 28, 2009
1 parent 75d2d59 commit 2644e59
Show file tree
Hide file tree
Showing 61 changed files with 302 additions and 1,163 deletions.
Expand Up @@ -32,4 +32,6 @@ public interface BeforeBeanDiscovery
public void addStereotype(Class<? extends Annotation> stereotype, Annotation... stereotypeDef);

public void addInterceptorBindingType(Class<? extends Annotation> bindingType);

public void addAnnotatedType(AnnotatedType<?> type);
}
Expand Up @@ -20,7 +20,6 @@
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
Expand All @@ -35,21 +34,4 @@
@Retention(RUNTIME)
@Target(ANNOTATION_TYPE)
@Documented
public @interface Stereotype
{

/**
* Restrict the scope of the stereotyped bean
*
* @return the allowed scopes
*/
public Class<? extends Annotation>[] supportedScopes() default {};

/**
* Require that stereotype beans have certain API types
*
* @return the required types
*/
public Class<?>[] requiredTypes() default {};

}
public @interface Stereotype {}
40 changes: 0 additions & 40 deletions core-api/src/main/java/org/jboss/webbeans/Realizes.java

This file was deleted.

14 changes: 7 additions & 7 deletions impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
Expand Up @@ -86,7 +86,7 @@
import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.manager.api.WebBeansManager;
import org.jboss.webbeans.metadata.cache.MetaDataCache;
import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.Proxies;
import org.jboss.webbeans.util.Reflections;
Expand Down Expand Up @@ -359,7 +359,7 @@ public <T> Set<Observer<T>> resolveObservers(T event, Annotation... bindings)
Class<?> clazz = event.getClass();
for (Annotation annotation : bindings)
{
if (!getServices().get(MetaDataCache.class).getBindingTypeModel(annotation.annotationType()).isValid())
if (!getServices().get(MetaAnnotationStore.class).getBindingTypeModel(annotation.annotationType()).isValid())
{
throw new IllegalArgumentException("Not a binding type " + annotation);
}
Expand Down Expand Up @@ -463,7 +463,7 @@ public Set<Bean<?>> getBeans(WBAnnotated<?, ?> element, Annotation... bindings)
{
for (Annotation annotation : element.getAnnotations())
{
if (!getServices().get(MetaDataCache.class).getBindingTypeModel(annotation.annotationType()).isValid())
if (!getServices().get(MetaAnnotationStore.class).getBindingTypeModel(annotation.annotationType()).isValid())
{
throw new IllegalArgumentException("Not a binding type " + annotation);
}
Expand Down Expand Up @@ -704,7 +704,7 @@ public Object getReference(Bean<?> bean, CreationalContext<?> creationalContext)
{
creationalContext = ((CreationalContextImpl<?>) creationalContext).getCreationalContext(bean);
}
if (getServices().get(MetaDataCache.class).getScopeModel(bean.getScopeType()).isNormal())
if (getServices().get(MetaAnnotationStore.class).getScopeModel(bean.getScopeType()).isNormal())
{
if (creationalContext != null || (creationalContext == null && getContext(bean.getScopeType()).get(bean) != null))
{
Expand Down Expand Up @@ -742,7 +742,7 @@ public Object getInjectableReference(InjectionPoint injectionPoint, CreationalCo
}
WBAnnotated<?, ?> element = ResolvableWBClass.of(injectionPoint.getType(), injectionPoint.getBindings().toArray(new Annotation[0]), this);
Bean<?> resolvedBean = getBean(element, element.getBindingsAsArray());
if (getServices().get(MetaDataCache.class).getScopeModel(resolvedBean.getScopeType()).isNormal() && !Proxies.isTypeProxyable(injectionPoint.getType()))
if (getServices().get(MetaAnnotationStore.class).getScopeModel(resolvedBean.getScopeType()).isNormal() && !Proxies.isTypeProxyable(injectionPoint.getType()))
{
throw new UnproxyableResolutionException("Attempting to inject an unproxyable normal scoped bean " + resolvedBean + " into " + injectionPoint);
}
Expand Down Expand Up @@ -802,7 +802,7 @@ else if (beans.size() > 1)
throw new AmbiguousResolutionException(element + "Resolved multiple Web Beans");
}
Bean<T> bean = (Bean<T>) beans.iterator().next();
boolean normalScoped = getServices().get(MetaDataCache.class).getScopeModel(bean.getScopeType()).isNormal();
boolean normalScoped = getServices().get(MetaAnnotationStore.class).getScopeModel(bean.getScopeType()).isNormal();
if (normalScoped && !Beans.isBeanProxyable(bean))
{
throw new UnproxyableResolutionException("Normal scoped bean " + bean + " is not proxyable");
Expand Down Expand Up @@ -890,7 +890,7 @@ public BeanManagerImpl createActivity()

public BeanManagerImpl setCurrent(Class<? extends Annotation> scopeType)
{
if (!getServices().get(MetaDataCache.class).getScopeModel(scopeType).isNormal())
if (!getServices().get(MetaAnnotationStore.class).getScopeModel(scopeType).isNormal())
{
throw new IllegalArgumentException("Scope must be a normal scope type " + scopeType);
}
Expand Down
4 changes: 2 additions & 2 deletions impl/src/main/java/org/jboss/webbeans/FacadeImpl.java
Expand Up @@ -24,7 +24,7 @@
import java.util.HashSet;
import java.util.Set;

import org.jboss.webbeans.metadata.cache.MetaDataCache;
import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;

/**
* Common implementation for binding-type-based helpers
Expand Down Expand Up @@ -77,7 +77,7 @@ protected Annotation[] mergeInBindings(Annotation... newBindings)
result.addAll(bindings);
for (Annotation newAnnotation : newBindings)
{
if (!getManager().getServices().get(MetaDataCache.class).getBindingTypeModel(newAnnotation.annotationType()).isValid())
if (!getManager().getServices().get(MetaAnnotationStore.class).getBindingTypeModel(newAnnotation.annotationType()).isValid())
{
throw new IllegalArgumentException(newAnnotation + " is not a binding for " + this);
}
Expand Down
6 changes: 3 additions & 3 deletions impl/src/main/java/org/jboss/webbeans/Validator.java
Expand Up @@ -48,7 +48,7 @@
import org.jboss.webbeans.bootstrap.api.Service;
import org.jboss.webbeans.injection.resolution.ResolvableWBClass;
import org.jboss.webbeans.introspector.WBAnnotated;
import org.jboss.webbeans.metadata.cache.MetaDataCache;
import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.ListComparator;
import org.jboss.webbeans.util.Names;
Expand All @@ -70,7 +70,7 @@ private void validateBean(Bean<?> bean, BeanManagerImpl beanManager)
{
validateInjectionPoint(ij, beanManager);
}
boolean normalScoped = beanManager.getServices().get(MetaDataCache.class).getScopeModel(bean.getScopeType()).isNormal();
boolean normalScoped = beanManager.getServices().get(MetaAnnotationStore.class).getScopeModel(bean.getScopeType()).isNormal();
if (normalScoped && !Beans.isBeanProxyable(bean))
{
throw new UnproxyableResolutionException("Normal scoped bean " + bean + " is not proxyable");
Expand Down Expand Up @@ -158,7 +158,7 @@ public void validateInjectionPoint(InjectionPoint ij, BeanManagerImpl beanManage
throw new AmbiguousResolutionException("The injection point " + ij + " with binding types " + Names.annotationsToString(ij.getBindings()) + " in " + ij.getBean() + " has ambiguous dependencies");
}
Bean<?> resolvedBean = (Bean<?>) resolvedBeans.iterator().next();
if (beanManager.getServices().get(MetaDataCache.class).getScopeModel(resolvedBean.getScopeType()).isNormal() && !Proxies.isTypeProxyable(ij.getType()))
if (beanManager.getServices().get(MetaAnnotationStore.class).getScopeModel(resolvedBean.getScopeType()).isNormal() && !Proxies.isTypeProxyable(ij.getType()))
{
throw new UnproxyableResolutionException("The injection point " + ij + " has non-proxyable dependencies");
}
Expand Down
4 changes: 2 additions & 2 deletions impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
Expand Up @@ -47,7 +47,7 @@
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.metadata.cache.MergedStereotypes;
import org.jboss.webbeans.metadata.cache.MetaDataCache;
import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
import org.jboss.webbeans.util.Reflections;

/**
Expand Down Expand Up @@ -292,7 +292,7 @@ protected void initPrimitive()

private boolean checkInjectionPointsAreSerializable()
{
boolean passivating = manager.getServices().get(MetaDataCache.class).getScopeModel(this.getScopeType()).isPassivating();
boolean passivating = manager.getServices().get(MetaAnnotationStore.class).getScopeModel(this.getScopeType()).isPassivating();
for (WBInjectionPoint<?, ?> injectionPoint : getAnnotatedInjectionPoints())
{
Annotation[] bindings = injectionPoint.getMetaAnnotationsAsArray(BindingType.class);
Expand Down
Expand Up @@ -45,7 +45,7 @@
import org.jboss.webbeans.introspector.WBMember;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.metadata.cache.MetaDataCache;
import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.Names;
import org.jboss.webbeans.util.Reflections;
Expand Down Expand Up @@ -206,7 +206,7 @@ protected void checkReturnValue(T instance)
{
throw new IllegalProductException("Cannot return null from a non-dependent producer method");
}
boolean passivating = manager.getServices().get(MetaDataCache.class).getScopeModel(getScopeType()).isPassivating();
boolean passivating = manager.getServices().get(MetaAnnotationStore.class).getScopeModel(getScopeType()).isPassivating();
if (passivating && !Reflections.isSerializable(instance.getClass()))
{
throw new IllegalProductException("Producers cannot declare passivating scope and return a non-serializable class");
Expand Down
4 changes: 2 additions & 2 deletions impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
Expand Up @@ -44,7 +44,7 @@
import org.jboss.webbeans.introspector.WBParameter;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.metadata.cache.MetaDataCache;
import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
import org.jboss.webbeans.persistence.PersistenceApiAbstraction;
import org.jboss.webbeans.persistence.spi.JpaServices;
import org.jboss.webbeans.resources.spi.ResourceServices;
Expand Down Expand Up @@ -335,7 +335,7 @@ protected void checkType()
{
throw new DefinitionException("Simple bean " + type + " cannot be a parameterized type");
}
boolean passivating = manager.getServices().get(MetaDataCache.class).getScopeModel(scopeType).isPassivating();
boolean passivating = manager.getServices().get(MetaAnnotationStore.class).getScopeModel(scopeType).isPassivating();
if (passivating && !_serializable)
{
throw new DefinitionException("Simple bean declaring a passivating scope must have a serializable implementation class " + toString());
Expand Down
Expand Up @@ -16,18 +16,14 @@
*/
package org.jboss.webbeans.bootstrap;

import java.lang.annotation.Annotation;
import java.util.Set;

import javax.enterprise.event.Observes;
import javax.enterprise.inject.BindingType;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Initializer;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.deployment.DeploymentType;

import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.Realizes;
import org.jboss.webbeans.bean.AbstractClassBean;
import org.jboss.webbeans.bean.DecoratorBean;
import org.jboss.webbeans.bean.DisposalMethodBean;
Expand All @@ -44,8 +40,6 @@
import org.jboss.webbeans.introspector.WBClass;
import org.jboss.webbeans.introspector.WBField;
import org.jboss.webbeans.introspector.WBMethod;
import org.jboss.webbeans.introspector.WrappedWBField;
import org.jboss.webbeans.introspector.WrappedWBMethod;
import org.jboss.webbeans.jsf.JsfApiAbstraction;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
Expand Down Expand Up @@ -121,13 +115,6 @@ protected <T> void createSubBeans(AbstractClassBean<T> bean)
createObserverMethods(bean, bean.getAnnotatedItem());
createDisposalMethods(bean, bean.getAnnotatedItem());

if (bean.getAnnotatedItem().isAnnotationPresent(Realizes.class))
{
createRealizedProducerMethods(bean, bean.getAnnotatedItem());
createRealizedProducerFields(bean, bean.getAnnotatedItem());
createRealizedObserverMethods(bean, bean.getAnnotatedItem());
}

}

protected void createProducerMethods(AbstractClassBean<?> declaringBean, WBClass<?> annotatedClass)
Expand All @@ -154,24 +141,6 @@ protected <T> void createProducerMethod(AbstractClassBean<?> declaringBean, WBMe
manager.getResolver().addInjectionPoints(bean.getAnnotatedInjectionPoints());
}

protected void createRealizedProducerMethods(AbstractClassBean<?> declaringBean, WBClass<?> realizingClass)
{
WBClass<?> realizedClass = realizingClass.getSuperclass();
for (WBMethod<?> realizedMethod : realizedClass.getDeclaredAnnotatedMethods(Produces.class))
{
createProducerMethod(declaringBean, realizeProducerMethod(realizedMethod, realizingClass));
}
}

protected void createRealizedProducerFields(AbstractClassBean<?> declaringBean, WBClass<?> realizingClass)
{
WBClass<?> realizedClass = realizingClass.getSuperclass();
for (final WBField<?> realizedField : realizedClass.getDeclaredAnnotatedFields(Produces.class))
{
createProducerField(declaringBean, realizeProducerField(realizedField, realizingClass));
}
}

protected <T> void createProducerField(AbstractClassBean<?> declaringBean, WBField<T> field)
{
ProducerFieldBean<T> bean = ProducerFieldBean.of(field, declaringBean, manager);
Expand All @@ -194,11 +163,6 @@ protected void createObserverMethods(RIBean<?> declaringBean, WBClass<?> annotat
}
}

protected void createRealizedObserverMethods(AbstractClassBean<?> declaringBean, WBClass<?> realizingClass)
{
createObserverMethods(declaringBean, realizingClass.getSuperclass());
}

protected void createObserverMethod(RIBean<?> declaringBean, WBMethod<?> method)
{
ObserverImpl<?> observer = ObserverFactory.create(method, declaringBean, manager);
Expand Down Expand Up @@ -257,75 +221,7 @@ private static boolean hasSimpleWebBeanConstructor(WBClass<?> type)
{
return type.getNoArgsConstructor() != null || type.getAnnotatedConstructors(Initializer.class).size() > 0;
}

private static <T> WBMethod<T> realizeProducerMethod(final WBMethod<T> method, final WBClass<?> realizingClass)
{
return new WrappedWBMethod<T>(method, realizingClass.getMetaAnnotations(BindingType.class))
{

@Override
public Set<Annotation> getMetaAnnotations(Class<? extends Annotation> metaAnnotationType)
{
if (metaAnnotationType.equals(DeploymentType.class))
{
return realizingClass.getMetaAnnotations(DeploymentType.class);
}
else
{
return super.getMetaAnnotations(metaAnnotationType);
}
}

@Override
public Set<Annotation> getDeclaredMetaAnnotations(Class<? extends Annotation> metaAnnotationType)
{
if (metaAnnotationType.equals(DeploymentType.class))
{
return realizingClass.getDeclaredMetaAnnotations(DeploymentType.class);
}
else
{
return super.getDeclaredMetaAnnotations(metaAnnotationType);
}
}

};
}

private static <T> WBField<T> realizeProducerField(final WBField<T> field, final WBClass<?> realizingClass)
{
return new WrappedWBField<T>(field, realizingClass.getMetaAnnotations(BindingType.class))
{

@Override
public Set<Annotation> getMetaAnnotations(Class<? extends Annotation> metaAnnotationType)
{
if (metaAnnotationType.equals(DeploymentType.class))
{
return realizingClass.getMetaAnnotations(DeploymentType.class);
}
else
{
return super.getMetaAnnotations(metaAnnotationType);
}
}

@Override
public Set<Annotation> getDeclaredMetaAnnotations(Class<? extends Annotation> metaAnnotationType)
{
if (metaAnnotationType.equals(DeploymentType.class))
{
return realizingClass.getDeclaredMetaAnnotations(DeploymentType.class);
}
else
{
return super.getDeclaredMetaAnnotations(metaAnnotationType);
}
}

};
}


public BeanDeployerEnvironment getBeanDeployerEnvironment()
{
return environment;
Expand Down

0 comments on commit 2644e59

Please sign in to comment.