XMPPServerInfoImpl.java 2.85 KB
Newer Older
1 2 3 4 5
/**
 * $RCSfile$
 * $Revision: 1583 $
 * $Date: 2005-07-03 17:55:39 -0300 (Sun, 03 Jul 2005) $
 *
6
 * Copyright (C) 2004-2008 Jive Software. All rights reserved.
7 8
 *
 * This software is published under the terms of the GNU Public License (GPL),
9 10
 * a copy of which is included in this distribution, or a commercial license
 * agreement with Jive.
11 12
 */

13
package org.jivesoftware.openfire.spi;
14

15 16 17
import org.jivesoftware.openfire.ConnectionManager;
import org.jivesoftware.openfire.ServerPort;
import org.jivesoftware.openfire.XMPPServerInfo;
Gaston Dombiak's avatar
Gaston Dombiak committed
18 19
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Version;
20

21
import java.util.Collection;
22
import java.util.Collections;
23
import java.util.Date;
24 25 26 27 28 29 30 31 32 33

/**
 * Implements the server info for a basic server. Optimization opportunities
 * in reusing this object the data is relatively static.
 *
 * @author Iain Shigeoka
 */
public class XMPPServerInfoImpl implements XMPPServerInfo {

    private Date startDate;
34 35
    private String xmppDomain;
    private String hostname;
36 37 38 39 40 41
    private Version ver;
    private ConnectionManager connectionManager;

    /**
     * Simple constructor
     *
42 43
     * @param xmppDomain the server's XMPP domain name (e.g. example.org).
     * @param hostname the server's host name (e.g. server1.example.org).
44 45 46 47 48
     * @param version the server's version number.
     * @param startDate the server's last start time (can be null indicating
     *      it hasn't been started).
     * @param connectionManager the object that keeps track of the active ports.
     */
49 50 51
    public XMPPServerInfoImpl(String xmppDomain, String hostname, Version version, Date startDate, ConnectionManager connectionManager) {
        this.xmppDomain = xmppDomain;
        this.hostname = hostname;
52 53 54 55 56 57 58 59 60
        this.ver = version;
        this.startDate = startDate;
        this.connectionManager = connectionManager;
    }

    public Version getVersion() {
        return ver;
    }

61
    @Deprecated
62
    public String getName() {
Gaston Dombiak's avatar
Gaston Dombiak committed
63
        return getXMPPDomain();
64 65
    }

66
    @Deprecated
67
    public void setName(String serverName) {
Gaston Dombiak's avatar
Gaston Dombiak committed
68
        setXMPPDomain(serverName);
69 70 71 72 73 74 75
    }

    public String getHostname()
	{
		return hostname;
	}

Gaston Dombiak's avatar
Gaston Dombiak committed
76
	public String getXMPPDomain()
77 78 79 80
	{
		return xmppDomain;
	}

Gaston Dombiak's avatar
Gaston Dombiak committed
81
	public void setXMPPDomain(String domainName)
82 83 84
	{
        this.xmppDomain = domainName;
        if (domainName == null) { 
85 86 87
            JiveGlobals.deleteProperty("xmpp.domain");
        }
        else {
88
            JiveGlobals.setProperty("xmpp.domain", domainName);
89 90 91 92 93 94 95
        }
    }

    public Date getLastStarted() {
        return startDate;
    }

96
    public Collection<ServerPort> getServerPorts() {
97
        if (connectionManager == null) {
98
            return Collections.emptyList();
99 100 101 102 103 104
        }
        else {
            return connectionManager.getPorts();
        }
    }
}