Class OSGiServiceInjector

java.lang.Object
org.apache.sling.models.impl.injectors.OSGiServiceInjector
All Implemented Interfaces:
AcceptsNullName, Injector, StaticInjectAnnotationProcessorFactory

public class OSGiServiceInjector extends Object implements Injector, StaticInjectAnnotationProcessorFactory, AcceptsNullName
  • Constructor Details

    • OSGiServiceInjector

      public OSGiServiceInjector()
  • Method Details

    • getName

      @NotNull public @NotNull String getName()
      Description copied from interface: Injector
      Return a logical name for the injector. Used in resolving
      @Source
      annotations.
      Specified by:
      getName in interface Injector
      Returns:
      the injector's name
    • activate

      public void activate(org.osgi.framework.BundleContext ctx)
    • getValue

      public Object getValue(@NotNull @NotNull Object adaptable, String name, @NotNull @NotNull Type type, @NotNull @NotNull AnnotatedElement element, @NotNull @NotNull DisposalCallbackRegistry callbackRegistry)
      Description copied from interface: Injector
      Produce a value for an injection point.
      Specified by:
      getValue in interface Injector
      Parameters:
      adaptable - the object which should be used as the basis for value resolution.
      name - the injection point name (may be only null if injector implements the AcceptsNullName interface, otherwise never null)
      type - the declared type of the injection point
      element - the injection point itself
      callbackRegistry - a registry object to register a callback object which will be invoked when the adapted object is disposed.
      Returns:
      the value to be injected or null if no value could be resolved
    • getValue

      public Object getValue(@NotNull @NotNull Object adaptable, String name, @NotNull @NotNull Type type, @NotNull @NotNull AnnotatedElement element, @NotNull @NotNull DisposalCallbackRegistry callbackRegistry, @Nullable @Nullable org.osgi.framework.BundleContext modelContext)
      Parameters:
      adaptable - Adaptable
      name - Name
      type - Type
      element - Element
      callbackRegistry - Callback registry
      modelContext - Model context
      Returns:
      Object
    • createAnnotationProcessor

      public InjectAnnotationProcessor2 createAnnotationProcessor(AnnotatedElement element)
      Specified by:
      createAnnotationProcessor in interface StaticInjectAnnotationProcessorFactory
      Parameters:
      element - the field or method which is annotated
      Returns:
      a ModelAnnotationProcessor in case there is a known injector-specific annotation on the given element found otherwise null