Search in sources :

Example 26 with Bundle

use of org.osgi.framework.Bundle in project tdi-studio-se by Talend.

the class TosBrandingService method getLicenseFile.

@Override
public URL getLicenseFile() throws IOException {
    final Bundle b = Platform.getBundle(Activator.PLUGIN_ID);
    //$NON-NLS-1$
    final URL url = FileLocator.toFileURL(FileLocator.find(b, new Path("resources/license.txt"), null));
    return url;
}
Also used : Path(org.eclipse.core.runtime.Path) Bundle(org.osgi.framework.Bundle) URL(java.net.URL)

Example 27 with Bundle

use of org.osgi.framework.Bundle in project tdi-studio-se by Talend.

the class ImportDemoProjectItemsPage method getFullImagePath.

/**
     * getFullImagePath.
     * 
     * @param languageName
     * @return
     */
private Image getFullImagePath(DemoProjectBean node) {
    URL url = null;
    String pluginPath = null;
    String relatedImagePath = null;
    Bundle bundle = null;
    if (node != null) {
        // ;
        relatedImagePath = node.getIconUrl();
        bundle = Platform.getBundle(node.getPluginId());
    }
    try {
        if (FileLocator.find(bundle, new Path(relatedImagePath), null) != null) {
            url = FileLocator.toFileURL(FileLocator.find(bundle, new Path(relatedImagePath), null));
            pluginPath = new Path(url.getFile()).toOSString();
        } else {
            url = FileLocator.find(bundle, new Path(DEFAUTL_DEMO_ICON), null);
            pluginPath = new Path(url.getFile()).toOSString();
        }
    } catch (IOException e1) {
    // nothing to do
    }
    return new Image(null, pluginPath);
}
Also used : Path(org.eclipse.core.runtime.Path) Bundle(org.osgi.framework.Bundle) IOException(java.io.IOException) Image(org.eclipse.swt.graphics.Image) URL(java.net.URL)

Example 28 with Bundle

use of org.osgi.framework.Bundle in project tdi-studio-se by Talend.

the class BDJobReArchieveCreator method getLibPath.

/**
     * 
     * maybe, should be same result with JobJavaScriptsManager.getLibPath
     */
public List<File> getLibPath(File zipTmpFolder, boolean isSpecialMR) {
    List<File> neededLibFiles = new ArrayList<File>();
    File libFolder = new File(zipTmpFolder, JavaUtils.JAVA_LIB_DIRECTORY);
    Set<String> compiledModulesSet = new HashSet<String>(100);
    Set<ModuleNeeded> neededModules = LastGenerationInfo.getInstance().getModulesNeededWithSubjobPerJob(processItem.getProperty().getId(), processItem.getProperty().getVersion());
    if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
        IDesignerCoreService designerCoreService = (IDesignerCoreService) GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
        IProcess process = designerCoreService.getProcessFromProcessItem(processItem);
        compiledModulesSet.addAll(PomUtil.getCodesExportJars(process));
        if (neededModules.isEmpty()) {
            neededModules = process.getNeededModules(true);
        }
    }
    for (ModuleNeeded module : neededModules) {
        if (((isSpecialMR || isSparkWithHDInsight) && module.isMrRequired()) || (!isSpecialMR && !isSparkWithHDInsight)) {
            compiledModulesSet.add(module.getModuleName());
        }
    }
    Set<String> jarNames = new HashSet<String>();
    try {
        // from org.talend.libraries.apache.storm/lib
        Bundle bundle = Platform.getBundle(PLUGIN_ID);
        if (bundle != null) {
            //$NON-NLS-1$
            URL stormLibUrl = FileLocator.toFileURL(FileLocator.find(bundle, new Path("lib"), null));
            if (stormLibUrl != null) {
                File file = new File(stormLibUrl.getFile());
                File[] jars = file.listFiles();
                for (File f : jars) {
                    jarNames.add(f.getName());
                }
            }
        }
    } catch (IOException e) {
        ExceptionHandler.process(e);
    }
    for (String jarName : compiledModulesSet) {
        File jarFile = new File(libFolder, jarName);
        if (jarFile.exists()) {
            if (!isSpecialMR && !jarNames.isEmpty()) {
                // for storm not include the jar from libraries.apache.strom
                if (!jarNames.contains(jarName)) {
                    neededLibFiles.add(jarFile);
                }
            } else {
                neededLibFiles.add(jarFile);
            }
        }
    }
    return neededLibFiles;
}
Also used : Path(org.eclipse.core.runtime.Path) Bundle(org.osgi.framework.Bundle) ArrayList(java.util.ArrayList) IOException(java.io.IOException) URL(java.net.URL) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) ZipToFile(org.talend.repository.ui.utils.ZipToFile) File(java.io.File) ModuleNeeded(org.talend.core.model.general.ModuleNeeded) IProcess(org.talend.core.model.process.IProcess) HashSet(java.util.HashSet)

