1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.store

File StartableTransactionRunnable.java

 

Coverage histogram

../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

2
7
1
1
58
17
2
0.29
7
1
2

Classes

Class Line # Actions
StartableTransactionRunnable 31 7 0% 2 0
1.0100%
 

Contributing tests

This file is covered by 23 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.store;
21   
22    /**
23    * A TransactionRunnable which is safe to start.
24    * If your TransactionRunnable can safely be started on it's own, and does not need to be run inside of
25    * another runnable, then it should extend StartableTransactionRunnable.
26    *
27    * @param <T> see: {@link TransactionRunnable}
28    * @version $Id: 708dffa42e6cf40c449a28708ae6db5f935f8f2b $
29    * @since 3.0M2
30    */
 
31    public class StartableTransactionRunnable<T> extends ProvidingTransactionRunnable<T, T>
32    {
33    /**
34    * True after this runnable has been started and once true, this runnable may not be run again.
35    */
36    private boolean alreadyRun;
37   
38    /**
39    * Start this TransactionRunnable and all that are chained to it.
40    *
41    * @throws TransactionException if something goes wrong while pre running, running, committing,
42    * rolling back or completeing this or any of the chained runnables.
43    * @throws IllegalStateException if the same runnable is started more than once.
44    */
 
45  25 toggle public void start() throws TransactionException
46    {
47  25 if (this.alreadyRun) {
48  1 throw new IllegalStateException("This TransactionRunnable has already been run and may not "
49    + "be run again.");
50    }
51  24 this.alreadyRun = true;
52   
53  24 this.preRun();
54  24 this.run();
55  16 this.commit();
56  16 this.complete();
57    }
58    }