Refine search
private static void checkBeanTypeForWildcardsAndTypeVariables(Type beanType, Type type, BeanAttributes<?> attributes) { if (type instanceof TypeVariable<?>) { if (!attributes.getScope().equals(Dependent.class)) { throw MetadataLogger.LOG.beanWithParameterizedTypeContainingTypeVariablesMustBeDependentScoped(beanType, attributes); } } else if (type instanceof WildcardType) { throw MetadataLogger.LOG.parameterizedTypeContainingWildcardParameterIsNotAValidBeanType(beanType, attributes); } else if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; for (Type typeArgument : parameterizedType.getActualTypeArguments()) { checkBeanTypeForWildcardsAndTypeVariables(beanType, typeArgument, attributes); } } else if (type instanceof GenericArrayType) { GenericArrayType arrayType = (GenericArrayType) type; checkBeanTypeForWildcardsAndTypeVariables(beanType, arrayType.getGenericComponentType(), attributes); } }
private static void checkBeanTypeNotATypeVariable(Type beanType, Type type, BeanAttributes<?> attributes) { if (type instanceof TypeVariable<?>) { throw MetadataLogger.LOG.typeVariableIsNotAValidBeanType(beanType, attributes); } else if (type instanceof GenericArrayType) { GenericArrayType arrayType = (GenericArrayType) type; checkBeanTypeNotATypeVariable(beanType, arrayType.getGenericComponentType(), attributes); } }
/** * @param source source {@link BeanAttributes}. * @return a safe copy of source {@link BeanAttributes}. */ public static <T> BeanAttributes<T> of(BeanAttributes<T> source, BeanManager manager) { validateBeanAttributes(source, manager); BeanAttributes<T> attributes = new ImmutableBeanAttributes<T>(defensiveCopy(source.getStereotypes()), source.isAlternative(), source.getName(), defensiveCopy(source.getQualifiers()), defensiveCopy(source.getTypes()), source.getScope()); return attributes; }
/** * Validates {@link BeanAttributes}. * @param attributes {@link BeanAttributes} to validate */ public static void validateBeanAttributes(BeanAttributes<?> attributes, BeanManager manager) { validateStereotypes(attributes, manager); validateQualifiers(attributes, manager); validateTypes(attributes, manager); validateScope(attributes, manager); }
private static void validateBeanType(Type type, BeanAttributes<?> attributes) { checkBeanTypeNotATypeVariable(type, type, attributes); checkBeanTypeForWildcardsAndTypeVariables(type, type, attributes); }
public static void validateTypes(BeanAttributes<?> attributes, BeanManager manager) { if(attributes.getTypes() == null) { throw MetadataLogger.LOG.typesNull(attributes); } if (attributes.getTypes().isEmpty()) { throw MetadataLogger.LOG.typesEmpty(attributes); } for (Type type : attributes.getTypes()) { validateBeanType(type, attributes); } }
@Override public void addBean(Bean<?> bean) { checkWithinObserverNotification(); Preconditions.checkArgumentNotNull(bean, "bean"); ExternalBeanAttributesFactory.validateBeanAttributes(bean, getBeanManager()); validateBean(bean); additionalBeans.add(bean); BootstrapLogger.LOG.addBeanCalled(getReceiver(), bean); }
protected <T, S> boolean fireProcessBeanAttributes(AbstractBean<T, S> bean) { if (!specializationAndEnablementRegistry.isCandidateForLifecycleEvent(bean)) { return false; } ProcessBeanAttributesImpl<T> event = containerLifecycleEvents.fireProcessBeanAttributes(getManager(), bean, bean.getAnnotated(), bean.getType()); if (event == null) { return false; } if (event.isVeto()) { return true; } if (event.isDirty()) { bean.setAttributes(ExternalBeanAttributesFactory.<T>of(event.getBeanAttributesInternal(), manager)); bean.checkSpecialization(); } return false; } }
public static void validateTypes(BeanAttributes<?> attributes, BeanManager manager) { if(attributes.getTypes() == null) { throw MetadataLogger.LOG.typesNull(attributes); } if (attributes.getTypes().isEmpty()) { throw MetadataLogger.LOG.typesEmpty(attributes); } for (Type type : attributes.getTypes()) { validateBeanType(type, attributes); } }
/** * Validates {@link BeanAttributes}. * @param attributes {@link BeanAttributes} to validate */ public static void validateBeanAttributes(BeanAttributes<?> attributes, BeanManager manager) { validateStereotypes(attributes, manager); validateQualifiers(attributes, manager); validateTypes(attributes, manager); validateScope(attributes, manager); }
private static void validateBeanType(Type type, BeanAttributes<?> attributes) { checkBeanTypeNotATypeVariable(type, type, attributes); checkBeanTypeForWildcardsAndTypeVariables(type, type, attributes); }
@Override public void addBean(Bean<?> bean) { checkWithinObserverNotification(); Preconditions.checkArgumentNotNull(bean, "bean"); ExternalBeanAttributesFactory.validateBeanAttributes(bean, getBeanManager()); validateBean(bean); additionalBeans.add(BeanRegistration.of(bean, getReceiver())); BootstrapLogger.LOG.addBeanCalled(getReceiver(), bean); }
protected <T, S> boolean fireProcessBeanAttributes(AbstractBean<T, S> bean) { if (!specializationAndEnablementRegistry.isCandidateForLifecycleEvent(bean)) { return false; } ProcessBeanAttributesImpl<T> event = containerLifecycleEvents.fireProcessBeanAttributes(getManager(), bean, bean.getAnnotated(), bean.getType()); if (event == null) { return false; } if (event.isVeto()) { return true; } if (event.isDirty()) { bean.setAttributes(ExternalBeanAttributesFactory.<T>of(event.getBeanAttributesInternal(), manager)); bean.checkSpecialization(); } if (event.isIgnoreFinalMethods()) { bean.setIgnoreFinalMethods(); } return false; } }
/** * @param source source {@link BeanAttributes}. * @return a safe copy of source {@link BeanAttributes}. */ public static <T> BeanAttributes<T> of(BeanAttributes<T> source, BeanManager manager) { validateBeanAttributes(source, manager); BeanAttributes<T> attributes = new ImmutableBeanAttributes<T>(defensiveCopy(source.getStereotypes()), source.isAlternative(), source.getName(), defensiveCopy(source.getQualifiers()), defensiveCopy(source.getTypes()), source.getScope()); return attributes; }
public static void validateTypes(BeanAttributes<?> attributes, BeanManager manager) { if(attributes.getTypes() == null) { throw MetadataLogger.LOG.typesNull(attributes); } if (attributes.getTypes().isEmpty()) { throw MetadataLogger.LOG.typesEmpty(attributes); } for (Type type : attributes.getTypes()) { validateBeanType(type, attributes); } }
private static void checkBeanTypeForWildcardsAndTypeVariables(Type beanType, Type type, BeanAttributes<?> attributes) { if (type instanceof TypeVariable<?>) { if (!attributes.getScope().equals(Dependent.class)) { throw MetadataLogger.LOG.beanWithParameterizedTypeContainingTypeVariablesMustBeDependentScoped(beanType, attributes); } } else if (type instanceof WildcardType) { throw MetadataLogger.LOG.parameterizedTypeContainingWildcardParameterIsNotAValidBeanType(beanType, attributes); } else if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; for (Type typeArgument : parameterizedType.getActualTypeArguments()) { checkBeanTypeForWildcardsAndTypeVariables(beanType, typeArgument, attributes); } } else if (type instanceof GenericArrayType) { GenericArrayType arrayType = (GenericArrayType) type; checkBeanTypeForWildcardsAndTypeVariables(beanType, arrayType.getGenericComponentType(), attributes); } }
/** * Validates {@link BeanAttributes}. * @param attributes {@link BeanAttributes} to validate */ public static void validateBeanAttributes(BeanAttributes<?> attributes, BeanManager manager) { validateStereotypes(attributes, manager); validateQualifiers(attributes, manager); validateTypes(attributes, manager); validateScope(attributes, manager); }
private static void checkBeanTypeNotATypeVariable(Type beanType, Type type, BeanAttributes<?> attributes) { if (type instanceof TypeVariable<?>) { throw MetadataLogger.LOG.typeVariableIsNotAValidBeanType(beanType, attributes); } else if (type instanceof GenericArrayType) { GenericArrayType arrayType = (GenericArrayType) type; checkBeanTypeNotATypeVariable(beanType, arrayType.getGenericComponentType(), attributes); } }
private static void validateBeanType(Type type, BeanAttributes<?> attributes) { checkBeanTypeNotATypeVariable(type, type, attributes); checkBeanTypeForWildcardsAndTypeVariables(type, type, attributes); }
@Override public void addBean(Bean<?> bean) { checkWithinObserverNotification(); Preconditions.checkArgumentNotNull(bean, "bean"); ExternalBeanAttributesFactory.validateBeanAttributes(bean, getBeanManager()); validateBean(bean); additionalBeans.add(BeanRegistration.of(bean, getReceiver())); BootstrapLogger.LOG.addBeanCalled(getReceiver(), bean); }