class ApolloRefresher extends AbstractRefresher implements ConfigFileChangeListener, InitializingBean {

    private static final Splitter NAMESPACE_SPLITTER = Splitter.on(",").omitEmptyStrings().trimResults();

    public ApolloRefresher(DtpProperties dtpProperties) {
        super(dtpProperties);
    }

    @Override
    public void onChange(ConfigFileChangeEvent changeEvent) {
        String namespace = changeEvent.getNamespace();
        String newValue = changeEvent.getNewValue();
        ConfigFileTypeEnum configFileType = deduceConfigFileType(namespace);
        refresh(newValue, configFileType);
    }

    @Override
    public void afterPropertiesSet() {<FILL_FUNCTION_BODY>}

    private ConfigFileFormat determineFileFormat(String namespaceName) {
        String lowerCase = namespaceName.toLowerCase();
        for (ConfigFileFormat format : ConfigFileFormat.values()) {
            if (lowerCase.endsWith("." + format.getValue())) {
                return format;
            }
        }
        return ConfigFileFormat.Properties;
    }

    private String trimNamespaceFormat(String namespaceName, ConfigFileFormat format) {
        String extension = "." + format.getValue();
        if (!namespaceName.toLowerCase().endsWith(extension)) {
            return namespaceName;
        }
        return namespaceName.substring(0, namespaceName.length() - extension.length());
    }

    private ConfigFileTypeEnum deduceConfigFileType(String namespace) {
        ConfigFileFormat configFileFormat = determineFileFormat(namespace);
        return ConfigFileTypeEnum.of(configFileFormat.getValue());
    }

    private boolean isDtpNamespace(String content, ConfigFileTypeEnum configFileType) {
        val configHandler = ConfigHandler.getInstance();
        try {
            val properties = configHandler.parseConfig(content, configFileType);
            return properties.keySet().stream().anyMatch(key -> key.toString().startsWith(MAIN_PROPERTIES_PREFIX));
        } catch (IOException e) {
            return false;
        }
    }
}

        String namespaces = environment.getProperty(PropertySourcesConstants.APOLLO_BOOTSTRAP_NAMESPACES,
                ConfigConsts.NAMESPACE_APPLICATION);
        log.debug("Apollo bootstrap namespaces: {}", namespaces);
        List<String> namespaceList = NAMESPACE_SPLITTER.splitToList(namespaces);

        for (String namespace : namespaceList) {
            ConfigFileFormat format = determineFileFormat(namespace);
            String actualNamespaceName = trimNamespaceFormat(namespace, format);
            ConfigFile configFile = ConfigService.getConfigFile(actualNamespaceName, format);
            if (!isDtpNamespace(configFile.getContent(), ConfigFileTypeEnum.of(format.getValue()))) {
                continue;
            }
            try {
                configFile.addChangeListener(this);
                log.info("DynamicTp refresher, add listener success, namespace: {}", actualNamespaceName);
            } catch (Exception e) {
                log.error("DynamicTp refresher, add listener error, namespace: {}", actualNamespaceName, e);
            }
        }
    
<methods>public void refresh(java.lang.String, org.dromara.dynamictp.common.em.ConfigFileTypeEnum) ,public void setEnvironment(Environment) <variables>protected final non-sealed org.dromara.dynamictp.common.properties.DtpProperties dtpProperties,protected Environment environment