Interface InjectionService

  • All Superinterfaces:
    PlaceholderResolver, Service

    public interface InjectionService
    extends Service, PlaceholderResolver
    Dependency injection service.

    Overview

    This interface represents the abstraction layer of dependency injection capabilities that are provided by an underlying IoC container like Spring Framework. Typically this service is used for injecting dependencies into objects that were received from some external sources (f.e. deserialized from a socket).

    Accessing the Service

    InjectionService is available only if Hekate instance was constructed via framework-specific bootstrap class (like HekateSpringBootstrap). Availability of this service can be checked via Hekate.has(Class) method. If service is available then it can be accessed via Hekate.get(Class) as in the example below:

    
    InjectionService injection = hekate.get(InjectionService.class);
    

    Enabling Injection

    In order to enable injection the HekateInject annotation must be added to a class who's dependencies should be injected. Classes that do not have this annotation will be ignored by the InjectionService.

    Injectable Components

    The following components can can be injected:

    • Hekate instance that manages this service.
    • All services that are registered within the Hekate instance
    • Any other components that are managed by the underlying IoC framework (f.e. beans from Spring Framework application context)

    Note: this service performs injection of fields/properties only. Other extended capabilities (like lifecycle management) that can be provided by an underlying IoC container are not supported.

    • Method Detail

      • inject

        void inject​(Object obj)
        Injects dependencies into the specified object.
        Parameters:
        obj - Dependent object.