use of java.io.FileFilter in project promoted-builds-plugin by jenkinsci.
the class JobPropertyImpl method loadAllProcesses.
private void loadAllProcesses(File rootDir) throws IOException {
File[] subdirs = rootDir.listFiles(new FileFilter() {
public boolean accept(File child) {
return child.isDirectory();
}
});
loadProcesses(subdirs);
}
use of java.io.FileFilter in project Openfire by igniterealtime.
the class ClusteringPlugin method initializePlugin.
public void initializePlugin(PluginManager manager, File pluginDirectory) {
// Check if we Enterprise is installed and stop loading this plugin if found
File pluginDir = new File(JiveGlobals.getHomeDirectory(), "plugins");
File[] jars = pluginDir.listFiles(new FileFilter() {
public boolean accept(File pathname) {
String fileName = pathname.getName().toLowerCase();
return (fileName.equalsIgnoreCase("enterprise.jar") || fileName.equalsIgnoreCase("hazelcast.jar"));
}
});
if (jars.length > 0) {
// Do not load this plugin since Enterprise is still installed
System.out.println("Conflicting plugin found. Stopping Clustering Plugin");
throw new IllegalStateException("This plugin cannot run with the Enterprise or Hazelcast plugin");
}
// Make sure that the enteprise folder exists under the home directory
File enterpriseDir = new File(JiveGlobals.getHomeDirectory() + File.separator + "enterprise");
if (!enterpriseDir.exists()) {
enterpriseDir.mkdirs();
}
// Check if Coherence libs are installed and stop loading this plugin if NOT found
// File libDir = new File(JiveGlobals.getHomeDirectory(), "lib");
// jars = libDir.listFiles(new FileFilter() {
// public boolean accept(File pathname) {
// String fileName = pathname.getName().toLowerCase();
// return (fileName.equalsIgnoreCase("coherence.jar"));
// }
// });
// if (jars.length == 0) {
// // Do not load this plugin since Coherence libs are not installed
// System.out.println("Coherence libs not found. Stopping Clustering Plugin. Copy tangosol.jar, " +
// "coherence.jar and coherence-work.jar files to [OPENFIRE_HOME]/lib and restart the server.");
// throw new IllegalStateException("Coherence libs not found. Stopping Clustering Plugin. Copy " +
// "tangosol.jar, coherence.jar and coherence-work.jar files to [OPENFIRE_HOME]/lib and restart the server.");
// }
// Delete no longer used COHERENCE_CONFIG file. Java system properties should be used
// to customize coherence
File configFile = new File(enterpriseDir, COHERENCE_CONFIG + ".xml");
if (configFile.exists()) {
configFile.delete();
}
// Delete no longer used COHERENCE_CACHE_CONFIG file. Admins should use system properties
// to override default values. Same system properties will be used when not using enterprise or not
// using clustering
configFile = new File(enterpriseDir, COHERENCE_CACHE_CONFIG + ".xml");
if (configFile.exists()) {
configFile.delete();
}
try {
// Add openfireHome/enterprise dir to pluginclassloader
// Add enterprise plugin dir to pluginclassloader
URL url = new File(pluginDirectory + File.separator).toURL();
manager.getPluginClassloader(manager.getPlugin(pluginDirectory.getName())).addURLFile(url);
} catch (MalformedURLException e) {
Log.error("Error adding openfireHome/enterprise to the classpath of the enterprise plugin", e);
}
CacheFactory.getClusterConfig();
ClusterManager.startup();
}
use of java.io.FileFilter in project Openfire by igniterealtime.
the class ClientControlPlugin method initializePlugin.
// Plugin Interface
public void initializePlugin(PluginManager manager, File pluginDirectory) {
// Check if we Enterprise is installed and stop loading this plugin if found
File pluginDir = new File(JiveGlobals.getHomeDirectory(), "plugins");
File[] jars = pluginDir.listFiles(new FileFilter() {
public boolean accept(File pathname) {
String fileName = pathname.getName().toLowerCase();
return (fileName.equalsIgnoreCase("enterprise.jar"));
}
});
if (jars.length > 0) {
// Do not load this plugin since Enterprise is still installed
System.out.println("Enterprise plugin found. Stopping Client Control Plugin");
throw new IllegalStateException("This plugin cannot run next to the Enterprise plugin");
}
taskEngine = TaskEngine.getInstance();
sparkManager = new SparkManager(taskEngine);
sparkManager.start();
// Create and start the Spark version manager
sparkVersionManager = new SparkVersionManager();
sparkVersionManager.start();
fileTransferFilterManager = new FileTransferFilterManager();
fileTransferFilterManager.start();
}
use of java.io.FileFilter in project hadoop by apache.
the class JournalNode method getJournalsStatus.
// JournalNodeMXBean
@Override
public String getJournalsStatus() {
// jid:{Formatted:True/False}
Map<String, Map<String, String>> status = new HashMap<String, Map<String, String>>();
synchronized (this) {
for (Map.Entry<String, Journal> entry : journalsById.entrySet()) {
Map<String, String> jMap = new HashMap<String, String>();
jMap.put("Formatted", Boolean.toString(entry.getValue().isFormatted()));
status.put(entry.getKey(), jMap);
}
}
// It is possible that some journals have been formatted before, while the
// corresponding journals are not in journalsById yet (because of restarting
// JN, e.g.). For simplicity, let's just assume a journal is formatted if
// there is a directory for it. We can also call analyzeStorage method for
// these directories if necessary.
// Also note that we do not need to check localDir here since
// validateAndCreateJournalDir has been called before we register the
// MXBean.
File[] journalDirs = localDir.listFiles(new FileFilter() {
@Override
public boolean accept(File file) {
return file.isDirectory();
}
});
for (File journalDir : journalDirs) {
String jid = journalDir.getName();
if (!status.containsKey(jid)) {
Map<String, String> jMap = new HashMap<String, String>();
jMap.put("Formatted", "true");
status.put(jid, jMap);
}
}
return JSON.toString(status);
}
use of java.io.FileFilter in project ansj_seg by NLPchina.
the class File2Stream method multiple.
private InputStream multiple(String path) throws FileNotFoundException {
File[] libs = new File[0];
File file = new File(path);
if (file.exists() && file.canRead()) {
if (file.isFile()) {
libs = new File[1];
libs[0] = file;
} else if (file.isDirectory()) {
File[] files = file.listFiles(new FileFilter() {
public boolean accept(File file) {
return file.canRead() && !file.isHidden() && !file.isDirectory();
}
});
if (files != null && files.length > 0) {
libs = files;
}
}
}
if (libs.length == 0) {
throw new LibraryException("not find any file in path : " + path);
}
if (libs.length == 1) {
return new FileInputStream(libs[0]);
}
Vector<InputStream> vector = new Vector<>(libs.length);
for (int i = 0; i < libs.length; i++) {
vector.add(new FileInputStream(libs[i]));
}
return new SequenceInputStream(vector.elements());
}
Aggregations