If you are new to the concept of SaaS itself, then you have some reading to do, before you read further. Can I suggest Wikipedia to being with first [http://en.wikipedia.org/wiki/SaaS]
Working on a SaaS model, multi-tenancy plays a major role to allow (their) multiple clients to live on the same system. There are various white papers and articles out there on the internet discussing on strategies on how to implement them. I've listed a few for your bed time reading;
- http://en.wikipedia.org/wiki/Multitenancy
- http://msdn.microsoft.com/en-us/library/aa479086.aspx
- http://wiki.developerforce.com/index.php/Multi_Tenant_Architecture
Consider your self as a big rental management firm, who can rent all the apartments in the building, so how's that with a software?
But my problem was how to implement it in my application with minimum effort or interference from other developers. I did not want multi-tenancy code seepage into my regular code. The whole point is to keep is as sanitized as possible. One of the really quick and dirty ways was the make every front end developer pass that as a parameter to the backend, but that is not something any developer would want to introduce in his app.
- It's an added dependency across the application for every developer to pass the parameter
- If a developer forgets to pass the parameter, the system starts to fail.
I'll try to cover the code in the next post, but here is how the flow of logic will occur.
- When the user logs in, get the "tenant code" and store it in the user's web session
- Next the request when reaches the filter, the "tenant code" is read and stored in a ThreadLocal
- This ThreadLocal is accessible through out the "request roundtrip".
- Use hibernate to set the "tenant" in the Filters and get the filtered data.

0 comments:
Post a Comment