KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jivesoftware > messenger > spi > XMPPServerInfoImpl


1 /**
2  * $RCSfile: XMPPServerInfoImpl.java,v $
3  * $Revision: 1.7 $
4  * $Date: 2005/07/03 20:55:39 $
5  *
6  * Copyright (C) 2004 Jive Software. All rights reserved.
7  *
8  * This software is published under the terms of the GNU Public License (GPL),
9  * a copy of which is included in this distribution.
10  */

11
12 package org.jivesoftware.messenger.spi;
13
14 import org.jivesoftware.util.Version;
15 import org.jivesoftware.messenger.XMPPServerInfo;
16 import org.jivesoftware.messenger.ConnectionManager;
17 import org.jivesoftware.util.JiveGlobals;
18
19 import java.util.Date JavaDoc;
20 import java.util.Iterator JavaDoc;
21 import java.util.Collections JavaDoc;
22
23 /**
24  * Implements the server info for a basic server. Optimization opportunities
25  * in reusing this object the data is relatively static.
26  *
27  * @author Iain Shigeoka
28  */

29 public class XMPPServerInfoImpl implements XMPPServerInfo {
30
31     private Date JavaDoc startDate;
32     private Date JavaDoc stopDate;
33     private String JavaDoc name;
34     private Version ver;
35     private ConnectionManager connectionManager;
36
37     /**
38      * Simple constructor
39      *
40      * @param serverName the server's serverName (e.g. example.org).
41      * @param version the server's version number.
42      * @param startDate the server's last start time (can be null indicating
43      * it hasn't been started).
44      * @param stopDate the server's last stop time (can be null indicating it
45      * is running or hasn't been started).
46      * @param connectionManager the object that keeps track of the active ports.
47      */

48     public XMPPServerInfoImpl(String JavaDoc serverName, Version version, Date JavaDoc startDate, Date JavaDoc stopDate,
49             ConnectionManager connectionManager)
50     {
51         this.name = serverName;
52         this.ver = version;
53         this.startDate = startDate;
54         this.stopDate = stopDate;
55         this.connectionManager = connectionManager;
56     }
57
58     public Version getVersion() {
59         return ver;
60     }
61
62     public String JavaDoc getName() {
63         return name;
64     }
65
66     public void setName(String JavaDoc serverName) {
67         name = serverName;
68         if (serverName == null) {
69             JiveGlobals.deleteProperty("xmpp.domain");
70         }
71         else {
72             JiveGlobals.setProperty("xmpp.domain", serverName);
73         }
74     }
75
76     public Date JavaDoc getLastStarted() {
77         return startDate;
78     }
79
80     public Date JavaDoc getLastStopped() {
81         return stopDate;
82     }
83
84     public Iterator JavaDoc getServerPorts() {
85         if (connectionManager == null) {
86             return Collections.EMPTY_LIST.iterator();
87         }
88         else {
89             return connectionManager.getPorts();
90         }
91     }
92 }
Popular Tags