1 45 package org.openejb.client; 46 47 import java.io.IOException ; 48 import java.io.ObjectInput ; 49 import java.io.ObjectOutput ; 50 51 56 public class EJBResponse implements Response { 57 58 59 private transient int responseCode = -1; 60 private transient Object result; 61 62 public EJBResponse(){ 63 64 } 65 66 public EJBResponse(int code, Object obj){ 67 responseCode = code; 68 result = obj; 69 } 70 71 public int getResponseCode(){ 72 return responseCode; 73 } 74 75 public Object getResult(){ 76 return result; 77 } 78 79 public void setResponse(int code, Object result){ 80 this.responseCode = code; 81 this.result = result; 82 } 83 84 public String toString(){ 85 StringBuffer s = null; 86 switch (responseCode) { 87 case EJB_APP_EXCEPTION: 88 s = new StringBuffer ( "EJB_APP_EXCEPTION" ); 89 break; 90 case EJB_ERROR: 91 s = new StringBuffer ( "EJB_ERROR" ); 92 break; 93 case EJB_OK: 94 s = new StringBuffer ( "EJB_OK" ); 95 break; 96 case EJB_OK_CREATE: 97 s = new StringBuffer ( "EJB_OK_CREATE" ); 98 break; 99 case EJB_OK_FOUND: 100 s = new StringBuffer ( "EJB_OK_FOUND" ); 101 break; 102 case EJB_OK_FOUND_COLLECTION: 103 s = new StringBuffer ( "EJB_OK_FOUND_COLLECTION" ); 104 break; 105 case EJB_OK_FOUND_ENUMERATION: 106 s = new StringBuffer ( "EJB_OK_FOUND_ENUMERATION" ); 107 break; 108 case EJB_OK_NOT_FOUND: 109 s = new StringBuffer ( "EJB_OK_NOT_FOUND" ); 110 break; 111 case EJB_SYS_EXCEPTION: 112 s = new StringBuffer ( "EJB_SYS_EXCEPTION" ); 113 break; 114 default: 115 s = new StringBuffer ( "UNKNOWN_RESPONSE" ); 116 } 117 s.append(':').append(result); 118 119 return s.toString(); 120 } 121 122 134 public void readExternal(ObjectInput in) throws IOException , ClassNotFoundException { 135 responseCode = in.readByte(); 136 result = in.readObject(); 140 } 141 142 157 public void writeExternal(ObjectOutput out) throws IOException { 158 out.writeByte(responseCode); 160 out.writeObject(result); 161 } 162 } 163 | Popular Tags |