spring
spring copied to clipboard
Profile issues with Spring add-on
This PR allows to use Spring Profiles with Routes :https://github.com/vaadin/spring/pull/575
But it works ONLY with Spring boot: because we are using a special way to find all classes annotated with @Route
via ClassPathScanningCandidateComponentProvider
.
The ClassPathScanningCandidateComponentProvider
instance filter out annotated classes annotated with Profile
whose profiles are not active.
But in Spring MVC case e.g. ClassPathScanningCandidateComponentProvider
is never used.
Also ClassPathScanningCandidateComponentProvider
won't be used if the application works as a war.
It means that Profiles won't be respected at runtime : classes are scanned using standard Servlet 3.0 specification.
So in not Spring boot case ANY route will be enabled even if its profile is not enabled.
( so https://github.com/vaadin/spring/pull/575 just allows to use routes which are annotated with profile).
To be able to support profiles we need changes in SpringInstantiator
class: it's method getOrCreate
should take into account that classes may be disabled via profile.
At the moment SpringInstantiator
will make an instance regardless of its profile.