Class EnvironmentPostProcessor

  • All Implemented Interfaces:
    org.springframework.boot.env.EnvironmentPostProcessor , org.springframework.core.Ordered

    
    public class EnvironmentPostProcessor
     implements EnvironmentPostProcessor, Ordered
                        

    Environment post-processor that activates Spring profiles based on Embabel Agent annotations.

    This processor runs very early in the Spring Boot startup sequence and examines the application's main class for agent-related annotations. It then activates corresponding Spring profiles to enable platform-specific configurations.

    • Platform Profiles - From @AgentPlatform or meta-annotations like @EnableAgentShell
    • Logging Theme - From @EnableAgents(loggingTheme="...")
    • Local Models - From @EnableAgents(localModels={...})
    • MCP Servers - From @EnableAgents(mcpServers={...})

    Profiles are activated through two mechanisms:

    • System property: spring.profiles.active - for compatibility
    • Environment API: environment.addActiveProfile() - for direct activation
    
    
     // Activates "shell" profile
    
        loggingTheme = LoggingThemes.START_WARS
        localModels = {LocalModels.OLAMA},
        mcpServer = {McpServers.DOCKER_DESKTOP}
    )
    public class MyApp {
        // Result: Application comes up with Start Wars Theme, Local Models for Ollama
        // and will try to connect to Docker Desktop MCP server.
    }
    
    • Runs with HIGHEST_PRECEDENCE to ensure early execution
    • Preserves existing profiles if already set
    • Handles multiple application sources (though typically there's only one)
    • Uses both annotation utils for proper meta-annotation support
    Since:

    1.0

    Author:

    Embabel Team

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) Post-processes the environment to activate profiles based on agent annotations.
      int getOrder() Returns the order of this post-processor.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EnvironmentPostProcessor

        EnvironmentPostProcessor()
    • Method Detail

      • postProcessEnvironment

         void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application)

        Post-processes the environment to activate profiles based on agent annotations.

        Parameters:
        environment - the environment to post-process
        application - the Spring application