Package me.gilbva.shrike
Class Shrike
java.lang.Object
me.gilbva.shrike.Shrike
public class Shrike
extends java.lang.Object
Facade for the Shrike IoC API.
This class provides the method context() which will deliver the IocContext for the application scope.
- Author:
- Gilberto Vento
-
Method Summary
Modifier and Type Method Description static IocContext<Application>context()This method returns theIocContextfor the APPLICATION scopedIocContext.static <T extends Scope>
IocContext<T>createChild(T scope)Create a child IocContext of this context.static booleanexists(java.lang.reflect.Type service)This method finds if a service is provided by a least one component in the context.static <T> Tfind(java.lang.Class<T> service)This method finds the highest priority component that provides the given service.static <T> T[]findAll(java.lang.Class<T> service)This method finds all the components that provides the given service.static java.lang.ObjectfindGeneric(java.lang.reflect.Type service)This method finds the highest priority component that provides the given generic service.static <T> TfindNext(java.lang.Class<T> service, int priority)This method finds the component that provides the given service with less priority than the priority parameter.static java.lang.ObjectfindNextGeneric(java.lang.reflect.Type service, int priority)This method finds the component that provides the given generic service with less priority than the priority parameter.static ClassRepositorygetClassRepository()Obtains the class repository associated with this context.static IocContext<?>getParent()The parent of this context.
-
Method Details
-
context
This method returns theIocContextfor the APPLICATION scopedIocContext.- Returns:
- The APPLICATION scoped
IocContextinstance for this application.
-
find
public static <T> T find(java.lang.Class<T> service)This method finds the highest priority component that provides the given service.- Type Parameters:
T- The generic type of the class of the service that this method should find.- Parameters:
service- The class that represents the service that this method must find.- Returns:
- An object that extends or implement the class of the service provided, or null if no component provides this services in the context.
-
findNext
public static <T> T findNext(java.lang.Class<T> service, int priority)This method finds the component that provides the given service with less priority than the priority parameter.- Type Parameters:
T- The generic type of the class of the service that this method should find.- Parameters:
service- The class that represents the service that this method must find.priority- The given component must have a priority value greater than this parameter.- Returns:
- An object that extends or implement the class of the service provided, or null if no component provides this services in the context.
-
findAll
public static <T> T[] findAll(java.lang.Class<T> service)This method finds all the components that provides the given service.- Type Parameters:
T- The generic type of the class of the service that this method should find.- Parameters:
service- The class that represents the service that this method must find.- Returns:
- An array of objects who extends or implement the class of the service provided, or an empty array if no component provides this services in the context.
-
findGeneric
public static java.lang.Object findGeneric(java.lang.reflect.Type service)This method finds the highest priority component that provides the given generic service.- Parameters:
service- TheTypethat represents the service that this method must find.- Returns:
- An object that extends or implement the service provided, or null if no component provides this services in the context.
-
findNextGeneric
public static java.lang.Object findNextGeneric(java.lang.reflect.Type service, int priority)This method finds the component that provides the given generic service with less priority than the priority parameter.- Parameters:
service- TheTypethat represents the service that this method must find.priority- The given component must have a priority value greater than this parameter.- Returns:
- An object that extends or implement the service provided, or null if no component provides this services in the context.
-
exists
public static boolean exists(java.lang.reflect.Type service)This method finds if a service is provided by a least one component in the context.- Parameters:
service- The type of the service to look for.- Returns:
- true If at least one component provides this service, false otherwise.
-
getParent
The parent of this context.- Returns:
- The IocContext instance representing the parent of this context, or null if this context has no parent.
-
createChild
Create a child IocContext of this context.- Type Parameters:
T- The type of the scope.- Parameters:
scope- The scope of the new context.- Returns:
- The new IocContext instance created as child of this context.
-
getClassRepository
Obtains the class repository associated with this context. that allows to find classes, fields and methods of the components in this context.- Returns:
- A ClassRepository instance
-