KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > riotfamily > riot > job > persistence > InMemoryJobDao


1 /* ***** BEGIN LICENSE BLOCK *****
2  * Version: MPL 1.1
3  * The contents of this file are subject to the Mozilla Public License Version
4  * 1.1 (the "License"); you may not use this file except in compliance with
5  * the License. You may obtain a copy of the License at
6  * http://www.mozilla.org/MPL/
7  *
8  * Software distributed under the License is distributed on an "AS IS" basis,
9  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
10  * for the specific language governing rights and limitations under the
11  * License.
12  *
13  * The Original Code is Riot.
14  *
15  * The Initial Developer of the Original Code is
16  * Neteye GmbH.
17  * Portions created by the Initial Developer are Copyright (C) 2006
18  * the Initial Developer. All Rights Reserved.
19  *
20  * Contributor(s):
21  * Felix Gnass [fgnass at neteye dot de]
22  *
23  * ***** END LICENSE BLOCK ***** */

24 package org.riotfamily.riot.job.persistence;
25
26 import java.util.ArrayList JavaDoc;
27 import java.util.Collection JavaDoc;
28 import java.util.HashMap JavaDoc;
29
30 /**
31  * @author Felix Gnass [fgnass at neteye dot de]
32  *
33  */

34 public class InMemoryJobDao implements JobDao {
35
36     private HashMap JavaDoc jobDetails = new HashMap JavaDoc();
37     
38     private HashMap JavaDoc jobLogEntries = new HashMap JavaDoc();
39     
40     public int getAverageStepTime(String JavaDoc type) {
41         return 0;
42     }
43
44     public JobDetail getJobDetail(Long JavaDoc jobId) {
45         return (JobDetail) jobDetails.get(jobId);
46     }
47
48     public Collection JavaDoc getJobDetails() {
49         return jobDetails.values();
50     }
51
52     public Collection JavaDoc getLogEntries(Long JavaDoc jobId) {
53         return (Collection JavaDoc) jobLogEntries.get(jobId);
54     }
55
56     public JobDetail getPendingJobDetail(String JavaDoc type, String JavaDoc objectId) {
57         return null;
58     }
59
60     public JobDetail getLastCompletedJobDetail(String JavaDoc type, String JavaDoc objectId) {
61         return null;
62     }
63     
64     public Collection JavaDoc getPendingJobDetails() {
65         return null;
66     }
67
68     public synchronized void log(JobLogEntry entry) {
69         ArrayList JavaDoc entries = (ArrayList JavaDoc) jobLogEntries.get(entry.getJobId());
70         if (entries == null) {
71             entries = new ArrayList JavaDoc();
72             jobLogEntries.put(entry.getJobId(), entries);
73         }
74         entries.add(entry);
75     }
76
77     public synchronized void saveJobDetail(JobDetail detail) {
78         detail.setId(new Long JavaDoc(jobDetails.size() + 1));
79         jobDetails.put(detail.getId(), detail);
80     }
81
82     public void updateJobDetail(JobDetail detail) {
83     }
84
85 }
86
Popular Tags