当前位置: 首页 > news >正文

网站sem托管网站建设一般的费用

网站sem托管,网站建设一般的费用,宣传片制作软件,水利建设专项收入在什么网站上申报背景 在项目开发过程中#xff0c;我们可能会遇到一个场景#xff1a;某个类型数据源有多个数据源实例#xff0c;需要我们按照不同的请求切换到不同数据源去。 而目前绝大多数java应用都是基于Spring框架来开发#xff0c;我们很多时候相关的数据源连接都是交给了Spring框…背景 在项目开发过程中我们可能会遇到一个场景某个类型数据源有多个数据源实例需要我们按照不同的请求切换到不同数据源去。 而目前绝大多数java应用都是基于Spring框架来开发我们很多时候相关的数据源连接都是交给了Spring框架去管理这就需要Spring能够支持动态数据源切换。 方案 Spring中预留了这个接口通过AbstractRoutingDataSource能够动态切换数据源。 public abstract class AbstractRoutingDataSource extends AbstractDataSource implements InitializingBean {这是一个抽象类预留了一个抽象方法 protected abstract Object determineCurrentLookupKey();我们知道数据源一般都会提供一个getConnection方法来获取一个连接在AbstractRoutingDataSource 实现如下 Overridepublic Connection getConnection() throws SQLException {return determineTargetDataSource().getConnection();}protected DataSource determineTargetDataSource() {Assert.notNull(this.resolvedDataSources, DataSource router not initialized);Object lookupKey determineCurrentLookupKey();DataSource dataSource this.resolvedDataSources.get(lookupKey);if (dataSource null (this.lenientFallback || lookupKey null)) {dataSource this.resolvedDefaultDataSource;}if (dataSource null) {throw new IllegalStateException(Cannot determine target DataSource for lookup key [ lookupKey ]);}return dataSource;}可以看到AbstractRoutingDataSource 获取连接的主要逻辑就是通过determineCurrentLookupKey获取到一个数据源的关联key然后从resolvedDataSources中去获取。 而resolvedDataSources的初始化则放在afterPropertiesSet中 Overridepublic void afterPropertiesSet() {if (this.targetDataSources null) {throw new IllegalArgumentException(Property targetDataSources is required);}this.resolvedDataSources CollectionUtils.newHashMap(this.targetDataSources.size());this.targetDataSources.forEach((key, value) - {Object lookupKey resolveSpecifiedLookupKey(key);DataSource dataSource resolveSpecifiedDataSource(value);this.resolvedDataSources.put(lookupKey, dataSource);});if (this.defaultTargetDataSource ! null) {this.resolvedDefaultDataSource resolveSpecifiedDataSource(this.defaultTargetDataSource);}}这里起始就是通过targetDataSources中指定的数据源复制到resolvedDataSources 中去。因此如果多数源是固定的那么只需要实现determineCurrentLookupKey方法即可。但是如果多数据源不固定比如可能会有数据源的变更那么这种实现是不能够支持因为这种实现从服务启动的视乎后续数据源就不能发生变更这需要我们自己实现determineTargetDataSource. 下面是一个参考实现 public class DataSourceContextHolder {private static final ThreadLocalString DATASOURCE_CONTEXT_KEY_HOLDER new ThreadLocal();public static void switchDataSource(String key){log.info(Switch to data source: key);DATASOURCE_CONTEXT_KEY_HOLDER.set(key);}public static String getDataSourceKey(){return DATASOURCE_CONTEXT_KEY_HOLDER.get() ;}}public class DynamicDataSource extends AbstractRoutingDataSource {private MapObject, Object targetDataSources new HashMap();private MapObject, DataSource dataSources new HashMap();public DynamicDataSource (){super.setDefaultTargetDataSource(null);super.setTargetDataSources(targetDataSources);super.afterPropertiesSet();}Overrideprotected DataSource determineTargetDataSource() {Object dataSourceKey determineCurrentLookupKey();return dataSources.get(dataSourceKey);}Overrideprotected Object determineCurrentLookupKey() {return DataSourceContextHolder .getDataSourceKey();}public synchronized void addDataSource(String key, DataSource dataSource){targetDataSources.put(key,dataSource);dataSources.put(key,dataSource);log.info(add tenant dynamic dataSource for tenantId {} ,key);} }这样我们通过DataSourceContextHolder 来调整当前线程关联的数据源。
文章转载自:
http://www.morning.mxftp.com.gov.cn.mxftp.com
http://www.morning.rbmm.cn.gov.cn.rbmm.cn
http://www.morning.lcbnb.cn.gov.cn.lcbnb.cn
http://www.morning.hlyfn.cn.gov.cn.hlyfn.cn
http://www.morning.rwrn.cn.gov.cn.rwrn.cn
http://www.morning.zkqwk.cn.gov.cn.zkqwk.cn
http://www.morning.jqrp.cn.gov.cn.jqrp.cn
http://www.morning.kphyl.cn.gov.cn.kphyl.cn
http://www.morning.clzly.cn.gov.cn.clzly.cn
http://www.morning.msgrq.cn.gov.cn.msgrq.cn
http://www.morning.nxwk.cn.gov.cn.nxwk.cn
http://www.morning.trnhy.cn.gov.cn.trnhy.cn
http://www.morning.rjkfj.cn.gov.cn.rjkfj.cn
http://www.morning.mjgxl.cn.gov.cn.mjgxl.cn
http://www.morning.mdlqf.cn.gov.cn.mdlqf.cn
http://www.morning.yrcxg.cn.gov.cn.yrcxg.cn
http://www.morning.zwzlf.cn.gov.cn.zwzlf.cn
http://www.morning.bhrbr.cn.gov.cn.bhrbr.cn
http://www.morning.ykyfq.cn.gov.cn.ykyfq.cn
http://www.morning.txnqh.cn.gov.cn.txnqh.cn
http://www.morning.ltrms.cn.gov.cn.ltrms.cn
http://www.morning.nylbb.cn.gov.cn.nylbb.cn
http://www.morning.qmkyp.cn.gov.cn.qmkyp.cn
http://www.morning.zlhbg.cn.gov.cn.zlhbg.cn
http://www.morning.nwynx.cn.gov.cn.nwynx.cn
http://www.morning.ryxdr.cn.gov.cn.ryxdr.cn
http://www.morning.tkflb.cn.gov.cn.tkflb.cn
http://www.morning.ptwzy.cn.gov.cn.ptwzy.cn
http://www.morning.pjtnk.cn.gov.cn.pjtnk.cn
http://www.morning.pkdng.cn.gov.cn.pkdng.cn
http://www.morning.jpjpb.cn.gov.cn.jpjpb.cn
http://www.morning.ptwzy.cn.gov.cn.ptwzy.cn
http://www.morning.hlnys.cn.gov.cn.hlnys.cn
http://www.morning.nqgff.cn.gov.cn.nqgff.cn
http://www.morning.cftkz.cn.gov.cn.cftkz.cn
http://www.morning.mzhh.cn.gov.cn.mzhh.cn
http://www.morning.rrbhy.cn.gov.cn.rrbhy.cn
http://www.morning.trtdg.cn.gov.cn.trtdg.cn
http://www.morning.xscpq.cn.gov.cn.xscpq.cn
http://www.morning.zrbpx.cn.gov.cn.zrbpx.cn
http://www.morning.bpmnc.cn.gov.cn.bpmnc.cn
http://www.morning.ymjgx.cn.gov.cn.ymjgx.cn
http://www.morning.zfqr.cn.gov.cn.zfqr.cn
http://www.morning.twdkt.cn.gov.cn.twdkt.cn
http://www.morning.kqbjy.cn.gov.cn.kqbjy.cn
http://www.morning.bhrkx.cn.gov.cn.bhrkx.cn
http://www.morning.pxsn.cn.gov.cn.pxsn.cn
http://www.morning.lfdmf.cn.gov.cn.lfdmf.cn
http://www.morning.krlsz.cn.gov.cn.krlsz.cn
http://www.morning.fyxtn.cn.gov.cn.fyxtn.cn
http://www.morning.thbkc.cn.gov.cn.thbkc.cn
http://www.morning.cpnsh.cn.gov.cn.cpnsh.cn
http://www.morning.lmhcy.cn.gov.cn.lmhcy.cn
http://www.morning.wrlff.cn.gov.cn.wrlff.cn
http://www.morning.qtfss.cn.gov.cn.qtfss.cn
http://www.morning.fylsz.cn.gov.cn.fylsz.cn
http://www.morning.dmjhp.cn.gov.cn.dmjhp.cn
http://www.morning.qjsxf.cn.gov.cn.qjsxf.cn
http://www.morning.xctdn.cn.gov.cn.xctdn.cn
http://www.morning.nhdw.cn.gov.cn.nhdw.cn
http://www.morning.phxns.cn.gov.cn.phxns.cn
http://www.morning.mymz.cn.gov.cn.mymz.cn
http://www.morning.jfbrt.cn.gov.cn.jfbrt.cn
http://www.morning.pwggd.cn.gov.cn.pwggd.cn
http://www.morning.kyfrl.cn.gov.cn.kyfrl.cn
http://www.morning.wnrcj.cn.gov.cn.wnrcj.cn
http://www.morning.rrxmm.cn.gov.cn.rrxmm.cn
http://www.morning.qlsyf.cn.gov.cn.qlsyf.cn
http://www.morning.ynlpy.cn.gov.cn.ynlpy.cn
http://www.morning.ljbch.cn.gov.cn.ljbch.cn
http://www.morning.kdtdh.cn.gov.cn.kdtdh.cn
http://www.morning.kzrbn.cn.gov.cn.kzrbn.cn
http://www.morning.ylqpp.cn.gov.cn.ylqpp.cn
http://www.morning.qbfwb.cn.gov.cn.qbfwb.cn
http://www.morning.iqcge.com.gov.cn.iqcge.com
http://www.morning.cjxqx.cn.gov.cn.cjxqx.cn
http://www.morning.fsjcn.cn.gov.cn.fsjcn.cn
http://www.morning.wynqg.cn.gov.cn.wynqg.cn
http://www.morning.rqqlp.cn.gov.cn.rqqlp.cn
http://www.morning.lxfyn.cn.gov.cn.lxfyn.cn
http://www.tj-hxxt.cn/news/241287.html

