KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hero > hook > TestDeadlines


1 /**
2  *
3  * Bonita
4  * Copyright (C) 1999 Bull S.A.
5  * Bull 68 route de versailles 78434 Louveciennes Cedex France
6  * Further information: bonita@objectweb.org
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21  * USA
22  *
23  *
24 --------------------------------------------------------------------------
25  * $Id: TestDeadlines.java,v 1.1 2005/01/31 12:15:06 mvaldes Exp $
26  *
27 --------------------------------------------------------------------------
28  */

29
30
31 package hero.hook;
32
33 import java.sql.Date JavaDoc;
34 import java.util.Calendar JavaDoc;
35 import java.util.Collection JavaDoc;
36 import java.util.GregorianCalendar JavaDoc;
37 import java.util.Iterator JavaDoc;
38
39 import hero.util.HeroHookException;
40 import hero.interfaces.BnNodeLocal;
41
42
43 public class TestDeadlines implements hero.hook.NodeHookI {
44
45     public void create(Object JavaDoc b,BnNodeLocal n) throws HeroHookException {
46
47     }
48
49     public void beforeStart(Object JavaDoc b,BnNodeLocal n) throws HeroHookException {
50     }
51     public void afterStart(Object JavaDoc b,BnNodeLocal n) throws HeroHookException {
52     }
53     public void beforeTerminate(Object JavaDoc b,BnNodeLocal n) throws HeroHookException {}
54     public void afterTerminate(Object JavaDoc b,BnNodeLocal n) throws HeroHookException {}
55     public void onCancel(Object JavaDoc b,BnNodeLocal n) throws HeroHookException {}
56     public void anticipate(Object JavaDoc b,BnNodeLocal n) throws HeroHookException {}
57     public void onReady(Object JavaDoc b,BnNodeLocal n) throws HeroHookException {}
58     public void onDeadline(Object JavaDoc b,BnNodeLocal n) throws HeroHookException {
59     try{
60         String JavaDoc name=n.getName();
61         if (n.getDeadlines().size()!=0){
62             Collection JavaDoc co = n.getDeadlines();
63             Iterator JavaDoc it = co.iterator();
64             System.out.println("Deadlines Test, node name: "+name);
65             System.out.println("One of the following deadline has been executed");
66             while (it.hasNext()){
67                 Date JavaDoc date = (Date JavaDoc)it.next();
68                 long lt = date.getTime();
69                 Calendar JavaDoc calendar = new GregorianCalendar JavaDoc();
70                 calendar.setTime(date);
71                 System.out.println("date (long) = " + lt + " - date (YY/MM/DD/HH/MM/SS)= " + calendar.get(Calendar.YEAR) + "/" + calendar.get(Calendar.MONTH) + "/" +
72                         calendar.get(Calendar.DAY_OF_MONTH) + "/" + calendar.get(Calendar.HOUR) + "/" + calendar.get(Calendar.MINUTE) +
73                         "/" + calendar.get(Calendar.SECOND));
74             }
75         }
76         if (n.getRelativeDeadlines().size()!=0){
77             Collection JavaDoc co = n.getRelativeDeadlines();
78             Iterator JavaDoc it = co.iterator();
79             System.out.println("Deadlines Test, node name: "+name);
80             System.out.println("One of the following relative deadline has been executed");
81             while (it.hasNext()){
82                 Date JavaDoc date = (Date JavaDoc)it.next();
83                 long lt = date.getTime();
84                 Calendar JavaDoc calendar = new GregorianCalendar JavaDoc();
85                 calendar.setTime(date);
86                 System.out.println("date (long) = " + lt + " - date (YY/MM/DD/HH/MM/SS) = " + calendar.get(Calendar.YEAR) + "/" + calendar.get(Calendar.MONTH) + "/" +
87                         calendar.get(Calendar.DAY_OF_MONTH) + "/" + calendar.get(Calendar.HOUR) + "/" + calendar.get(Calendar.MINUTE) +
88                         "/" + calendar.get(Calendar.SECOND));
89             }
90         }
91     }catch(Exception JavaDoc e){e.printStackTrace();}
92     }
93
94 }
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
Popular Tags