Search in sources :

Example 1 with IDynamicPlugin

use of org.talend.core.runtime.dynamic.IDynamicPlugin in project tbd-studio-se by Talend.

the class AbstractDynamicDistributionTemplate method registPluginExtensions.

@Override
public boolean registPluginExtensions() {
    if (registedPluginAdapter == null) {
        synchronized (registedPluginAdapterLock) {
            if (registedPluginAdapter == null) {
                DynamicPluginAdapter plugAdapter = getPluginAdapter();
                IDynamicPlugin plugin = plugAdapter.getPlugin();
                IDynamicPluginConfiguration pConfiguration = plugin.getPluginConfiguration();
                try {
                    plugin.setPluginConfiguration(null);
                    DynamicServiceUtil.addContribution(plugAdapter.getBundle(), plugin);
                    registedPluginAdapter = plugAdapter;
                    ILibrariesService libService = ILibrariesService.get();
                    if (libService != null) {
                        libService.resetModulesNeeded();
                    }
                    HadoopDistributionsHelper.updatePluginExtensionCacheVersion();
                    return true;
                } catch (Exception e) {
                    ExceptionHandler.process(e);
                } finally {
                    plugin.setPluginConfiguration(pConfiguration);
                }
            }
        }
    }
    return false;
}
Also used : DynamicPluginAdapter(org.talend.hadoop.distribution.dynamic.adapter.DynamicPluginAdapter) ILibrariesService(org.talend.core.model.general.ILibrariesService) IDynamicPlugin(org.talend.core.runtime.dynamic.IDynamicPlugin) IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration)

Example 2 with IDynamicPlugin

use of org.talend.core.runtime.dynamic.IDynamicPlugin in project tbd-studio-se by Talend.

the class DynamicDistributionManager method getUsersIdDynamicDistributionMap.

private Map<String, IDynamicPlugin> getUsersIdDynamicDistributionMap() throws Exception {
    if (usersIdDistributionMap != null) {
        String systemCacheVersion = HadoopDistributionsHelper.getCacheVersion();
        if (StringUtils.equals(systemCacheVersion, usersIdDistributionMapCacheVersion)) {
            return usersIdDistributionMap;
        }
    }
    usersIdDistributionMap = new HashMap<>();
    usersIdDistributionMapCacheVersion = HadoopDistributionsHelper.getCacheVersion();
    IDynamicMonitor monitor = new DummyDynamicMonitor();
    List<IDynamicPlugin> allBuiltinDynamicPlugins = getAllUsersDynamicPlugins(monitor);
    if (allBuiltinDynamicPlugins != null && !allBuiltinDynamicPlugins.isEmpty()) {
        for (IDynamicPlugin dynamicPlugin : allBuiltinDynamicPlugins) {
            IDynamicPluginConfiguration pluginConfiguration = dynamicPlugin.getPluginConfiguration();
            if (pluginConfiguration != null) {
                String id = pluginConfiguration.getId();
                usersIdDistributionMap.put(id, dynamicPlugin);
            }
        }
    }
    return usersIdDistributionMap;
}
Also used : IDynamicPlugin(org.talend.core.runtime.dynamic.IDynamicPlugin) DummyDynamicMonitor(org.talend.designer.maven.aether.DummyDynamicMonitor) IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration) IDynamicMonitor(org.talend.designer.maven.aether.IDynamicMonitor)

Example 3 with IDynamicPlugin

use of org.talend.core.runtime.dynamic.IDynamicPlugin in project tbd-studio-se by Talend.

the class DynamicDistributionManager method getAllUsersDynamicPlugins.

public List<IDynamicPlugin> getAllUsersDynamicPlugins(IDynamicMonitor monitor) throws Exception {
    if (usersPluginsCache != null) {
        String systemCacheVersion = HadoopDistributionsHelper.getCacheVersion();
        if (StringUtils.equals(systemCacheVersion, usersPluginsCacheVersion)) {
            return usersPluginsCache;
        }
    }
    usersPluginsCacheVersion = HadoopDistributionsHelper.getCacheVersion();
    List<IDynamicPlugin> dynamicPlugins = new LinkedList<>();
    List<IDynamicPlugin> tempDynPlugins = null;
    ProjectManager projectManager = ProjectManager.getInstance();
    List<Project> allRefProjects = ProjectManager.getInstance().getAllReferencedProjects();
    if (allRefProjects != null && 0 < allRefProjects.size()) {
        for (Project refProject : allRefProjects) {
            try {
                tempDynPlugins = getAllUsersDynamicPluginsForProject(refProject, monitor);
                if (tempDynPlugins != null && 0 < tempDynPlugins.size()) {
                    dynamicPlugins.addAll(tempDynPlugins);
                }
            } catch (Exception e) {
                ExceptionHandler.process(e);
            }
        }
    }
    /**
     * MUST put dynamic plugins of current project AT THE END OF THE LIST!!!<br>
     * so that they can overwrite the same id dynamic plugins from reference projects
     */
    tempDynPlugins = getAllUsersDynamicPluginsForProject(projectManager.getCurrentProject(), monitor);
    if (tempDynPlugins != null && 0 < tempDynPlugins.size()) {
        dynamicPlugins.addAll(tempDynPlugins);
    }
    usersPluginsCache = dynamicPlugins;
    return usersPluginsCache;
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) IDynamicPlugin(org.talend.core.runtime.dynamic.IDynamicPlugin) LinkedList(java.util.LinkedList) ProjectManager(org.talend.repository.ProjectManager)

