List of usage examples for org.apache.commons.vfs FileObject equals
public boolean equals(Object obj)
From source file:org.pentaho.di.core.plugins.BasePluginType.java
protected void registerPluginJars() throws KettlePluginException { List<JarFileAnnotationPlugin> jarFilePlugins = findAnnotatedClassFiles(pluginType.getName()); for (JarFileAnnotationPlugin jarFilePlugin : jarFilePlugins) { URLClassLoader urlClassLoader = createUrlClassLoader(jarFilePlugin.getJarFile(), getClass().getClassLoader()); try {/* w ww . ja v a 2s. c om*/ Class<?> clazz = urlClassLoader.loadClass(jarFilePlugin.getClassName()); if (clazz == null) { throw new KettlePluginException("Unable to load class: " + jarFilePlugin.getClassName()); } List<String> libraries = new ArrayList<String>(); java.lang.annotation.Annotation annotation = null; try { annotation = clazz.getAnnotation(pluginType); String jarFilename = URLDecoder.decode(jarFilePlugin.getJarFile().getFile(), "UTF-8"); libraries.add(jarFilename); FileObject fileObject = KettleVFS.getFileObject(jarFilename); FileObject parentFolder = fileObject.getParent(); String parentFolderName = KettleVFS.getFilename(parentFolder); String libFolderName = null; if (parentFolderName.endsWith(Const.FILE_SEPARATOR + "lib")) { libFolderName = parentFolderName; } else { libFolderName = parentFolderName + Const.FILE_SEPARATOR + "lib"; } PluginFolder folder = new PluginFolder(libFolderName, false, false, searchLibDir); FileObject[] jarFiles = folder.findJarFiles(true); if (jarFiles != null) { for (FileObject jarFile : jarFiles) { String fileName = KettleVFS.getFilename(jarFile); // If the plugin is in the lib folder itself, we'll ignore it here if (fileObject.equals(jarFile)) { continue; } libraries.add(fileName); } } } catch (Exception e) { throw new KettlePluginException( "Unexpected error loading class " + clazz.getName() + " of plugin type: " + pluginType, e); } handlePluginAnnotation(clazz, annotation, libraries, false, jarFilePlugin.getPluginFolder()); } catch (Exception e) { // Ignore for now, don't know if it's even possible. LogChannel.GENERAL .logError("Unexpected error registering jar plugin file: " + jarFilePlugin.getJarFile(), e); } finally { if (urlClassLoader != null && urlClassLoader instanceof KettleURLClassLoader) { ((KettleURLClassLoader) urlClassLoader).closeClassLoader(); } } } }
From source file:org.pentaho.di.ui.spoon.delegates.SpoonTabsDelegate.java
/** * Finds the tab for the transformation that matches the metadata provided (either the file must be the same or the * repository id).// www . j av a 2s. c om * * @param trans * Transformation metadata to look for * @return Tab with transformation open whose metadata matches {@code trans} or {@code null} if no tab exists. * @throws KettleFileException * If there is a problem loading the file object for an open transformation with an invalid a filename. */ public TabMapEntry findTabForTransformation(TransMeta trans) throws KettleFileException { // File for the transformation we're looking for. It will be loaded upon first request. FileObject transFile = null; for (TabMapEntry entry : tabMap) { if (entry == null || entry.getTabItem().isDisposed()) { continue; } if (trans.getFilename() != null && entry.getFilename() != null) { // If the entry has a file name it is the same as trans iff. they originated from the same files FileObject entryFile = KettleVFS.getFileObject(entry.getFilename()); if (transFile == null) { transFile = KettleVFS.getFileObject(trans.getFilename()); } if (entryFile.equals(transFile)) { return entry; } } else if (trans.getObjectId() != null && entry.getObject() != null) { EngineMetaInterface meta = entry.getObject().getMeta(); if (meta != null && trans.getObjectId().equals(meta.getObjectId())) { // If the transformation has an object id and the entry shares the same id they are the same return entry; } } } // No tabs for the transformation exist and are not disposed return null; }