All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.servicerocket.confluence.plugin.utility.library.ConversionAssistantWithModuleTracker Maven / Gradle / Ivy

The newest version!
package com.servicerocket.confluence.plugin.utility.library;

import com.atlassian.plugin.PluginAccessor;
import com.atlassian.plugin.event.PluginEventManager;
import com.atlassian.plugin.tracker.DefaultPluginModuleTracker;
import com.atlassian.plugin.tracker.PluginModuleTracker;
import com.servicerocket.confluence.randombits.support.core.convert.Converter;
import com.servicerocket.confluence.randombits.support.core.impl.DefaultConversionAssistant;
import org.springframework.beans.factory.DisposableBean;

/**
 * Temporary class to re-introduce module descriptor back into the plugin.
 * Should be merge with parent class once `randombits core` runtime library is consolidate into this plugin.
 *
 * @author Kai Ming
 * @since 2.1.1.20161207
 */
public class ConversionAssistantWithModuleTracker extends DefaultConversionAssistant implements DisposableBean {

    private final PluginModuleTracker converterTracker;

    public ConversionAssistantWithModuleTracker(PluginAccessor pluginAccessor, PluginEventManager pluginEventManager) {

        converterTracker = new DefaultPluginModuleTracker<>(pluginAccessor, pluginEventManager, ConverterModuleDescriptor.class, new PluginModuleTracker.Customizer() {
            @Override
            public ConverterModuleDescriptor adding(ConverterModuleDescriptor converterModuleDescriptor) {
                addConverter(converterModuleDescriptor.getModule());
                return converterModuleDescriptor;
            }

            @Override
            public void removed(ConverterModuleDescriptor converterModuleDescriptor) {
                removeConverter(converterModuleDescriptor.getModule());
            }
        });
    }

    @Override
    public void destroy() throws Exception {
        converterTracker.close();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy