01: /**
02: *
03: * Bonita
04: * Copyright (C) 1999 Bull S.A.
05: * Bull 68 route de versailles 78434 Louveciennes Cedex France
06: * Further information: bonita@objectweb.org
07: *
08: * This library is free software; you can redistribute it and/or
09: * 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: DeadlinesFixedTimesJavaHook.java,v 1.1 2005/01/31 12:14:22 mvaldes Exp $
26: *
27: --------------------------------------------------------------------------
28: */package hero.client.samples;
29:
30: import java.util.ArrayList;
31:
32: import javax.security.auth.login.LoginContext;
33: import hero.client.test.SimpleCallbackHandler;
34:
35: import hero.interfaces.Constants;
36: import hero.interfaces.ProjectSession;
37: import hero.interfaces.ProjectSessionHome;
38: import hero.interfaces.ProjectSessionUtil;
39:
40: import hero.interfaces.UserSession;
41: import hero.interfaces.UserSessionHome;
42: import hero.interfaces.UserSessionUtil;
43:
44: public class DeadlinesFixedTimesJavaHook {
45:
46: static public void main(String[] args) throws Exception {
47: // Admin login
48: char[] password = { 't', 'o', 't', 'o' };
49: SimpleCallbackHandler handler = new SimpleCallbackHandler(
50: "admin", password);
51: LoginContext lc = new LoginContext("TestClient", handler);
52: lc.login();
53:
54: ProjectSessionHome projectSessionh = ProjectSessionUtil
55: .getHome();
56: UserSessionHome usersh = UserSessionUtil.getHome();
57: UserSession usr = usersh.create();
58:
59: ProjectSession pss = projectSessionh.create();
60: pss.initModel("LoadJavaHookFixed");
61:
62: pss.addNode("node1", Constants.Nd.AND_JOIN_NODE);
63: pss.setNodeRole("node1", "admin");
64: pss.addNode("node2", Constants.Nd.AND_JOIN_NODE);
65: pss.addEdge("node1", "node2");
66:
67: // set absolute collection of deadlines
68: ArrayList ar = new ArrayList();
69: long date1 = System.currentTimeMillis() + (long) 60000;
70: long date2 = System.currentTimeMillis() + (long) 80000;
71: ar.add(new Long(date1));
72: ar.add(new Long(date2));
73: pss.setNodeDeadlines("node1", ar);
74:
75: pss.addNodeHook("node1", "hero.hook.TestDeadlines",
76: hero.interfaces.Constants.Nd.ONDEADLINE,
77: Constants.Hook.JAVA);
78:
79: String instName = pss.instantiateProject("LoadJavaHookFixed");
80:
81: usr.startActivity(instName, "node1");
82:
83: System.out
84: .println("Wait about 60 sec until the Fixed Deadlines hooks are executed...");
85: }
86: }
|