Package com.vaadin.hilla
Class EndpointCodeGenerator
java.lang.Object
com.vaadin.hilla.EndpointCodeGenerator
Handles (re)generation of the TypeScript code.
-
Constructor Summary
ConstructorsConstructorDescriptionEndpointCodeGenerator(com.vaadin.flow.server.VaadinContext context, EndpointController endpointController) Creates the singleton. -
Method Summary
Modifier and TypeMethodDescriptionfindBrowserCallables(com.vaadin.hilla.engine.EngineAutoConfiguration engineConfiguration, org.springframework.context.ApplicationContext applicationContext) Finds all beans in the application context that have a browser callable annotation.voidgenerate(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.static EndpointCodeGeneratorGets the singleton instance.voidRe-generates the endpoint TypeScript and re-registers the endpoints in Java.
-
Constructor Details
-
EndpointCodeGenerator
public EndpointCodeGenerator(com.vaadin.flow.server.VaadinContext context, EndpointController endpointController) Creates the singleton.- Parameters:
context- the context the application is running inendpointController- a reference to the endpoint controller
-
-
Method Details
-
getInstance
Gets the singleton instance. -
update
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 withapplicationContext- 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 forapplicationContext- the application context to search for beans in- Returns:
- a list of classes that qualify as browser callables
-
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
-