Class InjectionGenerator

java.lang.Object
org.springframework.beans.factory.generator.InjectionGenerator

public class InjectionGenerator extends Object
Generate the necessary code to create a bean instance or inject dependencies.

The generator assumes a number of variables to be accessible:

Author:
Stephane Nicoll, Brian Clozel
  • Constructor Details

    • InjectionGenerator

      public InjectionGenerator()
  • Method Details

    • generateInstantiation

      public org.springframework.javapoet.CodeBlock generateInstantiation(Executable creator)
      Generate the necessary code to instantiate an object using the specified Executable. The code is suitable to be assigned to a variable or used as a return statement.
      Parameters:
      creator - the executable to invoke to create an instance of the requested object
      Returns:
      the code to instantiate an object using the specified executable
    • generateInjection

      public org.springframework.javapoet.CodeBlock generateInjection(Member member, boolean required)
      Generate the code to inject a value resolved by BeanDefinitionRegistrar.BeanInstanceContext in the specified Member.
      Parameters:
      member - the field or method to inject
      required - whether the value is required
      Returns:
      a statement that injects a value to the specified member
      See Also:
    • getProtectedAccessInjectionOptions

      public ProtectedAccess.Options getProtectedAccessInjectionOptions(Member member)
      Return the ProtectedAccess.Options to use if protected access analysis is required for the specified Member.
      Parameters:
      member - the field or method to handle
      Returns:
      the options to use to analyse protected access
      See Also: