public ORecordHook . RESULT callbackHooks ( final ORecordHook . TYPE type , final OIdentifiable id ) { if ( id == null || hooks . isEmpty ( ) || id . getIdentity ( ) . getClusterId ( ) == 0 ) return ORecordHook . RESULT . RECORD_NOT_CHANGED ; final ORecordHook . SCOPE scope = ORecordHook . SCOPE . typeToScope ( type ) ; final int scopeOrdinal = scope . ordinal ( ) ; final ORID identity = id . getIdentity ( ) . copy ( ) ; if ( ! pushInHook ( identity ) ) return ORecordHook . RESULT . RECORD_NOT_CHANGED ; try { final ORecord rec = id . getRecord ( ) ; if ( rec == null ) return ORecordHook . RESULT . RECORD_NOT_CHANGED ; final OScenarioThreadLocal . RUN_MODE runMode = OScenarioThreadLocal . INSTANCE . getRunMode ( ) ; boolean recordChanged = false ; for ( ORecordHook hook : hooksByScope [ scopeOrdinal ] ) { switch ( runMode ) { case DEFAULT : // NON_DISTRIBUTED OR PROXIED DB if ( getStorage ( ) . isDistributed ( ) && hook . getDistributedExecutionMode ( ) == ORecordHook . DISTRIBUTED_EXECUTION_MODE . TARGET_NODE ) // SKIP continue ; break ; // TARGET NODE case RUNNING_DISTRIBUTED : if ( hook . getDistributedExecutionMode ( ) == ORecordHook . DISTRIBUTED_EXECUTION_MODE . SOURCE_NODE ) continue ; } final ORecordHook . RESULT res = hook . onTrigger ( type , rec ) ; if ( res == ORecordHook . RESULT . RECORD_CHANGED ) recordChanged = true ; else if ( res == ORecordHook . RESULT . SKIP_IO ) // SKIP IO OPERATION return res ; else if ( res == ORecordHook . RESULT . SKIP ) // SKIP NEXT HOOKS AND RETURN IT return res ; else if ( res == ORecordHook . RESULT . RECORD_REPLACED ) return res ; } return recordChanged ? ORecordHook . RESULT . RECORD_CHANGED : ORecordHook . RESULT . RECORD_NOT_CHANGED ; } finally { popInHook ( identity ) ; } }
Callback the registered hooks if any .