Commit 167b23dd authored by Guus der Kinderen's avatar Guus der Kinderen Committed by daryl herzmann

Minor improvements: more logging and removal of dead code. (#651)

* OF-1147: More debug logging.

* Removed unreachable code.
parent 7bbf9ef7
...@@ -560,19 +560,15 @@ public class XMPPServer { ...@@ -560,19 +560,15 @@ public class XMPPServer {
private void initModules() { private void initModules() {
for (Module module : modules.values()) { for (Module module : modules.values()) {
boolean isInitialized = false;
try { try {
module.initialize(this); module.initialize(this);
isInitialized = true;
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
// Remove the failed initialized module // Remove the failed initialized module
this.modules.remove(module.getClass()); this.modules.remove(module.getClass());
if (isInitialized) {
module.stop(); module.stop();
module.destroy(); module.destroy();
}
logger.error(LocaleUtils.getLocalizedString("admin.error"), e); logger.error(LocaleUtils.getLocalizedString("admin.error"), e);
} }
} }
...@@ -585,16 +581,12 @@ public class XMPPServer { ...@@ -585,16 +581,12 @@ public class XMPPServer {
*/ */
private void startModules() { private void startModules() {
for (Module module : modules.values()) { for (Module module : modules.values()) {
boolean started = false;
try { try {
logger.debug( "Starting module: " + module.getName() );
module.start(); module.start();
} }
catch (Exception e) { catch (Exception e) {
if (started && module != null) { logger.error( "An exception occurred while starting module '{}'.", module.getName(), e );
module.stop();
module.destroy();
}
logger.error(LocaleUtils.getLocalizedString("admin.error"), e);
} }
} }
} }
......
...@@ -20,24 +20,19 @@ ...@@ -20,24 +20,19 @@
package org.jivesoftware.openfire.spi; package org.jivesoftware.openfire.spi;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.security.KeyStore;
import java.security.cert.X509Certificate;
import java.util.*;
import org.apache.mina.core.buffer.IoBuffer; import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.buffer.SimpleBufferAllocator; import org.apache.mina.core.buffer.SimpleBufferAllocator;
import org.apache.mina.transport.socket.nio.NioSocketAcceptor; import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
import org.jivesoftware.openfire.*; import org.jivesoftware.openfire.Connection;
import org.jivesoftware.openfire.ConnectionManager;
import org.jivesoftware.openfire.ServerPort;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.container.BasicModule; import org.jivesoftware.openfire.container.BasicModule;
import org.jivesoftware.openfire.container.PluginManager; import org.jivesoftware.openfire.container.PluginManager;
import org.jivesoftware.openfire.container.PluginManagerListener; import org.jivesoftware.openfire.container.PluginManagerListener;
import org.jivesoftware.openfire.http.HttpBindManager; import org.jivesoftware.openfire.http.HttpBindManager;
import org.jivesoftware.openfire.keystore.CertificateStoreManager; import org.jivesoftware.openfire.keystore.CertificateStoreManager;
import org.jivesoftware.openfire.net.*; import org.jivesoftware.openfire.net.SocketSendingTracker;
import org.jivesoftware.openfire.session.ConnectionSettings; import org.jivesoftware.openfire.session.ConnectionSettings;
import org.jivesoftware.util.CertificateEventListener; import org.jivesoftware.util.CertificateEventListener;
import org.jivesoftware.util.CertificateManager; import org.jivesoftware.util.CertificateManager;
...@@ -46,6 +41,13 @@ import org.jivesoftware.util.PropertyEventListener; ...@@ -46,6 +41,13 @@ import org.jivesoftware.util.PropertyEventListener;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.security.KeyStore;
import java.security.cert.X509Certificate;
import java.util.*;
public class ConnectionManagerImpl extends BasicModule implements ConnectionManager, CertificateEventListener, PropertyEventListener public class ConnectionManagerImpl extends BasicModule implements ConnectionManager, CertificateEventListener, PropertyEventListener
{ {
public static final String EXECUTOR_FILTER_NAME = "threadModel"; public static final String EXECUTOR_FILTER_NAME = "threadModel";
...@@ -274,24 +276,32 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana ...@@ -274,24 +276,32 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
private synchronized void startListeners() private synchronized void startListeners()
{ {
// Check if plugins have been loaded // Check if plugins have been loaded
Log.debug( "Received a request to start listeners. Have plugins been loaded?" );
PluginManager pluginManager = XMPPServer.getInstance().getPluginManager(); PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
if (!pluginManager.isExecuted()) { if ( !pluginManager.isExecuted() )
pluginManager.addPluginManagerListener(new PluginManagerListener() { {
public void pluginsMonitored() { Log.debug( "Plugins not yet loaded. Waiting for plugins to be loaded..." );
pluginManager.addPluginManagerListener( new PluginManagerListener()
{
public void pluginsMonitored()
{
Log.debug( "Received plugin monitor event! Plugins should now be loaded." );
// Stop listening for plugin events // Stop listening for plugin events
XMPPServer.getInstance().getPluginManager().removePluginManagerListener(this); XMPPServer.getInstance().getPluginManager().removePluginManagerListener( this );
// Start listeners // Start listeners
startListeners(); startListeners();
} }
}); } );
return; return;
} }
Log.debug( "Starting listeners..." );
for ( final ConnectionListener listener : getListeners() ) for ( final ConnectionListener listener : getListeners() )
{ {
try try
{ {
listener.start(); listener.start();
Log.debug( "Started '{}' (port {}) listener.", listener.getType(), listener.getPort() );
} }
catch ( RuntimeException ex ) catch ( RuntimeException ex )
{ {
...@@ -303,6 +313,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana ...@@ -303,6 +313,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
try try
{ {
HttpBindManager.getInstance().start(); HttpBindManager.getInstance().start();
Log.debug( "Started HTTP client listener." );
} }
catch ( RuntimeException ex ) catch ( RuntimeException ex )
{ {
......
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