FileDocCategorySizeDatePackage
ServerConnectionInterceptor.javaAPI DocGlassfish v2 API10589Fri May 04 22:34:56 BST 2007com.sun.enterprise.iiop

ServerConnectionInterceptor

public class ServerConnectionInterceptor extends LocalObject implements ServerRequestInterceptor, Comparable

Fields Summary
private static Logger
_logger
public static final String
baseMsg
public int
order
Constructors Summary
public ServerConnectionInterceptor(int order)
Construct the interceptor.

param
the order in which the interceptor should run.


                     
       
	this.order = order;
    
Methods Summary
private voidcheckTransaction(org.omg.PortableInterceptor.ServerRequestInfo sri)

	/**
	ObjectImpl target = (ObjectImpl)sri.effective_target();
        if ( !target._is_local() ) {
	    J2EETransactionManager tm = 
				    Switch.getSwitch().getTransactionManager();
	    if ( tm != null )
		tm.checkTransactionExport();
	}
	**/
	J2EETransactionManager tm = Switch.getSwitch().getTransactionManager();
	if ( tm != null )
	    tm.checkTransactionImport();
    
public intcompareTo(java.lang.Object o)

	int otherOrder = -1;
	if( o instanceof ServerConnectionInterceptor) {
            otherOrder = ((ServerConnectionInterceptor)o).order;
	}
        if (order < otherOrder) {
            return -1;
        } else if (order == otherOrder) {
            return 0;
        }
        return 1;
    
public voiddestroy()

private booleanisEjbCall(org.omg.PortableInterceptor.ServerRequestInfo sri)
Returns true, if the incoming call is a EJB method call. This checks for is_a calls and ignores those calls. In callflow analysis when a component looks up another component, this lookup should be considered part of the same call coming in. Since a lookup triggers the iiop codebase, it will fire a new request start. With this check, we consider the calls that are only new incoming ejb method calls as new request starts.

        if (ORBManager.isEjbAdapterName(sri.adapter_name()) &&
                (!ORBManager.isIsACall(sri.operation()))) {
            return true;
        } else 
            return false;
    
public java.lang.Stringname()

 return baseMsg; 
public voidreceive_request(org.omg.PortableInterceptor.ServerRequestInfo sri)

        Socket s = null;
        Agent callFlowAgent = Switch.getSwitch().getCallFlowAgent();
        // callFlowAgent should never be null.
	// If the else block is executed, its a bug.
	// more investigation needed
	if (callFlowAgent != null) {
	    boolean callFlowEnabled = callFlowAgent.isEnabled();
	    if (callFlowEnabled){
	        // Only do callflow RequestStart,
	        // If it is a ejb call and not a is_a call. For everything else
	        // do a startTime for OTHER Container
	        if (isEjbCall(sri)){
		    try {
		        try{
			    Connection c = ((RequestInfoExt)sri).connection();
			    if (c != null) {
			        s = c.getSocket();
			    }
			} finally {
			    String callerIPAddress = null;
			    if (s != null) {
                                callerIPAddress = s.getInetAddress().getHostAddress();
			    }
			    callFlowAgent.requestStart(RequestType.REMOTE_EJB);
			    callFlowAgent.addRequestInfo(
							 RequestInfo.CALLER_IP_ADDRESS, callerIPAddress);
			}
		    } catch (Exception ex){
		        _logger.log( Level.WARNING,
				     "Callflow Agent's requestStart exception" + ex);
		    }
		} else {
		    try {
		        callFlowAgent.startTime(ContainerTypeOrApplicationType.ORB_CONTAINER);
		    } catch (Exception ex){
		        _logger.log( Level.WARNING,
				     "Callflow Agent's starttime exception" + ex);
		    }
		}
	    }
	} else {
	     _logger.log( Level.FINE, "CallFlow Agent not initialized. ");
	}	
    
