use of io.micronaut.core.annotation.UsedByGeneratedCode in project micronaut-core by micronaut-projects.
the class AbstractInitializableBeanDefinition method getBeanRegistrationsForField.
/**
* Obtains all bean definitions for a field injection point.
* <p>
* Warning: this method is used by internal generated code and should not be called by user code.
*
* @param resolutionContext The resolution context
* @param context The context
* @param fieldIndex The field index
* @param genericType The generic type
* @param qualifier The qualifier
* @return The resolved bean
*/
@Internal
@UsedByGeneratedCode
protected final Object getBeanRegistrationsForField(BeanResolutionContext resolutionContext, BeanContext context, int fieldIndex, Argument genericType, Qualifier qualifier) {
FieldReference fieldRef = fieldInjection[fieldIndex];
Argument argument = resolveEnvironmentArgument(context, fieldRef.argument);
try (BeanResolutionContext.Path ignored = resolutionContext.getPath().pushFieldResolve(this, argument, fieldRef.requiresReflection)) {
return resolveBeanRegistrations(resolutionContext, context, argument, resolveEnvironmentArgument(context, genericType), qualifier);
}
}
use of io.micronaut.core.annotation.UsedByGeneratedCode in project micronaut-core by micronaut-projects.
the class AbstractInitializableBeanDefinition method getValueForPath.
/**
* Resolve a value for the given field of the given type and path.
*
* @param resolutionContext The resolution context
* @param context The bean context
* @param propertyType The required property type
* @param propertyPath The property path
* @param <T1> The generic type
* @return An optional value
*/
@Internal
@UsedByGeneratedCode
protected final <T1> Optional<T1> getValueForPath(BeanResolutionContext resolutionContext, BeanContext context, Argument<T1> propertyType, String propertyPath) {
if (context instanceof PropertyResolver) {
PropertyResolver propertyResolver = (PropertyResolver) context;
String valString = substituteWildCards(resolutionContext, propertyPath);
return propertyResolver.getProperty(valString, ConversionContext.of(propertyType));
}
return Optional.empty();
}
use of io.micronaut.core.annotation.UsedByGeneratedCode in project micronaut-core by micronaut-projects.
the class AbstractInitializableBeanDefinition method getValueForConstructorArgument.
/**
* Obtains a value for a bean definition for a constructor at the given index
* <p>
* Warning: this method is used by internal generated code and should not be called by user code.
*
* @param resolutionContext The resolution context
* @param context The context
* @param argIndex The argument index
* @param qualifier The qualifier
* @return The resolved bean
*/
@Internal
@UsedByGeneratedCode
@Deprecated
protected final Object getValueForConstructorArgument(BeanResolutionContext resolutionContext, BeanContext context, int argIndex, Qualifier qualifier) {
MethodReference constructorRef = (MethodReference) constructor;
Argument<?> argument = constructorRef.arguments[argIndex];
try (BeanResolutionContext.Path ignored = resolutionContext.getPath().pushConstructorResolve(this, argument)) {
try {
Object result = resolveValue(resolutionContext, context, constructorRef.annotationMetadata, argument, qualifier);
if (this instanceof ValidatedBeanDefinition) {
((ValidatedBeanDefinition) this).validateBeanArgument(resolutionContext, getConstructor(), argument, argIndex, result);
}
return result;
} catch (NoSuchBeanException | BeanInstantiationException e) {
throw new DependencyInjectionException(resolutionContext, argument, e);
}
}
}
use of io.micronaut.core.annotation.UsedByGeneratedCode in project micronaut-core by micronaut-projects.
the class AbstractInitializableBeanDefinition method getBeansOfTypeForConstructorArgument.
/**
* Obtains all bean definitions for a constructor argument at the given index.
* <p>
*
* @param resolutionContext The resolution context
* @param context The context
* @param argumentIndex The argument index
* @param genericType The generic type
* @param qualifier The qualifier
* @return The resolved bean
*/
@Internal
@UsedByGeneratedCode
protected final Collection<Object> getBeansOfTypeForConstructorArgument(BeanResolutionContext resolutionContext, BeanContext context, int argumentIndex, Argument genericType, Qualifier qualifier) {
MethodReference constructorMethodRef = (MethodReference) constructor;
Argument argument = resolveArgument(context, argumentIndex, constructorMethodRef.arguments);
try (BeanResolutionContext.Path ignored = resolutionContext.getPath().pushConstructorResolve(this, argument)) {
return resolveBeansOfType(resolutionContext, context, argument, resolveEnvironmentArgument(context, genericType), qualifier);
}
}
use of io.micronaut.core.annotation.UsedByGeneratedCode in project micronaut-core by micronaut-projects.
the class AbstractInitializableBeanDefinition method findBeanForField.
/**
* Obtains a an optional for the field at the given index and the argument at the given index
* <p>
* Warning: this method is used by internal generated code and should not be called by user code.
*
* @param resolutionContext The resolution context
* @param context The context
* @param fieldIndex The field index
* @param genericType The generic type
* @param qualifier The qualifier
* @return The resolved bean
*/
@Internal
@UsedByGeneratedCode
protected final Optional findBeanForField(BeanResolutionContext resolutionContext, BeanContext context, int fieldIndex, Argument genericType, Qualifier qualifier) {
FieldReference fieldRef = fieldInjection[fieldIndex];
Argument argument = resolveEnvironmentArgument(context, fieldRef.argument);
try (BeanResolutionContext.Path ignored = resolutionContext.getPath().pushFieldResolve(this, argument, fieldRef.requiresReflection)) {
return resolveOptionalBean(resolutionContext, context, argument, resolveEnvironmentArgument(context, genericType), qualifier);
}
}
Aggregations