001: /********************************************************************************
002: * CruiseControl, a Continuous Integration Toolkit
003: * Copyright (c) 2007, ThoughtWorks, Inc.
004: * 200 E. Randolph, 25th Floor
005: * Chicago, IL 60601 USA
006: * All rights reserved.
007: *
008: * Redistribution and use in source and binary forms, with or without
009: * modification, are permitted provided that the following conditions
010: * are met:
011: *
012: * + Redistributions of source code must retain the above copyright
013: * notice, this list of conditions and the following disclaimer.
014: *
015: * + Redistributions in binary form must reproduce the above
016: * copyright notice, this list of conditions and the following
017: * disclaimer in the documentation and/or other materials provided
018: * with the distribution.
019: *
020: * + Neither the name of ThoughtWorks, Inc., CruiseControl, nor the
021: * names of its contributors may be used to endorse or promote
022: * products derived from this software without specific prior
023: * written permission.
024: *
025: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
026: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
027: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
028: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
029: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
030: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
031: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
032: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
033: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
034: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
035: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
036: ********************************************************************************/package net.sourceforge.cruisecontrol;
037:
038: import java.util.List;
039: import java.util.ArrayList;
040:
041: import net.sourceforge.cruisecontrol.util.BuildInformationHelper;
042: import net.sourceforge.cruisecontrol.util.UniqueBuildloopIdentifier;
043:
044: public class BuildLoopInformation {
045:
046: private String uuid;
047:
048: private JmxInfo jmx;
049:
050: private String servername = "";
051:
052: private String timestamp = "";
053:
054: private ProjectInfo[] projects;
055:
056: public BuildLoopInformation(ProjectInfo[] projects,
057: JmxInfo jmxinfo, String serverName, String timestamp) {
058: this .projects = projects;
059: this .jmx = jmxinfo;
060: this .servername = serverName;
061: this .timestamp = timestamp;
062: this .uuid = UniqueBuildloopIdentifier.id().toString();
063: }
064:
065: public String getServerName() {
066: return servername;
067: }
068:
069: public JmxInfo getJmxInfo() {
070: return jmx;
071: }
072:
073: public String getTimestamp() {
074: return timestamp;
075: }
076:
077: public ProjectInfo[] getProjects() {
078: return projects;
079: }
080:
081: public String getUuid() {
082: return uuid;
083: }
084:
085: public String toXml() {
086: return new BuildInformationHelper().toXml(this );
087: }
088:
089: public static class JmxInfo {
090:
091: public static final String CRUISECONTROL_RMIPORT = "cruisecontrol.rmiport";
092:
093: public static final String CRUISECONTROL_JMXPORT = "cruisecontrol.jmxport";
094:
095: public static final String JMX_HTTP_USERNAME = "jmx.http.username";
096:
097: public static final String JMX_HTTP_PASSWORD = "jmx.http.password";
098:
099: private String httpurl = "";
100:
101: private String rmiurl = "";
102:
103: private String username = System.getProperty(JMX_HTTP_USERNAME);
104:
105: private String password = System.getProperty(JMX_HTTP_PASSWORD);
106:
107: public JmxInfo(String serverName) {
108:
109: String httpPort = System.getProperty(CRUISECONTROL_JMXPORT);
110: if (httpPort != null) {
111: this .httpurl = "http://" + serverName + ":" + httpPort;
112: }
113:
114: String rmiPort = System.getProperty(CRUISECONTROL_RMIPORT);
115: if (rmiPort != null) {
116: this .rmiurl = "rmi://" + serverName + ":" + rmiPort;
117: }
118: }
119:
120: public String getHttpAdpatorUrl() {
121: return httpurl;
122: }
123:
124: public String getRmiUrl() {
125: return rmiurl;
126: }
127:
128: public String getUserName() {
129: return username;
130: }
131:
132: public String getPassword() {
133: return password;
134: }
135:
136: public int hashCode() {
137: final int prime = 31;
138: int result = 1;
139: result = prime * result + httpurl.hashCode();
140: result = prime * result
141: + ((password == null) ? 0 : password.hashCode());
142: result = prime * result + rmiurl.hashCode();
143: result = prime * result
144: + ((username == null) ? 0 : username.hashCode());
145: return result;
146: }
147:
148: public boolean equals(Object obj) {
149: if (this == obj) {
150: return true;
151: }
152: if (obj == null) {
153: return false;
154: }
155: if (getClass() != obj.getClass()) {
156: return false;
157: }
158: return equals((JmxInfo) obj);
159: }
160:
161: private boolean equals(final JmxInfo other) {
162: if (!httpurl.equals(other.httpurl)) {
163: return false;
164: }
165: if (!rmiurl.equals(other.rmiurl)) {
166: return false;
167: }
168: if (password == null) {
169: if (other.password != null) {
170: return false;
171: }
172: } else if (!password.equals(other.password)) {
173: return false;
174: }
175: if (username == null) {
176: if (other.username != null) {
177: return false;
178: }
179: } else if (!username.equals(other.username)) {
180: return false;
181: }
182: return true;
183: }
184: }
185:
186: public static class ProjectInfo {
187: private String name;
188:
189: private String status;
190:
191: private String buildstarttime;
192:
193: private List modifications = new ArrayList();
194:
195: public ProjectInfo(String name, String status,
196: String buildStartTime) {
197: this .name = name;
198: this .status = status;
199: this .buildstarttime = buildStartTime;
200: }
201:
202: public String getName() {
203: return name;
204: }
205:
206: public String getStatus() {
207: return status;
208: }
209:
210: public String getBuildStartTime() {
211: return buildstarttime;
212: }
213:
214: public List getModifications() {
215: return modifications;
216: }
217:
218: public void setModifications(List modifications) {
219: this.modifications = modifications;
220: }
221: }
222: }
|