public voidreceive_request_service_contexts(org.omg.PortableInterceptor.ServerRequestInfo sri)

        Socket s = null;
        Connection c = ((RequestInfoExt)sri).connection();
        SecurityMechanismSelector sms = new SecurityMechanismSelector();
        ServerConnectionContext scc = null;
        if (c != null) {
            s = c.getSocket();
            if(_logger.isLoggable(Level.FINE)) {
                _logger.log(Level.FINE,"RECEIVED request on connection: " + c);
                _logger.log(Level.FINE,"Socket =" + s);
            }
            scc = new ServerConnectionContext(s);
        } else {
            scc = new ServerConnectionContext();
        }
        sms.setServerConnectionContext(scc);
    
public voidsend_exception(org.omg.PortableInterceptor.ServerRequestInfo sri)

        try {
            checkTransaction(sri);
        } finally {
            if (isEjbCall(sri)) {
                Switch.getSwitch().getTransactionManager().cleanTxnTimeout();
            }
            Agent callFlowAgent = Switch.getSwitch().getCallFlowAgent();
	    // callFlowAgent should never be null.
	    // If the else block is executed, its a bug.
	    // more investigation needed
             if (callFlowAgent != null) {	       
	         boolean callFlowEnabled = callFlowAgent.isEnabled();
		 if(callFlowEnabled){
		     if (isEjbCall(sri)){
		         try {
			     callFlowAgent.requestEnd();
			 } catch (Exception ex) {
			     _logger.log(
				       Level.WARNING,
				       "Callflow Agent's requestEnd method exception" + ex);
			 }
		     } else {
		         try {
			     callFlowAgent.endTime();
			 } catch (Exception ex) {
			     _logger.log(
					 Level.WARNING,
					 "Callflow Agent's endtime method exception" + ex);
			 }
		     }
		 }
	     } else {
	         _logger.log( Level.FINE, "CallFlow Agent not initialized. ");
	     }	
	}
    
public voidsend_other(org.omg.PortableInterceptor.ServerRequestInfo sri)

        try {
            checkTransaction(sri);
        } finally {
            if (isEjbCall(sri)) {
                Switch.getSwitch().getTransactionManager().cleanTxnTimeout();
            }
            Agent callFlowAgent = Switch.getSwitch().getCallFlowAgent();
	    // callFlowAgent should never be null.
	    // If the else block is executed, its a bug.
	    // more investigation needed
	    if (callFlowAgent != null) {
	        boolean callFlowEnabled = callFlowAgent.isEnabled();
		if(callFlowEnabled){
		    if (isEjbCall(sri)) {
		        try {
			    callFlowAgent.requestEnd();
			} catch (Exception ex) {
			    _logger.log(
					Level.WARNING,
					"Callflow Agent's requestEnd method exception" + ex);
			}
		    } else {
		        try {
			    callFlowAgent.endTime();
			} catch (Exception ex) {
			    _logger.log(
					Level.WARNING,
					"Callflow Agent's endtime method exception" + ex);
			}
		    }
		}
            } else {
	        _logger.log( Level.FINE, "CallFlow Agent not initialized. ");
	    }	    
        }
    
public voidsend_reply(org.omg.PortableInterceptor.ServerRequestInfo sri)

        try {
            checkTransaction(sri);
        } finally {
            if (isEjbCall(sri)) {
                Switch.getSwitch().getTransactionManager().cleanTxnTimeout();
            }
            Agent callFlowAgent = Switch.getSwitch().getCallFlowAgent();
	    // callFlowAgent should never be null.
	    // If the else block is executed, its a bug.
	    // more investigation needed
            if (callFlowAgent != null) {
	        boolean callFlowEnabled = callFlowAgent.isEnabled();
		if(callFlowEnabled){
		    if (isEjbCall(sri)){
		        try {
			    callFlowAgent.requestEnd();
			} catch (Exception ex) {
			    _logger.log(
				      Level.WARNING,
				      "Callflow Agent's requestEnd method exception" + ex);
			}
		    } else {
		        try {
			    callFlowAgent.endTime();
			} catch (Exception ex) {
			    _logger.log(
					Level.WARNING,
					"Callflow Agent's endtime method exception" + ex);
			}
		    }
		}	    
	    } else {
	        _logger.log( Level.FINE, "CallFlow Agent not initialized. ");
	    }
	}