Commit ebc2c4c0 by Nepxion

重构事件总线

parent 4e1dd99f
......@@ -79,7 +79,7 @@ public class AdminEndpoint extends AbstractMvcEndpoint {
try {
InputStream inputStream = IOUtils.toInputStream(config, PluginConstant.ENCODING_UTF_8);
pluginPublisher.publish(inputStream);
pluginPublisher.asyncPublish(inputStream);
} catch (IOException e) {
throw new PluginException("To input stream failed", e);
}
......
......@@ -21,6 +21,6 @@ public abstract class ConfigAdapter extends AbstractConfigLoader {
private PluginPublisher pluginPublisher;
public void publish(InputStream inputStream) {
pluginPublisher.publish(inputStream);
pluginPublisher.asyncPublish(inputStream);
}
}
\ No newline at end of file
......@@ -18,7 +18,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import com.google.common.eventbus.Subscribe;
import com.nepxion.discovery.plugin.framework.context.PluginContextAware;
import com.nepxion.eventbus.annotation.EventBus;
import com.nepxion.eventbus.core.Event;
@EventBus
public class ConfigSubscriber {
......@@ -31,7 +30,7 @@ public class ConfigSubscriber {
private ConfigParser configParser;
@Subscribe
public void subscribe(Event event) {
public void subscribe(InputStream inputStream) {
Boolean discoveryControlEnabled = pluginContextAware.isDiscoveryControlEnabled();
Boolean remoteConfigEnabled = pluginContextAware.isRemoteConfigEnabled();
......@@ -47,12 +46,8 @@ public class ConfigSubscriber {
return;
}
Object object = event.getSource();
if (object instanceof InputStream) {
LOG.info("********** Remote config change has been subscribed **********");
InputStream inputStream = (InputStream) object;
configParser.parse(inputStream);
}
}
}
\ No newline at end of file
......@@ -11,14 +11,17 @@ package com.nepxion.discovery.plugin.framework.event;
import org.springframework.beans.factory.annotation.Autowired;
import com.nepxion.eventbus.core.Event;
import com.nepxion.eventbus.core.EventControllerFactory;
public class PluginPublisher {
@Autowired
private EventControllerFactory eventControllerFactory;
public void publish(Object object) {
eventControllerFactory.getAsyncController().post(new Event(object));
public void asyncPublish(Object object) {
eventControllerFactory.getAsyncController().post(object);
}
public void syncPublish(Object object) {
eventControllerFactory.getSyncController().post(object);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment