View Javadoc

1   /*
2    * $Id: FileSession.java 7963 2007-08-21 08:53:15Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.util.file;
12  
13  import org.mule.util.xa.ResourceManagerException;
14  
15  import java.io.File;
16  import java.io.FileInputStream;
17  import java.io.FileOutputStream;
18  import java.io.IOException;
19  import java.io.RandomAccessFile;
20  
21  public interface FileSession
22  {
23  
24      void begin() throws ResourceManagerException;
25  
26      void commit() throws ResourceManagerException;
27  
28      void rollback() throws ResourceManagerException;
29  
30      FileInputStream openInputStream(File f) throws IOException;
31  
32      FileOutputStream openOutputStream(File f, boolean append) throws IOException;
33  
34      FileOutputStream openOutputStream(File f) throws IOException;
35  
36      boolean mkdir(File f) throws IOException;
37  
38      RandomAccessFile openRandomAccess(File f, String mode) throws IOException;
39  
40      /**
41       * Delete the given file.
42       * 
43       * @throw IllegalStateException if this transaction has already been committed or
44       *        rolled back
45       * @throw FileNotFoundException if the file does not exist
46       * @throw DeleteException if the deletion fails
47       * @throw TransactionException if there is a problem maintaining transaction
48       *        information
49       * @throw InconsistentStateException if this transaction cannot be restored to a
50       *        consistent state (either no effect or all effects); failure of
51       *        atomicity
52       */
53      void delete(File f) throws IOException;
54  
55      void copy(File source, File dest) throws IOException;
56  
57      void rename(File source, File dest) throws IOException;
58  
59  }