class ConfigurationClassPostProcessorEnhance {
    private static final AgentLogger LOGGER = AgentLogger.getLogger(ConfigurationClassPostProcessorEnhance.class);

    private static final Map<BeanDefinitionRegistry,ConfigurationClassPostProcessorEnhance> INSTANCES = new ConcurrentHashMap<>(4);

    private static final String CONFIGURATION_CLASS_ATTRIBUTE =
            Conventions.getQualifiedAttributeName(ConfigurationClassPostProcessor.class, "configurationClass");

    private volatile ConfigurationClassPostProcessor processor;

    public static ConfigurationClassPostProcessorEnhance getInstance(BeanDefinitionRegistry registry) {
        ConfigurationClassPostProcessorEnhance result = INSTANCES.putIfAbsent(registry, new ConfigurationClassPostProcessorEnhance());
        if (result == null) {
            result = INSTANCES.get(registry);
        }
        return result;
    }

    private ConfigurationClassPostProcessorEnhance() {
    }

    public void setProcessor(ConfigurationClassPostProcessor processor) {
        LOGGER.trace("ConfigurationClassPostProcessorAgent.setProcessor({})", processor);
        this.processor = processor;
    }

    public ConfigurationClassPostProcessor getProcessor() {
        return processor;
    }

    public void resetConfigurationClassPostProcessor(BeanDefinitionRegistry registry) {
        LOGGER.trace("ConfigurationClassPostProcessorAgent.resetConfigurationClassPostProcessor({})");
        if (processor == null) {
            return;
        }

        resetCachingMetadataReaderFactoryCache();
        resetBeanNameCache();
        resetBeanFactoryCache(registry);
    }

    public void postProcess(BeanDefinitionRegistry registry, String beanName) {
        if (processor == null) {
            return;
        }

        resetCachingMetadataReaderFactoryCache();
        resetBeanNameCache();
        resetBeanFactoryCache(registry);
        removeBeanAttribute(registry, beanName);

        processor.processConfigBeanDefinitions(registry);
    }

    public void postProcess(BeanDefinitionRegistry registry) {<FILL_FUNCTION_BODY>}

    private MetadataReaderFactory getMetadataReaderFactory() {
        return (MetadataReaderFactory) ReflectionHelper.getNoException(processor, ConfigurationClassPostProcessor.class,
                "metadataReaderFactory");
    }

    private void resetCachingMetadataReaderFactoryCache() {
        LOGGER.trace("Clearing MetadataReaderFactory cache");
        MetadataReaderFactory metadataReaderFactory = getMetadataReaderFactory();
        if (metadataReaderFactory != null) {
            try {
                ReflectionHelper.invoke(metadataReaderFactory, "clearCache");
            } catch (Exception e) {
                LOGGER.debug("Unable to clear MetadataReaderFactory cache");
            }
        }
    }

    private void resetBeanFactoryCache(BeanDefinitionRegistry registry) {
        LOGGER.trace("Clearing BeanFactory cache");
        DefaultListableBeanFactory beanFactory = RegistryUtils.maybeRegistryToBeanFactory(registry);
        if (beanFactory == null) {
            return;
        }

        beanFactory.setAllowBeanDefinitionOverriding(true);
        resetFactoryMethodCandidateCache(beanFactory);
    }

    private void removeBeanAttribute(BeanDefinitionRegistry registry, String beanName) {
        BeanDefinition bd = registry.getBeanDefinition(beanName);
        if (bd.hasAttribute(CONFIGURATION_CLASS_ATTRIBUTE)) {
            LOGGER.trace("Removing attribute '{}' from bean definition '{}'", CONFIGURATION_CLASS_ATTRIBUTE, beanName);
            bd.removeAttribute(CONFIGURATION_CLASS_ATTRIBUTE);
        }
    }

    private void resetFactoryMethodCandidateCache(DefaultListableBeanFactory factory) {
        Map<Class<?>, Method[]> cache = (Map<Class<?>, Method[]>) ReflectionHelper.getNoException(factory,
                AbstractAutowireCapableBeanFactory.class, "factoryMethodCandidateCache");
        if (cache != null) {
            LOGGER.trace("Cache cleared: AbstractAutowireCapableBeanFactory.factoryMethodCandidateCache");
            cache.clear();
        }
    }

    private void resetBeanNameCache() {
        Map<Method, String> cache = (Map<Method, String>) ReflectionHelper.getNoException(null,
                "org.springframework.context.annotation.BeanAnnotationHelper",
                processor.getClass().getClassLoader(), "beanNameCache");
        if (cache != null) {
            LOGGER.trace("Cache cleared: BeanAnnotationHelper.beanNameCache");
            cache.clear();
        }
    }
}

        LOGGER.trace("ConfigurationClassPostProcessorAgent.postProcess({})", ObjectUtils.identityToString(registry));
        if (processor == null) {
            return;
        }

        resetCachingMetadataReaderFactoryCache();
        resetBeanNameCache();
        resetBeanFactoryCache(registry);

        processor.processConfigBeanDefinitions(registry);
    
<no_super_class>