Commit d7b5cba3 authored by Matt Tucker's avatar Matt Tucker Committed by matt

Code cleanup.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3815 b35dd754-fafc-0310-a699-88a17e54d16e
parent 8d801e92
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
<sourceFolder url="file://$MODULE_DIR$/src/plugins/registration/src/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/plugins/registration/src/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/plugins/search/src/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/plugins/search/src/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/plugins/userImportExport/src/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/plugins/userImportExport/src/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/plugins/userservice/src/java" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/src/plugins/enterprise" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
......
...@@ -935,7 +935,6 @@ ...@@ -935,7 +935,6 @@
<target name="plugin" description="build one plugin"> <target name="plugin" description="build one plugin">
<delete dir="${plugin.dev.dest.dir}/${plugin}"/> <delete dir="${plugin.dev.dest.dir}/${plugin}"/>
<delete file="${plugin.dev.dest.dir}/${plugin}.jar"/> <delete file="${plugin.dev.dest.dir}/${plugin}.jar"/>
<delete dir="${plugin.dest.dir}/${plugin}"/>
<delete file="${plugin.dest.dir}/${plugin}.jar"/> <delete file="${plugin.dest.dir}/${plugin}.jar"/>
<buildplugin plugin="${plugin}" pluginsrc="${plugin.src.dir}"/> <buildplugin plugin="${plugin}" pluginsrc="${plugin.src.dir}"/>
</target> </target>
......
...@@ -43,7 +43,7 @@ import org.jivesoftware.wildfire.XMPPServer; ...@@ -43,7 +43,7 @@ import org.jivesoftware.wildfire.XMPPServer;
public interface Module { public interface Module {
/** /**
* <p>Obtain the name of the module for display in administration interfaces.</p> * Returns the name of the module for display in administration interfaces.
* *
* @return The name of the module. * @return The name of the module.
*/ */
......
...@@ -78,7 +78,14 @@ public class PluginManager { ...@@ -78,7 +78,14 @@ public class PluginManager {
*/ */
public void start() { public void start() {
executor = new ScheduledThreadPoolExecutor(1); executor = new ScheduledThreadPoolExecutor(1);
executor.scheduleWithFixedDelay(new PluginMonitor(), 0, 15, TimeUnit.SECONDS); // See if we're in development mode. If so, check for new plugins once every 5 seconds.
// Otherwise, default to every 30 seconds.
if (Boolean.getBoolean("developmentMode")) {
executor.scheduleWithFixedDelay(new PluginMonitor(), 0, 5, TimeUnit.SECONDS);
}
else {
executor.scheduleWithFixedDelay(new PluginMonitor(), 0, 30, TimeUnit.SECONDS);
}
} }
/** /**
...@@ -150,7 +157,7 @@ public class PluginManager { ...@@ -150,7 +157,7 @@ public class PluginManager {
return; return;
} }
Log.debug("Loading plugin " + pluginDir.getName()); Log.debug("Loading plugin " + pluginDir.getName());
Plugin plugin = null; Plugin plugin;
try { try {
File pluginConfig = new File(pluginDir, "plugin.xml"); File pluginConfig = new File(pluginDir, "plugin.xml");
if (pluginConfig.exists()) { if (pluginConfig.exists()) {
...@@ -339,8 +346,8 @@ public class PluginManager { ...@@ -339,8 +346,8 @@ public class PluginManager {
// Modify all the URL's in the XML so that they are passed through // Modify all the URL's in the XML so that they are passed through
// the plugin servlet correctly. // the plugin servlet correctly.
List urls = adminElement.selectNodes("//@url"); List urls = adminElement.selectNodes("//@url");
for (int i = 0; i < urls.size(); i++) { for (Object url : urls) {
Attribute attr = (Attribute)urls.get(i); Attribute attr = (Attribute) url;
attr.setValue("plugins/" + pluginName + "/" + attr.getValue()); attr.setValue("plugins/" + pluginName + "/" + attr.getValue());
} }
AdminConsole.addModel(pluginName, adminElement); AdminConsole.addModel(pluginName, adminElement);
...@@ -566,8 +573,7 @@ public class PluginManager { ...@@ -566,8 +573,7 @@ public class PluginManager {
return; return;
} }
for (int i = 0; i < jars.length; i++) { for (File jarFile : jars) {
File jarFile = jars[i];
String pluginName = jarFile.getName().substring(0, String pluginName = jarFile.getName().substring(0,
jarFile.getName().length() - 4).toLowerCase(); jarFile.getName().length() - 4).toLowerCase();
// See if the JAR has already been exploded. // See if the JAR has already been exploded.
...@@ -651,8 +657,7 @@ public class PluginManager { ...@@ -651,8 +657,7 @@ public class PluginManager {
} }
// Load all plugins that need to be loaded. // Load all plugins that need to be loaded.
for (int i = 0; i < dirs.length; i++) { for (File dirFile : dirs) {
File dirFile = dirs[i];
// If the plugin hasn't already been started, start it. // If the plugin hasn't already been started, start it.
if (dirFile.exists() && !plugins.containsKey(dirFile.getName())) { if (dirFile.exists() && !plugins.containsKey(dirFile.getName())) {
loadPlugin(dirFile); loadPlugin(dirFile);
...@@ -693,7 +698,7 @@ public class PluginManager { ...@@ -693,7 +698,7 @@ public class PluginManager {
FileOutputStream out = new FileOutputStream(entryFile); FileOutputStream out = new FileOutputStream(entryFile);
InputStream zin = zipFile.getInputStream(entry); InputStream zin = zipFile.getInputStream(entry);
byte[] b = new byte[512]; byte[] b = new byte[512];
int len = 0; int len;
while ((len = zin.read(b)) != -1) { while ((len = zin.read(b)) != -1) {
out.write(b, 0, len); out.write(b, 0, len);
} }
...@@ -703,7 +708,6 @@ public class PluginManager { ...@@ -703,7 +708,6 @@ public class PluginManager {
} }
} }
zipFile.close(); zipFile.close();
zipFile = null;
} }
catch (Exception e) { catch (Exception e) {
Log.error(e); Log.error(e);
...@@ -716,8 +720,8 @@ public class PluginManager { ...@@ -716,8 +720,8 @@ public class PluginManager {
public boolean deleteDir(File dir) { public boolean deleteDir(File dir) {
if (dir.isDirectory()) { if (dir.isDirectory()) {
String[] children = dir.list(); String[] children = dir.list();
for (int i = 0; i < children.length; i++) { for (String file : children) {
boolean success = deleteDir(new File(dir, children[i])); boolean success = deleteDir(new File(dir, file));
if (!success) { if (!success) {
return false; return false;
} }
......
...@@ -37,15 +37,19 @@ public interface PacketInterceptor { ...@@ -37,15 +37,19 @@ public interface PacketInterceptor {
* the packet, or throw a PacketRejectedException to block it from being sent or processed * the packet, or throw a PacketRejectedException to block it from being sent or processed
* (when read).<p> * (when read).<p>
* *
* The exception can only be thrown when <tt>processed</tt> is false which means that the read * An exception can only be thrown when <tt>processed</tt> is false which means that the read
* packet has not been processed yet or the packet was not sent yet. If the exception is thrown * packet has not been processed yet or the packet was not sent yet. If the exception is thrown
* with a "read" packet then the sender of the packet will receive an answer with an error. But * with a "read" packet then the sender of the packet will receive an answer with an error. But
* if the exception is thrown with a "sent" packet then nothing will happen. * if the exception is thrown with a "sent" packet then nothing will happen.<p>
* *
* @param packet the packet to take action on. * Note that for each packet, every interceptor will be called twice: once before processing
* @param session the session that received or is sending the packet. * is complete (<tt>processing==true</tt>) and once after processing is complete. Typically,
* @param incoming flag that indicates if the packet was read by the server or sent from * an interceptor will want to ignore one or the other case.
* the server. *
* @param packet the packet to take action on.
* @param session the session that received or is sending the packet.
* @param incoming flag that indicates if the packet was read by the server or sent from
* the server.
* @param processed flag that indicates if the action (read/send) was performed. (PRE vs. POST). * @param processed flag that indicates if the action (read/send) was performed. (PRE vs. POST).
* @throws PacketRejectedException if the packet should be prevented from being processed. * @throws PacketRejectedException if the packet should be prevented from being processed.
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment