001: /**
002: *
003: * Bonita
004: * Copyright (C) 1999 Bull S.A.
005: * Bull 68 route de versailles 78434 Louveciennes Cedex France
006: * Further information: bonita@objectweb.org
007: *
008: * This library is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU Lesser General Public
010: * License as published by the Free Software Foundation; either
011: * version 2.1 of the License, or any later version.
012: *
013: * This library is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public
019: * License along with this library; if not, write to the Free Software
020: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
021: * USA
022: *
023: *
024: --------------------------------------------------------------------------
025: * $Id: TestDeadlines.java,v 1.4 2006/05/17 17:39:37 mvaldes Exp $
026: *
027: --------------------------------------------------------------------------
028: */package hero.hook;
029:
030: import java.sql.Date;
031: import java.sql.Timestamp;
032: import java.util.Calendar;
033: import java.util.Collection;
034: import java.util.GregorianCalendar;
035: import java.util.Iterator;
036:
037: import hero.util.HeroHookException;
038: import hero.interfaces.BnNodeLocal;
039: import hero.interfaces.Constants;
040:
041: public class TestDeadlines implements hero.hook.NodeHookI {
042:
043: public String getMetadata() {
044: return Constants.Nd.ONDEADLINE;
045: }
046:
047: public void create(Object b, BnNodeLocal n)
048: throws HeroHookException {
049:
050: }
051:
052: public void beforeStart(Object b, BnNodeLocal n)
053: throws HeroHookException {
054: }
055:
056: public void afterStart(Object b, BnNodeLocal n)
057: throws HeroHookException {
058: }
059:
060: public void beforeTerminate(Object b, BnNodeLocal n)
061: throws HeroHookException {
062: }
063:
064: public void afterTerminate(Object b, BnNodeLocal n)
065: throws HeroHookException {
066: }
067:
068: public void onCancel(Object b, BnNodeLocal n)
069: throws HeroHookException {
070: }
071:
072: public void anticipate(Object b, BnNodeLocal n)
073: throws HeroHookException {
074: }
075:
076: public void onReady(Object b, BnNodeLocal n)
077: throws HeroHookException {
078: }
079:
080: public void onDeadline(Object b, BnNodeLocal n)
081: throws HeroHookException {
082: try {
083: String name = n.getName();
084: if (n.getDeadlines().size() != 0) {
085: Collection co = n.getDeadlines();
086: Iterator it = co.iterator();
087: System.out
088: .println("Deadlines Test, node name: " + name);
089: System.out
090: .println("One of the following deadline has been executed");
091: while (it.hasNext()) {
092: Timestamp date = (Timestamp) it.next();
093: long lt = date.getTime();
094: Calendar calendar = new GregorianCalendar();
095: calendar.setTime(date);
096: System.out.println("date (long) = " + lt
097: + " - date (YY/MM/DD/HH/MM/SS)= "
098: + calendar.get(Calendar.YEAR) + "/"
099: + calendar.get(Calendar.MONTH) + "/"
100: + calendar.get(Calendar.DAY_OF_MONTH) + "/"
101: + calendar.get(Calendar.HOUR) + "/"
102: + calendar.get(Calendar.MINUTE) + "/"
103: + calendar.get(Calendar.SECOND));
104: }
105: }
106: if (n.getRelativeDeadlines().size() != 0) {
107: Collection co = n.getRelativeDeadlines();
108: Iterator it = co.iterator();
109: System.out
110: .println("Deadlines Test, node name: " + name);
111: System.out
112: .println("One of the following relative deadline has been executed");
113: while (it.hasNext()) {
114: Timestamp date = (Timestamp) it.next();
115: long lt = date.getTime();
116: Calendar calendar = new GregorianCalendar();
117: calendar.setTime(date);
118: System.out.println("date (long) = " + lt
119: + " - date (YY/MM/DD/HH/MM/SS) = "
120: + calendar.get(Calendar.YEAR) + "/"
121: + calendar.get(Calendar.MONTH) + "/"
122: + calendar.get(Calendar.DAY_OF_MONTH) + "/"
123: + calendar.get(Calendar.HOUR) + "/"
124: + calendar.get(Calendar.MINUTE) + "/"
125: + calendar.get(Calendar.SECOND));
126: }
127: }
128: } catch (Exception e) {
129: e.printStackTrace();
130: }
131: }
132:
133: }
|