KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > benchmark > fractal > latency > ClientLauncher


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA - USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Christophe Demarey.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.benchmark.fractal.latency;
28
29 // Package dependencies.
30
import java.util.HashMap JavaDoc;
31 import java.util.Map JavaDoc;
32 import java.util.Properties JavaDoc;
33
34 import org.objectweb.fractal.adl.Factory;
35 import org.objectweb.fractal.adl.FactoryFactory;
36 import org.objectweb.fractal.api.Component;
37 import org.objectweb.fractal.rmi.registry.NamingService;
38 import org.objectweb.fractal.rmi.registry.Registry;
39 import org.objectweb.fractal.util.Fractal;
40
41 /**
42  * This class looks up for server bootstrap,
43  * instantiates the assembly,
44  * and start the root component.
45  *
46  * @author <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</a>
47  *
48  * @version 0.1
49  */

50 public class ClientLauncher
51 {
52     public static void main(String JavaDoc[] args)
53     {
54         String JavaDoc name = "org.objectweb.benchmark.fractal.latency.Latency";
55         NamingService ns = null;
56         Component client = null;
57         Properties JavaDoc properties = new Properties JavaDoc();
58         String JavaDoc host = null;
59
60         // Get host name
61
try {
62             java.io.InputStream JavaDoc propStream = null;
63         
64             // Bench info
65
propStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("benchmark.properties");
66             properties.load(propStream);
67             host = properties.getProperty("com.host");
68         } catch (Exception JavaDoc e) {
69             e.printStackTrace();
70         }
71         
72         // Runs the assembly
73
try{
74             System.setSecurityManager(new SecurityManager JavaDoc());
75             
76             ns = Registry.getRegistry(host);
77             
78             Map JavaDoc context = new HashMap JavaDoc();
79             context.put("remote-node", ns.lookup("PingServer"));
80             
81             Factory f = FactoryFactory.getFactory(FactoryFactory.FRACTAL_BACKEND);
82             client = (Component) f.newComponent(name, context);
83             
84             // start root component
85
Fractal.getLifeCycleController(client).startFc();
86             Runnable JavaDoc r = (Runnable JavaDoc) client.getFcInterface("Runnable");
87             r.run();
88             Fractal.getLifeCycleController(client).stopFc();
89             System.out.println("Client stopped");
90         }catch(Exception JavaDoc ex){
91             ex.printStackTrace();
92         }
93     }
94 }
95
Popular Tags