KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > mybatchfwk > history > MemoryExecutionHistory


1 /*
2  * MyBatchFramework - Open-source batch framework.
3  * Copyright (C) 2006 Jérôme Bertèche cyberteche@users.sourceforge.net
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library 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  * Jérôme Bertèche
16  * Email: cyberteche@users.sourceforge.net
17  */

18 package net.sf.mybatchfwk.history;
19
20 import java.util.Iterator JavaDoc;
21 import java.util.List JavaDoc;
22 import java.util.Vector JavaDoc;
23
24 import net.sf.mybatchfwk.BatchConfiguration;
25 import net.sf.mybatchfwk.BatchException;
26
27 /**
28  * This implementation store the ids into the memory.<br>
29  * <i>Warning:</i><br>
30  * - the number of ids stored must be very limited, in order to prevents OutOfMemoryError.<br>
31  * - there is no persistence, so the ids are lost when the batch is stopped.
32  *
33  * @author Jérôme Bertèche (cyberteche@users.sourceforge.net)
34  */

35 public class MemoryExecutionHistory implements IExecutionHistory {
36     
37     protected List JavaDoc<String JavaDoc> completedTasksList;
38     protected List JavaDoc<String JavaDoc> failedTasksList;
39
40     /* (non-Javadoc)
41      * @see net.sf.mybatchfwk.history.IExecutionHistory#initStorage(net.sf.mybatchfwk.BatchConfiguration)
42      */

43     public void initStorage(BatchConfiguration configuration) throws BatchException {
44         completedTasksList = new Vector JavaDoc<String JavaDoc>();
45         failedTasksList = new Vector JavaDoc<String JavaDoc>();
46     }
47     
48     /* (non-Javadoc)
49      * @see net.sf.mybatchfwk.history.IExecutionHistory#closeStorage()
50      */

51     public void closeStorage() throws BatchException {
52     }
53
54     /* (non-Javadoc)
55      * @see net.sf.mybatchfwk.history.IExecutionHistory#completedTasksIdIterator()
56      */

57     public Iterator JavaDoc completedTasksIdIterator() throws BatchException {
58         return completedTasksList.iterator();
59     }
60
61     /* (non-Javadoc)
62      * @see net.sf.mybatchfwk.history.IExecutionHistory#failedTasksIdIterator()
63      */

64     public Iterator JavaDoc failedTasksIdIterator() throws BatchException {
65         return failedTasksList.iterator();
66     }
67
68     /* (non-Javadoc)
69      * @see net.sf.mybatchfwk.history.IExecutionHistory#isCompletedTask(java.lang.String)
70      */

71     public boolean isCompletedTask(String JavaDoc id) throws BatchException {
72         return completedTasksList.contains(id);
73     }
74
75     /* (non-Javadoc)
76      * @see net.sf.mybatchfwk.history.IExecutionHistory#isFailedTask(java.lang.String)
77      */

78     public boolean isFailedTask(String JavaDoc id) throws BatchException {
79         return failedTasksList.contains(id);
80     }
81
82     /* (non-Javadoc)
83      * @see net.sf.mybatchfwk.history.IExecutionHistory#storeCompletedTaskId(java.lang.String)
84      */

85     public void storeCompletedTaskId(String JavaDoc id) throws BatchException {
86         completedTasksList.add(id);
87     }
88
89     /* (non-Javadoc)
90      * @see net.sf.mybatchfwk.history.IExecutionHistory#storeFailedTaskId(java.lang.String)
91      */

92     public void storeFailedTaskId(String JavaDoc id) throws BatchException {
93         failedTasksList.add(id);
94     }
95 }
96
Popular Tags