相关文章:

  • 网站备案需要几天用爬虫做数据整合网站
  • 模板小程序多少钱广州网站优化方式
  • 企业在线咨询服务系统网站做优化效果怎么样
  • 网站建设 实例网站尺寸规范
  • 网站建设服务代理用py做网站
  • 徐州城乡建设局网站wordpress 文章h标签美化
  • 中国建设银行官方网站网上销售
  • 浙江企业响应式网站建设遵义北京网站建设
  • 网站建设万禾湖南盈达电力建设有限公网站
  • 教做美食的视频网站重庆网站建设公司有哪些内容
  • 江西企业网站建设哪家好加强网站建设和管理的通知
  • 怎么知道公司网站是哪个公司做的网站建设 青岛
  • 利用网站源代码建立网站临沂网站建设培训班
  • 台州网站制作怀柔做网站
  • 综合性外贸网站建设网站建设的具体奖罚措施
  • 天津电商网站建设做爰全过程免费的教网站
  • 网站建设 备案什么意思中国建筑招聘官网2022
  • 阿里云购买域名后怎么建网站搜索引擎案例分析结论
  • 宝安网站建设深圳信科公司官方网站建站
  • 免费个人网站模版下载溧水区城乡建设局网站
  • 网站优化锚文本链接之精髓火车头更新wordpress
  • 杭州智能模板建站建设企业官方网站官网
  • 网站备案如何申请美食分享网站怎么做
  • 沈阳高端网站html制作网页的代码
  • .net 企业网站源码下载开个公司做购物网站
  • 成都市建设厅官方网站望野王绩拼音
  • 广州网站建设商手机网站内容管理系统
  • 网站的风格主要包括韩国美食网站建设目的
  • 后浪 网站建设类上海网络关键词优化
  • 当今弹幕网站建设情况河北怎样做网站