Class ServicesToProcess

java.lang.Object
io.helidon.inject.tools.ServicesToProcess
All Implemented Interfaces:
Resettable

public class ServicesToProcess extends Object implements Resettable
Tracks the services to process, and ingests them to build the codegen model.

The basic flow: 'annotation processor(s)' -> ServicesToProcess -> AbstractCreator derivative.

Note that the flow might be repeated multiple times since annotation processors by definition are recurrent in nature.

  • Method Details

    • servicesInstance

      public static ServicesToProcess servicesInstance()
      The current services to process instance.
      Returns:
      the current services to process instance
    • create

      public static ServicesToProcess create()
      Creates a new instance, apart from the current global singleton instance exposed from servicesInstance().
      Returns:
      the new instance
      See Also:
    • onBeginProcessing

      public static void onBeginProcessing(Messager processor, Set<?> annotations, RoundEnvironment roundEnv)
      Called to signal the beginning of an annotation processing phase.
      Parameters:
      processor - the processor running
      annotations - the annotations being processed
      roundEnv - the round env
    • addOnDoneRunnable

      public static void addOnDoneRunnable(Runnable runnable)
      Called to add a runnable to call when done with all annotation processing.
      Parameters:
      runnable - the runnable to call
    • onEndProcessing

      public static void onEndProcessing(Messager processor, Set<?> annotations, RoundEnvironment roundEnv)
      Called to signal the end of an annotation processing phase.
      Parameters:
      processor - the processor running
      annotations - the annotations being processed
      roundEnv - the round env
    • reset

      public boolean reset(boolean ignoredDeep)
      Description copied from interface: Resettable
      Resets the state of this object.
      Specified by:
      reset in interface Resettable
      Parameters:
      ignoredDeep - true to iterate over any contained objects, to reflect the reset into the retained object
      Returns:
      returns true if the state was changed
    • addParentServiceType

      public boolean addParentServiceType(TypeName serviceTypeName, TypeName parentServiceTypeName)
      Introduce the parent superclass for a given service type name.
      Parameters:
      serviceTypeName - the service type name
      parentServiceTypeName - the parent for this service type name
      Returns:
      flag indicating whether the parent was accepted
    • addParentServiceType

      public boolean addParentServiceType(TypeName serviceTypeName, TypeName parentServiceTypeName, Optional<Boolean> lockParent)
      Introduce the parent superclass for a given service type name.
      Parameters:
      serviceTypeName - the service type name
      parentServiceTypeName - the parent for this service type name
      lockParent - flag indicating whether the parent should be locked
      Returns:
      flag indicating whether the parent was accepted
    • addActivatorGenericDecl

      public void addActivatorGenericDecl(TypeName serviceTypeName, String activatorGenericDecl)
      Introduce the activator generic portion of the declaration (e.g., the "CB extends MySingletonConfig" portion of MyService$$injectionActivator<CB extends MySingletonConfig>).
      Parameters:
      serviceTypeName - the service type name
      activatorGenericDecl - the generics portion of the class decl
    • addAccessLevel

      public void addAccessLevel(TypeName serviceTypeName, AccessModifier access)
      Introduce the parent superclass for a given service type name.
      Parameters:
      serviceTypeName - the service type name
      access - the access level for the service type name
      Throws:
      IllegalStateException - thrown if internal state inconsistencies are found
    • addIsAbstract

      public void addIsAbstract(TypeName serviceTypeName, boolean isAbstract)
      Introduce the flag whether the given service type name is abstract (i.e., interface or abstract) and not concrete.
      Parameters:
      serviceTypeName - the service type name
      isAbstract - whether the service type name is abstract (i.e., interface or abstract)
    • addServiceTypeHierarchy

      public void addServiceTypeHierarchy(TypeName serviceTypeName, List<TypeName> serviceTypeHierarchy)
      Introduce the parent superclass for a given service type name.
      Parameters:
      serviceTypeName - the service type name
      serviceTypeHierarchy - the list of superclasses (where this service type is the last in the list)
      Throws:
      IllegalStateException - thrown if internal state inconsistencies are found
    • hasHierarchyFor

      public boolean hasHierarchyFor(TypeName serviceTypeName)
      Checks whether the service type has an established super class hierarchy set.
      Parameters:
      serviceTypeName - the service type name
      Returns:
      true if the hierarchy is known for this service type
    • hasContractsFor

      public boolean hasContractsFor(TypeName serviceTypeName)
      Checks whether the service type has an established set of contracts that are known for it.
      Parameters:
      serviceTypeName - the service type name
      Returns:
      true if contracts are known about this service type
    • hasVisitedInterceptorPlanFor

      public boolean hasVisitedInterceptorPlanFor(TypeName serviceTypeName)
      Checks whether the service type has been evaluated for an interceptor plan.
      Parameters:
      serviceTypeName - the service type name
      Returns:
      true if this service type has already been considered for interceptors
    • addInterceptorPlanFor

      public void addInterceptorPlanFor(TypeName serviceTypeName, Optional<io.helidon.inject.tools.InterceptionPlan> plan)
      Sets the InterceptionPlan for the given service type.
      Parameters:
      serviceTypeName - the service type name
      plan - the interceptor plan
      Throws:
      IllegalStateException - thrown if internal state inconsistencies are found
    • interceptorPlans

      public Map<TypeName,io.helidon.inject.tools.InterceptionPlan> interceptorPlans()
      The interception plan for each service type that has a non-null interception plan.
      Returns:
      the interception plan for each service type
    • clearInterceptorPlans

      public void clearInterceptorPlans()
      Clears out just the interceptor plans.
    • addExtraCodeGen

      public void addExtraCodeGen(TypeName serviceTypeName, String codeGen)
      Adds extra code gen per service type.
      Parameters:
      serviceTypeName - the service type name
      codeGen - the extra code gen to tack onto the activator implementation
    • addExtraActivatorClassComments

      public void addExtraActivatorClassComments(TypeName serviceTypeName, String codeGen)
      Adds extra cactivator class level comments.
      Parameters:
      serviceTypeName - the service type name
      codeGen - the extra comments tack onto the activator implementation
    • addTypeForContract

      public void addTypeForContract(TypeName serviceTypeName, TypeName contractTypeName, boolean isExternal)
      Introduces a contract associated with a service type.
      Parameters:
      serviceTypeName - the service type name
      contractTypeName - the contract type name
      isExternal - whether the contract is external
    • addDependencies

      public void addDependencies(io.helidon.inject.api.DependenciesInfo dependencies)
      Introduces a new set of dependencies to the model.
      Parameters:
      dependencies - the dependencies
    • addPreDestroyMethod

      public void addPreDestroyMethod(TypeName serviceTypeName, String preDestroyMethodName)
      Introduces a PreDestroy method to the model for a given service type.
      Parameters:
      serviceTypeName - the service type name
      preDestroyMethodName - the method name
      Throws:
      IllegalStateException - thrown if internal state inconsistencies are found
    • addPostConstructMethod

      public void addPostConstructMethod(TypeName serviceTypeName, String postConstructMethodName)
      Introduces a PostConstruct method to the model for a given service type.
      Parameters:
      serviceTypeName - the service type name
      postConstructMethodName - the method name
      Throws:
      IllegalStateException - thrown if internal state inconsistencies are found
    • addDeclaredWeight

      public void addDeclaredWeight(TypeName serviceTypeName, Double weight)
      Sets the weight of a service type.
      Parameters:
      serviceTypeName - the service type name
      weight - the weight priority
      Throws:
      IllegalStateException - thrown if internal state inconsistencies are found
    • addDeclaredRunLevel

      public void addDeclaredRunLevel(TypeName serviceTypeName, Integer runLevel)
      Sets the run level for a service type name.
      Parameters:
      serviceTypeName - the service type name
      runLevel - its run level
      Throws:
      IllegalStateException - thrown if internal state inconsistencies are found
    • addScopeTypeName

      public void addScopeTypeName(TypeName serviceTypeName, TypeName scopeTypeName)
      Adds a scope type name for a service type name.
      Parameters:
      serviceTypeName - the service type name
      scopeTypeName - its scope type name
    • addProviderFor

      public void addProviderFor(TypeName serviceTypeName, Set<TypeName> providerFor)
      Establishes the fact that a given service type is a Provider type for the given provided types.
      Parameters:
      serviceTypeName - the service type name
      providerFor - the types that it provides
      Throws:
      IllegalStateException - thrown if internal state inconsistencies are found
    • addQualifiers

      public void addQualifiers(TypeName serviceTypeName, Set<io.helidon.inject.api.Qualifier> qualifiers)
      Sets the qualifiers associated with a service type.
      Parameters:
      serviceTypeName - the service type name
      qualifiers - its qualifiers
      Throws:
      IllegalStateException - thrown if internal state inconsistencies are found
    • serviceTypeNames

      public List<TypeName> serviceTypeNames()
      Fetches the set of known service type names being processed in this batch.
      Returns:
      the list of known service type names being processed
    • generatedServiceTypeNames

      public List<TypeName> generatedServiceTypeNames()
      Fetches the set of known service type names being code generated in this batch.
      Returns:
      the list of known service type names being code generated
    • generatedServiceTypeNames

      public void generatedServiceTypeNames(Collection<TypeName> coll)
      Sets the service type names being code generated in this batch.
      Parameters:
      coll - the collection of services to be code generated
    • weightedPriorities

      public Map<TypeName,Double> weightedPriorities()
      Fetches the map of service types to their priorities.
      Returns:
      the map of service types to their priorities
    • runLevels

      public Map<TypeName,Integer> runLevels()
      Fetches the map of service types to their run levels.
      Returns:
      the map of service types to their run levels
    • scopeTypeNames

      public Map<TypeName,Set<TypeName>> scopeTypeNames()
      Fetches the map of service types to their scope type names.
      Returns:
      the map of service types to their scope type names
    • addExternalRequiredModules

      public void addExternalRequiredModules(TypeName serviceTypeName, Collection<String> moduleNames)
      Introduces the need for external modules.
      Parameters:
      serviceTypeName - the service type name
      moduleNames - the required module names to support known external contracts
    • moduleName

      public void moduleName(String moduleName)
      Sets this module name.
      Parameters:
      moduleName - the module name
    • clearModuleName

      public void clearModuleName()
      Clears the module name.
    • moduleName

      public String moduleName()
      This module name.
      Returns:
      this module name
    • lastKnownModuleInfoDescriptor

      public void lastKnownModuleInfoDescriptor(io.helidon.inject.tools.ModuleInfoDescriptor descriptor)
      The last known descriptor being processed.
      Parameters:
      descriptor - the descriptor
    • lastKnownModuleInfoFilePath

      public void lastKnownModuleInfoFilePath(Path lastKnownModuleInfoFile)
      The last known file path location for the module-info descriptor being processed.
      Parameters:
      lastKnownModuleInfoFile - the file path location for the descriptor
    • lastKnownSourcePathBeingProcessed

      public void lastKnownSourcePathBeingProcessed(Path lastKnownSourcePathBeingProcessed)
      Sets the last known source path being processed.
      Parameters:
      lastKnownSourcePathBeingProcessed - the last source path being processed
    • lastKnownTypeSuffix

      public void lastKnownTypeSuffix(String typeSuffix)
      Sets the last known type suffix (e.g., "test").
      Parameters:
      typeSuffix - the optional type suffix
    • lastGeneratedPackageName

      public void lastGeneratedPackageName(String lastGeneratedPackageName)
      Sets the last generated package name.
      Parameters:
      lastGeneratedPackageName - the package name
    • defaultConstructor

      public void defaultConstructor(TypeName serviceType, String constructor)
      Use a custom default constructor code.
      Parameters:
      serviceType - type of service
      constructor - constructor generated code