00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 package org.objectweb.joram.shared.admin;
00026
00027 import java.io.IOException;
00028 import java.io.InputStream;
00029 import java.io.OutputStream;
00030
00031 import org.objectweb.joram.shared.stream.StreamUtil;
00032
00038 public class AdminReply extends AbstractAdminMessage {
00039
00040 private static final long serialVersionUID = 1L;
00041
00042 public final static int NAME_ALREADY_USED = 0;
00043
00044 public final static int START_FAILURE = 1;
00045
00046 public final static int SERVER_ID_ALREADY_USED = 2;
00047
00048 public final static int UNKNOWN_SERVER = 3;
00049
00051 private boolean success = false;
00052
00054 private String info;
00055
00057 private Object replyObj;
00058
00059 private int errorCode;
00060
00068 public AdminReply(boolean success,
00069 String info) {
00070 this(success, -1, info, null);
00071 }
00072
00081 public AdminReply(boolean success,
00082 String info,
00083 Object replyObj) {
00084 this(success, -1, info, replyObj);
00085 }
00086
00096 public AdminReply(boolean success,
00097 int errorCode,
00098 String info,
00099 Object replyObj) {
00100 this.success = success;
00101 this.errorCode = errorCode;
00102 this.info = info;
00103 this.replyObj = replyObj;
00104 }
00105
00106 public AdminReply() { }
00107
00111 public final boolean succeeded() {
00112 return success;
00113 }
00114
00116 public final String getInfo() {
00117 return info;
00118 }
00119
00121 public final Object getReplyObject() {
00122 return replyObj;
00123 }
00124
00125 public final int getErrorCode() {
00126 return errorCode;
00127 }
00128
00129 public String toString() {
00130 return '(' + super.toString() +
00131 ",success=" + success +
00132 ",info=" + info +
00133 ",errorCode=" + errorCode +
00134 ",replyObj=" + replyObj + ')';
00135 }
00136
00137 protected int getClassId() {
00138 return ADMIN_REPLY;
00139 }
00140
00141
00142
00143
00144
00145 public void writeTo(OutputStream os) throws IOException {
00146 StreamUtil.writeTo(success, os);
00147 StreamUtil.writeTo(info, os);
00148 StreamUtil.writeObjectTo(replyObj, os);
00149 StreamUtil.writeTo(errorCode, os);
00150 }
00151
00152 public void readFrom(InputStream is) throws IOException {
00153 success = StreamUtil.readBooleanFrom(is);
00154 info = StreamUtil.readStringFrom(is);
00155 replyObj = StreamUtil.readObjectFrom(is);
00156 errorCode = StreamUtil.readIntFrom(is);
00157 }
00158
00159 }