Is it possible to set a UIProvider instance in the Vaadin servlet class?

Version: Vaadin 7.6.1, TouchKit 4.1.0

I have a Vaadin webapp that runs in
apache karaf
with
pax web
:

https://github.com/steinarb/ukelonn/tree/using-vaadin

The webapp started out as an OSGi-ified WAR file (web.xml servlet registration, WAR-file internal layout).

I have since transformed it to be a normal OSGi jar bundle with an activator that registers the servlet when it starts, and unregisters the servlet when it

I am now in the process with the next step, which is switching to the pax web whiteboard pattern: in this pattern the servlet components I want to publish are made available as OSGi services, which are in turn picked up by the pax web listeners.

When implementing this pattern I would have liked to be able to set the UIProvider as an instance, rather than as a class. If I can set the UIProvider as an instance it can set a reference to the database connection (also an OSGi service) when it creates a UI, rather than having the UI rely on a singleton (which is what I currently do).

But I haven’t found anywhere in the Vaadin API where this is possible.
Is it possible to set a UIProvider instance in the servlet?
Is it possible to set a UIProvider instance in the servlet in a newer Vaadin version? (I’m on 7.6.1 since I’m using TouchKit 4.1.0)

Thanks!

  • Steinar

One possible solution would be to subclass the TouchKitServlet and add a SessionInitListener, that adds the custom UIProvider on the session in the sessionInit() method,
like the SpringVaadinServlet does
.

I will try that approach.