1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 package net.sf.tm;
34
35 import org.apache.commons.lang.builder.EqualsBuilder;
36 import org.apache.commons.lang.builder.HashCodeBuilder;
37 import org.apache.commons.lang.builder.ToStringBuilder;
38
39 /***
40 * Class holds the status of current state of a web context.
41 *
42 * @author Andreas Pataki
43 * @version $Id: WebContext.java,v 1.5 2004/02/10 20:05:38 apataki Exp $
44 */
45 public class WebContext {
46
47 /***
48 * The path of the context e.g. /something
49 */
50 private String path;
51 /***
52 * The docPath of the context is the path in the filesystem where
53 * the context is installed.
54 */
55 private String docPath;
56 /***
57 * Gives informations of the running status of the context.
58 */
59 private WebContextStatus status = WebContextStatus.STOPPED;
60 /***
61 * Session count
62 */
63 private int activeSessions;
64
65 /***
66 * @return The doc path of the context.
67 */
68 public String getDocPath() {
69 return docPath;
70 }
71
72 /***
73 * @return The context path
74 */
75 public String getPath() {
76 return path;
77 }
78
79 /***
80 * @return The status. See the constant definitions in this class for
81 * the values.
82 */
83 public WebContextStatus getStatus() {
84 return status;
85 }
86
87 /***
88 * @param string new doc path
89 */
90 public void setDocPath(String string) {
91 docPath = string;
92 }
93
94 /***
95 * @param string new path
96 */
97 public void setPath(String string) {
98 path = string;
99 }
100
101 /***
102 * @param i New status. Must be one of the constants defined in this class.
103 */
104 public void setStatus(WebContextStatus i) {
105 status = i;
106 }
107
108 /***
109 * @return The session count
110 */
111 public int getActiveSessions() {
112 return activeSessions;
113 }
114
115 /***
116 * @param count Session count
117 */
118 public void setActiveSessions(int count) {
119 activeSessions = count;
120 }
121
122 /***
123 * Overwritten to ensure that a refreshed context object is the same as the
124 * old one in the tree. Only this way the selection in the
125 * tree will get preserved.
126 *
127 * @see java.lang.Object#equals(java.lang.Object)
128 */
129 public boolean equals(Object obj) {
130 if (!(obj instanceof WebContext)) {
131 return false;
132 }
133 WebContext other = (WebContext) obj;
134 return new EqualsBuilder()
135 .append(getDocPath(), other.getDocPath())
136 .append(getPath(), other.getPath())
137 .isEquals();
138 }
139
140 /***
141 * Overwritten to provide the hash for the same fields used in the
142 * equals method.
143 *
144 * @see java.lang.Object#hashCode()
145 */
146 public int hashCode() {
147 return new HashCodeBuilder()
148 .append(getDocPath())
149 .append(getPath())
150 .toHashCode();
151 }
152
153 /***
154 * Overwriten for debuging purposes only.
155 *
156 * @see java.lang.Object#toString()
157 */
158 public String toString() {
159 return ToStringBuilder.reflectionToString(this);
160 }
161
162 }