Java Code Examples for org.jeecg.common.util.SpringContextUtils#getBean()

The following examples show how to use org.jeecg.common.util.SpringContextUtils#getBean() . 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: DataSourceCachePool.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
/**
 * 获取多数据源缓存
 *
 * @param dbKey
 * @return
 */
public static DynamicDataSourceModel getCacheDynamicDataSourceModel(String dbKey) {
    String redisCacheKey = CacheConstant.SYS_DYNAMICDB_CACHE + dbKey;
    if (getRedisTemplate().hasKey(redisCacheKey)) {
        return (DynamicDataSourceModel) getRedisTemplate().opsForValue().get(redisCacheKey);
    }
    ISysBaseAPI sysBaseAPI = SpringContextUtils.getBean(ISysBaseAPI.class);
    DynamicDataSourceModel dbSource = sysBaseAPI.getDynamicDbSourceByCode(dbKey);
    if (dbSource != null) {
        getRedisTemplate().opsForValue().set(redisCacheKey, dbSource);
    }
    return dbSource;
}
 
Example 2
Source File: EmailSendMsgHandle.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
@Override
public void SendMsg(String es_receiver, String es_title, String es_content) {
	JavaMailSender mailSender = (JavaMailSender) SpringContextUtils.getBean("mailSender");
	SimpleMailMessage message = new SimpleMailMessage();
	// 设置发送方邮箱地址
	message.setFrom(emailFrom);
	message.setTo(es_receiver);
	message.setSubject(es_title);
	message.setText(es_content);
	mailSender.send(message);

}
 
Example 3
Source File: DataSourceCachePool.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 获取多数据源缓存
 *
 * @param dbKey
 * @return
 */
public static DynamicDataSourceModel getCacheDynamicDataSourceModel(String dbKey) {
    DynamicDataSourceModel dbSource = dynamicDbSourcesCache.get(dbKey);
    if (dbSource == null) {
        ISysBaseAPI sysBaseAPI = SpringContextUtils.getBean(ISysBaseAPI.class);
        dbSource = sysBaseAPI.getDynamicDbSourceByCode(dbKey);
        dynamicDbSourcesCache.put(dbKey, dbSource);
        dynamicDbSourcesIdToCode.put(dbSource.getId(), dbKey);
    }
    return dbSource;
}
 
Example 4
Source File: DataSourceCachePool.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 获取多数据源缓存
 *
 * @param dbKey
 * @return
 */
public static DynamicDataSourceModel getCacheDynamicDataSourceModel(String dbKey) {
    String redisCacheKey = CacheConstant.SYS_DYNAMICDB_CACHE + dbKey;
    if (getRedisTemplate().hasKey(redisCacheKey)) {
        return (DynamicDataSourceModel) getRedisTemplate().opsForValue().get(redisCacheKey);
    }
    ISysBaseAPI sysBaseAPI = SpringContextUtils.getBean(ISysBaseAPI.class);
    DynamicDataSourceModel dbSource = sysBaseAPI.getDynamicDbSourceByCode(dbKey);
    if (dbSource != null) {
        getRedisTemplate().opsForValue().set(redisCacheKey, dbSource);
    }
    return dbSource;
}
 
Example 5
Source File: DataSourceCachePool.java    From jeecg-cloud with Apache License 2.0 4 votes vote down vote up
private static RedisTemplate<String, Object> getRedisTemplate() {
    if (redisTemplate == null) {
        redisTemplate = (RedisTemplate<String, Object>) SpringContextUtils.getBean("redisTemplate");
    }
    return redisTemplate;
}
 
Example 6
Source File: DataSourceCachePool.java    From jeecg-boot with Apache License 2.0 4 votes vote down vote up
private static RedisTemplate<String, Object> getRedisTemplate() {
    if (redisTemplate == null) {
        redisTemplate = (RedisTemplate<String, Object>) SpringContextUtils.getBean("redisTemplate");
    }
    return redisTemplate;
}