org.elasticsearch.common.inject
Class Injectors

java.lang.Object
  extended by org.elasticsearch.common.inject.Injectors

public class Injectors
extends Object


Constructor Summary
Injectors()
           
 
Method Summary
static void cleanCaches(Injector injector)
           
static void close(Injector injector)
           
static Binding<?> getBinding(Injector injector, Key<?> key)
          Returns the binding for the given key or null if there is no such binding
static Set<Binding<?>> getBindingsOf(Injector injector, Class<?> baseClass)
          Returns a collection of all bindings of the given base type
static Set<Binding<?>> getBindingsOf(Injector injector, Matcher<Class> matcher)
          Returns a collection of all of the bindings matching the given matcher
static Throwable getFirstErrorFailure(CreationException e)
           
static
<T> T
getInstance(Injector injector, Class<T> type, String name)
          Returns an instance of the given type with the Named annotation value.
static
<T> Set<T>
getInstancesOf(Injector injector, Class<T> baseClass)
          Returns a collection of all instances of the given base type
static
<T> Set<T>
getInstancesOf(Injector injector, Matcher<Class> matcher)
          Returns a collection of all instances matching the given matcher
static
<T> Class<?>
getKeyType(Key<?> key)
          Returns the key type of the given key
static
<T> Set<Provider<T>>
getProvidersOf(Injector injector, Class<T> baseClass)
          Returns a collection of all providers of the given base type
static
<T> Set<Provider<T>>
getProvidersOf(Injector injector, Matcher<Class> matcher)
          Returns a collection of all of the providers matching the given matcher
static boolean hasBinding(Injector injector, Class<?> baseClass)
          Returns true if a binding exists for the given base class
static boolean hasBinding(Injector injector, Key<?> key)
          Returns true if a binding exists for the given key
static boolean hasBinding(Injector injector, Matcher<Class> matcher)
          Returns true if a binding exists for the given matcher
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Injectors

public Injectors()
Method Detail

getFirstErrorFailure

public static Throwable getFirstErrorFailure(CreationException e)

getInstance

public static <T> T getInstance(Injector injector,
                                Class<T> type,
                                String name)
Returns an instance of the given type with the Named annotation value.

This method allows you to switch this code injector.getInstance(Key.get(type, Names.named(name)));

to the more concise Injectors.getInstance(injector, type, name);


getInstancesOf

public static <T> Set<T> getInstancesOf(Injector injector,
                                        Class<T> baseClass)
Returns a collection of all instances of the given base type

Type Parameters:
T - the base type
Parameters:
baseClass - the base type of objects required
Returns:
a set of objects returned from this injector

getInstancesOf

public static <T> Set<T> getInstancesOf(Injector injector,
                                        Matcher<Class> matcher)
Returns a collection of all instances matching the given matcher

Parameters:
matcher - matches the types to return instances
Returns:
a set of objects returned from this injector

getProvidersOf

public static <T> Set<Provider<T>> getProvidersOf(Injector injector,
                                                  Matcher<Class> matcher)
Returns a collection of all of the providers matching the given matcher

Parameters:
matcher - matches the types to return instances
Returns:
a set of objects returned from this injector

getProvidersOf

public static <T> Set<Provider<T>> getProvidersOf(Injector injector,
                                                  Class<T> baseClass)
Returns a collection of all providers of the given base type

Type Parameters:
T - the base type
Parameters:
baseClass - the base type of objects required
Returns:
a set of objects returned from this injector

hasBinding

public static boolean hasBinding(Injector injector,
                                 Matcher<Class> matcher)
Returns true if a binding exists for the given matcher


hasBinding

public static boolean hasBinding(Injector injector,
                                 Class<?> baseClass)
Returns true if a binding exists for the given base class


hasBinding

public static boolean hasBinding(Injector injector,
                                 Key<?> key)
Returns true if a binding exists for the given key


getBinding

public static Binding<?> getBinding(Injector injector,
                                    Key<?> key)
Returns the binding for the given key or null if there is no such binding


getBindingsOf

public static Set<Binding<?>> getBindingsOf(Injector injector,
                                            Matcher<Class> matcher)
Returns a collection of all of the bindings matching the given matcher

Parameters:
matcher - matches the types to return instances
Returns:
a set of objects returned from this injector

getBindingsOf

public static Set<Binding<?>> getBindingsOf(Injector injector,
                                            Class<?> baseClass)
Returns a collection of all bindings of the given base type

Parameters:
baseClass - the base type of objects required
Returns:
a set of objects returned from this injector

getKeyType

public static <T> Class<?> getKeyType(Key<?> key)
Returns the key type of the given key


close

public static void close(Injector injector)

cleanCaches

public static void cleanCaches(Injector injector)


Copyright © 2009-2012. All Rights Reserved.