dropwizard-auth-multitenancy-example
dropwizard-auth-multitenancy-example copied to clipboard
Tenant Cache in MultitenantRequestListener does not make any sense
Hello, I read your article here and could not seem to understand why you need a cache of tenants in MultitenancyRequestListener
. MultitenancyApplicationListener
creates a new instance of RequestListener on every request and the cache exists only during one request. Am I missing something?
I agree, it does not make sense for the reason you stated.
I actually don't even know how that got in there, I went back and looked at the production code for our app on which this is based and it is not in that code. I can only imagine I added it on an not-fully-thought-through whim at some point while writing my blog post.
I can try to find time to update the code, but it might be a little while. If you want to open a PR to fix it that would be welcome as well.
It's not a big deal. I got all I wanted from this sample project. So it's up to you to fix this. I also added a hibernate interceptor, so a tenant id is injected automatically on each save or update operation. This makes code a little bit cleaner and safer.