KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > test > orb > CallbackServerImpl


1 package org.jacorb.test.orb;
2
3 import org.jacorb.test.CallbackServerPOA;
4 import org.jacorb.test.EmptyException;
5 import org.jacorb.test.NonEmptyException;
6 import org.omg.CORBA.CharHolder JavaDoc;
7 import org.omg.CORBA.IntHolder JavaDoc;
8 import org.omg.CORBA.portable.InputStream JavaDoc;
9 import org.omg.CORBA.portable.OutputStream JavaDoc;
10 import org.omg.CORBA.portable.ResponseHandler JavaDoc;
11
12 public class CallbackServerImpl extends CallbackServerPOA
13 {
14
15     public void ping()
16     {
17         return;
18     }
19
20     public void delayed_ping(int delay)
21     {
22         delay( delay );
23         return;
24     }
25
26     public void pass_in_char(char x, int delay)
27     {
28         delay( delay );
29     }
30
31     public char return_char(short unicode_number, int delay)
32     {
33         delay( delay );
34         return ( char ) unicode_number;
35     }
36
37     public int operation(CharHolder JavaDoc p1, IntHolder JavaDoc p2, boolean p3, int delay)
38     {
39         delay( delay );
40         p1.value = Character.toUpperCase(p1.value);
41         if ( p3 )
42             p2.value = 1234;
43         else
44             p2.value = 4321;
45         return p2.value;
46     }
47
48
49
50     private synchronized void delay( long time )
51     {
52         try
53         {
54             wait( time );
55         }
56         catch( InterruptedException JavaDoc e )
57         {
58             throw new RuntimeException JavaDoc( "delay interrupted" );
59         }
60     }
61
62     public void ex_1( boolean do_it, int delay ) throws EmptyException
63     {
64         delay( delay );
65         if ( do_it )
66             throw new EmptyException();
67         else
68             return;
69     }
70
71     public int ex_2( IntHolder JavaDoc p, boolean do_it, int delay )
72         throws NonEmptyException
73     {
74         delay( delay );
75         if ( do_it )
76             throw new NonEmptyException( "just do it", p.value, "xxx" );
77         else
78             return p.value;
79     }
80
81     public void ex_3( boolean non_empty, int delay )
82         throws NonEmptyException, EmptyException
83     {
84         delay( delay );
85         if ( non_empty )
86             throw new NonEmptyException( 4321, "zzz" );
87         else
88             throw new EmptyException( "reason" );
89     }
90
91 }
92
Popular Tags