1 package org.kuali.mobility.push.dao;
2
3 import java.util.List;
4
5 import org.apache.log4j.Logger;
6 import org.kuali.mobility.push.entity.PushDeviceTuple;
7 import org.kuali.mobility.push.service.PushService;
8 import org.springframework.beans.factory.annotation.Autowired;
9
10
11
12
13
14
15
16
17 public class PushInitBean {
18
19
20 private static final Logger LOG = Logger.getLogger(PushInitBean.class);
21
22
23
24
25 @Autowired
26 private PushService pushService;
27
28
29
30
31 public void checkPushes() {
32 try{
33 List<PushDeviceTuple> tuplelist = this.pushService.findUnsentPushTuples();
34 int numberOfPendingPushes = tuplelist.size();
35 if(numberOfPendingPushes > 0){
36 LOG.info("Checked for unsent Push notifications, found " + numberOfPendingPushes + " pending push notification.");
37 pushService.sendPush(tuplelist);
38 }else{
39 LOG.info("Checked for unsent Push notifications, found 0 pending push notifications.");
40 }
41 }catch(Exception e){
42 LOG.error("Exception while running Task", e);
43 }
44 }
45
46
47
48
49
50 public void setPushService(PushService pushService){
51 this.pushService = pushService;
52 }
53 }