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;
 
 import static org.jboss.weld.injection.Exceptions.rethrowException;
 
 import java.util.List;
 import java.util.Map;
 
 
 
 import  edu.umd.cs.findbugs.annotations.SuppressWarnings;

High-level representation of an injected constructor. This class does not need to be serializable because it is never injected.

Parameters:
<T>
Author(s):
Pete Muir
Jozef Hartinger
 
 @SuppressWarnings("EQ_DOESNT_OVERRIDE_EQUALS")
 public class ConstructorInjectionPoint<T> extends AbstractCallableInjectionPoint<T, T, Constructor<T>> {
 
     private final AnnotatedConstructor<T> constructor;
     private final ConstructorSignature signature;
     private final Constructor<T> accessibleConstructor;
 
     protected ConstructorInjectionPoint(EnhancedAnnotatedConstructor<T> constructorBean<T> declaringBeanClass<?> declaringComponentClassInjectionPointFactory factoryBeanManagerImpl manager) {
         super(constructordeclaringBeandeclaringComponentClassfalsefactorymanager);
         this. = constructor.slim();
         this. = constructor.getSignature();
         this. = AccessController.doPrivileged(new GetAccessibleCopyOfMember<Constructor<T>>(constructor.getJavaMember()));
     }
 
     public T newInstance(BeanManagerImpl managerCreationalContext<?> ctx) {
         CreationalContext<?> transientReferenceContext = null;
         if () {
             transientReferenceContext = manager.createCreationalContext(null);
         }
         try {
             Object[] parameterValues = getParameterValues(managerctxtransientReferenceContext);
             if (ctx instanceof CreationalContextImpl<?>) {
                 CreationalContextImpl<T> weldCtx = Reflections.cast(ctx);
                 return invokeAroundConstructCallbacks(parameterValuesweldCtx);
             } else {
                 return newInstance(parameterValues);
             }
         } finally {
             if () {
                 transientReferenceContext.release();
             }
         }
     }
 
     private T invokeAroundConstructCallbacks(Object[] parametersCreationalContextImpl<T> ctx) {
         final List<AroundConstructCallback<T>> callbacks = ctx.getAroundConstructCallbacks();
         if (callbacks.isEmpty()) {
             return newInstance(parameters);
         }
         final Iterator<AroundConstructCallback<T>> iterator = callbacks.iterator();
         return invokeAroundConstructCallback(iterator.next(), new ConstructionHandle<T>() {
             @Override
             public T proceed(Object[] parametersMap<StringObjectdata) {
                 if (iterator.hasNext()) {
                     return invokeAroundConstructCallback(iterator.next(), thisgetComponentConstructor(), parametersdata);
                } else {
                    return newInstance(parameters);
                }
            }
        }, getComponentConstructor(), parametersnew HashMap<StringObject>());
    }
    private T invokeAroundConstructCallback(AroundConstructCallback<T> callbackConstructionHandle<T> ctxAnnotatedConstructor<T> constructorObject[] parametersMap<StringObjectdata) {
        try {
            return callback.aroundConstruct(ctxconstructorparametersdata);
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new WeldException(e);
        }
    }
    protected T newInstance(Object[] parameterValues) {
        try {
            return .newInstance(parameterValues);
        } catch (IllegalArgumentException e) {
            rethrowException(e);
        } catch (InstantiationException e) {
            rethrowException(e);
        } catch (IllegalAccessException e) {
            rethrowException(e);
        } catch (InvocationTargetException e) {
            rethrowException(e);
        }
        return null;
    }

    
Helper method for getting the current parameter values from a list of annotated parameters.

Parameters:
parameters The list of annotated parameter to look up
manager The Bean manager
Returns:
The object array of looked up values
    public Object[] getParameterValues(BeanManagerImpl managerCreationalContext<?> ctxCreationalContext<?> transientReference) {
        if (getInjectionPoints().isEmpty()) {
            return .;
        }
        Object[] parameterValues = new Object[getParameterInjectionPoints().size()];
        Iterator<ParameterInjectionPoint<?, T>> iterator = getParameterInjectionPoints().iterator();
        for (int i = 0; i < parameterValues.lengthi++) {
            ParameterInjectionPoint<?, ?> param = iterator.next();
            if ( && param.getAnnotated().isAnnotationPresent(TransientReference.class)) {
                parameterValues[i] = param.getValueToInject(managertransientReference);
            } else {
                parameterValues[i] = param.getValueToInject(managerctx);
            }
        }
        return parameterValues;
    }
    public AnnotatedConstructor<T> getAnnotated() {
        return ;
    }
        return ;
    }
        return ;
    }
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = super.hashCode();
        result = prime * result + (( == null) ? 0 : .hashCode());
        return result;
    }
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!super.equals(obj)) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        ConstructorInjectionPoint<?> other = (ConstructorInjectionPoint<?>) obj;
        if ( == null) {
            if (other.constructor != null) {
                return false;
            }
        } else if (!.equals(other.constructor)) {
            return false;
        }
        return true;
    }
New to GrepCode? Check out our FAQ X