MongoPersister.java 文件源码

java
阅读 23 收藏 0 点赞 0 评论 0

项目:statefulj 作者:
@Override
public void postProcessBeanDefinitionRegistry(
        BeanDefinitionRegistry registry) throws BeansException {

    if (this.mongoTemplate == null) {

        if (this.repoId != null) {

            // Fetch the MongoTemplate Bean Id
            //
            BeanDefinition repo = registry.getBeanDefinition(this.repoId);
            this.templateId = ((BeanReference)repo.getPropertyValues().get("mongoOperations")).getBeanName();
        }

        // Check to make sure we have a reference to the MongoTemplate
        //
        if (this.templateId == null) {
            throw new RuntimeException("Unable to obtain a reference to a MongoTemplate");
        }
    }


    // Add in CascadeSupport
    //
    BeanDefinition mongoCascadeSupportBean = BeanDefinitionBuilder
            .genericBeanDefinition(MongoCascadeSupport.class)
            .getBeanDefinition();
    ConstructorArgumentValues args = mongoCascadeSupportBean.getConstructorArgumentValues();
    args.addIndexedArgumentValue(0, this);
    registry.registerBeanDefinition(Long.toString((new Random()).nextLong()), mongoCascadeSupportBean);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号