Java – data source for multi tenant applications

I am developing a multi tenant application based on Hibernate 4

Solution

To answer your questions directly, you can expose your application context through JMX and modify it programmatically The problem with this is that the changes will be temporary, that is, if you restart the server, they will not be retained

Another option is to modify the underlying XML file programmatically (assuming that you are using XML) and call refresh () in the context of the application. For example, you can create a speed template using placeholders for data sources:

<beans>
...
#foreach ( $datasource in $datasources )
  $datasource
#end
...
</beans>

Then, you pass a list of all the required data sources to velocity and generate an updated datasource - context xml

But as other users have pointed out, this is not a good idea. It is best to use partitioning or other methods

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>