In my earlier post, Multi-tenancy part 1: Strategy, I talked about a few of the advanced decisions we must make when building a one software product for multiple users with diverse requirements. Today I’m going to look at implementing basic multi-tenancy with Suteki Shop. I’ll presume that my customers have identical functional requirements, but will certainly have to have distinct styles and directories. Some other simple configurable items will also be different, such as the true name of their company and their contact email address.
But first I want to suggest something that’s become quite clear as I’ve started to think more about implementing multi-tenancy. Hadlow’s first laws of multi-tenancy: A multi-tenanted program should not look like a multi-tenanted application. What do After all by this? The idea is that you shouldn’t have to improve your existing single-tenant program at all in order to have it provide multiple clients. I am going to get Suteki Shop to provide two different tenants without changing an individual existing line of of (component) code.
We will be serving two clients. The first you are our existing customer, the mod-tastic Jump the Gun. I simply made the name up, it’s actually a registered website name but it isn’t being used. We will serve our clients from the same program instance, so we create a new web site and point it to an instance of Suteki Shop. Conventiently Suteki Shop has two services define these items. Remember that this enables us to to set the name of the style-sheet and some basic information about the shop.
In order to choose which component is used to satisfy a ongoing service at runtime we use an IHandlerSelector. This interface was recently introduced to the Windsor IoC container by Oren Eini (AKA Ayende Rahien) specifically to fulfill the requirements of multi-tenanted applications. You need to compile the trunk if you want to use it. It’s not in the discharge candidate. The comments are self explanatory. It works like this: It desires a range of types to be provided as constructor quarrels.
These are the service types that people want to choose predicated on the sponsor name. The HasOpinionAbout method simply checks the supplied serivce type against the selection of types and returns true if there are any matches.
- Sketch the trip
- On the message package, click Yes to show on developer mode
- Event Responses
- Proofread your marketing materials
- How PERHAPS YOU HAVE Resolved Invoice Disputes
- SolarWinds Virtualization Manager (FREE TRIAL)
- 4 out of 5 folks have left a web page because of a pop-up or automated video ad.Source: Hubspot
- Online Forums
If we’ve an opinion about a service type the container will ask the IHandlerSelector to provide a handler by calling the SelectHandler method.
We create an id by concatenating the service name with the host name and then come back the element that’s configured with this id. Note the identification is :. Note that you can have multiple configurations for the same service/component in Windsor as long as ids are different.