EnvironmentPostProcessor

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.

Processing Order:

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

Profile Activation:

Profiles are activated through two mechanisms:

  • System property: spring.profiles.active - for compatibility
  • Environment API: environment.addActiveProfile() - for direct activation

Example:



 // 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.
}

Implementation Notes:

  • 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

Author

Embabel Team

Since

1.0

See also

org.springframework.boot.env.EnvironmentPostProcessor

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
open fun getOrder(): Int
Returns the order of this post-processor.
Link copied to clipboard
open fun postProcessEnvironment(environment: ConfigurableEnvironment, application: SpringApplication)
Post-processes the environment to activate profiles based on agent annotations.