1 7 package org.jboss.mq.il.oil2; 8 9 import java.io.IOException ; 10 import java.rmi.RemoteException ; 11 12 import org.jboss.mq.Connection; 13 import org.jboss.mq.ReceiveRequest; 14 import org.jboss.mq.SpyDestination; 15 16 22 public final class OIL2ClientILService 23 implements org.jboss.mq.il.ClientILService, OIL2RequestListner 24 { 25 private Connection connection; 27 28 OIL2ServerIL serverIL; 30 31 OIL2SocketHandler socketHandler; 33 34 40 public org.jboss.mq.il.ClientIL getClientIL() throws java.lang.Exception 41 { 42 return new OIL2ClientIL(); 43 } 44 45 52 public void init(org.jboss.mq.Connection connection, java.util.Properties props) throws java.lang.Exception 53 { 54 this.connection = connection; 55 56 } 57 58 63 public void start() throws java.lang.Exception 64 { 65 serverIL = (OIL2ServerIL) connection.getServerIL(); 66 socketHandler = serverIL.socketHandler; 67 socketHandler.setRequestListner(this); 68 } 69 70 73 public void stop() throws java.lang.Exception 74 { 75 } 76 77 public void handleConnectionException(Exception e) 78 { 79 connection.asynchFailure("Connection failure", e); 80 serverIL.close(); 81 } 82 83 public void handleRequest(OIL2Request request) 84 { 85 Object result = null; 86 Exception resultException = null; 87 88 try 93 { 94 switch (request.operation) 95 { 96 case OIL2Constants.CLIENT_RECEIVE : 97 connection.asynchDeliver((ReceiveRequest[]) request.arguments[0]); 98 break; 99 case OIL2Constants.CLIENT_DELETE_TEMPORARY_DESTINATION : 100 connection.asynchDeleteTemporaryDestination((SpyDestination) request.arguments[0]); 101 break; 102 103 case OIL2Constants.CLIENT_CLOSE : 104 connection.asynchClose(); 105 break; 106 107 case OIL2Constants.CLIENT_PONG : 108 connection.asynchPong(((Long ) request.arguments[0]).longValue()); 109 break; 110 default : 111 throw new RemoteException ("Bad method code !"); 112 } } 114 catch (Exception e) 115 { 116 resultException = e; 117 } 119 try 120 { 121 OIL2Response response = new OIL2Response(request); 122 response.result = result; 123 response.exception = resultException; 124 socketHandler.sendResponse(response); 125 } 126 catch (IOException e) 127 { 128 handleConnectionException(e); 129 } 130 131 } 132 133 } 134 | Popular Tags |