I have a project that has the following requeriments:
- Allow users to login in the same Web Application using different schemas following a criteria;
- Dynamically route the datasource against a rule - for example, users in Company A should access schema A, users in Company B should access schema B;
- The business logic which authenticates the user`s should be in a business component - EJB, because new applications can be added and this logic must be outside the Web Application.
I read about using Dynamic Data Source Routing. The CustomerContextHolder
has a field which is ThreadLocal
. Is ThreadLocal
a guarantee that the user A will access the schema A following my criteria? Will the code be thread safe?