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 the IocContext for the APPLICATION scoped IocContext.
    static <T extends Scope>
    IocContext<T>
    createChild​(T scope)
    Create a child IocContext of this context.
    static boolean exists​(java.lang.reflect.Type service)
    This method finds if a service is provided by a least one component in the context.
    static <T> T find​(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.Object findGeneric​(java.lang.reflect.Type service)
    This method finds the highest priority component that provides the given generic service.
    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.
    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.
    static ClassRepository getClassRepository()
    Obtains the class repository associated with this context.
    static IocContext<?> getParent()
    The parent of this context.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • context

      public static IocContext<Application> context()
      This method returns the IocContext for the APPLICATION scoped IocContext.

      Returns:
      The APPLICATION scoped IocContext instance 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 - The Type that 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 - The Type 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 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

      public static IocContext<?> 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

      public static <T extends Scope> IocContext<T> createChild​(T scope)
      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

      public static ClassRepository 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