1 29 30 package hero.client.samples; 31 32 import java.util.ArrayList ; 33 34 import javax.security.auth.login.LoginContext ; 35 import hero.client.test.SimpleCallbackHandler; 36 37 import hero.interfaces.Constants; 38 import hero.interfaces.ProjectSession; 39 import hero.interfaces.ProjectSessionHome; 40 import hero.interfaces.ProjectSessionUtil; 41 42 import hero.interfaces.UserSession; 43 import hero.interfaces.UserSessionHome; 44 import hero.interfaces.UserSessionUtil; 45 46 public class DeadlinesMixedTimesJavaHook { 47 48 static public void main(String [] args) throws Exception { 49 char[] password={'t','o','t','o'}; 51 SimpleCallbackHandler handler = new SimpleCallbackHandler("admin",password); 52 LoginContext lc = new LoginContext ("TestClient", handler); 53 lc.login(); 54 55 ProjectSessionHome projectSessionh=ProjectSessionUtil.getHome(); 56 UserSessionHome usersh=UserSessionUtil.getHome(); 57 UserSession usr=usersh.create(); 58 59 ProjectSession pss=projectSessionh.create(); 60 pss.initModel("LoadJavaHookMixed"); 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 ArrayList ar = new ArrayList (); 69 long date1 = System.currentTimeMillis()+(long)60000; 70 ar.add(new Long (date1)); 71 pss.setNodeDeadlines("node1",ar); 72 73 ArrayList ar2 = new ArrayList (); 75 long relDate1 = (long)80000; 76 ar2.add(new Long (relDate1)); 77 pss.setNodeRelativeDeadlines("node1",ar2); 78 79 pss.addNodeHook("node1","hero.hook.TestDeadlines",hero.interfaces.Constants.Nd.ONDEADLINE,Constants.Hook.JAVA); 80 81 String instName=pss.instantiateProject("LoadJavaHookMixed"); 82 83 usr.startActivity(instName,"node1"); 84 85 System.out.println("Wait about 60 sec until the Fixed and Relative Deadlines hooks are executed..."); 86 } 87 } 88 89 90 | Popular Tags |