class XPluginImp implements Plugin, InitializingBean {
    private Timer clientTimer = new Timer();
    private CloudProps cloudProps;
    private boolean inited = false;

    private boolean initDo(AppContext context) throws Throwable {
        if (cloudProps == null) {
            cloudProps = new CloudProps(context, "water");
        }

        if (inited) {
            return true;
        }

        if (Utils.isEmpty(cloudProps.getServer())) {
            return false;
        }

        //1.初始化服务地址
        String server = cloudProps.getServer();
        String configServer = cloudProps.getConfigServer();
        String discoveryServer = cloudProps.getDiscoveryServer();
        String eventServer = cloudProps.getEventServer();
        String logServer = cloudProps.getLogServer();

        String logDefault = cloudProps.getLogDefault();

        CloudProps.LOG_DEFAULT_LOGGER = logDefault;

        //1.1.设置water默认基础配置
        System.setProperty(WW.water_host, server);
        if (Utils.isNotEmpty(logDefault)) {
            System.setProperty(WW.water_logger, logDefault);
        }

        if (server.equals(configServer) == false) {
            WaterAddress.setCfgApiUrl(configServer);
        }

        if (server.equals(discoveryServer) == false) {
            WaterAddress.setRegApiUrl(discoveryServer);
        }

        if (server.equals(eventServer) == false) {
            WaterAddress.setMsgApiUrl(eventServer);
        }

        if (server.equals(logServer) == false) {
            WaterAddress.setLogApiUrl(logServer);
        }

        inited = true;
        return true;
    }

    @Override
    public void afterInjection() throws Throwable {
        if (initDo(Solon.context()) == false) {
            return;
        }

        CloudTraceServiceWaterImpl traceServiceImp = new CloudTraceServiceWaterImpl();
        WaterClient.localHostSet(Instance.local().address());
        WaterClient.localServiceSet(Instance.local().service());
        WaterSetting.water_trace_id_supplier(traceServiceImp::getTraceId);

        if (cloudProps.getLogEnable()) {
            CloudManager.register(new CloudLogServiceWaterImpl(cloudProps));
        }

        if (cloudProps.getTraceEnable()) {
            CloudManager.register(traceServiceImp);
        }
    }

    @Override
    public void start(AppContext context) throws Throwable {<FILL_FUNCTION_BODY>}

    @Override
    public void prestop() throws Throwable {
        if (clientTimer != null) {
            clientTimer.cancel();
        }
    }

    public String getEventReceive() {
        return cloudProps.getValue(WaterProps.PROP_EVENT_receive);
    }

    public void setEventReceive(String value) {
        cloudProps.setValue(WaterProps.PROP_EVENT_receive, value);
    }
}

        if (initDo(context) == false) {
            return;
        }

        //2.初始化服务
        CloudDiscoveryServiceWaterImpl discoveryServiceImp = null;
        CloudConfigServiceWaterImpl configServiceImp = null;
        CloudEventServiceWaterImpl eventServiceImp = new CloudEventServiceWaterImpl(cloudProps);
        CloudI18nServiceWaterImpl i18nServiceImp = null;

        if (cloudProps.getMetricEnable()) {
            CloudManager.register(new CloudMetricServiceWaterImpl());
        }


        if (cloudProps.getConfigEnable()) {
            configServiceImp = new CloudConfigServiceWaterImpl(cloudProps);
            CloudManager.register(configServiceImp);

            if (Solon.cfg().isFilesMode()) {
                if (configServiceImp.getRefreshInterval() > 0) {
                    long interval = configServiceImp.getRefreshInterval();
                    clientTimer.schedule(configServiceImp, interval, interval);
                }
            }

            //配置加载
            CloudClient.configLoad(cloudProps.getConfigLoad());
        }

        if (cloudProps.getI18nEnable()) {
            i18nServiceImp = new CloudI18nServiceWaterImpl(cloudProps);
            CloudManager.register(i18nServiceImp);
        }


        if (cloudProps.getDiscoveryEnable()) {
            discoveryServiceImp = new CloudDiscoveryServiceWaterImpl(cloudProps);
            CloudManager.register(discoveryServiceImp);

            if (Solon.cfg().isFilesMode()) {
                if (discoveryServiceImp.getRefreshInterval() > 0) {
                    long interval = discoveryServiceImp.getRefreshInterval();
                    clientTimer.schedule(discoveryServiceImp, interval, interval);
                }
            }
        }

        if (cloudProps.getEventEnable()) {
            String receive = getEventReceive();
            if (receive != null && receive.startsWith("@")) {
                if (CloudClient.config() != null) {
                    Config cfg = CloudClient.config().pull(Solon.cfg().appGroup(), receive.substring(1));
                    if (cfg == null || Utils.isEmpty(cfg.value())) {
                        throw new IllegalArgumentException("Configuration " + receive + " does not exist");
                    }
                    setEventReceive(cfg.value());
                }
            }

            CloudManager.register(eventServiceImp);

            if (discoveryServiceImp != null || i18nServiceImp != null) {
                //关注缓存更新事件
                eventServiceImp.attention(EventLevel.instance, "", "", WW.msg_ucache_topic, "",
                        0, new HandlerCacheUpdate(discoveryServiceImp, i18nServiceImp));
            }

            if (configServiceImp != null) {
                //关注配置更新事件
                eventServiceImp.attention(EventLevel.instance, "", "", WW.msg_uconfig_topic, "",
                       0, new HandlerConfigUpdate(configServiceImp));
            }

            context.lifecycle(-99, () -> eventServiceImp.subscribe());
        }

        if (cloudProps.getLockEnable()) {
            CloudManager.register(new CloudLockServiceWaterImpl());
        }

        if (cloudProps.getListEnable()) {
            CloudManager.register(new CloudListServiceWaterImpl());
        }

        if (cloudProps.getJobEnable()) {
            CloudManager.register(CloudJobServiceWaterImpl.instance);

            context.lifecycle(-99, () -> {
                CloudJobServiceWaterImpl.instance.push();
            });
        }


        //3.注册http监听
        if (cloudProps.getJobEnable()) {
            Solon.app().http(WW.path_run_job, new HandlerJob());
        }

        Solon.app().http(WW.path_run_check, new HandlerCheck());
        Solon.app().http(WW.path_run_status, new HandlerStatus());
        Solon.app().http(WW.path_run_stop, new HandlerStop());
        Solon.app().http(WW.path_run_msg, new HandlerReceive(eventServiceImp));
    
<no_super_class>