KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > test > orb > policies > TimingServerImpl


1 package org.jacorb.test.orb.policies;
2
3 import org.jacorb.test.EmptyException;
4 import org.jacorb.test.TimingServerPOA;
5 import org.omg.CORBA.portable.InputStream JavaDoc;
6 import org.omg.CORBA.portable.OutputStream JavaDoc;
7 import org.omg.CORBA.portable.ResponseHandler JavaDoc;
8
9 public class TimingServerImpl extends TimingServerPOA
10 {
11     public int operation(int id, int delay)
12     {
13         synchronized (this)
14         {
15             try
16             {
17                 if (delay > 0) this.wait (delay);
18             }
19             catch (InterruptedException JavaDoc ex)
20             {
21                 System.out.println ("wait interrupted");
22             }
23         }
24         return id;
25     }
26
27     public char ex_op(char ch, int delay) throws EmptyException
28     {
29         synchronized (this)
30         {
31             try
32             {
33                 if (delay > 0) this.wait (delay);
34             }
35             catch (InterruptedException JavaDoc ex)
36             {
37                 System.out.println ("wait interrupted");
38             }
39         }
40         if (ch == 'e')
41             throw new EmptyException();
42         else if (ch == '$')
43             return '\u20AC'; // euro sign, will raise DATA_CONVERSION
44
else
45             return ch;
46     }
47
48     public long server_time(int delay)
49     {
50         long time = System.currentTimeMillis();
51         synchronized (this)
52         {
53             try
54             {
55                 if (delay > 0) this.wait (delay);
56             }
57             catch (InterruptedException JavaDoc ex)
58             {
59                 System.out.println ("wait interrupted");
60             }
61         }
62         return time;
63     }
64 }
65
Popular Tags