View Javadoc

1   /*
2    * $Id: FileSession.java 7976 2007-08-21 14:26:13Z 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  /**
22   * @author <a href="mailto:gnt@codehaus.org">Guillaume Nodet</a>
23   * @version $Revision: 7976 $
24   */
25  public interface FileSession
26  {
27  
28      void begin() throws ResourceManagerException;
29  
30      void commit() throws ResourceManagerException;
31  
32      void rollback() throws ResourceManagerException;
33  
34      FileInputStream openInputStream(File f) throws IOException;
35  
36      FileOutputStream openOutputStream(File f, boolean append) throws IOException;
37  
38      FileOutputStream openOutputStream(File f) throws IOException;
39  
40      boolean mkdir(File f) throws IOException;
41  
42      RandomAccessFile openRandomAccess(File f, String mode) throws IOException;
43  
44      /**
45       * Delete the given file.
46       * 
47       * @throw IllegalStateException if this transaction has already been committed or
48       *        rolled back
49       * @throw FileNotFoundException if the file does not exist
50       * @throw DeleteException if the deletion fails
51       * @throw TransactionException if there is a problem maintaining transaction
52       *        information
53       * @throw InconsistentStateException if this transaction cannot be restored to a
54       *        consistent state (either no effect or all effects); failure of
55       *        atomicity
56       */
57      void delete(File f) throws IOException;
58  
59      void copy(File source, File dest) throws IOException;
60  
61      void rename(File source, File dest) throws IOException;
62  
63  }