001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 2005 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or modify it
007: * under the terms of the GNU Lesser General Public License as published by the
008: * Free Software Foundation; either version 2.1 of the License, or any later
009: * version.
010: *
011: * This library is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
014: * for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public License
017: * along with this library; if not, write to the Free Software Foundation,
018: * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
019: * --------------------------------------------------------------------------
020: * $Id: DiscGreeting.java 9358 2006-08-04 11:46:51Z durieuxp $
021: * --------------------------------------------------------------------------
022: */package org.objectweb.jonas.discovery;
023:
024: /**
025: * This class represents a special greeting message which has two uses:
026: * 1) To act as a broadcast to the domain that a new server with a given
027: * server name has started. It also includes a port that the server will
028: * listen to objections at, the domain name and state set to STARTUP.
029: * 2) To inform the newly started server that server name is already in use
030: * by another server.
031: *
032: * @author Vivek Lakshmanan
033: * @version 1.0
034: */
035: public class DiscGreeting extends DiscMessage {
036: /**
037: *
038: */
039: private static final long serialVersionUID = 1L;
040: /**
041: *
042: */
043: private String state = null;
044: /**
045: *
046: */
047: private String serverName = null;
048: /**
049: *
050: */
051: private String domainName = null;
052: /**
053: *
054: */
055: private String serverId = null;
056:
057: /**
058: * @param sourceAddress
059: * @param sourcePort
060: */
061: public DiscGreeting(String sourceAddress, int sourcePort) {
062: super (sourceAddress, sourcePort);
063: }
064:
065: /**
066: * Constructor for a Discovery Greeting.
067: * @param sourceAddress
068: * the host address to use to receive a response.
069: * @param sourcePort
070: * is the port used in the case of a point to point response.
071: * @param serverName
072: * is Jonas server name.
073: * @param domainName
074: * is Jonas domain name.
075: * @param startingUp
076: * is this server starting up or is it reporting back with a
077: * notification stating that it owns this server name?
078: * @param serverId TODO
079: */
080: public DiscGreeting(String sourceAddress, int sourcePort,
081: String serverName, String domainName, boolean startingUp,
082: String serverId) {
083: super (sourceAddress, sourcePort);
084: this .serverName = serverName;
085: this .domainName = domainName;
086: this .serverId = serverId;
087:
088: if (startingUp) {
089: this .state = DiscoveryState.STARTUP;
090: } else {
091: this .state = DiscoveryState.DUPLICATE_NAME;
092: }
093:
094: }
095:
096: /**
097: * returns server name.
098: *
099: * @return serverName
100: */
101: public String getServerName() {
102: return serverName;
103: }
104:
105: /**
106: * returns domain name.
107: *
108: * @return domain name.
109: */
110: public String getDomainName() {
111: return domainName;
112: }
113:
114: /**
115: * sets the domain name.
116: *
117: * @param domainName the management domain name
118: */
119: public void setDomainName(String domainName) {
120: this .domainName = domainName;
121: }
122:
123: /**
124: * sets the serverName
125: *
126: * @param serverName the name of the server sending the discovery greeting
127: */
128: public void setServerName(String serverName) {
129: this .serverName = serverName;
130: }
131:
132: /**
133: * @return server state.
134: */
135: public String getState() {
136: return state;
137: }
138:
139: /**
140: * sets the server state : STARTINGUP or DUPLICATE_NAME.
141: *
142: * @param state state of the server sending the discovery greeting, one of DiscGreeting.STARTUP or DiscGreeting.DUPLICATE_NAME
143: */
144: public void setState(String state) {
145: this .state = state;
146: }
147:
148: /**
149: * The string version of the message
150: * @return the message
151: */
152: public String toString() {
153: String str = super .toString() + " State=" + state
154: + " DomainName=" + domainName + " ServerName= "
155: + serverName + " serverId= " + serverId;
156: return str;
157:
158: }
159:
160: /**
161: *
162: * @return serverId
163: */
164: public String getServerId() {
165: return serverId;
166: }
167:
168: /**
169: * Set the serverId
170: * @param serverId value of the serverId to set
171: */
172: public void setServerId(String serverId) {
173: this.serverId = serverId;
174: }
175: }
|