TxnOp.java
01 /*
02  *
03  * Licensed to the Apache Software Foundation (ASF) under one
04  * or more contributor license agreements.  See the NOTICE file
05  * distributed with this work for additional information
06  * regarding copyright ownership.  The ASF licenses this file
07  * to you under the Apache License, Version 2.0 (the
08  * "License"); you may not use this file except in compliance
09  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  */
21 package org.apache.qpid.server.txn;
22 
23 import org.apache.qpid.AMQException;
24 import org.apache.qpid.server.store.StoreContext;
25 
26 /**
27  * This provides the abstraction of an individual operation within a
28  * transaction. It is used by the TxnBuffer class.
29  */
30 public interface TxnOp
31 {
32     /**
33      * Do the part of the operation that updates persistent state
34      */
35     public void prepare(StoreContext contextthrows AMQException;
36     /**
37      * Complete the operation started by prepare. Can now update in
38      * memory state or make netork transfers.
39      */
40     public void commit(StoreContext contextthrows AMQException;
41     /**
42      * This is not the same as rollback. Unfortunately the use of an
43      * in memory reference count as a locking mechanism and a test for
44      * whether a message should be deleted means that as things are,
45      * handling an acknowledgement unavoidably alters both memory and
46      * persistent state on prepare. This is needed to 'compensate' or
47      * undo the in-memory change if the peristent update of later ops
48      * fails.
49      */
50     public void undoPrepare();
51     /**
52      * Rolls back the operation.
53      */
54     public void rollback(StoreContext contextthrows AMQException;
55 }