-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multitenant support #57
base: master
Are you sure you want to change the base?
Conversation
…tenant). Modified build.xml to read build.properties.
pardon me but is this a support for managing multiple databases (rather than different collections in a db) in one single morphia session? I'm not clear with that. |
This implementation is for managing collection names. By implementing the TenantContext interface you can modify the collection names to include a tenant-specific identifier, see the interface: https://github.com/anttip/play-morphia/blob/f01ac360e06f23d2d5455c1a3c103aa98b47dc79/src/play/modules/morphia/TenantContext.java and an example implementation https://github.com/anttip/play-morphia/blob/f01ac360e06f23d2d5455c1a3c103aa98b47dc79/src/play/modules/morphia/ThreadLocalTenantContext.java |
Hi, sorry for the late response. Just come back from holiday. So it looks like it's not what I am thinking of. I prefer to provide a way that programmer could specify a different db rather than a different collection where the model could be mapped into. Anyway let me check your code and see how it goes. |
* | ||
*/ | ||
public class ThreadLocalTenantContext implements TenantContext { | ||
private static ThreadLocal<String> userLocal = new ThreadLocal<String>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using threadlocal variable in this way is not safe in play environment. Because a thread might very possible be to handle another incoming request where the context is totally different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain how it is not safe? This is meant to be used from Play's lifecycle methods (@before, @Final). I followed this discussion and assumed it would be ok : http://groups.google.com/group/play-framework/browse_thread/thread/5a568d6aa7cb8c9b
Hi, the reason I went with using collections/customer instead of But I think these approaches are not mutually exclusive. For example Grails 2012/1/10 Green Luo <
|
That's an interesting point. Probably providing multi-tenant solution cater On Tue, Jan 10, 2012 at 6:38 PM, anttip <
|
I saw that you were considering implementing multitenant support to play-morphia. I would really like to see this happen, so here's one take on implementing multitenant support to play-morphia.
This implementation allows modifying the collection name for each tenant. I couldn't find clear documentation on how to modify Morphia's collection names dynamically, but overriding DatastoreImpl.getCollection seemed to work against the current test suite and also in my own testing.