XMPPServerInfoImpl.java 2.14 KB
Newer Older
Matt Tucker's avatar
Matt Tucker committed
1
/**
Matt Tucker's avatar
Matt Tucker committed
2 3 4 5
 * $RCSfile$
 * $Revision$
 * $Date$
 *
Matt Tucker's avatar
Matt Tucker committed
6
 * Copyright (C) 2004 Jive Software. All rights reserved.
Matt Tucker's avatar
Matt Tucker committed
7
 *
Matt Tucker's avatar
Matt Tucker committed
8 9
 * This software is published under the terms of the GNU Public License (GPL),
 * a copy of which is included in this distribution.
Matt Tucker's avatar
Matt Tucker committed
10
 */
Matt Tucker's avatar
Matt Tucker committed
11

Matt Tucker's avatar
Matt Tucker committed
12 13 14 15
package org.jivesoftware.messenger.spi;

import org.jivesoftware.util.Version;
import org.jivesoftware.messenger.XMPPServerInfo;
16
import org.jivesoftware.util.JiveGlobals;
17

Matt Tucker's avatar
Matt Tucker committed
18 19 20 21 22 23 24 25 26 27
import java.util.Date;
import java.util.Iterator;

/**
 * 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 {
28

Matt Tucker's avatar
Matt Tucker committed
29 30 31 32 33 34 35 36 37
    private Date startDate;
    private Date stopDate;
    private String name;
    private Version ver;
    private Iterator ports;

    /**
     * Simple constructor
     *
Matt Tucker's avatar
Matt Tucker committed
38 39
     * @param serverName the server's serverName (e.g. example.org).
     * @param version the server's version number.
40 41 42 43
     * @param startDate the server's last start time (can be null indicating
     *      it hasn't been started).
     * @param stopDate the server's last stop time (can be null indicating it
     *      is running or hasn't been started).
Matt Tucker's avatar
Matt Tucker committed
44
     * @param portIter the portIter active on the server.
Matt Tucker's avatar
Matt Tucker committed
45
     */
46 47 48
    public XMPPServerInfoImpl(String serverName, Version version, Date startDate, Date stopDate,
            Iterator portIter)
    {
Matt Tucker's avatar
Matt Tucker committed
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
        this.name = serverName;
        this.ver = version;
        this.startDate = startDate;
        this.stopDate = stopDate;
        this.ports = portIter;
    }

    public Version getVersion() {
        return ver;
    }

    public String getName() {
        return name;
    }

    public void setName(String serverName) {
        name = serverName;
        if (serverName == null) {
67
            JiveGlobals.deleteProperty("xmpp.domain");
Matt Tucker's avatar
Matt Tucker committed
68 69
        }
        else {
70
            JiveGlobals.setProperty("xmpp.domain", serverName);
Matt Tucker's avatar
Matt Tucker committed
71 72 73 74 75 76 77 78 79 80 81 82 83 84
        }
    }

    public Date getLastStarted() {
        return startDate;
    }

    public Date getLastStopped() {
        return stopDate;
    }

    public Iterator getServerPorts() {
        return ports;
    }
85
}