if(log.isDebugEnabled()) log.debug("calling request handler (" + (request_handler != null? request_handler.getClass().getName() : "null") + ") with request " + hdr.id);
if(log.isTraceEnabled()) log.trace("calling request handler (" + (request_handler != null? request_handler.getClass().getName() : "null") + ") with request " + hdr.id);
    private void handleRequest(Message req) {        Object        retval;        byte[]        rsp_buf=null;        Header        hdr, rsp_hdr;        Message       rsp;        // i. Remove the request correlator header from the msg and pass it to        // the registered handler        //        // ii. If a reply is expected, pack the return value from the request        // handler to a reply msg and send it back. The reply msg has the same        // ID as the request and the name of the sender request correlator        hdr    = (Header)req.removeHeader(name);            if(log.isDebugEnabled()) log.debug("calling request handler (" +                    (request_handler != null? request_handler.getClass().getName() : "null") +                    ") with request " + hdr.id);        try {            retval = request_handler.handle(req);        }        catch(Throwable t) {            if(log.isErrorEnabled()) log.error("error invoking method, exception=" + t.toString());            retval=t;        }        if(!hdr.rsp_expected) // asynchronous call, we don't need to send a response; terminate call here            return;        if (transport == null) {            if(log.isErrorEnabled()) log.error("failure sending " + "response; no transport available");            return;        }        // changed (bela Feb 20 2004): catch exception and return exception        try {            rsp_buf=Util.objectToByteBuffer(retval);  // retval could be an exception, or a real value        }        catch(Throwable t) {            try {                rsp_buf=Util.objectToByteBuffer(t); // this call shoudl succeed (all exceptions are serializable)            }            catch(Throwable tt) {                if(log.isErrorEnabled()) log.error("failed sending response: " +                        "return value (" + retval + ") is not serializable");                return;            }        }        rsp=req.makeReply();        if(rsp_buf != null)            rsp.setBuffer(rsp_buf);        rsp_hdr=new Header(Header.RSP, hdr.id, false, name);        rsp.putHeader(name, rsp_hdr);            if(log.isDebugEnabled()) log.debug("sending rsp for " +                    rsp_hdr.id + " to " + rsp.getDest());        try {            if(transport instanceof Protocol)                ((Protocol)transport).passDown(new Event(Event.MSG, rsp));            else if(transport instanceof Transport)                ((Transport)transport).send(rsp);            else                if(log.isErrorEnabled()) log.error("transport object has to be either a " +                            "Transport or a Protocol, however it is a " + transport.getClass());        }        catch(Throwable e) {            if(log.isErrorEnabled()) log.error(throwableToString(e));        }    }