View Javadoc

1   package uk.ac.ebi.intenz.tools.importer;
2   
3   import java.io.IOException;
4   import java.util.Properties;
5   
6   /**
7    * This interface defines the imported for all data.
8    *
9    * @author local_admin
10   * @version $id 31-May-2005 13:46:10
11   *          History:
12   *          Developer    Date    Description
13   *          local_admin      31-May-2005 Created class
14   */
15  public abstract class Importer {
16  
17  	protected Properties importerProps;
18  
19  	protected Importer() throws IOException{
20  		importerProps = new Properties();
21  		importerProps.load(this.getClass().getClassLoader()
22  				.getResourceAsStream("Importer.properties"));
23  	}
24  
25  	/**
26  	 * Using the template pattern to do the import.
27  	 *
28  	 * @throws Exception
29  	 */
30  	public final void doImport () throws Exception {
31  		try {
32  			setup();
33  			importData();
34  			loadData();
35  		} finally {
36  			destroy();
37  		}
38  	}
39  
40  	/**
41  	 * Used to setup all network connections.
42  	 */
43  	protected abstract void setup () throws Exception;
44  
45  
46  	/**
47  	 * Used to import the data from the source
48  	 */
49  	protected abstract void importData () throws Exception;
50  
51  	/**
52  	 * Method called after the data has been imported succesfully.
53  	 */
54  	protected abstract void loadData () throws Exception;
55  
56  	/**
57  	 * Method used to close all loose ends.
58  	 */
59  	protected abstract void destroy ();
60  
61  }