.
This commit is contained in:
parent
7e0351cfc6
commit
96adba4e48
@ -1,54 +0,0 @@
|
||||
/*
|
||||
package com.zdemo;
|
||||
|
||||
import org.redkale.boot.Application;
|
||||
import org.redkale.boot.ApplicationListener;
|
||||
import org.redkale.service.Service;
|
||||
import org.redkale.util.AnyValue;
|
||||
import org.redkale.util.RedkaleClassLoader;
|
||||
import org.redkale.util.ResourceFactory;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
*/
|
||||
/**
|
||||
* 服务监听
|
||||
*
|
||||
* @author: liangxy.
|
||||
*//*
|
||||
|
||||
@Deprecated
|
||||
public class ZhubListener implements ApplicationListener {
|
||||
|
||||
@Override
|
||||
public void preStart(Application application) {
|
||||
|
||||
CompletableFuture.runAsync(() -> {
|
||||
ResourceFactory resourceFactory = application.getResourceFactory();
|
||||
RedkaleClassLoader classLoader = application.getClassLoader();
|
||||
|
||||
AnyValue appConfig = application.getAppConfig();
|
||||
AnyValue zhubs = appConfig.getAnyValue("zhubs");
|
||||
AnyValue[] values = zhubs.getAnyValues("zhub");
|
||||
for (AnyValue zhub : values) {
|
||||
String className = zhub.getValue("value", "com.zdemo.zhub.ZHubClient");
|
||||
try {
|
||||
Class<?> clazz = classLoader.loadClass(className);
|
||||
Service obj = (Service) clazz.getDeclaredConstructor().newInstance();
|
||||
application.getResourceFactory().inject(obj);
|
||||
obj.init(zhub);
|
||||
resourceFactory.register(zhub.get("name"), clazz, obj);
|
||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preShutdown(Application application) {
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
@ -65,13 +65,12 @@ public class ZHubClient extends AbstractConsumer implements IConsumer, IProducer
|
||||
|
||||
if (config == null) {
|
||||
initClient(null);
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, AnyValue> nodes = getNodes(config);
|
||||
for (String rsName : nodes.keySet()) {
|
||||
ZHubClient client = new ZHubClient().initClient(nodes.get(rsName));
|
||||
application.getResourceFactory().register(rsName, client);
|
||||
} else {
|
||||
Map<String, AnyValue> nodes = getNodes(config);
|
||||
for (String rsName : nodes.keySet()) {
|
||||
ZHubClient client = new ZHubClient().initClient(nodes.get(rsName));
|
||||
application.getResourceFactory().register(rsName, client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ import org.redkale.util.AnyValue;
|
||||
/**
|
||||
* @author zhangjx
|
||||
*/
|
||||
@Priority(10001)
|
||||
@Priority(1)
|
||||
public class RedisCacheSourceProvider implements CacheSourceProvider {
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user