KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > prevayler > Prevayler


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;
6
7 import java.io.IOException JavaDoc;
8
9
10 /** Implementations of this interface can provide transparent persistence and replication to all Business Objects in a Prevalent System. ALL operations that alter the observable state of the Prevalent System must be implemented as Transaction or TransactionWithQuery objects and must be executed using the Prevayler.execute(...) methods.
11  * See the demo applications in org.prevayler.demos for examples.
12  * @see PrevaylerFactory
13  */

14 public interface Prevayler {
15
16     /** Returns the Object which holds direct or indirect references to all other Business Objects in the system.
17      */

18     public Object JavaDoc prevalentSystem();
19
20     /** Returns the Clock used to determine the execution time of all Transaction and Queries executed using this Prevayler. This Clock is useful only to Communication Objects and must NOT be used by Transactions, Queries or Business Objects, since that would make them become non-deterministic. Instead, Transactions, Queries and Business Objects must use the executionTime parameter which is passed on their execution.
21      */

22     public Clock clock();
23
24     /** Executes the given Transaction on the prevalentSystem(). ALL operations that alter the observable state of the prevalentSystem() must be implemented as Transaction or TransactionWithQuery objects and must be executed using the Prevayler.execute() methods. This method synchronizes on the prevalentSystem() to execute the Transaction. It is therefore guaranteed that only one Transaction is executed at a time. This means the prevalentSystem() does not have to worry about concurrency issues among Transactions.
25      * Implementations of this interface can log the given Transaction for crash or shutdown recovery, for example, or execute it remotely on replicas of the prevalentSystem() for fault-tolerance and load-balancing purposes. Such a "replicating" implementation is planned for Prevayler release 2.1.
26      * @see PrevaylerFactory
27      */

28     public void execute(Transaction transaction);
29
30     /** Executes the given sensitiveQuery on the prevalentSystem(). A sensitiveQuery is a Query that would be affected by the concurrent execution of a Transaction or other sensitiveQuery. This method synchronizes on the prevalentSystem() to execute the sensitiveQuery. It is therefore guaranteed that no other Transaction or sensitiveQuery is executed at the same time.
31      * <br> Robust Queries (queries that do not affect other operations and that are not affected by them) can be executed directly as plain old method calls on the prevalentSystem() without the need of being implemented as Query objects. Examples of Robust Queries are queries that reead the value of a single field or historical queries such as: "What was this account's balance at mid-night?".
32      * @return The result returned by the execution of the sensitiveQuery on the prevalentSystem().
33      * @throws Exception The Exception thrown by the execution of the sensitiveQuery on the prevalentSystem().
34      */

35     public Object JavaDoc execute(Query sensitiveQuery) throws Exception JavaDoc;
36
37     /** Executes the given transactionWithQuery on the prevalentSystem().
38      * Implementations of this interface can log the given transaction for crash or shutdown recovery, for example, or execute it remotely on replicas of the prevalentSystem() for fault-tolerance and load-balancing purposes. Such a "replicating" implementation is planned for Prevayler release 2.1.
39      * @return The result returned by the execution of the sensitiveQuery on the prevalentSystem().
40      * @throws Exception The Exception thrown by the execution of the sensitiveQuery on the prevalentSystem().
41      * @see PrevaylerFactory
42      */

43     public Object JavaDoc execute(TransactionWithQuery transactionWithQuery) throws Exception JavaDoc;
44
45     /** Produces a complete serialized image of the underlying PrevalentSystem.
46      * This will accelerate future system startups. Taking a snapshot once a day is enough for most applications.
47      * This method synchronizes on the prevalentSystem() in order to take the snapshot. This means that transaction execution will be blocked while the snapshot is taken.
48      * @throws IOException if there is trouble writing to the snapshot file.
49      */

50     public void takeSnapshot() throws IOException JavaDoc;
51
52     /** Closes any files or other system resources opened by this Prevayler.
53      * @throws IOException if there is trouble closing a file or some other system resource.
54      */

55     public void close() throws IOException JavaDoc;
56
57 }
58
Popular Tags