Come Usare L'evento Onendrequest?

La CApplication ha il metodo onEndReqeust




    if(!$this->_ended)

    {

        $this->_ended=true;

        $this->raiseEvent('onEndRequest',$event);

    }



Come faccio io ad agganciarmi all’evento ? Cioè, devo eseguire un po’ di codice.