KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > joram > shared > admin > AdminReply


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  * Copyright (C) 2001 - 2006 ScalAgent Distributed Technologies
4  * Copyright (C) 2004 France Telecom R&D
5  * Copyright (C) 1996 - 2000 Dyade
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20  * USA.
21  *
22  * Initial developer(s): Frederic Maistre (INRIA)
23  * Contributor(s): ScalAgent Distributed Technologies
24  */

25 package org.objectweb.joram.shared.admin;
26
27 /**
28  * An <code>AdminReply</code> is a reply sent by a
29  * <code>org.objectweb.joram.mom.dest.AdminTopic</code> topic and containing data or
30  * information destinated to a client administrator.
31  */

32 public class AdminReply implements java.io.Serializable JavaDoc {
33   private static final long serialVersionUID = 1188608769364211862L;
34
35   public final static int NAME_ALREADY_USED = 0;
36
37   public final static int START_FAILURE = 1;
38
39   public final static int SERVER_ID_ALREADY_USED = 2;
40
41   public final static int UNKNOWN_SERVER = 3;
42   
43   /** <code>true</code> if this reply replies to a successful request. */
44   private boolean success = false;
45
46   /** Information. */
47   private String JavaDoc info;
48
49   /** Object. */
50   private Object JavaDoc replyObj;
51
52   private int errorCode;
53
54   /**
55    * Constructs an <code>AdminReply</code> instance.
56    *
57    * @param success <code>true</code> if this reply replies to a successful
58    * request.
59    * @param info Information to carry.
60    */

61   public AdminReply(boolean success,
62                     String JavaDoc info) {
63     this(success, -1, info, null);
64   }
65
66   /**
67    * Constructs an <code>AdminReply</code> instance.
68    *
69    * @param success <code>true</code> if this reply replies to a successful
70    * request.
71    * @param info Information to carry.
72    * @param replyObj Object to carry.
73    */

74   public AdminReply(boolean success,
75                     String JavaDoc info,
76                     Object JavaDoc replyObj) {
77     this(success, -1, info, replyObj);
78   }
79
80   /**
81    * Constructs an <code>AdminReply</code> instance.
82    *
83    * @param success <code>true</code> if this reply replies to a successful
84    * request.
85    * @param errorCode error code defining the type of the error
86    * @param info Information to carry.
87    * @param replyObj Object to carry.
88    */

89   public AdminReply(boolean success,
90                     int errorCode,
91                     String JavaDoc info,
92                     Object JavaDoc replyObj) {
93     this.success = success;
94     this.errorCode = errorCode;
95     this.info = info;
96     this.replyObj = replyObj;
97   }
98
99   /**
100    * Returns <code>true</code> if this reply replies to a successful request.
101    */

102   public final boolean succeeded() {
103     return success;
104   }
105
106   /** Returns the carried info. */
107   public final String JavaDoc getInfo() {
108     return info;
109   }
110
111   /** Returns the carried object. */
112   public final Object JavaDoc getReplyObject() {
113     return replyObj;
114   }
115
116   public final int getErrorCode() {
117     return errorCode;
118   }
119
120   public String JavaDoc toString() {
121     return '(' + super.toString() +
122       ",success=" + success +
123       ",info=" + info +
124       ",errorCode=" + errorCode +
125       ",replyObj=" + replyObj + ')';
126   }
127 }
128
Popular Tags