Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
1
About	
  me	
  
3	
  
Eugene	
  Fedorenko	
  
	
  
Master	
  principal	
  R&D	
  architect	
  
adfprac=ce-­‐fedor.blogspot...
The	
  Briefing	
  
4	
  
ADF BC Transaction
Shared Transaction
Transaction Commit Cycle
ADF BC Save Points
ADF Model Trans...
5	
  
Transac=on	
  
Ø  A logical unit-of-work with a start and end
Ø  Must be entirely completed or aborted
Ø  If the start ...
7	
  
ADF	
  Business	
  Components	
  
ADF	
  Faces	
  
ADF	
  Task	
  Flows	
  
ADF	
  Data	
  Controls	
  /	
  ADF	
  B...
Giant	
  Stride	
  Entry	
  
8	
  
The	
  Briefing	
  
9	
  
ADF BC Transaction
Shared Transaction
Transaction Commit Cycle
ADF BC Save Points
ADF Model Trans...
Oracle	
  ADF	
  BC	
  Revisited	
  
10	
  
View	
  Object	
  
	
  
Nested	
  Applica?on	
  Module	
  
	
  
	
  
En?ty	
  ...
DB	
  Transac=on	
  Object	
  
11	
  
JDBC	
  Connec?on	
  
DB	
  
View	
  Object	
  
	
  
Nested	
  Applica?on	
  Module	...
Shared	
  Transac=on	
  
12	
  
JDBC	
  Connec?on	
  
DB	
  
View	
  Object	
  
	
  
En?ty	
  Object	
  
	
  
	
  
	
  
Vi...
Ø  Based on jbo.shared.txn property
Ø  Designed for shared Application Modules
Ø  Used for not-shared root AMs to reduc...
The	
  Briefing	
  
14	
  
ADF BC Transaction
Shared Transaction
Transaction Commit Cycle
ADF BC Save Points
ADF Model Tran...
Ø  Validation Listener List
Ø  Entities for validation
Ø  Transaction Post Listener List
Ø  Dirty entities
Ø  Transac...
16	
  
	
  
DB	
  Transac?on	
  
	
  
Commit	
  Cycle	
  
	
  
AM	
  
	
  
	
  
En?ty	
  
	
  Commit	
  
beforeValidate	
 ...
Ø  Validation
Ø  Raises validation exception
Ø  Post Changes
Ø  Rollbacks DB to savepoint
Ø  Restores state of posted...
Ø  Validation logic in beforeCommit method
Ø  Deferrable constraints
Ø  jbo.txn.handleafterpostexc = true
Ø  Forces in...
The	
  Briefing	
  
19	
  
