1 22 package fr.dyade.aaa.jndi2.ha; 23 24 import fr.dyade.aaa.jndi2.msg.*; 25 import fr.dyade.aaa.jndi2.server.*; 26 27 import java.net.*; 28 import java.io.*; 29 30 import org.objectweb.util.monolog.api.BasicLevel; 31 import org.objectweb.util.monolog.api.Logger; 32 33 public class HARequestContext extends RequestContext { 34 35 private transient IOControl ioCtrl; 36 37 private JndiRequest request; 38 39 private JndiReply reply; 40 41 private int id; 42 43 private transient HARequestManager manager; 44 45 HARequestContext(IOControl ioCtrl, 46 int id) throws Exception { 47 this.ioCtrl = ioCtrl; 48 this.id = id; 49 request = (JndiRequest)ioCtrl.readObject(); 50 } 51 52 public final int getId() { 53 return id; 54 } 55 56 void recover(HARequestContext ctx) { 57 ioCtrl = ctx.ioCtrl; 58 } 59 60 final JndiReply getReply() { 61 return reply; 62 } 63 64 68 public final JndiRequest getRequest() { 69 return request; 70 } 71 72 public void reply(JndiReply reply) { 73 this.reply = reply; 74 if (ioCtrl != null) { 75 try { 76 ioCtrl.writeObject(reply); 77 } catch (Exception exc) { 78 Trace.logger.log(BasicLevel.ERROR, "", exc); 79 } finally { 80 ioCtrl.close(); 81 } 82 } 83 } 84 85 private void close() { 86 ioCtrl.close(); 88 if (manager != null) 89 manager.removeContext(id); 90 } 91 92 public String toString() { 93 return '(' + super.toString() + 94 ",request=" + request + ')'; 95 } 96 } 97 | Popular Tags |