class SingletonExtensionFactory extends DefaultExtensionFactory {

    private final List<String> extensionClassNames;

    private final Map<ClassLoader, Map<String, Object>> cache;

    public SingletonExtensionFactory(PluginManager pluginManager, String... extensionClassNames) {
        this.extensionClassNames = Arrays.asList(extensionClassNames);

        cache = new HashMap<>();

        pluginManager.addPluginStateListener(event -> {
            if (event.getPluginState() != PluginState.STARTED) {
                cache.remove(event.getPlugin().getPluginClassLoader());
            }
        });
    }

    @Override
    @SuppressWarnings("unchecked")
    public <T> T create(Class<T> extensionClass) {<FILL_FUNCTION_BODY>}

}

        String extensionClassName = extensionClass.getName();
        ClassLoader extensionClassLoader = extensionClass.getClassLoader();

        if (!cache.containsKey(extensionClassLoader)) {
            cache.put(extensionClassLoader, new HashMap<>());
        }

        Map<String, Object> classLoaderBucket = cache.get(extensionClassLoader);

        if (classLoaderBucket.containsKey(extensionClassName)) {
            return (T) classLoaderBucket.get(extensionClassName);
        }

        T extension = super.create(extensionClass);
        if (extensionClassNames.isEmpty() || extensionClassNames.contains(extensionClassName)) {
            classLoaderBucket.put(extensionClassName, extension);
        }

        return extension;
    
<methods>public non-sealed void <init>() ,public T create(Class<T>) <variables>private static final org.slf4j.Logger log