Skip to content

Commit

Permalink
Adapt to SPI changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jharting committed Oct 9, 2013
1 parent e39e18e commit eda6562
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 29 deletions.
21 changes: 3 additions & 18 deletions impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployment.java
Expand Up @@ -68,9 +68,6 @@
import org.jboss.weld.metadata.FilterPredicate;
import org.jboss.weld.metadata.ScanningPredicate;
import org.jboss.weld.persistence.PersistenceApiAbstraction;
import org.jboss.weld.resolution.spi.ExtensionObserverMethod;
import org.jboss.weld.resolution.spi.ProcessAnnotatedTypeObserverMethodResolver;
import org.jboss.weld.resolution.spi.ResolutionServices;
import org.jboss.weld.resources.DefaultResourceLoader;
import org.jboss.weld.resources.WeldClassLoaderResourceLoader;
import org.jboss.weld.resources.spi.ClassFileInfo;
Expand Down Expand Up @@ -106,7 +103,6 @@ public class BeanDeployment {
private final ContainerLifecycleEvents lifecycleEvents;
// these optional services are only available if the integrator provided them
private final ClassFileServices classFileServices;
private final ProcessAnnotatedTypeObserverMethodResolver fastObserverMethodResolver;

public BeanDeployment(BeanDeploymentArchive beanDeploymentArchive, BeanManagerImpl deploymentManager, ServiceRegistry deploymentServices, Collection<ContextHolder<? extends Context>> contexts) {
this(beanDeploymentArchive, deploymentManager, deploymentServices, contexts, false);
Expand Down Expand Up @@ -162,19 +158,9 @@ public BeanDeployment(BeanDeploymentArchive beanDeploymentArchive, BeanManagerIm

this.contexts = contexts;
this.classFileServices = services.get(ClassFileServices.class);
this.fastObserverMethodResolver = initFastObserverMethodResolver(services, deploymentManager);
this.lifecycleEvents = services.get(ContainerLifecycleEvents.class);
}

private ProcessAnnotatedTypeObserverMethodResolver initFastObserverMethodResolver(ServiceRegistry services, BeanManagerImpl deploymentManager) {
final ResolutionServices resolutionServices = services.get(ResolutionServices.class);
if (resolutionServices == null) {
return null;
}
Set<ExtensionObserverMethod<?>> observers = Reflections.cast(deploymentManager.getObservers());
return resolutionServices.getProcessAnnotatedTypeObserverMethodResolver(observers);
}

public BeanManagerImpl getBeanManager() {
return beanManager;
}
Expand Down Expand Up @@ -236,7 +222,7 @@ public Predicate<String> apply(Metadata<Filter> from) {
* We can safe some time by not loading such classes at all!
*/
protected Iterable<String> filterOutUselessClasses(Iterable<String> classes) {
if (classFileServices == null || fastObserverMethodResolver == null) {
if (classFileServices == null) {
return classes;
}
Set<String> result = new HashSet<String>();
Expand All @@ -253,9 +239,8 @@ protected Iterable<String> filterOutUselessClasses(Iterable<String> classes) {
}
// if not, we still need to check wheter this class is required by a ProcessAnnotatedType observer
if (lifecycleEvents.isProcessAnnotatedTypeObserved()) {
if (!fastObserverMethodResolver.resolveObserverMethods(className).isEmpty()) {
result.add(className);
}
// TODO
result.add(className);
}
}
return result;
Expand Down
Expand Up @@ -42,10 +42,10 @@
import org.jboss.weld.bean.ProducerMethod;
import org.jboss.weld.bean.SessionBean;
import org.jboss.weld.bootstrap.api.helpers.AbstractBootstrapService;
import org.jboss.weld.event.ExtensionObserverMethodImpl;
import org.jboss.weld.injection.attributes.FieldInjectionPointAttributes;
import org.jboss.weld.injection.attributes.ParameterInjectionPointAttributes;
import org.jboss.weld.manager.BeanManagerImpl;
import org.jboss.weld.resolution.spi.ExtensionObserverMethod;
import org.jboss.weld.resources.spi.AnnotationDiscovery;
import org.jboss.weld.util.reflection.Reflections;

Expand All @@ -69,7 +69,7 @@ public ContainerLifecycleEvents(ContainerLifecycleEventPreloader preloader, Anno
}

public void processObserverMethod(ObserverMethod<?> observer) {
if (observer instanceof ExtensionObserverMethod<?>) {
if (observer instanceof ExtensionObserverMethodImpl<?, ?>) {
processObserverMethodType(observer.getObservedType());
}
}
Expand Down
Expand Up @@ -37,7 +37,6 @@
import org.jboss.weld.injection.MethodInjectionPoint;
import org.jboss.weld.logging.EventLogger;
import org.jboss.weld.manager.BeanManagerImpl;
import org.jboss.weld.resolution.spi.ExtensionObserverMethod;
import org.jboss.weld.util.reflection.Reflections;

import com.google.common.collect.ImmutableSet;
Expand All @@ -50,7 +49,7 @@
* @author Jozef Hartinger
*
*/
public class ExtensionObserverMethodImpl<T, X> extends ObserverMethodImpl<T, X> implements ExtensionObserverMethod<T> {
public class ExtensionObserverMethodImpl<T, X> extends ObserverMethodImpl<T, X> {

private final Container containerLifecycleEventDeliveryLock;
private final Set<Class<? extends Annotation>> requiredTypeAnnotations;
Expand Down Expand Up @@ -121,7 +120,6 @@ protected void sendEvent(T event, Object receiver, CreationalContext<?> creation
}
}

@Override
public Collection<Class<? extends Annotation>> getRequiredAnnotations() {
return requiredTypeAnnotations;
}
Expand Down
Expand Up @@ -22,8 +22,8 @@
import javax.enterprise.inject.spi.ObserverMethod;

import org.jboss.weld.bootstrap.events.ProcessAnnotatedTypeEventResolvable;
import org.jboss.weld.event.ExtensionObserverMethodImpl;
import org.jboss.weld.metadata.cache.MetaAnnotationStore;
import org.jboss.weld.resolution.spi.ExtensionObserverMethod;
import org.jboss.weld.util.Beans;
import org.jboss.weld.util.Observers;
import org.jboss.weld.util.reflection.Reflections;
Expand Down Expand Up @@ -51,8 +51,8 @@ protected boolean matches(Resolvable resolvable, ObserverMethod<?> observer) {
if (!Beans.containsAllQualifiers(QualifierInstance.qualifiers(metaAnnotationStore, observer.getObservedQualifiers()), resolvable.getQualifiers())) {
return false;
}
if (observer instanceof ExtensionObserverMethod<?>) {
ExtensionObserverMethod<?> extensionObserver = (ExtensionObserverMethod<?>) observer;
if (observer instanceof ExtensionObserverMethodImpl<?, ?>) {
ExtensionObserverMethodImpl<?, ?> extensionObserver = (ExtensionObserverMethodImpl<?, ?>) observer;
if (resolvable instanceof ProcessAnnotatedTypeEventResolvable && !extensionObserver.getRequiredAnnotations().isEmpty()) {
// this is a ProcessAnnotatedType observer method with @WithAnnotations and a resolvable for ProcessAnnotatedType
ProcessAnnotatedTypeEventResolvable patResolvable = (ProcessAnnotatedTypeEventResolvable) resolvable;
Expand Down
2 changes: 1 addition & 1 deletion impl/src/main/java/org/jboss/weld/util/Beans.java
Expand Up @@ -495,7 +495,7 @@ public static boolean isTypeManagedBeanOrDecoratorOrInterceptor(ClassFileInfo cl
return ((classFileInfo.getModifiers() & BytecodeUtils.ENUM) == 0) && !classFileInfo.isAssignableTo(Extension.class)
&& classFileInfo.isTopLevelClass() || Modifier.isStatic(classFileInfo.getModifiers())
&& classFileInfo.hasCdiConstructor()
&& (!Modifier.isAbstract(classFileInfo.getModifiers()) || classFileInfo.isAnnotationPresent(Decorator.class));
&& (!Modifier.isAbstract(classFileInfo.getModifiers()) || classFileInfo.isAnnotationDeclared(Decorator.class));
}

public static boolean hasSimpleCdiConstructor(AnnotatedType<?> type) {
Expand Down
4 changes: 2 additions & 2 deletions impl/src/main/java/org/jboss/weld/util/Observers.java
Expand Up @@ -41,9 +41,9 @@
import javax.enterprise.inject.spi.ProcessSyntheticAnnotatedType;

import org.jboss.weld.bootstrap.SpecializationAndEnablementRegistry;
import org.jboss.weld.event.ExtensionObserverMethodImpl;
import org.jboss.weld.event.ObserverMethodImpl;
import org.jboss.weld.manager.BeanManagerImpl;
import org.jboss.weld.resolution.spi.ExtensionObserverMethod;
import org.jboss.weld.util.reflection.Reflections;

/**
Expand Down Expand Up @@ -91,7 +91,7 @@ private Observers() {

public static boolean isContainerLifecycleObserverMethod(ObserverMethod<?> method) {
return CONTAINER_LIFECYCLE_EVENT_TYPES.contains(Reflections.getRawType(method.getObservedType()))
|| (Object.class.equals(method.getObservedType()) && method instanceof ExtensionObserverMethod<?>);
|| (Object.class.equals(method.getObservedType()) && method instanceof ExtensionObserverMethodImpl<?, ?>);
}

public static boolean isObserverMethodEnabled(ObserverMethod<?> method, BeanManagerImpl manager) {
Expand Down

0 comments on commit eda6562

Please sign in to comment.