Java Code Examples for org.springframework.data.mongodb.core.MongoClientFactoryBean#afterPropertiesSet()

The following examples show how to use org.springframework.data.mongodb.core.MongoClientFactoryBean#afterPropertiesSet() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MongoTransactionOperateRepository.java    From Lottor with MIT License 5 votes vote down vote up
/**
 * 初始化操作
 *
 * @param modelName 模块名称
 * @param txConfig  配置信息
 */
@Override
public void init(String modelName, TxConfig txConfig) {
    collectionName = RepositoryPathUtils.buildMongoTableName(modelName);
    final TxMongoConfig txMongoConfig = txConfig.getTxMongoConfig();
    MongoClientFactoryBean clientFactoryBean = buildMongoClientFactoryBean(txMongoConfig);
    try {
        clientFactoryBean.afterPropertiesSet();
        template = new MongoTemplate(clientFactoryBean.getObject(), txMongoConfig.getMongoDbName());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 2
Source File: MongoTransactionRecoverRepository.java    From Raincat with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void init(final String appName, final TxConfig txConfig) {
    collectionName = RepositoryPathUtils.buildMongoTableName(appName);
    final TxMongoConfig txMongoConfig = txConfig.getTxMongoConfig();
    MongoClientFactoryBean clientFactoryBean = buildMongoClientFactoryBean(txMongoConfig);
    try {
        clientFactoryBean.afterPropertiesSet();
        template = new MongoTemplate(clientFactoryBean.getObject(), txMongoConfig.getMongoDbName());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 3
Source File: MongoCoordinatorRepository.java    From hmily with Apache License 2.0 5 votes vote down vote up
@Override
public void init(final String modelName, final HmilyConfig hmilyConfig) {
    collectionName = RepositoryPathUtils.buildMongoTableName(modelName);
    final HmilyMongoConfig hmilyMongoConfig = hmilyConfig.getHmilyMongoConfig();
    MongoClientFactoryBean clientFactoryBean = buildMongoClientFactoryBean(hmilyMongoConfig);
    try {
        clientFactoryBean.afterPropertiesSet();
        template = new MongoTemplate(Objects.requireNonNull(clientFactoryBean.getObject()), hmilyMongoConfig.getMongoDbName());
    } catch (Exception e) {
        LogUtil.error(LOGGER, "mongo init error please check you config:{}", e::getMessage);
        throw new HmilyRuntimeException(e);
    }
}
 
Example 4
Source File: MongoCoordinatorRepository.java    From myth with Apache License 2.0 5 votes vote down vote up
@Override
public void init(final String modelName, final MythConfig mythConfig) {
    collectionName = RepositoryPathUtils.buildMongoTableName(modelName);
    final MythMongoConfig tccMongoConfig = mythConfig.getMythMongoConfig();
    MongoClientFactoryBean clientFactoryBean = buildMongoClientFactoryBean(tccMongoConfig);
    try {
        clientFactoryBean.afterPropertiesSet();
        template = new MongoTemplate(Objects.requireNonNull(clientFactoryBean.getObject()), tccMongoConfig.getMongoDbName());
    } catch (Exception e) {
        throw new MythRuntimeException(e);
    }
}