KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > discovery > DiscEvent


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 2004 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published by the
8  * Free Software Foundation; either version 2.1 of the License, or any later
9  * version.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14  * for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library; if not, write to the Free Software Foundation,
18  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19  *
20  */

21
22 package org.objectweb.jonas.discovery;
23
24 import javax.management.remote.JMXServiceURL JavaDoc;
25
26 /**
27  * @author <a HREF="mailto:Takoua.Abdellatif@inria.fr">Takoua Abdellatif </a>
28  * @version 1.0
29  */

30 public class DiscEvent extends DiscMessage {
31     /**
32      *
33      */

34     public static final String JavaDoc RUNNING = "running";
35     /**
36      *
37      */

38     public static final String JavaDoc STOPPING = "stopping";
39     /**
40      *
41      */

42     private String JavaDoc state = RUNNING;
43     /**
44      *
45      */

46     private String JavaDoc serverName = null;
47     /**
48      *
49      */

50     private String JavaDoc domainName = null;
51
52     private String JavaDoc serverId = null;
53
54     /**
55      *
56      */

57     private String JavaDoc[] urls = null;
58
59     /**
60      * @param sourceAddress
61      * @param sourcePort
62      * @param serverId TODO
63      * @param serverID The serverID for this server.
64      */

65     public DiscEvent(String JavaDoc sourceAddress, int sourcePort, String JavaDoc serverId) {
66         super(sourceAddress, sourcePort);
67     }
68
69     /**
70      * Constructor for a Discovery Event.
71      * @param sourceAddress
72      * the host address to use to receive a response.
73      * @param sourcePort
74      * is the port used in the case of a point to point response.
75      * @param serverName
76      * is Jonas server name.
77      * @param domainName
78      * is Jonas domain name.
79      * @param serverId TODO
80      * @param connectorURLs
81      * contains the list of all connector urls registered in the mbean
82      * server.
83      */

84     public DiscEvent(String JavaDoc sourceAddress, int sourcePort, String JavaDoc serverName,
85             String JavaDoc domainName, String JavaDoc serverId, String JavaDoc[] connectorURLs) {
86         super(sourceAddress, sourcePort);
87         this.serverName = serverName;
88         this.domainName = domainName;
89         this.serverId = serverId;
90         this.urls = connectorURLs;
91     }
92
93     /**
94      * returns server name.
95      *
96      * @return serverName
97      */

98     public String JavaDoc getServerName() {
99         return serverName;
100     }
101
102     /**
103      * returns domain name.
104      *
105      * @return domain name.
106      */

107     public String JavaDoc getDomainName() {
108         return domainName;
109     }
110
111     /**
112      * sets the domain name.
113      *
114      * @param domainName the management domain name
115      */

116     public void setDomainName(String JavaDoc domainName) {
117         this.domainName = domainName;
118     }
119
120     /**
121      * sets the serverName
122      *
123      * @param serverName the name of the server sending the discovery event
124      */

125     public void setServerName(String JavaDoc serverName) {
126         this.serverName = serverName;
127     }
128
129     /**
130      * @return the connector URLs of the server sending the discovery event
131      */

132     public String JavaDoc[] getConnectorURL() {
133         return urls;
134     }
135
136     /**
137      * @param connectorURLs the connector URLs of the server sending the discovery event
138      */

139     public void setConnectorURL(String JavaDoc[] connectorURLs) {
140         this.urls = connectorURLs;
141     }
142
143     /**
144      * @return server state.
145      */

146     public String JavaDoc getState() {
147         return state;
148     }
149
150     /**
151      * sets the server state : RUNNING or STOPPING.
152      *
153      * @param state state of the server sending the discovery event
154      */

155     public void setState(String JavaDoc state) {
156         this.state = state;
157     }
158
159     /**
160      * The string version of the message
161      * @return the message
162      */

163     public String JavaDoc toString() {
164         String JavaDoc str = super.getSourceAddress() + ": " + super.getSourcePort() + " State="
165         + state + " DomainName=" + domainName + " ServerName= " + serverName + " Serverid = " + serverId;
166         if (urls != null) {
167             str = str + " URLs= ";
168             for (int i = 0; i < urls.length; i++) {
169                 str = str + urls[i] + " ";
170             }
171         }
172         return str;
173
174     }
175
176     public String JavaDoc getServerId() {
177         return serverId;
178     }
179
180     public void setServerId(String JavaDoc serverId) {
181         this.serverId = serverId;
182     }
183
184 }
Popular Tags