优化Redis信道订阅代码

v1.4.1
Parker 4 years ago
parent 9fc78b1579
commit 914a7ef529

@ -61,7 +61,7 @@ public class RedisPushSubReceiver extends BaseReceiver {
private AutowireCapableBeanFactory beanFactory; private AutowireCapableBeanFactory beanFactory;
@Autowired @Autowired
DefaultListableBeanFactory defaultListableBeanFactory; private DefaultListableBeanFactory defaultListableBeanFactory;
public RedisPushSubReceiver() { public RedisPushSubReceiver() {
super(CHANNEL); super(CHANNEL);
@ -75,7 +75,6 @@ public class RedisPushSubReceiver extends BaseReceiver {
, RedisPushSubHandler.class , RedisPushSubHandler.class
); );
int count = 0;
for (Class<?> aClass : clazzSet) { for (Class<?> aClass : clazzSet) {
// 位运算 去除抽象类 // 位运算 去除抽象类
if((aClass.getModifiers() & Modifier.ABSTRACT) != 0){ if((aClass.getModifiers() & Modifier.ABSTRACT) != 0){
@ -91,7 +90,7 @@ public class RedisPushSubReceiver extends BaseReceiver {
HANDLER_MAP.put(handler.getType(),handler); HANDLER_MAP.put(handler.getType(),handler);
//将new出的对象放入Spring容器中 //将new出的对象放入Spring容器中
defaultListableBeanFactory.registerSingleton("redisPushSubHandler"+count, obj); defaultListableBeanFactory.registerSingleton(aClass.getSimpleName(), obj);
//自动注入依赖 //自动注入依赖
beanFactory.autowireBean(obj); beanFactory.autowireBean(obj);
@ -99,7 +98,6 @@ public class RedisPushSubReceiver extends BaseReceiver {
} catch (Exception e){ } catch (Exception e){
log.error(CoreMsg.REDIS_EXCEPTION_PUSH_SUB.getMessage()); log.error(CoreMsg.REDIS_EXCEPTION_PUSH_SUB.getMessage());
} }
count ++;
} }
} }

Loading…
Cancel
Save