KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > prevayler > implementation > TransactionWithQueryExecuter


1 //Prevayler(TM) - The Free-Software Prevalence Layer.
2
//Copyright (C) 2001-2003 Klaus Wuestefeld
3
//This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
4

5 package org.prevayler.implementation;
6
7 import java.util.Date JavaDoc;
8
9 import org.prevayler.*;
10
11
12 class TransactionWithQueryExecuter implements Transaction {
13
14     static final long serialVersionUID = 0L;
15
16     private TransactionWithQuery _delegate;
17
18     private transient Object JavaDoc _result;
19     private transient Exception JavaDoc _exception;
20
21
22     private TransactionWithQueryExecuter() {} //Necessary for Skaringa XML serialization
23
TransactionWithQueryExecuter(TransactionWithQuery transactionWithQuery) {
24         _delegate = transactionWithQuery;
25     }
26
27     public final void executeOn(Object JavaDoc prevalentSystem, Date JavaDoc timestamp) {
28         try {
29             _result = _delegate.executeAndQuery(prevalentSystem, timestamp);
30         } catch (RuntimeException JavaDoc rx) {
31             throw rx; //This is necessary because of the rollback feature.
32
} catch (Exception JavaDoc ex) {
33             _exception = ex;
34         }
35     }
36
37     Object JavaDoc result() throws Exception JavaDoc {
38         if (_exception != null) throw _exception;
39         return _result;
40     }
41
42 }
Popular Tags