KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > interceptor > client_flow > Server


1 package test.interceptor.client_flow;
2
3 import java.io.*;
4
5 import org.omg.CORBA.*;
6 import org.omg.PortableServer.*;
7
8 class TestObjectImpl
9     extends TestObjectPOA
10 {
11     
12     public void foo()
13     {
14         System.out.println("Server recv foo");
15     }
16 }
17
18 public class Server
19 {
20     public static ORB orb = null;
21
22     public static void main(String JavaDoc[] args)
23     {
24         if( args.length != 1 )
25     {
26             System.out.println(
27                 "Usage: jaco test.interceptor.ctx_passing.Server <ior_file>");
28             System.exit( 1 );
29         }
30
31         try
32         {
33 // System.setProperty( "org.omg.PortableInterceptor.ORBInitializerClass.a",
34
// "test.interceptor.ctx_passing.ServerInitializer" );
35
//init ORB
36
orb = ORB.init( args, null );
37
38         //init POA
39
POA poa =
40                 POAHelper.narrow( orb.resolve_initial_references( "RootPOA" ));
41
42         poa.the_POAManager().activate();
43     
44             // create the object reference
45
org.omg.CORBA.Object JavaDoc obj =
46                 poa.servant_to_reference( new TestObjectImpl() );
47
48             PrintWriter pw =
49                 new PrintWriter( new FileWriter( args[ 0 ] ));
50
51             // print stringified object reference to file
52
pw.println( orb.object_to_string( obj ));
53             
54             pw.flush();
55             pw.close();
56     
57             // wait for requests
58
orb.run();
59         }
60         catch( Exception JavaDoc e )
61         {
62             System.out.println( e );
63         }
64     }
65 }
66
Popular Tags