KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > rmi > clt > ClientImpl


1 /***
2  * Julia: France Telecom's implementation of the Fractal API
3  * Copyright (C) 2001-2002 France Telecom R&D
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: Eric.Bruneton@rd.francetelecom.com
20  *
21  * Author: Eric Bruneton
22  */

23
24 package rmi.clt;
25
26 import org.objectweb.fractal.api.control.BindingController;
27
28 public class ClientImpl implements Main, BindingController {
29
30   private Service service;
31
32   public ClientImpl () {
33     System.err.println("CLIENT CREATED");
34   }
35
36   public void main (final String JavaDoc[] args) {
37     service.print("hello world");
38     ///*
39
int l = 0;
40     float n = 0;
41     float total = 0;
42     while (true) {
43       long t = System.currentTimeMillis();
44       for (int i = 0; i < 10000; ++i) {
45         service.init();
46       }
47       float d = System.currentTimeMillis() - t;
48       ++l;
49       if (l > 5) {
50         d = d/10000f;
51         n = n + 1;
52         total = total + d;
53         System.err.println(
54           "empty remote method call: " + d + " ms (mean = " + total/n+ ")");
55       }
56     }
57     //*/
58
}
59
60   public String JavaDoc[] listFc () {
61     return new String JavaDoc[] { "s" };
62   }
63
64   public Object JavaDoc lookupFc (final String JavaDoc cItf) {
65     if (cItf.equals("s")) {
66       return service;
67     }
68     return null;
69   }
70
71   public void bindFc (final String JavaDoc cItf, final Object JavaDoc sItf) {
72     if (cItf.equals("s")) {
73       service = (Service)sItf;
74     }
75   }
76
77   public void unbindFc (final String JavaDoc cItf) {
78     if (cItf.equals("s")) {
79       service = null;
80     }
81   }
82 }
83
Popular Tags