Commit f046600d authored by Alex Wenckus's avatar Alex Wenckus Committed by alex

Making JiveProperties mockable

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@8590 b35dd754-fafc-0310-a699-88a17e54d16e
parent 83882b86
...@@ -32,7 +32,12 @@ public class JiveProperties implements Map<String, String> { ...@@ -32,7 +32,12 @@ public class JiveProperties implements Map<String, String> {
private static final String UPDATE_PROPERTY = "UPDATE jiveProperty SET propValue=? WHERE name=?"; private static final String UPDATE_PROPERTY = "UPDATE jiveProperty SET propValue=? WHERE name=?";
private static final String DELETE_PROPERTY = "DELETE FROM jiveProperty WHERE name LIKE ?"; private static final String DELETE_PROPERTY = "DELETE FROM jiveProperty WHERE name LIKE ?";
private static JiveProperties instance; private static class JivePropertyHolder {
private static final JiveProperties instance = new JiveProperties();
static {
instance.init();
}
}
private Map<String, String> properties; private Map<String, String> properties;
...@@ -41,15 +46,11 @@ public class JiveProperties implements Map<String, String> { ...@@ -41,15 +46,11 @@ public class JiveProperties implements Map<String, String> {
* *
* @return an instance of JiveProperties. * @return an instance of JiveProperties.
*/ */
public static synchronized JiveProperties getInstance() { public static JiveProperties getInstance() {
if (instance == null) { return JivePropertyHolder.instance;
instance = new JiveProperties();
}
return instance;
} }
private JiveProperties() { private JiveProperties() {
init();
} }
/** /**
......
...@@ -14,8 +14,8 @@ package org.jivesoftware.openfire.plugin; ...@@ -14,8 +14,8 @@ package org.jivesoftware.openfire.plugin;
import org.dom4j.Element; import org.dom4j.Element;
import org.jivesoftware.openfire.SessionManager; import org.jivesoftware.openfire.SessionManager;
import org.jivesoftware.openfire.XMPPServer; import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.container.Plugin;
import org.jivesoftware.openfire.container.PluginManager; import org.jivesoftware.openfire.container.PluginManager;
import org.jivesoftware.openfire.container.AbstractPlugin;
import org.jivesoftware.openfire.group.Group; import org.jivesoftware.openfire.group.Group;
import org.jivesoftware.openfire.group.GroupManager; import org.jivesoftware.openfire.group.GroupManager;
import org.jivesoftware.openfire.group.GroupNotFoundException; import org.jivesoftware.openfire.group.GroupNotFoundException;
...@@ -25,7 +25,6 @@ import org.jivesoftware.util.PropertyEventListener; ...@@ -25,7 +25,6 @@ import org.jivesoftware.util.PropertyEventListener;
import org.xmpp.component.Component; import org.xmpp.component.Component;
import org.xmpp.component.ComponentException; import org.xmpp.component.ComponentException;
import org.xmpp.component.ComponentManager; import org.xmpp.component.ComponentManager;
import org.xmpp.component.ComponentManagerFactory;
import org.xmpp.packet.*; import org.xmpp.packet.*;
import java.io.File; import java.io.File;
...@@ -40,7 +39,7 @@ import java.util.*; ...@@ -40,7 +39,7 @@ import java.util.*;
* *
* @author Matt Tucker * @author Matt Tucker
*/ */
public class BroadcastPlugin implements Plugin, Component, PropertyEventListener { public class BroadcastPlugin extends AbstractPlugin implements Component, PropertyEventListener {
private String serviceName; private String serviceName;
private SessionManager sessionManager; private SessionManager sessionManager;
...@@ -48,7 +47,6 @@ public class BroadcastPlugin implements Plugin, Component, PropertyEventListener ...@@ -48,7 +47,6 @@ public class BroadcastPlugin implements Plugin, Component, PropertyEventListener
private List<JID> allowedUsers; private List<JID> allowedUsers;
private boolean groupMembersAllowed; private boolean groupMembersAllowed;
private boolean disableGroupPermissions; private boolean disableGroupPermissions;
private ComponentManager componentManager;
private PluginManager pluginManager; private PluginManager pluginManager;
/** /**
...@@ -71,7 +69,6 @@ public class BroadcastPlugin implements Plugin, Component, PropertyEventListener ...@@ -71,7 +69,6 @@ public class BroadcastPlugin implements Plugin, Component, PropertyEventListener
groupManager = GroupManager.getInstance(); groupManager = GroupManager.getInstance();
// Register as a component. // Register as a component.
componentManager = ComponentManagerFactory.getComponentManager();
try { try {
componentManager.addComponent(serviceName, this); componentManager.addComponent(serviceName, this);
} }
...@@ -81,6 +78,9 @@ public class BroadcastPlugin implements Plugin, Component, PropertyEventListener ...@@ -81,6 +78,9 @@ public class BroadcastPlugin implements Plugin, Component, PropertyEventListener
PropertyEventDispatcher.addListener(this); PropertyEventDispatcher.addListener(this);
} }
public void initializePlugin() {
}
public void destroyPlugin() { public void destroyPlugin() {
PropertyEventDispatcher.removeListener(this); PropertyEventDispatcher.removeListener(this);
// Unregister component. // Unregister component.
...@@ -90,7 +90,6 @@ public class BroadcastPlugin implements Plugin, Component, PropertyEventListener ...@@ -90,7 +90,6 @@ public class BroadcastPlugin implements Plugin, Component, PropertyEventListener
catch (Exception e) { catch (Exception e) {
componentManager.getLog().error(e); componentManager.getLog().error(e);
} }
componentManager = null;
pluginManager = null; pluginManager = null;
sessionManager = null; sessionManager = null;
groupManager = null; groupManager = null;
......
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