private void updateTimers ( List < org . mobicents . slee . example . sjr . data . RegistrationBinding > contacts ) { String bindingAciName = null ; ActivityContextInterface aci = null ; for ( RegistrationBinding binding : contacts ) { bindingAciName = getACIName ( binding . getContactAddress ( ) , binding . getSipAddress ( ) ) ; aci = this . activityContextNamingFacility . lookup ( bindingAciName ) ; if ( aci != null ) { // binding update, cancel old timer for ( TimerID timerID : ( ( ActivityContextInterfaceExt ) aci ) . getTimers ( ) ) { this . timerFacility . cancelTimer ( timerID ) ; } // NOTE: DO NOT END activity, we will reuse it. } else { // binding creation, create null aci, bind a name and store the // jdbc task for removal (to run if timer expires) NullActivity nullActivity = this . nullActivityFactory . createNullActivity ( ) ; aci = this . nullActivityContextInterfaceFactory . getActivityContextInterface ( nullActivity ) ; // NOTE: DO NOT ATTACH to activity, so the sbb entity is // claimed. The timer event is initial! // set name try { this . activityContextNamingFacility . bind ( aci , bindingAciName ) ; } catch ( Exception e ) { this . tracer . severe ( "Failed to bind aci name " + bindingAciName , e ) ; } SbbActivityContextInterface rgAci = asSbbActivityContextInterface ( aci ) ; rgAci . setData ( new RegistrationBindingData ( ) . setAddress ( binding . getSipAddress ( ) ) . setContact ( binding . getContactAddress ( ) ) ) ; } // set new timer timerFacility . setTimer ( aci , null , System . currentTimeMillis ( ) + ( ( binding . getExpires ( ) + 1 ) * 1000 ) , defaultTimerOptions ) ; } }
Simple method to update timers for passed contacts . If timer exists it will be reset to new timeout . If it does not exist it will be create along with NullActivity .