Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2012, 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;
 
 
Instantiates an enhanced subclass of a given component class. This class is thread-safe.

Parameters:
<T>
Author(s):
Jozef Hartinger
 
 public class SubclassedComponentInstantiator<T> extends AbstractInstantiator<T> {
 
     public static <T> SubclassedComponentInstantiator<T> forSubclassedEjb(EnhancedAnnotatedType<T> componentTypeEnhancedAnnotatedType<T> subclassBean<T> beanBeanManagerImpl manager) {
         final EnhancedAnnotatedConstructor<T> componentConstructor = Beans.getBeanConstructor(componentType);
         final EnhancedAnnotatedConstructor<T> subclassConstructor = findMatchingConstructor(componentConstructor.getSignature(), subclass);
         final ConstructorInjectionPoint<T> cip = InjectionPointFactory.instance().createConstructorInjectionPoint(beancomponentType.getJavaClass(), subclassConstructormanager);
         return new SubclassedComponentInstantiator<T>(cipcomponentConstructor.getJavaMember());
     }
 
     public static <T> SubclassedComponentInstantiator<T> forInterceptedDecoratedBean(EnhancedAnnotatedType<T> typeBean<T> beanAbstractInstantiator<T> delegateBeanManagerImpl manager) {
         return new SubclassedComponentInstantiator<T>(typebeandelegate.getConstructorInjectionPoint(), manager);
     }
 
     private static <T> EnhancedAnnotatedConstructor<T> findMatchingConstructor(ConstructorSignature componentConstructorEnhancedAnnotatedType<T> subclass) {
         return subclass.getDeclaredEnhancedConstructor(componentConstructor);
     }
 
     private final Constructor<T> componentClassConstructor;
 
     private SubclassedComponentInstantiator(ConstructorInjectionPoint<T> proxyClassConstructorInjectionPointConstructor<T> componentClassConstructor) {
         this. = proxyClassConstructorInjectionPoint;
         this. = componentClassConstructor;
     }
 
     protected SubclassedComponentInstantiator(EnhancedAnnotatedType<T> typeBean<T> beanConstructorInjectionPoint<T> originalConstructorBeanManagerImpl manager) {
         EnhancedAnnotatedConstructor<T> constructorForEnhancedSubclass = initEnhancedSubclass(managertypebeanoriginalConstructor);
         this. = new ProxyClassConstructorInjectionPointWrapper<T>(beantype.getJavaClass(), constructorForEnhancedSubclassoriginalConstructormanager);
         this. = originalConstructor.getAnnotated().getJavaMember();
     }
 
     protected EnhancedAnnotatedConstructor<T> initEnhancedSubclass(BeanManagerImpl managerEnhancedAnnotatedType<T> typeBean<?> beanConstructorInjectionPoint<T> originalConstructorInjectionPoint) {
         ClassTransformer transformer = manager.getServices().get(ClassTransformer.class);
         EnhancedAnnotatedType<T> enhancedSubclass = transformer.getEnhancedAnnotatedType(createEnhancedSubclass(typebeanmanager), type.slim().getIdentifier().getBdaId());
         return findMatchingConstructor(originalConstructorInjectionPoint.getSignature(), enhancedSubclass);
     }
 
     protected Class<T> createEnhancedSubclass(EnhancedAnnotatedType<T> typeBean<?> beanBeanManagerImpl manager) {
         Set<InterceptionModelmodels = getInterceptionModelsForType(typemanagerbean);
         Set<MethodSignatureenhancedMethodSignatures = new HashSet<MethodSignature>();
         Set<MethodSignatureinterceptedMethodSignatures = (models == null) ? enhancedMethodSignatures : new HashSet<MethodSignature>();
 
         for (AnnotatedMethod<?> method : Beans.getInterceptableMethods(type)) {
             enhancedMethodSignatures.add(MethodSignatureImpl.of(method));
             if (models != null) {
                 for (InterceptionModel model : models) {
                     if (!model.getInterceptors(.method.getJavaMember()).isEmpty()) {
                        interceptedMethodSignatures.add(MethodSignatureImpl.of(method));
                        break;
                    }
                }
            }
        }
        Set<Typetypes = null;
        if (bean == null) {
            // TODO we may need to really discover types here
            types = Collections.<Type>singleton(type.getJavaClass());
        } else {
            types = bean.getTypes();
        }
        return new InterceptedSubclassFactory<T>(manager.getContextId(), type.getJavaClass(), typesbeanenhancedMethodSignaturesinterceptedMethodSignatures).getProxyClass();
    }
        // if the bean has decorators consider all methods as intercepted
        // TODO - reduce this to decorated types only
        if (bean != null && !manager.resolveDecorators(bean.getTypes(), bean.getQualifiers()).isEmpty()) {
            return null;
        }
        SlimAnnotatedTypeStore store = manager.getServices().get(SlimAnnotatedTypeStore.class);
        Set<InterceptionModelmodels = new HashSet<InterceptionModel>();
        WeldCollections.addIfNotNull(modelsmanager.getInterceptorModelRegistry().get(type.slim()));
        for (SlimAnnotatedType<?> slimType : store.get(type.getJavaClass())) {
            WeldCollections.addIfNotNull(modelsmanager.getInterceptorModelRegistry().get(slimType));
        }
        return models;
    }
    @Override
    public String toString() {
        return "SubclassedComponentInstantiator for " + .getType();
    }
    @Override
    public boolean hasInterceptorSupport() {
        return false;
    }
    @Override
    public boolean hasDecoratorSupport() {
        return false;
    }

    
Note that this method return a org.jboss.weld.injection.ConstructorInjectionPoint that represents the constructor of an enhanced subclass. Use getConstructor() to get the matching component class constructor.
    @Override
    }
    @Override
    public Constructor<T> getConstructor() {
        return ;
    }
New to GrepCode? Check out our FAQ X