ADF BC Transaction
Shared Transaction
Transaction Commit Cycle
ADF BC Save Points
ADF Model Tran...
Ø  Invoke a PL/SQL procedure
Ø  Modify entity attributes
Ø  Invoke another PL/SQL procedure
Ø  Commit the transaction
...
Ø  passivateStateForUndo
Ø  Makes a snapshot with AM’s state
Ø  activateStateForUndo
Ø  Restores AM’s state from snaps...
 
	
  public	
  class	
  AppModuleImpl	
  extends	
  Applica?onModuleImpl	
  {	
  
	
  
	
  public	
  void	
  someBusiness...
The	
  Briefing	
  
23	
  
ADF BC Transaction
Shared Transaction
Transaction Commit Cycle
ADF BC Save Points
ADF Model Tran...
Oracle	
  ADF	
  Model	
  
24	
  
ADF	
  Faces	
  
ADF	
  Bindings	
  
DB	
  
ADF	
  Data	
  Controls	
  
ADF	
  Task	
  F...
Ø  ADF BC
Ø  EJB
Ø  Bean
Ø  WebService (SOAP/REST)
Ø  URL
Ø  JMX
Ø  BAM
Ø  Placeholder
Ø  Custom Data Controls
	
...
Mul=ple	
  Data	
  Controls	
  
26	
  
REST	
  API	
  
DB	
  
ADF	
  BC	
  
Global	
  Divers	
  
Accommoda?on
Data	
  Control	
  Frame	
  
27	
  
REST	
  API	
  
DB	
  
ADF	
  BC	
  
Data	
  Control	
  Frame	
  
Global	
  Divers	
  ...
Oracle	
  ADF	
  Controller	
  
28	
  
ADF	
  Faces	
  
	
  
ADF	
  Bindings	
  
	
  
DB	
  
ADF	
  Data	
  Controls	
  
A...
 
	
  
	
  
Task	
  Flow	
  
29	
  
 
	
  
	
  
Task	
  Flow	
  Transac=on	
  Op=ons	
  
30	
  
Ø  Shared Data Control Frame
Ø  Data Control Instance (same type & name)
Ø AM instance
Ø VO instances
Ø  Transaction ...
Ø  Isolated Data Control Frame
Ø  Data Control Instance (same type & name)
Ø AM instance
Ø VO instances
Ø  Transactio...
The	
  Briefing	
  
33	
  
ADF BC Transaction
Shared Transaction
Transaction Commit Cycle
ADF BC Save Points
ADF Model Tran...
Data	
  Control	
  Frame	
  #1	
  
Data	
  Control	
  Frames	
  
34	
  
Main.jspx	
  
UTF	
  
Menu	
  
BTF	
  
Data	
  Con...
 
Task	
  Flow	
  Transac=on	
  Op=ons	
  
35	
  
	
  	
  	
  	
  	
  <transac?on>	
  
	
  	
  	
  	
  	
  	
  	
  	
  <ne...
Ø  Starts a new transaction on Data Control Frame
Ø  Supports Both Data Control Scopes
Ø  Isolated
Ø  Shared
Ø Called...
Ø  Only Transaction starter can finish it
Ø  Always Begin New Transaction
Ø  Use Existing Transaction if Possible (no c...
38	
  
	
  
Data	
  Control	
  Frame	
  
	
  
Task	
  Flow	
  Commit	
  
	
  
Transac?on	
  
	
  
	
  
Data	
  Control	
  ...
Ø  Prematurely Terminated Task Flow
Ø  Finished not via return activities
Ø  Task Flow’s container is not rendered anym...
The	
  Briefing	
  
40	
  
ADF BC Transaction
Shared Transaction
Transaction Commit Cycle
ADF BC Save Points
ADF Model Tran...
Ø  Joins an existing transaction
Ø  Supports Only Shared Data Control Scope
Ø  Isolated is disabled
Ø  Can not Finish ...
Ø  Created by default when shared transaction is reused
Ø  Used to restore model state on task flow exit
Ø  ”No Save Po...
Ø  Root AM requires a dedicated DB connection
Ø  Parent and Child Task Flows should share Transaction
Ø  Too many DB co...
Ø  Root AMs refer to the same data source
Ø  Task Flows use Transaction Options
Ø  Any but <No Controller Transaction>
...
The	
  Briefing	
  
45	
  
ADF BC Transaction
Shared Transaction
Transaction Commit Cycle
ADF BC Save Points
ADF Model Tran...
Ø  Dynamic transaction option
Ø  Isolated Data Control Scope
Ø  Always Begin New Transaction
Ø  Shared Data Control Sc...
Ø  Switches Off controller transaction management
Ø  Does not start a transaction on task flow entry
Ø  Does not create...
Ø  Get current binding context
Ø  Get current Data Control Frame
Ø  Start a new transaction on the frame
	
  
	
  publi...
Ø  Get current binding context
Ø  Get current Data Control Frame
Ø  Commit or Rollback transaction
	
  
	
  public	
  v...
Ø  Create Save Point
Ø  Save Save Point handle in pageFlowScope bean
Ø  Restore Save Point
	
  
	
  private	
  Savepoin...
 
	
  
	
  
CRUD	
  Task	
  Flow	
  
51	
  
Safety	
  Stop.	
  Ques=ons	
  &	
  Answers	
  
52	
  
ADF BC Transaction
Shared Transaction
Transaction Commit Cycle
ADF ...
53
Join Your Community!
Tonight from 8:00 – 10:00 in Sheraton I
ADF Monday Night Foosball
What is more fun than foosball a...
54
Deep Dive into Oracle ADF Transactions
Upcoming SlideShare
Loading in …5
×

Deep Dive into Oracle ADF Transactions

1,451 views

Published on

Presentation from KScope2016

Published in: Software
  • Be the first to comment

Deep Dive into Oracle ADF Transactions

  1. 1. 1
  2. 2. About  me   3   Eugene  Fedorenko     Master  principal  R&D  architect   adfprac=ce-­‐fedor.blogspot.com   @fisbudo            
  3. 3. The  Briefing   4   ADF BC Transaction Shared Transaction Transaction Commit Cycle ADF BC Save Points ADF Model Transaction Data Control Frame Programmatic Approach Q&A Data Control Scope Task Flow Transaction Options Transaction Definition
  4. 4. 5  
  5. 5. Transac=on   Ø  A logical unit-of-work with a start and end Ø  Must be entirely completed or aborted Ø  If the start state is valid, the end state is valid Ø  Is not affected by and does not affect any other transaction Ø  State management of uncommitted changes 6  
  6. 6. 7   ADF  Business  Components   ADF  Faces   ADF  Task  Flows   ADF  Data  Controls  /  ADF  Bindings   DB   Transac=on  Management  in  Oracle  ADF  
  7. 7. Giant  Stride  Entry   8  
  8. 8. The  Briefing   9   ADF BC Transaction Shared Transaction Transaction Commit Cycle ADF BC Save Points ADF Model Transaction Data Control Frame Programmatic Approach Q&A Data Control Scope Task Flow Transaction Options Transaction Definition
  9. 9. Oracle  ADF  BC  Revisited   10   View  Object     Nested  Applica?on  Module       En?ty  Object    
  10. 10. DB  Transac=on  Object   11   JDBC  Connec?on   DB   View  Object     Nested  Applica?on  Module       En?ty  Object        
  11. 11. Shared  Transac=on   12   JDBC  Connec?on   DB   View  Object     En?ty  Object         View  Object   View  Object  
  12. 12. Ø  Based on jbo.shared.txn property Ø  Designed for shared Application Modules Ø  Used for not-shared root AMs to reduce number of DB connections   Shared  Transac=on   13  
  13. 13. The  Briefing   14   ADF BC Transaction Shared Transaction Transaction Commit Cycle ADF BC Save Points ADF Model Transaction Data Control Frame Programmatic Approach Q&A Data Control Scope Task Flow Transaction Options Transaction Definition
  14. 14. Ø  Validation Listener List Ø  Entities for validation Ø  Transaction Post Listener List Ø  Dirty entities Ø  Transaction Listener List Ø  AMs and entities listening to commit phase   DB  Transac=on  Listeners   15  
  15. 15. 16     DB  Transac?on     Commit  Cycle     AM       En?ty    Commit   beforeValidate   validate   aFerValidate   postChanges   lock   prepareForDML   doDML   beforeCommit   doCommit   beforeCommit   aFerCommit   aFerCommit  
  16. 16. Ø  Validation Ø  Raises validation exception Ø  Post Changes Ø  Rollbacks DB to savepoint Ø  Restores state of posted entities Ø  Raises an exception Ø  Before Commit or Commit Ø  Rollbacks DB to savepoint Ø  Raises an exception Ø  Does not restore state of posted entities by default   Failure  at  Commit  Cycle   17  
  17. 17. Ø  Validation logic in beforeCommit method Ø  Deferrable constraints Ø  jbo.txn.handleafterpostexc = true Ø  Forces in memory passivation snapshot Ø  Activation of all AMs with all VO instances Error  at  Commit  phase   18    public  void  beforeCommit(Transac?onEvent  e)  {          if  (  !isDataValid()  )                throw  new  Valida?onExcep?on(VALIDATION_EXCEPTION);      }   CONSTRAINT  "CK_DIVEBOAT_WIDTH"  CHECK  (WIDTH<5)   DEFERRABLE  INITIALLY  DEFERRED  
  18. 18. The  Briefing   19   ADF BC Transaction Shared Transaction Transaction Commit Cycle ADF BC Save Points ADF Model Transaction Data Control Frame Programmatic Approach Q&A Data Control Scope Task Flow Transaction Options Transaction Definition
  19. 19. Ø  Invoke a PL/SQL procedure Ø  Modify entity attributes Ø  Invoke another PL/SQL procedure Ø  Commit the transaction    public  class  AppModuleImpl  extends  Applica?onModuleImpl  {        public  void  someBusinessServiceMethod()  {                  invokePLSQLProcedure1();                  modifySomeA^ributes();                  invokePLSQLProcedure2();                                getDBTransac?on().commit();                                          }     Business  Service  Method   20  
  20. 20. Ø  passivateStateForUndo Ø  Makes a snapshot with AM’s state Ø  activateStateForUndo Ø  Restores AM’s state from snapshot Ø  Rollbacks the transaction  public  class  AppModuleImpl  extends  Applica?onModuleImpl  {        private  String  passivateStateForUndo()  {                  String  savePoint  =  super.passivateStateForUndo(null,  null,  PASSIVATE_UNDO_FLAG);                  return  savePoint;            }          private  void  ac?vateStateForUndo(String  savePointId)  {                    super.ac?vateStateForUndo(savePointId,    ACTIVATE_UNDO_FLAG);                  }         Managing  Savepoints  with  ADF  BC   21  
  21. 21.    public  class  AppModuleImpl  extends  Applica?onModuleImpl  {      public  void  someBusinessServiceMethod()  {                      String  spid  =  passivateStateForUndo();                      try  {                                                    invokePLSQLProcedure1();                                                      modifySomeA^ributes();                                                    invokePLSQLProcedure2();                                            getDBTransac?on().commit();                                                    }  catch  (Run?meExcep?on  e)  {                              ac=vateStateForUndo(spid);                              throw  new  JboExcep?on(e);                      }              }       Managing  Savepoints  with  ADF  BC   22  
  22. 22. The  Briefing   23   ADF BC Transaction Shared Transaction Transaction Commit Cycle ADF BC Save Points ADF Model Transaction Data Control Frame Programmatic Approach Q&A Data Control Scope Task Flow Transaction Options Transaction Definition
  23. 23. Oracle  ADF  Model   24   ADF  Faces   ADF  Bindings   DB   ADF  Data  Controls   ADF  Task  Flows   ADF  Business  Components  
  24. 24. Ø  ADF BC Ø  EJB Ø  Bean Ø  WebService (SOAP/REST) Ø  URL Ø  JMX Ø  BAM Ø  Placeholder Ø  Custom Data Controls       ADF  Data  Controls   25  
  25. 25. Mul=ple  Data  Controls   26   REST  API   DB   ADF  BC   Global  Divers   Accommoda?on
  26. 26. Data  Control  Frame   27   REST  API   DB   ADF  BC   Data  Control  Frame   Global  Divers   Accommoda?on BC  Data  Control   REST  Data  Control   Transac=on  
  27. 27. Oracle  ADF  Controller   28   ADF  Faces     ADF  Bindings     DB   ADF  Data  Controls   ADF  Task  Flows   ADF  Business  Components  
  28. 28.       Task  Flow   29  
  29. 29.       Task  Flow  Transac=on  Op=ons   30  
  30. 30. Ø  Shared Data Control Frame Ø  Data Control Instance (same type & name) Ø AM instance Ø VO instances Ø  Transaction Handler Ø DB Transaction Object Ø DB Connection Ø Entity Cache Ø  Default Option for BTF     Shared  Data  Control  Scope   31  
  31. 31. Ø  Isolated Data Control Frame Ø  Data Control Instance (same type & name) Ø AM instance Ø VO instances Ø  Transaction Handler Ø DB Transaction Object Ø DB Connection Ø Entity Cache Ø  Always for UTF     Isolated  Data  Control  Scope   32  
  32. 32. The  Briefing   33   ADF BC Transaction Shared Transaction Transaction Commit Cycle ADF BC Save Points ADF Model Transaction Data Control Frame Programmatic Approach Q&A Data Control Scope Task Flow Transaction Options Transaction Definition
  33. 33. Data  Control  Frame  #1   Data  Control  Frames   34   Main.jspx   UTF   Menu   BTF   Data  Control  Frame  #2   Divers   BTF   Log  Book   Record   BTF   Data  Control  Frame  #3   Dive  Sites   BTF  
  34. 34.   Task  Flow  Transac=on  Op=ons   35            <transac?on>                  <new-­‐transac?on/>            </transac?on>      
  35. 35. Ø  Starts a new transaction on Data Control Frame Ø  Supports Both Data Control Scopes Ø  Isolated Ø  Shared Ø Called from UTF Ø The caller has ”No Controller Transaction” Ø  Must Finish the Transaction     Always  Begin  New  Transac=on  (new-­‐transac=on)   36  
  36. 36. Ø  Only Transaction starter can finish it Ø  Always Begin New Transaction Ø  Use Existing Transaction if Possible (no caller’s transaction)     Commit  and  Rollback  on  Return   37  
  37. 37. 38     Data  Control  Frame     Task  Flow  Commit     Transac?on       Data  Control    Commit   commit   commitTransac?on   commit     DB  Transac?on     For  each  data  control  
  38. 38. Ø  Prematurely Terminated Task Flow Ø  Finished not via return activities Ø  Task Flow’s container is not rendered anymore Ø  Has been refreshed by the parent Ø  Task Flow owns the transaction Ø  Auto-rollback behavior     Prematurely  Terminated  Transac=on   39  
  39. 39. The  Briefing   40   ADF BC Transaction Shared Transaction Transaction Commit Cycle ADF BC Save Points ADF Model Transaction Data Control Frame Programmatic Approach Q&A Data Control Scope Task Flow Transaction Options Transaction Definition
  40. 40. Ø  Joins an existing transaction Ø  Supports Only Shared Data Control Scope Ø  Isolated is disabled Ø  Can not Finish the Transaction     Always  Use  Exis=ng  Transac=on  (requires-­‐exis=ng-­‐transac=on)   41  
  41. 41. Ø  Created by default when shared transaction is reused Ø  Used to restore model state on task flow exit Ø  ”No Save Point on Task Flow Entry” to prevent creation     Task  Flow  Save  Points   42  
  42. 42. Ø  Root AM requires a dedicated DB connection Ø  Parent and Child Task Flows should share Transaction Ø  Too many DB connections for multi-root-AMs application     Root  AM  Connec=on  Challenge   43   Divers  VO   Log  Book  VO   Divers Root AM Log Book Root AM Log Book Record BTFDivers BTF
  43. 43. Ø  Root AMs refer to the same data source Ø  Task Flows use Transaction Options Ø  Any but <No Controller Transaction> Ø  Value for jbo.shared.txn is generated Ø  Transaction is shared     Root  AM  Connec=on  Sharing   44   JDBC  Connec?on   Divers  VO       Log  Book  VO   Divers Root AM Log Book Root AM
  44. 44. The  Briefing   45   ADF BC Transaction Shared Transaction Transaction Commit Cycle ADF BC Save Points ADF Model Transaction Data Control Frame Programmatic Approach Q&A Data Control Scope Task Flow Transaction Options Transaction Definition
  45. 45. Ø  Dynamic transaction option Ø  Isolated Data Control Scope Ø  Always Begin New Transaction Ø  Shared Data Control Scope Ø There is open transaction Ø  Always Use Existing Transaction Ø There is No open transaction Ø  Always Begin New Transaction     Use  Exis=ng  Transac=on  if  Possible  (requires-­‐transac=on)   46  
  46. 46. Ø  Switches Off controller transaction management Ø  Does not start a transaction on task flow entry Ø  Does not create a save point on task flow entry Ø  Does not restore to save point Ø  Does not rollback or commit transaction     No  Controller  Transac=on   47  
  47. 47. Ø  Get current binding context Ø  Get current Data Control Frame Ø  Start a new transaction on the frame    public  void  startTransac?on()  {          BindingContext  context  =  BindingContext.getCurrent();                        //Get  the  name  of  Data  Control  Frame          String  dcFrameName  =  context.getCurrentDataControlFrame();            //Get  Data  Control  Frame          DataControlFrame  dcFrame  =  context.findDataControlFrame(dcFrameName);                      //Start  Transac?on          dcFrame.beginTransac?on(new  Transac?onProper?es());      }         Start  a  Transac=on   48  
  48. 48. Ø  Get current binding context Ø  Get current Data Control Frame Ø  Commit or Rollback transaction    public  void  finishTransac?on()  {          BindingContext  context  =  BindingContext.getCurrent();                      //Get  the  name  of  Data  Control  Frame          String  dcFrameName  =  context.getCurrentDataControlFrame();            //Get  Data  Control  Frame          DataControlFrame  dcFrame  =  context.findDataControlFrame(dcFrameName);                      //Finish  Transac?on            if  (doRollback)  dcFrame.rollback();                else  dcFrame.commit();         }     Finish  a  Transac=on   49  
  49. 49. Ø  Create Save Point Ø  Save Save Point handle in pageFlowScope bean Ø  Restore Save Point    private  SavepointHandle  savepointHandle;            public  void  createSavePoint()  {          DataControlFrame  dcFrame  =  getCurrentDataControlFrame();          savepointHandle  =  dcFrame.createSavepoint();        }        public  void  restoreSavePoint()  {          DataControlFrame  dcFrame  =  getCurrentDataControlFrame();          dcFrame.restoreSavepoint(savepointHandle);      }   Create  Savepoint  &  Restore  to  Savepoint   50  
  50. 50.       CRUD  Task  Flow   51  
  51. 51. Safety  Stop.  Ques=ons  &  Answers   52   ADF BC Transaction Shared Transaction Transaction Commit Cycle ADF BC Save Points ADF Model Transaction Data Control Frame Programmatic Approach Q&A Data Control Scope Task Flow Transaction Options Transaction Definition
  52. 52. 53 Join Your Community! Tonight from 8:00 – 10:00 in Sheraton I ADF Monday Night Foosball What is more fun than foosball and beer at your best friend’s house? Well, how about a foosball tournament with a whole bunch of friends at Kscope16? Join your fellow ADF enthusiasts for some great networking and friendly competition.
  53. 53. 54

×