private void addTriggerAfterAndExitTxn ( CodeBuilder b , String opType , LocalVariable forTryVar , boolean forTry , LocalVariable triggerVar , LocalVariable txnVar , LocalVariable stateVar ) { // if (trigger != null) { b . loadLocal ( triggerVar ) ; Label cont = b . createLabel ( ) ; b . ifNullBranch ( cont , true ) ; // if (forTry) { // trigger.afterTryXxx(this, state); // } else { // trigger.afterXxx(this, state); // } b . loadLocal ( triggerVar ) ; b . loadThis ( ) ; b . loadLocal ( stateVar ) ; if ( forTryVar == null ) { if ( forTry ) { b . invokeVirtual ( TypeDesc . forClass ( Trigger . class ) , "afterTry" + opType , null , new TypeDesc [ ] { TypeDesc . OBJECT , TypeDesc . OBJECT } ) ; } else { b . invokeVirtual ( TypeDesc . forClass ( Trigger . class ) , "after" + opType , null , new TypeDesc [ ] { TypeDesc . OBJECT , TypeDesc . OBJECT } ) ; } } else { b . loadLocal ( forTryVar ) ; Label isForTry = b . createLabel ( ) ; b . ifZeroComparisonBranch ( isForTry , "!=" ) ; b . invokeVirtual ( TypeDesc . forClass ( Trigger . class ) , "after" + opType , null , new TypeDesc [ ] { TypeDesc . OBJECT , TypeDesc . OBJECT } ) ; Label commitAndExit = b . createLabel ( ) ; b . branch ( commitAndExit ) ; isForTry . setLocation ( ) ; b . invokeVirtual ( TypeDesc . forClass ( Trigger . class ) , "afterTry" + opType , null , new TypeDesc [ ] { TypeDesc . OBJECT , TypeDesc . OBJECT } ) ; commitAndExit . setLocation ( ) ; } // txn.commit(); // txn.exit(); TypeDesc transactionType = TypeDesc . forClass ( Transaction . class ) ; b . loadLocal ( txnVar ) ; b . invokeInterface ( transactionType , COMMIT_METHOD_NAME , null , null ) ; b . loadLocal ( txnVar ) ; b . invokeInterface ( transactionType , EXIT_METHOD_NAME , null , null ) ; cont . setLocation ( ) ; }
Generates code to call a trigger after the persistence operation has been invoked .