Directory

← Back

Serializable Service References for Vaadin Flow

Serializable Service References for Vaadin Flow

Author

Rating

This mini add-on provides serializable service references. Supports Spring Boot and CDI.

What does this do and how does it work?

Vaadin stores all UIs in their respective HTTP session. If you want to be able to persist your sessions (so they survive a server restart or can be migrated to a different server), everything in these UIs needs to be serializable. While dependency injection provides easy and convenient access to your services, these services aren't and shouldn't be serializable. You could always use static methods to access your services, but you would lose the convenience of DI. This add-on solves this by injecting serializable service references instead of services directly.

Example

Inject your service like this:

// Spring
@Autowired
private ServiceRef<MyService> myService;

// CDI
@Inject
private ServiceRef<MyService> myService;

And then use it like this:

myService.get().doStuff();

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

  • Supports and requires Vaadin 24.
Released
2023-03-09
Maturity
STABLE
License
Apache License 2.0

Compatibility

Framework
Vaadin 24+
Vaadin 14+ in 0.7.1
Browser
Browser Independent
Online