# 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
  Constructor
  Description
  `AdkWebServer()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addResourceHandlers(org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry registry)`
  Configures resource handlers for serving static content (like the Dev UI).
  `void`
  `addViewControllers(org.springframework.web.servlet.config.annotation.ViewControllerRegistry registry)`
  Configures simple automated controllers: - Redirects the root path "/" to "/dev-ui".
  `BaseArtifactService`
  `artifactService()`
  Provides the singleton instance of the ArtifactService (InMemory).
  `static void`
  `main(String[] args)`
  Main entry point for the Spring Boot application.
  `org.springframework.http.converter.json.MappingJackson2HttpMessageConverter`
  `mappingJackson2HttpMessageConverter(com.fasterxml.jackson.databind.ObjectMapper objectMapper)`
  Configures the message converter to use the custom ADK ObjectMapper.
  `BaseMemoryService`
  `memoryService()`
  Provides the singleton instance of the MemoryService (InMemory).
  `com.fasterxml.jackson.databind.ObjectMapper`
  `objectMapper()`
  Configures the Jackson ObjectMapper for JSON serialization.
  `BaseSessionService`
  `sessionService()`
  `static void`
  `start(BaseAgent... agents)`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods 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

    @Bean public BaseSessionService sessionService()

  - ### artifactService

    @Bean public BaseArtifactService 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

    @Bean public BaseMemoryService 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)
    Configures resource handlers for serving static content (like the Dev UI). Maps requests starting with "/dev-ui/" to the directory specified by the 'adk.web.ui.dir' system property.
    Specified by:
      `addResourceHandlers` in interface `org.springframework.web.servlet.config.annotation.WebMvcConfigurer`

  - ### addViewControllers

    public void addViewControllers(org.springframework.web.servlet.config.annotation.ViewControllerRegistry registry)
    Configures simple automated controllers: - Redirects the root path "/" to "/dev-ui". - Forwards requests to "/dev-ui" to "/dev-ui/index.html" so the ResourceHandler serves it.
    Specified by:
      `addViewControllers` in interface `org.springframework.web.servlet.config.annotation.WebMvcConfigurer`

  - ### main

    public static void main(String[] args)
    Main entry point for the Spring Boot application.
    Parameters:
      `args` - Command line arguments.

  - ### start

    public static void start(BaseAgent... agents)