Example 29 with Bundle

use of org.osgi.framework.Bundle in project tdi-studio-se by Talend.

the class DemoImportTestUtil method getResourceManager.

public static ResourcesManager getResourceManager(DemoProjectBean checkedProjectBean) {
    ResourcesManager resManager = null;
    try {
        Bundle bundle = Platform.getBundle(checkedProjectBean.getPluginId());
        URL demoURL = FileLocator.find(bundle, new Path(checkedProjectBean.getDemoProjectFilePath()), null);
        demoURL = FileLocator.toFileURL(demoURL);
        String filePath = new Path(demoURL.getFile()).toOSString();
        File srcFile = new File(filePath);
        FileResourcesUnityManager fileUnityManager = ResourcesManagerFactory.getInstance().createFileUnityManager(srcFile);
        resManager = fileUnityManager.doUnify();
    } catch (ZipException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (TarException e) {
        e.printStackTrace();
    }
    return resManager;
}
Also used : Path(org.eclipse.core.runtime.Path) TarException(org.eclipse.ui.internal.wizards.datatransfer.TarException) Bundle(org.osgi.framework.Bundle) FileNotFoundException(java.io.FileNotFoundException) ResourcesManager(org.talend.repository.items.importexport.manager.ResourcesManager) FileResourcesUnityManager(org.talend.repository.items.importexport.ui.managers.FileResourcesUnityManager) ZipException(java.util.zip.ZipException) IOException(java.io.IOException) File(java.io.File) URL(java.net.URL)

Example 30 with Bundle

use of org.osgi.framework.Bundle in project tdi-studio-se by Talend.

the class AutoConvertTypesUtilsTest method init.

@Before
public void init() throws Exception {
    //$NON-NLS-1$
    Bundle b = Platform.getBundle("org.talend.repository.test");
    //$NON-NLS-1$
    URL url = FileLocator.toFileURL(FileLocator.find(b, new Path("AutoConversionTypesTest.xml"), null));
    Assert.assertNotNull(url);
    testFile = new File(url.getPath());
    Assert.assertTrue(testFile.exists());
    //
    AutoConversionType bean = new AutoConversionType();
    bean.setSourceDataType(JavaTypesManager.getDefaultJavaType().getId());
    bean.setTargetDataType(JavaTypesManager.INTEGER.getId());
    //$NON-NLS-1$
    bean.setConversionFunction("Integer.parseInt(${0})");
    testBeanList.add(bean);
}
Also used : Path(org.eclipse.core.runtime.Path) AutoConversionType(org.talend.core.model.metadata.types.AutoConversionType) Bundle(org.osgi.framework.Bundle) File(java.io.File) URL(java.net.URL) Before(org.junit.Before)

Aggregations

Bundle (org.osgi.framework.Bundle)2527 Test (org.junit.Test)674 URL (java.net.URL)389 BundleContext (org.osgi.framework.BundleContext)319 ArrayList (java.util.ArrayList)299 File (java.io.File)298 IOException (java.io.IOException)281 BundleException (org.osgi.framework.BundleException)273 HashMap (java.util.HashMap)155 ServiceReference (org.osgi.framework.ServiceReference)152 Hashtable (java.util.Hashtable)131 Path (org.eclipse.core.runtime.Path)126 HashSet (java.util.HashSet)98 InputStream (java.io.InputStream)94 List (java.util.List)87 IStatus (org.eclipse.core.runtime.IStatus)86 Status (org.eclipse.core.runtime.Status)82 Map (java.util.Map)74 BundleWiring (org.osgi.framework.wiring.BundleWiring)74 Version (org.osgi.framework.Version)73