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

Added JID creation

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@8625 b35dd754-fafc-0310-a699-88a17e54d16e
parent 75d1e7b0
......@@ -9,6 +9,7 @@ package org.jivesoftware.openfire.container;
import com.google.inject.*;
import org.jivesoftware.openfire.*;
import org.jivesoftware.openfire.container.plugin.ServerName;
import org.jivesoftware.openfire.group.GroupManager;
import org.jivesoftware.openfire.session.RemoteSessionLocator;
import org.jivesoftware.openfire.vcard.VCardManager;
......@@ -43,7 +44,12 @@ public class PluginModule extends AbstractModule {
bind(JiveProperties.class).toInstance(JiveProperties.getInstance());
bind(Logger.class).toInstance(getLogger());
XMPPServer server = XMPPServer.getInstance();
final XMPPServer server = XMPPServer.getInstance();
bind(String.class).annotatedWith(ServerName.class).toProvider(new Provider<String>() {
public String get() {
return server.getServerInfo().getName();
}
});
bind(XMPPServer.class).toInstance(server);
bind(ConnectionManager.class).toInstance(server.getConnectionManager());
bind(RoutingTable.class).toInstance(server.getRoutingTable());
......
......@@ -12,7 +12,6 @@ import com.google.inject.Inject;
import java.io.File;
import java.util.concurrent.FutureTask;
import java.util.concurrent.Callable;
import java.util.Set;
import java.util.List;
import java.util.ArrayList;
......@@ -23,6 +22,7 @@ import org.jivesoftware.util.PropertyEventDispatcher;
import org.xmpp.component.ComponentManager;
import org.xmpp.component.Component;
import org.xmpp.component.ComponentException;
import org.xmpp.packet.JID;
import org.jivesoftware.openfire.component.ComponentLifecycle;
import org.jivesoftware.openfire.container.Plugin;
import org.jivesoftware.openfire.container.PluginManager;
......@@ -36,6 +36,7 @@ public abstract class AbstractPlugin implements Plugin {
protected ComponentManager componentManager;
protected Logger log;
protected String serverName;
@Inject
public void setComponentManager(ComponentManager componentManager) {
......@@ -47,6 +48,15 @@ public abstract class AbstractPlugin implements Plugin {
this.log = log;
}
@Inject
public void setServerName(@ServerName String serverName) {
this.serverName = serverName;
}
protected JID createJid(String username) {
return new JID(username, serverName, null);
}
protected ComponentLifecycle addComponent(String domain, Component component)
throws ComponentException
{
......
/**
* $Revision:$
* $Date:$
*
* Copyright (C) 2007 Jive Software. All rights reserved.
* This software is the proprietary information of Jive Software. Use is subject to license terms.
*/
package org.jivesoftware.openfire.container.plugin;
import com.google.inject.BindingAnnotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
/**
* The name, or domain, of the server.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.PARAMETER})
@BindingAnnotation
public @interface ServerName {
}
......@@ -13,7 +13,6 @@ 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.AbstractPlugin;
import org.jivesoftware.openfire.container.plugin.PluginName;
import org.jivesoftware.openfire.container.plugin.PluginDescription;
......@@ -43,12 +42,12 @@ import com.google.inject.Inject;
*/
public class BroadcastPlugin extends AbstractPlugin implements Component, PropertyEventListener {
private SessionManager sessionManager;
private GroupManager groupManager;
private final String pluginName;
private final String pluginDescription;
private final JiveProperties jiveProperties;
private final SessionManager sessionManager;
private final GroupManager groupManager;
private String serviceName;
/**
......@@ -58,25 +57,21 @@ public class BroadcastPlugin extends AbstractPlugin implements Component, Proper
* @param pluginDescription the description configured for this plugin.
* @param jiveProperties system properties which stores the configuration paramters for the
* broadcast plugin.
* @param sessionManager the session manager.
* @param groupManager the group manager.
*/
@Inject
public BroadcastPlugin(@PluginName String pluginName,
@PluginDescription String pluginDescription,
JiveProperties jiveProperties)
JiveProperties jiveProperties,
SessionManager sessionManager,
GroupManager groupManager)
{
this.pluginName = pluginName;
this.pluginDescription = pluginDescription;
this.jiveProperties = jiveProperties;
this.serviceName = jiveProperties.getProperty("plugin.broadcast.serviceName", "broadcast");
}
@Inject
public void setSessionManager(SessionManager sessionManager) {
this.sessionManager = sessionManager;
}
@Inject
public void setGroupManager(GroupManager groupManager) {
this.groupManager = groupManager;
}
......@@ -540,7 +535,7 @@ public class BroadcastPlugin extends AbstractPlugin implements Component, Proper
values.add(new JID(value));
}
else {
values.add(XMPPServer.getInstance().createJID(value, null));
values.add(createJid(value));
}
}
}
......
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