View Javadoc

1   package org.apache.torque.betwixt;
2   
3   /*
4    * Copyright 2001-2006 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License")
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  /***
20   * Interface that all record handlers called by the Importer class should
21   * impliment.
22   * <p>
23   * 
24   * Note that to allow for import transactions to be rolled back, 
25   * implementors should use the Importer.getConnection() method
26   * when any DB save, update, or delete actions are performed.
27   * <p>
28   * 
29   * @author <a href="mailto:greg.monroe@dukece.com">Greg Monroe</a>
30   */
31  public interface RecordHandler extends Cloneable
32  {
33  
34      /***
35       * Handles both creating new record or updating existing record.
36       * <p>
37       * 
38       * Implementors need to report any error or success back via the 
39       * dispatcher's notifyListeners method.
40       * <p>
41       * 
42       * @param record The record object to process.
43       * @param dispatcher The object to get connection, event listener info, 
44       *                      and the like from.
45       * @throws Exception
46       */
47      public void addUpdateRecord( Object record, Importer dispatcher ) 
48                                                          throws Exception;
49      
50      /***
51       * Handles deleting records. 
52       * <p>
53       * 
54       * Implementors need to report any error or success back via the 
55       * dispatcher's notifyListeners method.
56       * <p>
57       * 
58       * @param record The record object to process.
59       * @param dispatcher The object to get connection, event listener info, 
60       *                      and the like from.
61       * @throws Exception
62       */
63      public void deleteRecord( Object record, Importer dispatcher )
64                                                       throws Exception;
65      
66      /***
67       * RecordHandlers need to be cloneable so the dispatcher can clone
68       * handlers as needed.
69       * 
70       * @return
71       * @throws CloneNotSupportedException
72       */
73      public Object clone() throws CloneNotSupportedException; 
74  
75  }