View Javadoc
1   package com.atlassian.sal.core.transaction;
2   
3   import com.atlassian.sal.api.transaction.TransactionCallback;
4   import com.atlassian.sal.api.transaction.TransactionTemplate;
5   import com.atlassian.sal.spi.HostContextAccessor;
6   
7   /**
8    * This provides a default implementation that delegates to the underlying host context accessor
9    */
10  public class HostContextTransactionTemplate implements TransactionTemplate {
11      private final HostContextAccessor hostContentAccessor;
12  
13      public HostContextTransactionTemplate(HostContextAccessor hostContentAccessor) {
14          this.hostContentAccessor = hostContentAccessor;
15      }
16  
17      public Object execute(final TransactionCallback action) {
18          return hostContentAccessor.doInTransaction(new HostContextAccessor.HostTransactionCallback() {
19  
20              public Object doInTransaction() {
21                  return action.doInTransaction();
22              }
23          });
24      }
25  }