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

com.servicerocket.confluence.plugin.utility.library.InjectionAdaptorWithModuleTracker 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.supplier.core.SupplierAssistant;
import com.servicerocket.confluence.randombits.supplier.core.param.Adaptor;
import com.servicerocket.confluence.randombits.supplier.core.param.InjectionInterceptor;
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 InjectionAdaptorWithModuleTracker extends InjectionInterceptor implements DisposableBean {

    private final PluginModuleTracker, InjectionAdaptorModuleDescriptor> adaptorTracker;

    public InjectionAdaptorWithModuleTracker(SupplierAssistant supplierAssistant, PluginAccessor pluginAccessor, PluginEventManager pluginEventManager) {
        super(supplierAssistant);
        adaptorTracker = new DefaultPluginModuleTracker<>(pluginAccessor, pluginEventManager, InjectionAdaptorModuleDescriptor.class,
                new PluginModuleTracker.Customizer, InjectionAdaptorModuleDescriptor>() {
                    @Override
                    public InjectionAdaptorModuleDescriptor adding(InjectionAdaptorModuleDescriptor moduleDescriptor) {
                        registerAdaptor(moduleDescriptor.getModule());
                        return moduleDescriptor;
                    }

                    @Override
                    public void removed(InjectionAdaptorModuleDescriptor moduleDescriptor) {
                        unregisterAdaptor(moduleDescriptor.getModule());
                    }
                }
        );
    }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy