KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > test > common > TestServer_before_2_2


1 package org.jacorb.test.common;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1997-2002 Gerald Brose.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */

22
23 import org.omg.CORBA.*;
24 import org.omg.PortableServer.*;
25 import java.io.*;
26
27 /**
28  * This is a version of the TestServer class that works for JacORB prior
29  * to version 2.2.
30  * <p>
31  * @author Andre Spiegel <spiegel@gnu.org>
32  * @version $Id: TestServer_before_2_2.java,v 1.1 2005/05/13 13:07:57 andre.spiegel Exp $
33  */

34 public class TestServer_before_2_2
35 {
36     public static void main (String JavaDoc[] args)
37     {
38         try
39         {
40             //init ORB
41
ORB orb = ORB.init( args, null );
42
43             //init POA
44
POA poa =
45                 POAHelper.narrow( orb.resolve_initial_references( "RootPOA" ));
46             poa.the_POAManager().activate();
47
48             String JavaDoc className = args[0];
49             Class JavaDoc servantClass = Class.forName (className);
50             Servant servant = ( Servant ) servantClass.newInstance();
51
52             // create the object reference
53
org.omg.CORBA.Object JavaDoc obj = poa.servant_to_reference( servant );
54
55             System.out.println ("SERVER IOR: " + orb.object_to_string(obj));
56             System.out.flush();
57
58             // wait for requests
59
orb.run();
60         }
61         catch( Exception JavaDoc e )
62         {
63             System.err.println ("ERROR " + e);
64         }
65     }
66 }
67
Popular Tags