Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2013, 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.bootstrap;
 
 import java.util.Set;
 
 
Specialized version of org.jboss.weld.bootstrap.AnnotatedTypeLoader. This implementation uses org.jboss.weld.resources.spi.ClassFileServices to avoid loading application classes that are not needed for Weld. In addition, this implementation feeds org.jboss.weld.annotated.slim.SlimAnnotatedTypeContext with org.jboss.weld.resources.spi.ClassFileInfo and resolved javax.enterprise.inject.spi.ProcessAnnotatedType observer methods.

Author(s):
Jozef Hartinger
 
 public class FastAnnotatedTypeLoader extends AnnotatedTypeLoader {
 
     private final ClassFileServices classFileServices;
     private final FastProcessAnnotatedTypeResolver resolver;
 
     public FastAnnotatedTypeLoader(BeanManagerImpl managerClassTransformer transformerClassFileServices classFileServices,
             ContainerLifecycleEvents eventsFastProcessAnnotatedTypeResolver resolver) {
         super(managertransformerevents);
         this. = classFileServices;
         this. = resolver;
     }
 
     @Override
     public <T> SlimAnnotatedTypeContext<T> loadAnnotatedType(String classNameString bdaId) {
         try {
             final ClassFileInfo classFileInfo = .getClassFileInfo(className);
 
             // firstly, check if this class is an annotation
             if ((classFileInfo.getModifiers() & .) != 0) {
                 // This is an annotation - an annotation may not end up as a managed bean nor be observer by PAT observer. Skip it.
                 return null;
             }
             if (classFileInfo.isVetoed()) {
                 return null;
             }
 
             // secondly, let's resolve PAT observers for this class
             Set<ExtensionObserverMethodImpl<?, ?>> observerMethods = Collections.emptySet();
             if (.isProcessAnnotatedTypeObserved()) {
                 observerMethods = .resolveProcessAnnotatedTypeObservers(className);
                 if (!observerMethods.isEmpty()) {
                     // there are PAT observers for this class, register the class now
                     return createContext(classNameclassFileInfoobserverMethodsbdaId);
                 }
             }
 
             // lastly, check if this class fulfills CDI managed bean requirements - if it does, add the class
             if (Beans.isTypeManagedBeanOrDecoratorOrInterceptor(classFileInfo)) {
                 return createContext(classNameclassFileInfoobserverMethodsbdaId);
             }
             return null;
         } catch (ClassFileInfoException e) {
             return super.loadAnnotatedType(classNamebdaId);
         }
     }
 
     private <T> SlimAnnotatedTypeContext<T> createContext(String classNameClassFileInfo classFileInfo,
             Set<ExtensionObserverMethodImpl<?, ?>> observerMethodsString bdaId) {
         final SlimAnnotatedType<T> type = loadAnnotatedType(this.<T> loadClass(className), bdaId);
         if (type != null) {
             return SlimAnnotatedTypeContext.of(typeclassFileInfoobserverMethods);
         }
         return null;
    }
    @Override
    protected <T> SlimAnnotatedType<T> loadAnnotatedType(Class<T> clazzString bdaId) {
        if (clazz != null) {
            try {
                return .getBackedAnnotatedType(clazzbdaId);
            } catch (ResourceLoadingException e) {
                .handleResourceLoadingException(clazz.getName(), e);
            }
        }
        return null;
    }
New to GrepCode? Check out our FAQ X