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.manager;
 
 
Factory capable of producing javax.enterprise.inject.spi.InjectionTarget implementations for a given combination of javax.enterprise.inject.spi.AnnotatedType and javax.enterprise.inject.spi.Bean objects.

Parameters:
<T>
Author(s):
Jozef Hartinger
 
 public class InjectionTargetFactoryImpl<T> implements WeldInjectionTargetFactory<T> {
 
     private final BeanManagerImpl manager;
     private final EnhancedAnnotatedType<T> type;
     private final InjectionServices injectionServices;
 
     protected InjectionTargetFactoryImpl(AnnotatedType<T> typeBeanManagerImpl manager) {
         this. = manager;
         this. = manager.getServices().get(ClassTransformer.class).getEnhancedAnnotatedType(typemanager.getId());
         this. = manager.getServices().get(InjectionTargetService.class);
         this. = manager.getServices().get(InjectionServices.class);
     }
 
     @Override
     public WeldInjectionTarget<T> createInjectionTarget(Bean<T> bean) {
         return createInjectionTarget(beanfalse);
     }
 
     @Override
         return createInjectionTarget(nulltrue);
     }
 
     private WeldInjectionTarget<T> createInjectionTarget(Bean<T> beanboolean interceptor) {
         try {
             return validate(createInjectionTarget(beaninterceptor));
         } catch (Throwable e) {
             throw new IllegalArgumentException(e);
         }
     }
 
     public BasicInjectionTarget<T> createInjectionTarget(EnhancedAnnotatedType<T> typeBean<T> beanboolean interceptor) {
         BasicInjectionTarget<T> injectionTarget = chooseInjectionTarget(typebeaninterceptor);
         /*
          * Every InjectionTarget, regardless whether it's used within Weld's Bean implementation or requested from extension has
          * to be initialized after beans (interceptors) are deployed.
          */
         initialize(injectionTarget);
         postProcess(injectionTarget);
         return injectionTarget;
     }
 
     private BasicInjectionTarget<T> chooseInjectionTarget(EnhancedAnnotatedType<T> typeBean<T> beanboolean interceptor) {
         if (bean instanceof Decorator<?> || type.isAnnotationPresent(javax.decorator.Decorator.class)) {
             return new DecoratorInjectionTarget<T>(typebean);
        }
        if (type.isAbstract()) {
            if (type.getJavaClass().isInterface()) {
                throw ..injectionTargetCannotBeCreatedForInterface(type);
            }
            return new NonProducibleInjectionTarget<T>(typebean);
        }
        if (Reflections.isNonStaticInnerClass(type.getJavaClass())) {
            return new NonProducibleInjectionTarget<T>(typebean);
        }
        if (Beans.getBeanConstructor(type) == null) {
            if (bean != null) {
            }
            return new NonProducibleInjectionTarget<T>(typenull);
        }
        if (bean instanceof SessionBean<?>) {
            return SessionBeanInjectionTarget.of(type, (SessionBean<T>) bean);
        }
        if (bean instanceof Interceptor<?> || type.isAnnotationPresent(javax.interceptor.Interceptor.class)) {
            return BeanInjectionTarget.forCdiInterceptor(typebean);
        }
        if (interceptor) {
            return BasicInjectionTarget.createNonCdiInterceptor(type);
        }
        return BeanInjectionTarget.createDefault(typebean);
    }
        EnhancedAnnotatedType<T> implementationClass = Beans.getEjbImplementationClass(descriptor);
        AbstractInstantiator<T> instantiator = null;
        if (.equals(implementationClass)) {
            instantiator = new DefaultInstantiator<T>(null);
        } else {
            // Session bean subclassed by the EJB container
            instantiator = SubclassedComponentInstantiator.forSubclassedEjb(implementationClassnull);
        }
        return prepareInjectionTarget(BasicInjectionTarget.createDefault(nullinstantiator));
    }
    private BasicInjectionTarget<T> initialize(BasicInjectionTarget<T> injectionTarget) {
        return injectionTarget;
    }
    private <I extends InjectionTarget<T>> I validate(I injectionTarget) {
        .validateProducer(injectionTarget);
        return injectionTarget;
    }
    private void postProcess(InjectionTarget<T> injectionTarget) {
        if ( != null) {
            .registerInjectionTarget(injectionTarget.slim());
        }
    }
    /*
     * Just a shortcut for calling validate, initialize and postProcess
     */
    private BasicInjectionTarget<T> prepareInjectionTarget(BasicInjectionTarget<T> injectionTarget) {
        try {
            postProcess(initialize(validate(injectionTarget)));
            return injectionTarget;
        } catch (Throwable e) {
            throw new IllegalArgumentException(e);
        }
    }
    @Override
        return prepareInjectionTarget(new NonProducibleInjectionTarget<T>(null));
    }
New to GrepCode? Check out our FAQ X