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 JNDIResponse implements Response { 57 58 private transient int responseCode = -1; 59 private transient Object result; 60 61 public JNDIResponse(){ 62 } 63 64 public JNDIResponse(int code, Object obj){ 65 responseCode = code; 66 result = obj; 67 } 68 69 public int getResponseCode(){ 70 return responseCode; 71 } 72 73 public Object getResult(){ 74 return result; 75 } 76 77 public void setResponseCode(int responseCode){ 78 this.responseCode = responseCode; 79 } 80 81 public void setResult(Object result){ 82 this.result = result; 83 } 84 85 97 public void readExternal(ObjectInput in) throws IOException , ClassNotFoundException { 98 responseCode = in.readByte(); 99 101 switch (responseCode) { 102 case JNDI_OK: 103 case JNDI_NAMING_EXCEPTION: 104 case JNDI_RUNTIME_EXCEPTION: 105 case JNDI_ERROR: 106 result = in.readObject(); 107 break; 108 case JNDI_CONTEXT: 109 case JNDI_NOT_FOUND: 110 break; 111 case JNDI_EJBHOME: 112 EJBMetaDataImpl m = new EJBMetaDataImpl(); 113 m.readExternal(in); 114 result = m; 115 break; 116 } 117 } 118 119 134 public void writeExternal(ObjectOutput out) throws IOException { 135 out.writeByte((byte)responseCode); 137 138 switch (responseCode) { 139 case JNDI_OK: 140 case JNDI_NAMING_EXCEPTION: 141 case JNDI_RUNTIME_EXCEPTION: 142 case JNDI_ERROR: 143 out.writeObject(result); 144 break; 145 case JNDI_CONTEXT: 146 case JNDI_NOT_FOUND: 147 break; 148 case JNDI_EJBHOME: 149 EJBMetaDataImpl m = (EJBMetaDataImpl)result; 150 m.writeExternal(out); 151 break; 152 153 } 154 } 155 } 156 | Popular Tags |