Commit d0a20d7d authored by guus's avatar guus

OF-534: Transformed STUN implementation from a Module to a Plugin.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13015 b35dd754-fafc-0310-a699-88a17e54d16e
parent 75343df8
......@@ -557,7 +557,6 @@ public class XMPPServer {
loadModule(DefaultFileTransferManager.class.getName());
loadModule(FileTransferProxy.class.getName());
loadModule(MediaProxyService.class.getName());
loadModule(STUNService.class.getName());
loadModule(PubSubModule.class.getName());
loadModule(IQDiscoInfoHandler.class.getName());
loadModule(IQDiscoItemsHandler.class.getName());
......
......@@ -16,6 +16,7 @@
package org.jivesoftware.openfire.stun;
import java.io.File;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
......@@ -29,7 +30,8 @@ import org.dom4j.Element;
import org.jivesoftware.openfire.IQHandlerInfo;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.auth.UnauthorizedException;
import org.jivesoftware.openfire.container.BasicModule;
import org.jivesoftware.openfire.container.Plugin;
import org.jivesoftware.openfire.container.PluginManager;
import org.jivesoftware.openfire.handler.IQHandler;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.PropertyEventDispatcher;
......@@ -48,7 +50,7 @@ import de.javawi.jstun.test.demo.StunServer;
*
* @author Thiago Camargo
*/
public class STUNService extends BasicModule {
public class STUNService implements Plugin {
private static final Logger Log = LoggerFactory.getLogger(STUNService.class);
......@@ -72,23 +74,7 @@ public class STUNService extends BasicModule {
private List<StunServerAddress> externalServers = null;
/**
* Constructs a new STUN Service
*/
public STUNService() {
super("STUN Service");
}
@Override
public void destroy() {
super.destroy();
stunServer = null;
}
@Override
public void initialize(XMPPServer server) {
super.initialize(server);
public void initializePlugin(PluginManager manager, File pluginDirectory) {
this.enabled = JiveGlobals.getBooleanProperty("stun.enabled", true);
primaryAddress = JiveGlobals.getProperty("stun.address.primary");
......@@ -114,6 +100,8 @@ public class STUNService extends BasicModule {
}
}
start();
// Add listeners for STUN service being enabled and disabled via manual property changes.
PropertyEventDispatcher.addListener(new PropertyEventListener() {
......@@ -150,7 +138,10 @@ public class STUNService extends BasicModule {
});
}
@Override
public void destroyPlugin() {
stop();
}
public void start() {
if (isEnabled()) {
startSTUNService();
......@@ -200,9 +191,7 @@ public class STUNService extends BasicModule {
}
}
@Override
public void stop() {
super.stop();
this.enabled = false;
stopSTUNService();
stopLocal();
......@@ -215,11 +204,6 @@ public class STUNService extends BasicModule {
stunServer = null;
}
@Override
public String getName() {
return "stun";
}
public List<StunServerAddress> getExternalServers() {
return externalServers;
}
......
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