Instantiator usage in add-ons

Is the Instantiator class in Flow considered a public API? In a sense that can I use it to improve the DX of add-ons :man_shrugging: I found a documentation page for it, but that pretty much just discusses customizing its implementation, not about its usage. The Javadocs only discusses framework internal usage.

With many add-ons, DI framework support could improve the DX. Like with a map component, configuration of the background layers could be delegated to some bean (kind of a cross cutting concern), . I have been tempted to use Spring dependency in some add-ons, but I wouldn’t like to close the door for CDI or plain Java users.

I quickly tested that something like this seems to work at least with SB project, but I have no idea if I can trust it works in the next version :man_shrugging::

public interface Jorma {
    String getMyConfig();

public class JormaImpl implements Jorma {

    public String getMyConfig() {
        return "It works!?";

public static class MainView extends VerticalLayout {
    public MainView() {
        // Add-on would use Jorma like this:
        Jorma bean = VaadinService.getCurrent().getInstantiator().getOrCreate(Jorma.class);
        // if not available, use some default config
        String myConfig = bean.getMyConfig();

Should be sufficiently safe to use the Instantiator API in add-ons for the kind of purpose that you’re describing.

The API is public in the sense that we will think twice before making any breaking changes to it but it’s still internal-ish in the sense that we haven’t put in the effort of making it easy to use outside the internal needs of the framework itself.

Users perspective: I’m using it all over the place with spring to create prototype spring based components

I’m fine being the pioneer :nerd_face:I’ll make a PoC to the Maplibre add-on. I’d guess only the getOrCreate or createComponent methods would be relevant for any add-ons. I wonder how framework is using the latter :thinking:

@knoobie Intersting approach. Are you trying to keep you UI code independent of Spring DI or why?

The change in the demo project looks quite good compared to the old haxie :sunglasses:

Release build in progress (for public example)…

Funny thing… the complete opposite… I’m using it so that I don’t have to create component instances by hand that need 3-x spring services… and let spring create that component for me.

Can show you some code at JCon