KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hero > client > samples > LoadReadyHook


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: LoadReadyHook.java,v 1.2 2005/03/30 15:16:56 mvaldes Exp $
26  *
27 --------------------------------------------------------------------------
28  */

29
30 package hero.client.samples;
31
32 import javax.security.auth.login.LoginContext JavaDoc;
33
34 import hero.client.test.SimpleCallbackHandler;
35
36 import hero.interfaces.Constants;
37 import hero.interfaces.ProjectSession;
38 import hero.interfaces.ProjectSessionHome;
39 import hero.interfaces.ProjectSessionUtil;
40
41 import hero.interfaces.UserSession;
42 import hero.interfaces.UserSessionHome;
43 import hero.interfaces.UserSessionUtil;
44
45 public class LoadReadyHook {
46     
47     static public void main(String JavaDoc[] args) throws Exception JavaDoc{
48         // Admin login
49
char[] password={'t','o','t','o'};
50         SimpleCallbackHandler handler = new SimpleCallbackHandler("admin",password);
51         LoginContext JavaDoc lc = new LoginContext JavaDoc("TestClient", handler);
52         lc.login();
53         
54         ProjectSessionHome projectSessionh=ProjectSessionUtil.getHome();
55         UserSessionHome usersh=UserSessionUtil.getHome();
56         UserSession usr=usersh.create();
57         
58         ProjectSession pss=projectSessionh.create();
59         pss.initModel("LoadReadyHook");
60         
61         pss.addNode("node1",Constants.Nd.AND_JOIN_NODE);
62         pss.setNodeRole("node1","admin");
63         pss.addNode("node2",Constants.Nd.AND_JOIN_NODE);
64         pss.setNodeTraditional("node2");
65         pss.setNodeRole("node2","admin");
66         pss.addEdge("node1","node2");
67         pss.addNodeHook("node2","hero.hook.TestReady",hero.interfaces.Constants.Nd.ONREADY,Constants.Hook.JAVA);
68         
69         String JavaDoc instance = pss.instantiateProject("LoadReadyHook");
70         usr.startActivity(instance,"node1");
71         usr.terminateActivity(instance,"node1");
72     }
73 }
74
75
76
Popular Tags