KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmanage > core > services > AlertServiceImpl


1 /**
2 * Copyright (c) 2004-2005 jManage.org
3 *
4 * This is a free software; you can redistribute it and/or
5 * modify it under the terms of the license at
6 * http://www.jmanage.org.
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */

14 package org.jmanage.core.services;
15
16 import org.jmanage.core.alert.delivery.ConsoleAlerts;
17 import org.jmanage.core.alert.AlertInfo;
18
19 import java.util.*;
20
21 /**
22  *
23  * Date: Aug 3, 2005
24  * @author Rakesh Kalra
25  */

26 public class AlertServiceImpl implements AlertService {
27
28     public List getConsoleAlerts(ServiceContext context)
29             throws ServiceException {
30
31         List alerts = new LinkedList();
32         // create a copy
33
for(Iterator it=ConsoleAlerts.getInstance().getAll().iterator(); it.hasNext();){
34             alerts.add(it.next());
35         }
36         Collections.sort(alerts, new Comparator(){
37             public int compare(Object JavaDoc o1, Object JavaDoc o2) {
38                 AlertInfo info1 = (AlertInfo)o1;
39                 AlertInfo info2 = (AlertInfo)o2;
40                 if(info1.getTimeStamp() == info2.getTimeStamp()){
41                     return 0;
42                 }else if(info1.getTimeStamp() < info2.getTimeStamp()){
43                     return -1;
44                 }else{
45                     return 1;
46                 }
47             }
48         });
49
50         return alerts;
51     }
52
53     public void removeConsoleAlert(ServiceContext context,
54                                    String JavaDoc alertId) {
55         ConsoleAlerts.getInstance().remove(alertId);
56     }
57 }
58
Popular Tags