Example 4 with IDynamicPlugin

use of org.talend.core.runtime.dynamic.IDynamicPlugin in project tbd-studio-se by Talend.

the class DynamicDistributionManager method getBuiltinIdDynamicDistributionMap.

private Map<String, IDynamicPlugin> getBuiltinIdDynamicDistributionMap() throws Exception {
    if (builtinIdDistributionMap != null) {
        String systemCacheVersion = HadoopDistributionsHelper.getCacheVersion();
        if (StringUtils.equals(systemCacheVersion, builtinIdDistributionMapCacheVersion)) {
            return builtinIdDistributionMap;
        }
    }
    builtinIdDistributionMap = new HashMap<>();
    builtinIdDistributionMapCacheVersion = HadoopDistributionsHelper.getCacheVersion();
    IDynamicMonitor monitor = new DummyDynamicMonitor();
    List<IDynamicPlugin> allBuiltinDynamicPlugins = getAllBuiltinDynamicPlugins(monitor);
    if (allBuiltinDynamicPlugins != null && !allBuiltinDynamicPlugins.isEmpty()) {
        for (IDynamicPlugin dynamicPlugin : allBuiltinDynamicPlugins) {
            IDynamicPluginConfiguration pluginConfiguration = dynamicPlugin.getPluginConfiguration();
            if (pluginConfiguration != null) {
                String id = pluginConfiguration.getId();
                builtinIdDistributionMap.put(id, dynamicPlugin);
            }
        }
    }
    return builtinIdDistributionMap;
}
Also used : IDynamicPlugin(org.talend.core.runtime.dynamic.IDynamicPlugin) DummyDynamicMonitor(org.talend.designer.maven.aether.DummyDynamicMonitor) IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration) IDynamicMonitor(org.talend.designer.maven.aether.IDynamicMonitor)

Example 5 with IDynamicPlugin

use of org.talend.core.runtime.dynamic.IDynamicPlugin in project tbd-studio-se by Talend.

the class DynamicDistributionOptionForm method refreshExistingConfigsCombo.

private void refreshExistingConfigsCombo(IDynamicMonitor monitor, IDynamicDistributionsGroup dynamicDistributionsGroup) throws Exception {
    List<IDynamicPlugin> distriDynamicPlugins = copyAllUsersDynamicPlugins(monitor, dynamicDistributionsGroup);
    existingConfigsComboViewer.setInput(distriDynamicPlugins);
    if (0 < distriDynamicPlugins.size()) {
        existingConfigsComboViewer.setSelection(new StructuredSelection(distriDynamicPlugins.get(0)));
    }
}
Also used : IDynamicPlugin(org.talend.core.runtime.dynamic.IDynamicPlugin) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection)

Aggregations

IDynamicPlugin (org.talend.core.runtime.dynamic.IDynamicPlugin)25 IDynamicPluginConfiguration (org.talend.core.runtime.dynamic.IDynamicPluginConfiguration)16 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 DummyDynamicMonitor (org.talend.designer.maven.aether.DummyDynamicMonitor)6 IDynamicMonitor (org.talend.designer.maven.aether.IDynamicMonitor)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 LinkedList (java.util.LinkedList)4 Project (org.talend.core.model.general.Project)4 DynamicPluginAdapter (org.talend.hadoop.distribution.dynamic.adapter.DynamicPluginAdapter)4 DynamicDistributionSetupData (org.talend.repository.hadoopcluster.ui.dynamic.DynamicDistributionSetupData)4 File (java.io.File)3 LoginException (org.talend.commons.exception.LoginException)3 PersistenceException (org.talend.commons.exception.PersistenceException)3 IDynamicDistributionsGroup (org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup)3 ArrayList (java.util.ArrayList)2 IProject (org.eclipse.core.resources.IProject)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 Bundle (org.osgi.framework.Bundle)2 DynamicPluginComparator (org.talend.hadoop.distribution.dynamic.comparator.DynamicPluginComparator)2 IDynamicDistributionPreference (org.talend.hadoop.distribution.dynamic.pref.IDynamicDistributionPreference)2