mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-12-01 12:27:58 +00:00
Updating plugin framework.
git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@4722 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
@ -22,8 +22,6 @@ import org.jivesoftware.spark.plugin.PublicPlugin;
|
||||
import org.jivesoftware.spark.util.URLFileSystem;
|
||||
import org.jivesoftware.spark.util.log.Log;
|
||||
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FilenameFilter;
|
||||
@ -43,6 +41,8 @@ import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
/**
|
||||
* This manager is responsible for the loading of all Plugins and Workspaces within Spark environment.
|
||||
*
|
||||
@ -83,6 +83,18 @@ public class PluginManager implements MainWindowListener {
|
||||
}
|
||||
|
||||
private PluginManager() {
|
||||
try {
|
||||
PLUGINS_DIRECTORY = new File(Spark.getBinDirectory().getParentFile(), "plugins").getCanonicalFile();
|
||||
}
|
||||
catch (IOException e) {
|
||||
Log.error(e);
|
||||
}
|
||||
|
||||
// Copy Files over if not on Windows. This is a workaround for installation issues.
|
||||
if (!Spark.isWindows()) {
|
||||
copyFiles();
|
||||
}
|
||||
|
||||
SparkManager.getMainWindow().addMainWindowListener(this);
|
||||
|
||||
// Create the extension directory if one does not exist.
|
||||
@ -91,6 +103,30 @@ public class PluginManager implements MainWindowListener {
|
||||
}
|
||||
}
|
||||
|
||||
private void copyFiles() {
|
||||
// Current Plugin directory
|
||||
File newPlugins = new File(Spark.getLogDirectory().getParentFile(), "plugins").getAbsoluteFile();
|
||||
newPlugins.mkdirs();
|
||||
|
||||
File[] files = PLUGINS_DIRECTORY.listFiles();
|
||||
final int no = files != null ? files.length : 0;
|
||||
for (int i = 0; i < no; i++) {
|
||||
File file = files[i];
|
||||
if (file.isFile()) {
|
||||
// Copy over
|
||||
File newFile = new File(newPlugins, file.getName());
|
||||
try {
|
||||
URLFileSystem.copy(file.toURL(), newFile);
|
||||
}
|
||||
catch (IOException e) {
|
||||
Log.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PLUGINS_DIRECTORY = newPlugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all {@link Plugin} from the agent plugins.xml and extension lib.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user