Skip to content

TechnicalOverview

Marco Collovati edited this page Dec 16, 2023 · 2 revisions

Technical Overview

An overview of the adjustments and hacks applied to Hilla in order to run on Quarkus.

Applied modifications including bytecode manipulation

Hilla is based primarily on Spring and is using some Spring classes and utilities. These are mostly not abstracted and thus it is required to replace or remove this calls directly at bytecode level.
The following gives an overview of the applied hacks.

  • created a shaded jar to contain the minimum possible set of Spring classes that allows to compile a module with Hilla components

    • ApplicationContext and directly referenced interfaces, classes and exceptions

    • subset of spring-web classes to be able to wrap the EndpointController instead of copy/paste its logics

    • to support the Auto-Grid feature, a subset of spring-data-common is required

  • create a jandex index for Hilla

  • partial implementation of a custom ApplicationContext, required by EndpointInvoker and EndpointController

  • custom ViewAccessChecker integrated with Quarkus security

  • custom Atmosphere InjectableObjectFactory to inject required beans in PushEndpoint

  • custom security policy and form authentication mechanism

  • bytecode manipulations to remove/replace calls to Spring classes

    • replacement of @Autowired annotation

    • support for package level @NonNullApi

      • added own @NonNullApi annotation

      • added new AnnotationMatcher for it to NonnullPluginConfig.Processor on bytecode

  • removed the DevToolsMessageHandler service loader descriptor from 'hilla-dev-mode' artifact, because of DevToolsDatabase plugin Spring coupling.

Table 1. Replaced and dropped Spring related method calls
Modified Method Called Method Replaced / Dropped

dev.hilla.EndpointRegistry

  • registerEndpoint

dev.hilla.EndpointInvoker

  • invokeVaadinEndpointMethod

org.springframework.util.ClassUtils

  • getUserClass

Replaced

dev.hilla.EndpointInvoker

  • invokeVaadinEndpointMethod

org.springframework.util.ClassUtils

  • getUserClass

Replaced

dev.hilla.push.PushMessageHandler

  • handleBrowserSubscribe

dev.hilla.AuthenticationUtil

  • getSecurityHolderAuthentication

  • getSecurityHolderRoleChecker

Replaced

dev.hilla.push.PushEndpoint

  • onMessageRequest

org.springframework.security.core.context.SecurityContextHolder

  • setContext

  • clearContext

Dropped

Possible Hilla refactorings

These refactorings can be done by the Hilla team to ease the development and improve the overall adaptability of Hilla.

(Minor) Internal improvements without public API breakage

  • Replacement of field injection with constructor injection

  • Remove direct usage of ApplicationContext in Hilla components, providing instead the required beans or collections of beans

  • Refactor and avoid shortcuts to Spring API such as ApplicationContextProvider.getApplicationContext()

  • Hilla OOB Jandex index

(Major) Refactorings resulting in possible public API breakage

  • Hilla 2.3 Auto Grid: introduce Pageable abstraction to be used in ListService instead of using Spring org.springframework.data.domain.Pageable

  • Introduce and abstraction for spring ResponseEntity to be used in EndpointController. This should allow reusing the Hilla controller in any servlet-based framework, by wrapping it.

  • Another breaking refactoring, could be creating abstraction for request/response as in Vaadin so that the controller could be used even with not servlet toolkits (e.g. Vert.x, Micronaut, …​)