Commit ebc2c4c0 by Nepxion

重构事件总线

parent 4e1dd99f
...@@ -79,7 +79,7 @@ public class AdminEndpoint extends AbstractMvcEndpoint { ...@@ -79,7 +79,7 @@ public class AdminEndpoint extends AbstractMvcEndpoint {
try { try {
InputStream inputStream = IOUtils.toInputStream(config, PluginConstant.ENCODING_UTF_8); InputStream inputStream = IOUtils.toInputStream(config, PluginConstant.ENCODING_UTF_8);
pluginPublisher.publish(inputStream); pluginPublisher.asyncPublish(inputStream);
} catch (IOException e) { } catch (IOException e) {
throw new PluginException("To input stream failed", e); throw new PluginException("To input stream failed", e);
} }
......
...@@ -21,6 +21,6 @@ public abstract class ConfigAdapter extends AbstractConfigLoader { ...@@ -21,6 +21,6 @@ public abstract class ConfigAdapter extends AbstractConfigLoader {
private PluginPublisher pluginPublisher; private PluginPublisher pluginPublisher;
public void publish(InputStream inputStream) { 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; ...@@ -18,7 +18,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import com.google.common.eventbus.Subscribe; import com.google.common.eventbus.Subscribe;
import com.nepxion.discovery.plugin.framework.context.PluginContextAware; import com.nepxion.discovery.plugin.framework.context.PluginContextAware;
import com.nepxion.eventbus.annotation.EventBus; import com.nepxion.eventbus.annotation.EventBus;
import com.nepxion.eventbus.core.Event;
@EventBus @EventBus
public class ConfigSubscriber { public class ConfigSubscriber {
...@@ -31,7 +30,7 @@ public class ConfigSubscriber { ...@@ -31,7 +30,7 @@ public class ConfigSubscriber {
private ConfigParser configParser; private ConfigParser configParser;
@Subscribe @Subscribe
public void subscribe(Event event) { public void subscribe(InputStream inputStream) {
Boolean discoveryControlEnabled = pluginContextAware.isDiscoveryControlEnabled(); Boolean discoveryControlEnabled = pluginContextAware.isDiscoveryControlEnabled();
Boolean remoteConfigEnabled = pluginContextAware.isRemoteConfigEnabled(); Boolean remoteConfigEnabled = pluginContextAware.isRemoteConfigEnabled();
...@@ -47,12 +46,8 @@ public class ConfigSubscriber { ...@@ -47,12 +46,8 @@ public class ConfigSubscriber {
return; return;
} }
Object object = event.getSource(); LOG.info("********** Remote config change has been subscribed **********");
if (object instanceof InputStream) {
LOG.info("********** Remote config change has been subscribed **********");
InputStream inputStream = (InputStream) object; configParser.parse(inputStream);
configParser.parse(inputStream);
}
} }
} }
\ No newline at end of file
...@@ -11,14 +11,17 @@ package com.nepxion.discovery.plugin.framework.event; ...@@ -11,14 +11,17 @@ package com.nepxion.discovery.plugin.framework.event;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import com.nepxion.eventbus.core.Event;
import com.nepxion.eventbus.core.EventControllerFactory; import com.nepxion.eventbus.core.EventControllerFactory;
public class PluginPublisher { public class PluginPublisher {
@Autowired @Autowired
private EventControllerFactory eventControllerFactory; private EventControllerFactory eventControllerFactory;
public void publish(Object object) { public void asyncPublish(Object object) {
eventControllerFactory.getAsyncController().post(new Event(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