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> {
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 JiveProperties instance;
private static class JivePropertyHolder {
private static final JiveProperties instance = new JiveProperties();
static {
instance.init();
}
}
private Map<String, String> properties;
......@@ -41,15 +46,11 @@ public class JiveProperties implements Map<String, String> {
*
* @return an instance of JiveProperties.
*/
public static synchronized JiveProperties getInstance() {
if (instance == null) {
instance = new JiveProperties();
}
return instance;
public static JiveProperties getInstance() {
return JivePropertyHolder.instance;
}
private JiveProperties() {
init();
}
/**
......
......@@ -14,8 +14,8 @@ package org.jivesoftware.openfire.plugin;
import org.dom4j.Element;
import org.jivesoftware.openfire.SessionManager;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.container.Plugin;
import org.jivesoftware.openfire.container.PluginManager;
import org.jivesoftware.openfire.container.AbstractPlugin;
import org.jivesoftware.openfire.group.Group;
import org.jivesoftware.openfire.group.GroupManager;
import org.jivesoftware.openfire.group.GroupNotFoundException;
......@@ -25,7 +25,6 @@ import org.jivesoftware.util.PropertyEventListener;
import org.xmpp.component.Component;
import org.xmpp.component.ComponentException;
import org.xmpp.component.ComponentManager;
import org.xmpp.component.ComponentManagerFactory;
import org.xmpp.packet.*;
import java.io.File;
......@@ -40,7 +39,7 @@ import java.util.*;
*
* @author Matt Tucker
*/
public class BroadcastPlugin implements Plugin, Component, PropertyEventListener {
public class BroadcastPlugin extends AbstractPlugin implements Component, PropertyEventListener {
private String serviceName;
private SessionManager sessionManager;
......@@ -48,7 +47,6 @@ public class BroadcastPlugin implements Plugin, Component, PropertyEventListener
private List<JID> allowedUsers;
private boolean groupMembersAllowed;
private boolean disableGroupPermissions;
private ComponentManager componentManager;
private PluginManager pluginManager;
/**
......@@ -71,7 +69,6 @@ public class BroadcastPlugin implements Plugin, Component, PropertyEventListener
groupManager = GroupManager.getInstance();
// Register as a component.
componentManager = ComponentManagerFactory.getComponentManager();
try {
componentManager.addComponent(serviceName, this);
}
......@@ -81,6 +78,9 @@ public class BroadcastPlugin implements Plugin, Component, PropertyEventListener
PropertyEventDispatcher.addListener(this);
}
public void initializePlugin() {
}
public void destroyPlugin() {
PropertyEventDispatcher.removeListener(this);
// Unregister component.
......@@ -90,7 +90,6 @@ public class BroadcastPlugin implements Plugin, Component, PropertyEventListener
catch (Exception e) {
componentManager.getLog().error(e);
}
componentManager = null;
pluginManager = null;
sessionManager = 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