org/objectweb/joram/shared/admin/AdminReply.java

00001 /*
00002  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
00003  * Copyright (C) 2001 - 2007 ScalAgent Distributed Technologies
00004  * Copyright (C) 2004 France Telecom R&D
00005  * Copyright (C) 1996 - 2000 Dyade
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or any later version.
00011  * 
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00020  * USA.
00021  *
00022  * Initial developer(s): Frederic Maistre (INRIA)
00023  * Contributor(s): ScalAgent Distributed Technologies
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    * Streamable interface
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 }

Generated on Tue Sep 16 16:14:34 2008 for joram by  doxygen 1.5.0