Class AdkWebServer
java.lang.Object
com.google.adk.web.AdkWebServer
- All Implemented Interfaces:
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
@SpringBootApplication
@ConfigurationPropertiesScan
public class AdkWebServer
extends Object
implements org.springframework.web.servlet.config.annotation.WebMvcConfigurer
Spring Boot application for the Agent Server.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddResourceHandlers(org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry registry) Maps requests under "/dev-ui/" to the directory named by the 'adk.web.ui.dir' property, or to the bundled copy on the classpath when that is unset.voidaddViewControllers(org.springframework.web.servlet.config.annotation.ViewControllerRegistry registry) Configures simple automated controllers: "/" and "/dev-ui" both redirect to "/dev-ui/", which forwards to the UI's index.html.Provides the singleton instance of the ArtifactService (InMemory).static voidMain entry point for the Spring Boot application.org.springframework.http.converter.json.MappingJackson2HttpMessageConvertermappingJackson2HttpMessageConverter(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Configures the message converter to use the custom ADK ObjectMapper.Provides the singleton instance of the MemoryService (InMemory).com.fasterxml.jackson.databind.ObjectMapperConfigures the Jackson ObjectMapper for JSON serialization.static voidMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.web.servlet.config.annotation.WebMvcConfigurer
addArgumentResolvers, addCorsMappings, addErrorResponseInterceptors, addFormatters, addInterceptors, addReturnValueHandlers, configureApiVersioning, configureAsyncSupport, configureContentNegotiation, configureDefaultServletHandling, configureHandlerExceptionResolvers, configureMessageConverters, configureMessageConverters, configurePathMatch, configureViewResolvers, extendHandlerExceptionResolvers, extendMessageConverters, getMessageCodesResolver, getValidator
-
Constructor Details
-
AdkWebServer
public AdkWebServer()
-
-
Method Details
-
sessionService
-
artifactService
Provides the singleton instance of the ArtifactService (InMemory). TODO: configure this based on config (e.g., DB URL)- Returns:
- An instance of BaseArtifactService (currently InMemoryArtifactService).
-
memoryService
Provides the singleton instance of the MemoryService (InMemory). Will be made configurable once we have the Vertex MemoryService.- Returns:
- An instance of BaseMemoryService (currently InMemoryMemoryService).
-
objectMapper
@Bean @Primary public com.fasterxml.jackson.databind.ObjectMapper objectMapper()Configures the Jackson ObjectMapper for JSON serialization. Uses the ADK standard mapper configuration.- Returns:
- Configured ObjectMapper instance
-
mappingJackson2HttpMessageConverter
@Bean public org.springframework.http.converter.json.MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Configures the message converter to use the custom ADK ObjectMapper. This ensures that Spring Web uses the correct JSON serialization settings (like omitting absent optional fields) and prevents double-serialization issues, particularly for Server-Sent Events (SSE).- Parameters:
objectMapper- The primary ObjectMapper configured for the ADK.- Returns:
- A configured MappingJackson2HttpMessageConverter.
-
addResourceHandlers
public void addResourceHandlers(org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry registry) Maps requests under "/dev-ui/" to the directory named by the 'adk.web.ui.dir' property, or to the bundled copy on the classpath when that is unset.- Specified by:
addResourceHandlersin interfaceorg.springframework.web.servlet.config.annotation.WebMvcConfigurer
-
addViewControllers
public void addViewControllers(org.springframework.web.servlet.config.annotation.ViewControllerRegistry registry) Configures simple automated controllers: "/" and "/dev-ui" both redirect to "/dev-ui/", which forwards to the UI's index.html. The trailing slash is required: index.html declares a<base href="./">, so served from "/dev-ui" the app resolves its own router path to "dev-ui" and matches none of its routes. The query string is carried across because the UI selects its agent from?app=and the sample READMEs send users to the slashless "/dev-ui", so a redirect that dropped it would silently ignore the selection.- Specified by:
addViewControllersin interfaceorg.springframework.web.servlet.config.annotation.WebMvcConfigurer
-
main
Main entry point for the Spring Boot application.- Parameters:
args- Command line arguments.
-
start
-