flow icon indicating copy to clipboard operation
flow copied to clipboard

Integrate hotswap support from the Hotswap Agent plugin

Open Artur- opened this issue 3 months ago • 5 comments

Describe your motivation

The Hotswap agent plugin at https://github.com/HotswapProjects/HotswapAgent/tree/master/plugin/hotswap-agent-vaadin-plugin implements support for hot reloading of various parts of Flow but it has the issue that it tries to support all Flow versions at the same time, and that it is an external project so it is always lagging behind when Flow gets new features. As it tries to support many Flow versions, the code becomes quite complex.

Describe the solution you'd like

Implement the same approach already tested in Hilla here https://github.com/vaadin/hilla/blob/main/packages/java/endpoint/src/main/java/com/vaadin/hilla/Hotswapper.java#L34 and here https://github.com/vaadin/hilla/blob/main/packages/java/hilla-dev/src/main/java/com/vaadin/hilla/devmode/hotswapagent/HillaPlugin.java

In other words, make the Hotswap Agent plugin call a Flow method when hotswapping has taken place without doing any filtering or trying to figure out what needs to be done. Let the onHotswap method in Flow decide what needs to be done due to reloading of the given class(es).

This would have many benefits:

  1. The Hotswap Agent plugin does not need to support multiple Flow versions. It only needs to find onHotswap and different Flow versions can implement the method in different ways
  2. There is no need for strange reflection code to clear caches etc. The code in onHotswap will become much simpler than what is in the hotswap agent plugin
  3. The JRebel plugin can use the same method so that hotswapping will work equally well regardless of which product you use

Artur- avatar Apr 26 '24 07:04 Artur-

Acceptance Criteria:

  • [ ] Flow has an API for updating routes, its implementation does the same as the existing logic does in hotswap-agent-vaadin-plugin - 3 SP
  • [ ] Platform (or Hilla, or Flow, should be checked which is better) has one single public method onHotswap that is called from hotswap-agent-vaadin-plugin
  • [ ] Vaadin's onHotswap method implementation delegates to corresponding hot swap methods in Flow and Hilla, depending on what is used in a project. - 5 SP (includes the previous point)
  • [ ] hotswap-agent-vaadin-plugin has still VaadinIntegration class, but the logic in there is called only if the onHotswap method is not found in Vaadin, otherwise the plugin does nothing, just calls the onHotswap method. This is needed for backwards compatibility between further versions of HA plugin and older Vaadin versions (before 24.5) - 5 SP
  • [ ] Hilla's HA plugin HillaPlugin is removed (basically remove the whole module hilla-dev) - 3 SP

Let's not pick these changes to older maintained Vaadin branches. If this feature will be needed for older Vaadin versions or requested by Customers, let's do it, otherwise ignore it for now and let VaadinIntegration class do the job.

mshabarov avatar May 08 '24 11:05 mshabarov