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 DeadlinesFixedTimesJavaHook { 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("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 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",hero.interfaces.Constants.Nd.ONDEADLINE,Constants.Hook.JAVA); 76 77 String instName=pss.instantiateProject("LoadJavaHookFixed"); 78 79 usr.startActivity(instName,"node1"); 80 81 System.out.println("Wait about 60 sec until the Fixed Deadlines hooks are executed..."); 82 } 83 } 84 85 86 | Popular Tags |