use of org.talend.core.model.components.AbstractComponentsProvider in project tdi-studio-se by Talend.
the class ComponentsFactory method init.
private void init(boolean duringLogon) {
// not used anymore
removeOldComponentsUserFolder();
long startTime = System.currentTimeMillis();
// TimeMeasure.display = true;
// TimeMeasure.displaySteps = true;
// TimeMeasure.measureActive = true;
// TimeMeasure.begin("initComponents");
componentList = Collections.synchronizedSet(new HashSet<IComponent>());
customComponentList = new HashSet<IComponent>();
skeletonList = new ArrayList<String>();
userComponentList = new HashSet<IComponent>();
String installLocation = new Path(Platform.getConfigurationLocation().getURL().getPath()).toFile().getAbsolutePath();
componentToProviderMap = new HashMap<IComponent, AbstractComponentsProvider>();
boolean isNeedClean = !cleanDone && TalendCacheUtils.isSetCleanComponentCache();
// only check this parameter one time, or it will reinitialize things all the time...
cleanDone = true;
isCreated = hasComponentFile(installLocation) && !isNeedClean;
ComponentsCache cache = ComponentManager.getComponentCache();
try {
if (isCreated) {
// it avoids to reload from disk again even more for commandline at each logon, since it's no use.
if (cache.getComponentEntryMap().isEmpty()) {
ComponentsCache loadCache = loadComponentResource(installLocation);
cache.getComponentEntryMap().putAll(loadCache.getComponentEntryMap());
}
} else {
cache.getComponentEntryMap().clear();
}
} catch (IOException e) {
ExceptionHandler.process(e);
cache.getComponentEntryMap().clear();
isCreated = false;
}
loadComponentsFromComponentsProviderExtension();
// TimeMeasure.step("initComponents", "loadComponentsFromProvider");
// 2.Load Component from extension point: component_definition
loadComponentsFromExtensions();
// TimeMeasure.step("initComponents", "loadComponentsFromExtension[joblets?]");
// will save only if needed.
ComponentManager.saveResource();
// init component name map, used to pick specified component immediately
initComponentNameMap();
// TimeMeasure.step("initComponents", "createCache");
//$NON-NLS-1$ //$NON-NLS-2$
log.debug(componentList.size() + " components loaded in " + (System.currentTimeMillis() - startTime) + " ms");
// TimeMeasure.end("initComponents");
// TimeMeasure.display = false;
// TimeMeasure.displaySteps = false;
// TimeMeasure.measureActive = false;
}
use of org.talend.core.model.components.AbstractComponentsProvider in project tdi-studio-se by Talend.
the class ComponentsFactory method getComponentResourceBundle.
private ResourceBundle getComponentResourceBundle(IComponent currentComp, String source, String cachedPathSource, AbstractComponentsProvider provider) {
try {
AbstractComponentsProvider currentProvider = provider;
if (currentProvider == null) {
ComponentsProviderManager componentsProviderManager = ComponentsProviderManager.getInstance();
Collection<AbstractComponentsProvider> providers = componentsProviderManager.getProviders();
for (AbstractComponentsProvider curProvider : providers) {
String path = new Path(curProvider.getInstallationFolder().toString()).toPortableString();
if (source.startsWith(path)) {
// fix for TDI-19889 and TDI-20507 to get the correct component provider
if (cachedPathSource != null) {
if (path.contains(cachedPathSource)) {
currentProvider = curProvider;
break;
}
} else {
currentProvider = curProvider;
break;
}
}
}
}
String installPath = currentProvider.getInstallationFolder().toString();
String label = ComponentFilesNaming.getInstance().getBundleName(currentComp.getName(), installPath.substring(installPath.lastIndexOf(IComponentsFactory.COMPONENTS_INNER_FOLDER)));
if (currentProvider.isUseLocalProvider()) {
// if the component use local provider as storage (for user / ecosystem components)
// then get the bundle resource from the current main component provider.
// note: code here to review later, service like this shouldn't be used...
ResourceBundle bundle = null;
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
if (brandingService.isPoweredOnlyCamel()) {
bundle = currentProvider.getResourceBundle(label);
} else {
ITisLocalProviderService service = (ITisLocalProviderService) GlobalServiceRegister.getDefault().getService(ITisLocalProviderService.class);
bundle = service.getResourceBundle(label);
}
return bundle;
} else {
ResourceBundle bundle = ResourceBundle.getBundle(label, Locale.getDefault(), new ResClassLoader(currentProvider.getClass().getClassLoader()));
return bundle;
}
} catch (IOException e) {
ExceptionHandler.process(e);
}
return null;
}
use of org.talend.core.model.components.AbstractComponentsProvider in project tdi-studio-se by Talend.
the class ComponentsProviderManager method loadComponentsProvidersFromExtension.
private void loadComponentsProvidersFromExtension() {
if (providers == null) {
providers = new ArrayList<AbstractComponentsProvider>();
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
//$NON-NLS-1$
IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint("org.talend.core.components_provider");
IExtension[] extensions = extensionPoint.getExtensions();
for (IExtension extension : extensions) {
IConfigurationElement[] configurationElements = extension.getConfigurationElements();
for (IConfigurationElement configurationElement : configurationElements) {
//$NON-NLS-1$
String id = configurationElement.getAttribute("id");
//$NON-NLS-1$
String folderName = configurationElement.getAttribute("folderName");
String contributerName = configurationElement.getContributor().getName();
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
if (!brandingService.isPoweredOnlyCamel() && id.equals("org.talend.designer.camel.components.localprovider.CamelLocalComponentsProvider")) {
folderName = "camel";
}
try {
AbstractComponentsProvider componentsProvider = (AbstractComponentsProvider) configurationElement.createExecutableExtension(//$NON-NLS-1$
"class");
componentsProvider.setId(id);
componentsProvider.setFolderName(folderName);
componentsProvider.setContributer(contributerName);
providers.add(componentsProvider);
} catch (CoreException e) {
//$NON-NLS-1$
log.error(Messages.getString("ComponentsProviderManager.unableLoad") + id, e);
}
}
}
}
}
use of org.talend.core.model.components.AbstractComponentsProvider in project tdi-studio-se by Talend.
the class ComponentsFactory method getComponentsProvidersFolder.
@Override
public Map<String, File> getComponentsProvidersFolder() {
Map<String, File> list = new HashMap<String, File>();
ComponentsProviderManager componentsProviderManager = ComponentsProviderManager.getInstance();
for (AbstractComponentsProvider componentsProvider : componentsProviderManager.getProviders()) {
try {
// list.add(componentsProvider.getInstallationFolder());
list.put(componentsProvider.getContributer(), componentsProvider.getInstallationFolder());
} catch (IOException e) {
ExceptionHandler.process(e);
continue;
}
}
return list;
}
use of org.talend.core.model.components.AbstractComponentsProvider in project tdi-studio-se by Talend.
the class ComponentsFactory method getComponentsProvidersInfo.
@Override
public List<ComponentProviderInfo> getComponentsProvidersInfo() {
List<ComponentProviderInfo> list = new ArrayList<ComponentProviderInfo>();
ComponentsProviderManager componentsProviderManager = ComponentsProviderManager.getInstance();
for (AbstractComponentsProvider componentsProvider : componentsProviderManager.getProviders()) {
try {
ComponentProviderInfo info = new ComponentProviderInfo();
info.setId(componentsProvider.getId());
info.setContributer(componentsProvider.getContributer());
info.setLocation(componentsProvider.getInstallationFolder().getAbsolutePath());
list.add(info);
} catch (IOException e) {
ExceptionHandler.process(e);
continue;
}
}
return list;
}
Aggregations