1 23 24 package com.sun.enterprise.iiop; 25 26 import java.net.Socket ; 27 import org.omg.PortableInterceptor.ServerRequestInfo ; 28 import com.sun.corba.ee.spi.legacy.interceptor.RequestInfoExt; 29 import com.sun.corba.ee.spi.legacy.connection.Connection; 30 import com.sun.enterprise.iiop.security.SecurityMechanismSelector; 31 import com.sun.enterprise.iiop.security.ServerConnectionContext; 32 33 import com.sun.enterprise.J2EETransactionManager; 34 import com.sun.enterprise.Switch; 35 import com.sun.enterprise.distributedtx.J2EETransactionManagerOpt; 36 37 import com.sun.enterprise.admin.monitor.callflow.Agent; 38 import com.sun.enterprise.admin.monitor.callflow.RequestType; 39 import com.sun.enterprise.admin.monitor.callflow.RequestInfo; 40 import com.sun.enterprise.admin.monitor.callflow.ContainerTypeOrApplicationType; 41 import com.sun.enterprise.util.ORBManager; 42 import java.util.logging.*; 43 import com.sun.logging.*; 44 45 46 public class ServerConnectionInterceptor extends org.omg.CORBA.LocalObject 47 implements org.omg.PortableInterceptor.ServerRequestInterceptor , Comparable 48 { 49 private static Logger _logger=null; 50 static{ 51 _logger=LogDomains.getLogger(LogDomains.CORBA_LOGGER); 52 } 53 public static final String baseMsg = "ServerConnectionInterceptor"; 54 public int order; 55 56 60 public ServerConnectionInterceptor(int order) { 61 this.order = order; 62 } 63 64 public String name() { return baseMsg; } 65 66 public void receive_request_service_contexts(ServerRequestInfo sri) 67 { 68 Socket s = null; 69 Connection c = ((RequestInfoExt)sri).connection(); 70 SecurityMechanismSelector sms = new SecurityMechanismSelector(); 71 ServerConnectionContext scc = null; 72 if (c != null) { 73 s = c.getSocket(); 74 if(_logger.isLoggable(Level.FINE)) { 75 _logger.log(Level.FINE,"RECEIVED request on connection: " + c); 76 _logger.log(Level.FINE,"Socket =" + s); 77 } 78 scc = new ServerConnectionContext(s); 79 } else { 80 scc = new ServerConnectionContext(); 81 } 82 sms.setServerConnectionContext(scc); 83 } 84 85 public int compareTo(Object o) 86 { 87 int otherOrder = -1; 88 if( o instanceof ServerConnectionInterceptor) { 89 otherOrder = ((ServerConnectionInterceptor)o).order; 90 } 91 if (order < otherOrder) { 92 return -1; 93 } else if (order == otherOrder) { 94 return 0; 95 } 96 return 1; 97 } 98 99 public void destroy() {} 100 101 public void receive_request(ServerRequestInfo sri) 102 { 103 Socket s = null; 104 Agent callFlowAgent = Switch.getSwitch().getCallFlowAgent(); 105 if (callFlowAgent != null) { 109 boolean callFlowEnabled = callFlowAgent.isEnabled(); 110 if (callFlowEnabled){ 111 if (isEjbCall(sri)){ 115 try { 116 try{ 117 Connection c = ((RequestInfoExt)sri).connection(); 118 if (c != null) { 119 s = c.getSocket(); 120 } 121 } finally { 122 String callerIPAddress = null; 123 if (s != null) { 124 callerIPAddress = s.getInetAddress().getHostAddress(); 125 } 126 callFlowAgent.requestStart(RequestType.REMOTE_EJB); 127 callFlowAgent.addRequestInfo( 128 RequestInfo.CALLER_IP_ADDRESS, callerIPAddress); 129 } 130 } catch (Exception ex){ 131 _logger.log( Level.WARNING, 132 "Callflow Agent's requestStart exception" + ex); 133 } 134 } else { 135 try { 136 callFlowAgent.startTime(ContainerTypeOrApplicationType.ORB_CONTAINER); 137 } catch (Exception ex){ 138 _logger.log( Level.WARNING, 139 "Callflow Agent's starttime exception" + ex); 140 } 141 } 142 } 143 } else { 144 _logger.log( Level.FINE, "CallFlow Agent not initialized. "); 145 } 146 } 147 public void send_reply(ServerRequestInfo sri) 148 { 149 try { 150 checkTransaction(sri); 151 } finally { 152 if (isEjbCall(sri)) { 153 Switch.getSwitch().getTransactionManager().cleanTxnTimeout(); 154 } 155 Agent callFlowAgent = Switch.getSwitch().getCallFlowAgent(); 156 if (callFlowAgent != null) { 160 boolean callFlowEnabled = callFlowAgent.isEnabled(); 161 if(callFlowEnabled){ 162 if (isEjbCall(sri)){ 163 try { 164 callFlowAgent.requestEnd(); 165 } catch (Exception ex) { 166 _logger.log( 167 Level.WARNING, 168 "Callflow Agent's requestEnd method exception" + ex); 169 } 170 } else { 171 try { 172 callFlowAgent.endTime(); 173 } catch (Exception ex) { 174 _logger.log( 175 Level.WARNING, 176 "Callflow Agent's endtime method exception" + ex); 177 } 178 } 179 } 180 } else { 181 _logger.log( Level.FINE, "CallFlow Agent not initialized. "); 182 } 183 } 184 } 185 186 public void send_exception(ServerRequestInfo sri) 187 { 188 try { 189 checkTransaction(sri); 190 } finally { 191 if (isEjbCall(sri)) { 192 Switch.getSwitch().getTransactionManager().cleanTxnTimeout(); 193 } 194 Agent callFlowAgent = Switch.getSwitch().getCallFlowAgent(); 195 if (callFlowAgent != null) { 199 boolean callFlowEnabled = callFlowAgent.isEnabled(); 200 if(callFlowEnabled){ 201 if (isEjbCall(sri)){ 202 try { 203 callFlowAgent.requestEnd(); 204 } catch (Exception ex) { 205 _logger.log( 206 Level.WARNING, 207 "Callflow Agent's requestEnd method exception" + ex); 208 } 209 } else { 210 try { 211 callFlowAgent.endTime(); 212 } catch (Exception ex) { 213 _logger.log( 214 Level.WARNING, 215 "Callflow Agent's endtime method exception" + ex); 216 } 217 } 218 } 219 } else { 220 _logger.log( Level.FINE, "CallFlow Agent not initialized. "); 221 } 222 } 223 } 224 225 public void send_other(ServerRequestInfo sri) 226 { 227 try { 228 checkTransaction(sri); 229 } finally { 230 if (isEjbCall(sri)) { 231 Switch.getSwitch().getTransactionManager().cleanTxnTimeout(); 232 } 233 Agent callFlowAgent = Switch.getSwitch().getCallFlowAgent(); 234 if (callFlowAgent != null) { 238 boolean callFlowEnabled = callFlowAgent.isEnabled(); 239 if(callFlowEnabled){ 240 if (isEjbCall(sri)) { 241 try { 242 callFlowAgent.requestEnd(); 243 } catch (Exception ex) { 244 _logger.log( 245 Level.WARNING, 246 "Callflow Agent's requestEnd method exception" + ex); 247 } 248 } else { 249 try { 250 callFlowAgent.endTime(); 251 } catch (Exception ex) { 252 _logger.log( 253 Level.WARNING, 254 "Callflow Agent's endtime method exception" + ex); 255 } 256 } 257 } 258 } else { 259 _logger.log( Level.FINE, "CallFlow Agent not initialized. "); 260 } 261 } 262 } 263 264 private void checkTransaction(ServerRequestInfo sri) { 265 274 J2EETransactionManager tm = Switch.getSwitch().getTransactionManager(); 275 if ( tm != null ) 276 tm.checkTransactionImport(); 277 } 278 287 private boolean isEjbCall (ServerRequestInfo sri) { 288 if (ORBManager.isEjbAdapterName(sri.adapter_name()) && 289 (!ORBManager.isIsACall(sri.operation()))) { 290 return true; 291 } else 292 return false; 293 } 294 } 295 | Popular Tags |