Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.infinispan.cdi.util.defaultbean;
  
  import java.util.Set;
  
  import  javax.enterprise.context.spi.CreationalContext;
  import  javax.enterprise.event.Observes;
  import  javax.enterprise.event.Reception;
 import  javax.enterprise.inject.spi.AnnotatedMethod;
 import  javax.enterprise.inject.spi.Bean;
 import  javax.enterprise.inject.spi.BeanManager;
 import  javax.enterprise.inject.spi.ObserverMethod;
 
 
 class DefaultObserverMethod<T, X> extends ForwardingObserverMethod<T> {
 
     private final ObserverMethod<T> originalObserverMethod;
     private final InjectableMethod<X> observerMethod;
     private final BeanManager beanManager;
     private final Type declaringBeanType;
     private final Annotation[] declaringBeanQualifiers;
     private final Set<Annotationqualifiers;
 
     private static final Annotation[] EMPTY_QUALIFIER_ARRAY = {};
 
     static <T, X> DefaultObserverMethod<T, X> of(ObserverMethod<T> originalObserverMethod, AnnotatedMethod<X> observerMethodSet<AnnotationdeclaringBeanQualifiersSet<Annotationqualifiers, Bean<?> defaultBean, BeanManager beanManager) {
         return new DefaultObserverMethod<T, X>(originalObserverMethodobserverMethoddeclaringBeanQualifiersqualifiersdefaultBeanbeanManager);
     }
 
     DefaultObserverMethod(ObserverMethod<T> originalObserverMethod, AnnotatedMethod<X> observerMethodSet<AnnotationdeclaringBeanQualifiersSet<Annotationqualifiers, Bean<?> defaultBean, BeanManager beanManager) {
         this. = originalObserverMethod;
         this. = new InjectableMethod<X>(observerMethoddefaultBeanbeanManager);
         this. = beanManager;
         this. = declaringBeanQualifiers.toArray();
         this. = originalObserverMethod.getBeanClass();
         this. = qualifiers;
     }
 
     @Override
     protected ObserverMethod<T> delegate() {
         return ;
     }
 
     @Override
     public Set<AnnotationgetObservedQualifiers() {
         return ;
     }
 
     @Override
     public void notify(final T event) {
         Bean<?> declaringBean = .resolve(.getBeans());
         final CreationalContext<?> creationalContext = createCreationalContext(declaringBean);
         try {
             Object instance = .getReference(declaringBeancreationalContext);
             if (instance == null) {
                 return;
             }
             .invoke(instancecreationalContextnew ParameterValueRedefiner() {
 
                 public Object redefineParameterValue(ParameterValue value) {
                     if (value.getInjectionPoint().getAnnotated().isAnnotationPresent(Observes.class)) {
                         return event;
                     } else {
                         return value.getDefaultValue(creationalContext);
                     }
                 }
             });
 
         } finally {
             // Generic beans are always dependent scoped
             if (creationalContext != null) {
                 creationalContext.release();
             }
         }
 
     }
 
     private CreationalContext<?> createCreationalContext(Bean<?> declaringBean) {
         if (getReception().equals(Reception.ALWAYS)) {
             return .createCreationalContext(declaringBean);
         } else {
             return null;
         }
     }
 
     @Override
     public boolean equals(Object obj) {
         if (obj instanceof DefaultObserverMethod<?, ?>) {
             DefaultObserverMethod<?, ?> that = (DefaultObserverMethod<?, ?>) obj;
             return this.delegate().equals(that.delegate()) && this.getObservedType().equals(that.getObservedType()) && this.getObservedQualifiers().equals(that.getObservedQualifiers());
         } else {
             return false;
         }
     }
 
    @Override
    public int hashCode() {
        int hash = 2;
        hash = 31 * hash + this.getObservedType().hashCode();
        hash = 31 * hash + this.getObservedQualifiers().hashCode();
        return hash;
    }
New to GrepCode? Check out our FAQ X