How to integrate Vaadin 7 with OSGi?

2019-05-14 02:47发布

I want to integrate vaadin 7 with osgi but there is no longer any AbstractApplicationServlet class.

I've followed the integration using the vaadin bridge by Neil Bartlett https://github.com/njbartlett/VaadinOSGi.

I've tried using the VaadinServlet somehow but with no luck.

I've also searched for other solutions but found none.

Do you have any suggestions?

Thanks

标签: osgi vaadin
1条回答
做个烂人
2楼-- · 2019-05-14 03:14

Vaadin 7 has a lot of design changes that are not visible for default use cases, but especially for OSGi integration you have to do some extra work. To get you started you should try to understand the initialization process concerning the classes: VaadinServlet, VaadinServletService, VaadinSession and UIProvider.

The problematic parts are the methods that use classname parameters as arguments, you will have to work around this by e.g. implementing a factory that directly injects your instances. If you look at the source for UIProvider.createInstance(..) you can see that the original implementation tries to create a new instance, this will fail since vaadin does not see your classes in OSGi. The same principle applies for the other classes i mentioned as well.

Another thing you have to look at is the new separation of jars in Vaadin 7. A good approach is to attach a bundle fragment with a blueprint context. that registers a BundleHttpContext the same way it worked in Vaadin 6. Attaching fragments also works for the themes you want to use.

Sorry that i can't provide a turnkey solution, but i hope this helps you to look into it yourself.

查看更多
登录 后发表回答