Add examples of using DS features in Vaadin components
Closed this issue · 8 comments
This is a demo for vaadin/flow#5125.
Could be done before vaadin/flow#5125 but won't work until the feature is implemented.
The purpose of this ticket is: demo OSGi DS features used for Vaadin components.
This is quite similar to https://github.com/vaadin/flow-spring-tutorial.
May be @Sandared may help with meaningful examples.
Would an example as the Spring one be sufficient?
Or do you need something different?
Well, the most obvious example is to "inject" a service into a component.
But this just only one usecase.
Would be good to see some other features in action (may be @activate, etc.) and I'm not aware about any good example for other usecase here.
Ok, I will create some examples. Probably over the weekend.
@denis-anisimov I've created a small sample repository with two examples on how OSGi components that are also Routes might look like: https://github.com/Sandared/flow-osgi-example
You can use Gitpod to run the examples or you can run locally from your console. The aliases I use in Gitpod are defined here: https://github.com/Sandared/flow-osgi-example/blob/master/Dockerfile
Example1
is just your Flow Hello World Application. @Activate
is used on the consturctor and only one service is referenced.
Example2
additionally makes use of the OSGi eventing system and receives an event every 5 seconds which should result in a Notification being shown in Vaadin. This class does use an activation method instead of the constructor and makes use of ComponentPropertyTypes.
In the parent POM I reference the current Vaadin Flow 12.0.7 vaadin-bom.
If you need any other examples just notify me :)
Thank you very much @Sandared for the examples !
Quite short and good demo for OSGi features usage.
Hey, @Sandared could we integrate this with CDI?
Hi Julian,
same here as with vaadin/flow#5125 ;)
But maybe @rotty3000 could help you with this.
I'm closing this issue for now as there are examples in https://github.com/vaadin/base-starter-flow-osgi/tree/v19/starter/src/main/java/com/example/starter/base and https://github.com/vaadin/base-starter-flow-karaf/tree/v19/starter/src/main/java/com/example/starter/base. Further improvements should be on specific use case bases.