Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * 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.util;
 
 import java.util.Set;
 
 

Author(s):
pmuir
 
 public class Observers {
 
     /*
      * Contains all container lifecycle event types
      */
     public static final Set<Class<?>> CONTAINER_LIFECYCLE_EVENT_TYPES;
     /*
      * Contains only top superinterfaces of each chain of container lifecycle event types.
      */
     public static final Set<Class<?>> CONTAINER_LIFECYCLE_EVENT_CANONICAL_SUPERTYPES;
 
     private Observers() {
     }
 
     static {
         Set<Class<?>> canonicalSupertypes = new HashSet<Class<?>>();
         canonicalSupertypes.add(BeforeBeanDiscovery.class);
         canonicalSupertypes.add(AfterTypeDiscovery.class);
         canonicalSupertypes.add(AfterBeanDiscovery.class);
         canonicalSupertypes.add(AfterDeploymentValidation.class);
         canonicalSupertypes.add(BeforeShutdown.class);
         canonicalSupertypes.add(ProcessAnnotatedType.class);
         canonicalSupertypes.add(ProcessInjectionPoint.class);
         canonicalSupertypes.add(ProcessInjectionTarget.class);
         canonicalSupertypes.add(ProcessProducer.class);
         canonicalSupertypes.add(ProcessBeanAttributes.class);
         canonicalSupertypes.add(ProcessBean.class);
         canonicalSupertypes.add(ProcessObserverMethod.class);
          = Collections.unmodifiableSet(canonicalSupertypes);
 
         Set<Class<?>> types = new HashSet<Class<?>>();
         types.add(ProcessSyntheticAnnotatedType.class);
         types.add(ProcessSessionBean.class);
         types.add(ProcessManagedBean.class);
         types.add(ProcessProducerMethod.class);
         types.add(ProcessProducerField.class);
          = Collections.unmodifiableSet(types);
 
     }
 
     public static boolean isContainerLifecycleObserverMethod(ObserverMethod<?> method) {
         return .contains(Reflections.getRawType(method.getObservedType()))
                 || (Object.class.equals(method.getObservedType()) && method instanceof ExtensionObserverMethodImpl<?, ?>);
     }
    public static boolean isObserverMethodEnabled(ObserverMethod<?> methodBeanManagerImpl manager) {
        if (method instanceof ObserverMethodImpl<?, ?>) {
            Bean<?> declaringBean = Reflections.<ObserverMethodImpl<?, ?>> cast(method).getDeclaringBean();
            return manager.getServices().get(SpecializationAndEnablementRegistry.class).isCandidateForLifecycleEvent(declaringBean);
        }
        return true;
    }
    public static void validateObserverMethod(ObserverMethod<?> observerMethodBeanManager beanManager) {
        Set<Annotationqualifiers = observerMethod.getObservedQualifiers();
        if (observerMethod.getBeanClass() == null) {
            throw ..observerMethodsMethodReturnsNull("getBeanClass"observerMethod);
        }
        if (observerMethod.getObservedType() == null) {
            throw ..observerMethodsMethodReturnsNull("getObservedType"observerMethod);
        }
        Bindings.validateQualifiers(qualifiersbeanManagerobserverMethod"ObserverMethod.getObservedQualifiers");
        if (observerMethod.getReception() == null) {
            throw ..observerMethodsMethodReturnsNull("getReception"observerMethod);
        }
        if (observerMethod.getTransactionPhase() == null) {
            throw ..observerMethodsMethodReturnsNull("getTransactionPhase"observerMethod);
        }
    }

    
Determines whether the given observer method is either extension-provided or contains an injection point with javax.enterprise.inject.spi.EventMetadata type.
    public static boolean isEventMetadataRequired(ObserverMethod<?> observer) {
        if (observer instanceof ObserverMethodImpl<?, ?>) {
            ObserverMethodImpl<?, ?> observerImpl = (ObserverMethodImpl<?, ?>) observer;
            return observerImpl.isEventMetadataRequired();
        } else {
            return true;
        }
    }
New to GrepCode? Check out our FAQ X