Search in sources :

Example 1 with Key

use of org.elasticsearch.common.inject.Key in project elasticsearch by elastic.

the class PrivateElementsImpl method applyTo.

@Override
public void applyTo(Binder binder) {
    PrivateBinder privateBinder = binder.withSource(source).newPrivateBinder();
    for (Element element : getElements()) {
        element.applyTo(privateBinder);
    }
    // ensure exposedKeysToSources is populated
    getExposedKeys();
    for (Map.Entry<Key<?>, Object> entry : exposedKeysToSources.entrySet()) {
        privateBinder.withSource(entry.getValue()).expose(entry.getKey());
    }
}
Also used : PrivateBinder(org.elasticsearch.common.inject.PrivateBinder) Element(org.elasticsearch.common.inject.spi.Element) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Collections.unmodifiableMap(java.util.Collections.unmodifiableMap) Key(org.elasticsearch.common.inject.Key)

Example 2 with Key

use of org.elasticsearch.common.inject.Key in project crate by crate.

the class Errors method formatSource.

public static void formatSource(Formatter formatter, Object source) {
    if (source instanceof Dependency) {
        Dependency<?> dependency = (Dependency<?>) source;
        InjectionPoint injectionPoint = dependency.getInjectionPoint();
        if (injectionPoint != null) {
            formatInjectionPoint(formatter, dependency, injectionPoint);
        } else {
            formatSource(formatter, dependency.getKey());
        }
    } else if (source instanceof InjectionPoint) {
        formatInjectionPoint(formatter, null, (InjectionPoint) source);
    } else if (source instanceof Class) {
        formatter.format("  at %s%n", StackTraceElements.forType((Class<?>) source));
    } else if (source instanceof Member) {
        formatter.format("  at %s%n", StackTraceElements.forMember((Member) source));
    } else if (source instanceof TypeLiteral) {
        formatter.format("  while locating %s%n", source);
    } else if (source instanceof Key) {
        Key<?> key = (Key<?>) source;
        formatter.format("  while locating %s%n", convert(key));
    } else {
        formatter.format("  at %s%n", source);
    }
}
Also used : TypeLiteral(org.elasticsearch.common.inject.TypeLiteral) InjectionPoint(org.elasticsearch.common.inject.spi.InjectionPoint) Dependency(org.elasticsearch.common.inject.spi.Dependency) Member(java.lang.reflect.Member) Key(org.elasticsearch.common.inject.Key)

Example 3 with Key

use of org.elasticsearch.common.inject.Key in project elasticsearch by elastic.

the class Errors method formatSource.

public static void formatSource(Formatter formatter, Object source) {
    if (source instanceof Dependency) {
        Dependency<?> dependency = (Dependency<?>) source;
        InjectionPoint injectionPoint = dependency.getInjectionPoint();
        if (injectionPoint != null) {
            formatInjectionPoint(formatter, dependency, injectionPoint);
        } else {
            formatSource(formatter, dependency.getKey());
        }
    } else if (source instanceof InjectionPoint) {
        formatInjectionPoint(formatter, null, (InjectionPoint) source);
    } else if (source instanceof Class) {
        formatter.format("  at %s%n", StackTraceElements.forType((Class<?>) source));
    } else if (source instanceof Member) {
        formatter.format("  at %s%n", StackTraceElements.forMember((Member) source));
    } else if (source instanceof TypeLiteral) {
        formatter.format("  while locating %s%n", source);
    } else if (source instanceof Key) {
        Key<?> key = (Key<?>) source;
        formatter.format("  while locating %s%n", convert(key));
    } else {
        formatter.format("  at %s%n", source);
    }
}
Also used : TypeLiteral(org.elasticsearch.common.inject.TypeLiteral) InjectionPoint(org.elasticsearch.common.inject.spi.InjectionPoint) Dependency(org.elasticsearch.common.inject.spi.Dependency) Member(java.lang.reflect.Member) Key(org.elasticsearch.common.inject.Key)

Example 4 with Key

use of org.elasticsearch.common.inject.Key in project crate by crate.

the class PrivateElementsImpl method applyTo.

@Override
public void applyTo(Binder binder) {
    PrivateBinder privateBinder = binder.withSource(source).newPrivateBinder();
    for (Element element : getElements()) {
        element.applyTo(privateBinder);
    }
    // ensure exposedKeysToSources is populated
    getExposedKeys();
    for (Map.Entry<Key<?>, Object> entry : exposedKeysToSources.entrySet()) {
        privateBinder.withSource(entry.getValue()).expose(entry.getKey());
    }
}
Also used : PrivateBinder(org.elasticsearch.common.inject.PrivateBinder) Element(org.elasticsearch.common.inject.spi.Element) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Collections.unmodifiableMap(java.util.Collections.unmodifiableMap) Key(org.elasticsearch.common.inject.Key)

Aggregations

Key (org.elasticsearch.common.inject.Key)4 Member (java.lang.reflect.Member)2 Collections.unmodifiableMap (java.util.Collections.unmodifiableMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 PrivateBinder (org.elasticsearch.common.inject.PrivateBinder)2 TypeLiteral (org.elasticsearch.common.inject.TypeLiteral)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