Search in sources :

Example 21 with Errors

use of org.elasticsearch.common.inject.internal.Errors in project crate by crate.

the class MembersInjectorStore method getInjectors.

/**
 * Returns the injectors for the specified injection points.
 */
List<SingleMemberInjector> getInjectors(Set<InjectionPoint> injectionPoints, Errors errors) {
    List<SingleMemberInjector> injectors = new ArrayList<>();
    for (InjectionPoint injectionPoint : injectionPoints) {
        try {
            Errors errorsForMember = injectionPoint.isOptional() ? new Errors(injectionPoint) : errors.withSource(injectionPoint);
            SingleMemberInjector injector = injectionPoint.getMember() instanceof Field ? new SingleFieldInjector(this.injector, injectionPoint, errorsForMember) : new SingleMethodInjector(this.injector, injectionPoint, errorsForMember);
            injectors.add(injector);
        } catch (ErrorsException ignoredForNow) {
        // ignored for now
        }
    }
    return Collections.unmodifiableList(injectors);
}
Also used : Errors(org.elasticsearch.common.inject.internal.Errors) Field(java.lang.reflect.Field) InjectionPoint(org.elasticsearch.common.inject.spi.InjectionPoint) ArrayList(java.util.ArrayList) ErrorsException(org.elasticsearch.common.inject.internal.ErrorsException)

Example 22 with Errors

use of org.elasticsearch.common.inject.internal.Errors in project crate by crate.

the class MembersInjectorImpl method injectMembers.

@Override
public void injectMembers(T instance) {
    Errors errors = new Errors(typeLiteral);
    try {
        injectAndNotify(instance, errors);
    } catch (ErrorsException e) {
        errors.merge(e.getErrors());
    }
    errors.throwProvisionExceptionIfErrorsExist();
}
Also used : Errors(org.elasticsearch.common.inject.internal.Errors) ErrorsException(org.elasticsearch.common.inject.internal.ErrorsException)

Aggregations

Errors (org.elasticsearch.common.inject.internal.Errors)22 ErrorsException (org.elasticsearch.common.inject.internal.ErrorsException)14 ConfigurationException (org.elasticsearch.common.inject.ConfigurationException)6 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 InternalContext (org.elasticsearch.common.inject.internal.InternalContext)4 Annotation (java.lang.annotation.Annotation)2 Field (java.lang.reflect.Field)2 Inject (org.elasticsearch.common.inject.Inject)2 BindingImpl (org.elasticsearch.common.inject.internal.BindingImpl)2 InstanceBindingImpl (org.elasticsearch.common.inject.internal.InstanceBindingImpl)2 InternalFactory (org.elasticsearch.common.inject.internal.InternalFactory)2 LinkedBindingImpl (org.elasticsearch.common.inject.internal.LinkedBindingImpl)2 LinkedProviderBindingImpl (org.elasticsearch.common.inject.internal.LinkedProviderBindingImpl)2 SourceProvider (org.elasticsearch.common.inject.internal.SourceProvider)2 Dependency (org.elasticsearch.common.inject.spi.Dependency)2 Element (org.elasticsearch.common.inject.spi.Element)2 InjectionPoint (org.elasticsearch.common.inject.spi.InjectionPoint)2