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.injection.producer;
 
 import java.util.Set;
 
 
Basic javax.enterprise.inject.spi.InjectionTarget implementation. The implementation supports:
  • @Inject injection + initializers
  • @PostConstruct/@PreDestroy callbacks
Interception and decoration is not supported but can be added using extension points.

Author(s):
Pete Muir
Jozef Hartinger
 
 public class BasicInjectionTarget<T> extends AbstractProducer<T> implements WeldInjectionTarget<T> {
 
     public static <T> BasicInjectionTarget<T> create(EnhancedAnnotatedType<T> typeBean<T> beanBeanManagerImpl beanManagerInjector<T> injectorLifecycleCallbackInvoker<T> invoker) {
         return new BasicInjectionTarget<T>(typebeanbeanManagerinjectorinvoker);
     }
 
     public static <T> BasicInjectionTarget<T> createDefault(EnhancedAnnotatedType<T> typeBean<T> beanBeanManagerImpl beanManager) {
         return new BasicInjectionTarget<T>(typebeanbeanManagernull);
     }
 
     public static <T> BasicInjectionTarget<T> createDefault(EnhancedAnnotatedType<T> typeBean<T> beanBeanManagerImpl beanManagerInstantiator<T> instantiator) {
         return new BasicInjectionTarget<T>(typebeanbeanManagerinstantiator);
     }

    
Creates javax.enterprise.inject.spi.InjectionTarget for interceptors which do not have associated javax.enterprise.inject.spi.Interceptor. These interceptors are a result of using javax.interceptor.Interceptors annotation directly on the target class.
 
     public static <T> BasicInjectionTarget<T> createNonCdiInterceptor(EnhancedAnnotatedType<T> typeBeanManagerImpl beanManager) {
         return new BasicInjectionTarget<T>(typenullbeanManager, DefaultInjector.of(typenullbeanManager), NoopLifecycleCallbackInvoker.<T>getInstance());
     }
 
     protected final BeanManagerImpl beanManager;
     private final SlimAnnotatedType<T> type;
     private final Set<InjectionPointinjectionPoints;
 
     // Instantiation
     private Instantiator<T> instantiator;
     private final Injector<T> injector;
     private final LifecycleCallbackInvoker<T> invoker;
 
     protected BasicInjectionTarget(EnhancedAnnotatedType<T> typeBean<T> beanBeanManagerImpl beanManagerInjector<T> injectorLifecycleCallbackInvoker<T> invoker) {
         this(typebeanbeanManagerinjectorinvokernull);
     }
 
     protected BasicInjectionTarget(EnhancedAnnotatedType<T> typeBean<T> beanBeanManagerImpl beanManagerInjector<T> injectorLifecycleCallbackInvoker<T> invokerInstantiator<T> instantiator) {
         this. = beanManager;
         this. = type.slim();
         this. = injector;
         this. = invoker;
 
         final Set<InjectionPointinjectionPoints = new HashSet<InjectionPoint>();
 
         checkType(type);
         this..registerInjectionPoints(injectionPoints);
         if (instantiator != null) {
             this. = instantiator;
         } else {
             this. = initInstantiator(typebeanbeanManagerinjectionPoints);
         }
        this. = WeldCollections.immutableGuavaSet(injectionPoints);
    }
    protected BasicInjectionTarget(EnhancedAnnotatedType<T> typeBean<T> beanBeanManagerImpl beanManagerInstantiator<T> instantiator) {
        this(typebeanbeanManager, DefaultInjector.of(typebeanbeanManager), DefaultLifecycleCallbackInvoker.of(type), instantiator);
    }
    protected void checkType(EnhancedAnnotatedType<T> type) {
        if (!Reflections.isTopLevelOrStaticNestedClass(type.getJavaClass())) {
            throw ..simpleBeanAsNonStaticInnerClassNotAllowed(type);
        }
    }
    @Override
    public T produce(CreationalContext<T> ctx) {
        return .newInstance(ctx);
    }
    @Override
    public void inject(T instanceCreationalContext<T> ctx) {
        .inject(instancectxthis);
    }
    @Override
    public void postConstruct(T instance) {
        .postConstruct(instance);
    }
    @Override
    public void preDestroy(T instance) {
        .preDestroy(instance);
    }
    @Override
    public void dispose(T instance) {
        // No-op
    }
    @Override
        return ;
    }
    protected SlimAnnotatedType<T> getType() {
        return ;
    }
    public BeanManagerImpl getBeanManager() {
        return ;
    }
    public Instantiator<T> getInstantiator() {
        return ;
    }
    public void setInstantiator(Instantiator<T> instantiator) {
        this. = instantiator;
    }
    public boolean hasInterceptors() {
        return .hasInterceptorSupport();
    }
    public boolean hasDecorators() {
        return .hasDecoratorSupport();
    }
    protected void initializeAfterBeanDiscovery(EnhancedAnnotatedType<T> annotatedType) {
    }

    
Returns an instantiator that will be used to create a new instance of a given component. If the instantiator uses a constructor with injection points, the implementation of the initInstantiator(org.jboss.weld.annotated.enhanced.EnhancedAnnotatedType,javax.enterprise.inject.spi.Bean,org.jboss.weld.manager.BeanManagerImpl,java.util.Set) method is supposed to register all these injection points within the injectionPoints set passed in as a parameter.
    protected Instantiator<T> initInstantiator(EnhancedAnnotatedType<T> typeBean<T> beanBeanManagerImpl beanManagerSet<InjectionPointinjectionPoints) {
        DefaultInstantiator<T> instantiator = new DefaultInstantiator<T>(typebeanbeanManager);
        injectionPoints.addAll(instantiator.getParameterInjectionPoints());
        return instantiator;
    }
    @Override
    public AnnotatedType<T> getAnnotated() {
        return ;
    }
    @Override
    public AnnotatedType<T> getAnnotatedType() {
        return getAnnotated();
    }
    public Injector<T> getInjector() {
        return ;
    }
        return ;
    }
    @Override
    public String toString() {
        StringBuilder result = new StringBuilder("InjectionTarget for ");
        if (getBean() == null) {
            result.append(getAnnotated());
        } else {
            result.append(getBean());
        }
        return result.toString();
    }
    @Override
    public Bean<T> getBean() {
        return null;
    }
New to GrepCode? Check out our FAQ X