Class EndpointCodeGenerator

java.lang.Object
com.vaadin.hilla.EndpointCodeGenerator

@Component public class EndpointCodeGenerator extends Object
Handles (re)generation of the TypeScript code.
  • Constructor Summary

    Constructors
    Constructor
    Description
    EndpointCodeGenerator(com.vaadin.flow.server.VaadinContext context, EndpointController endpointController)
    Creates the singleton.
  • Method Summary

    Modifier and Type
    Method
    Description
    static List<Class<?>>
    findBrowserCallables(com.vaadin.hilla.engine.EngineAutoConfiguration engineConfiguration, org.springframework.context.ApplicationContext applicationContext)
    Finds all beans in the application context that have a browser callable annotation.
    void
    generate(com.vaadin.hilla.engine.EngineAutoConfiguration engineConfiguration, org.springframework.context.ApplicationContext applicationContext)
    Walks the browser callable classes of the application and writes their TypeScript, remembering what it is written from, so that the first change to a class does not have to walk them all again to tell whether it matters.
    The classes the TypeScript of the endpoints is written from: the browser callable ones and the types their methods send and take.
    Gets the singleton instance.
    void
    update(String... proposedNewBrowserCallables)
    Re-generates the endpoint TypeScript and re-registers the endpoints in Java.

    Methods inherited from class java.lang.Object

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

    • EndpointCodeGenerator

      public EndpointCodeGenerator(com.vaadin.flow.server.VaadinContext context, EndpointController endpointController)
      Creates the singleton.
      Parameters:
      context - the context the application is running in
      endpointController - a reference to the endpoint controller
  • Method Details

    • getInstance

      public static EndpointCodeGenerator getInstance()
      Gets the singleton instance.
    • update

      public void update(String... proposedNewBrowserCallables)
      Re-generates the endpoint TypeScript and re-registers the endpoints in Java.
      Parameters:
      proposedNewBrowserCallables - Some classes that might be new browser callables, for example coming from a hotswap event.
    • generate

      public void generate(com.vaadin.hilla.engine.EngineAutoConfiguration engineConfiguration, org.springframework.context.ApplicationContext applicationContext)
      Walks the browser callable classes of the application and writes their TypeScript, remembering what it is written from, so that the first change to a class does not have to walk them all again to tell whether it matters.
      Parameters:
      engineConfiguration - the configuration to generate with
      applicationContext - the application context to find the browser callable classes in
    • findBrowserCallables

      public static List<Class<?>> findBrowserCallables(com.vaadin.hilla.engine.EngineAutoConfiguration engineConfiguration, org.springframework.context.ApplicationContext applicationContext)
      Finds all beans in the application context that have a browser callable annotation.
      Parameters:
      engineConfiguration - the engine configuration that provides the annotations to search for
      applicationContext - the application context to search for beans in
      Returns:
      a list of classes that qualify as browser callables
    • getClassesUsedInEndpoints

      public Optional<Set<String>> getClassesUsedInEndpoints()
      The classes the TypeScript of the endpoints is written from: the browser callable ones and the types their methods send and take. They are what a change has to touch to be worth generating again for.
      Returns:
      the classes, or nothing where the browser callable classes have not been walked yet