1 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 26 public class AlertServiceImpl implements AlertService { 27 28 public List getConsoleAlerts(ServiceContext context) 29 throws ServiceException { 30 31 List alerts = new LinkedList(); 32 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 o1, Object 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 alertId) { 55 ConsoleAlerts.getInstance().remove(alertId); 56 } 57 } 58 | Popular Tags |