/[classpath]/classpath/gnu/CORBA/NamingService/NamingServiceTransient.java
ViewVC logotype

Diff of /classpath/gnu/CORBA/NamingService/NamingServiceTransient.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.2.2 by gnu_andrew, Tue Aug 2 20:12:08 2005 UTC revision 1.1.2.3 by gnu_andrew, Sat Sep 10 15:31:36 2005 UTC
# Line 39  exception statement from your version. * Line 39  exception statement from your version. *
39  package gnu.CORBA.NamingService;  package gnu.CORBA.NamingService;
40    
41  import gnu.CORBA.Functional_ORB;  import gnu.CORBA.Functional_ORB;
42    import gnu.CORBA.IOR;
43    
44  import org.omg.CosNaming.NamingContextExt;  import org.omg.CosNaming.NamingContextExt;
45    
# Line 47  import java.io.PrintStream; Line 48  import java.io.PrintStream;
48  import java.io.UnsupportedEncodingException;  import java.io.UnsupportedEncodingException;
49    
50  /**  /**
51   * The server for the gnu classpath naming service. This is an executable   * The server for the gnu classpath naming service. This is an executable class
52   * class that must be started to launch the GNU Classpath CORBA   * that must be started to launch the GNU Classpath CORBA transient naming
53   * transient naming service.   * service.
54   *   *
55   * GNU Classpath currently works with this naming service and is also   * GNU Classpath currently works with this naming service and is also
56   * interoperable with the Sun Microsystems naming services from   * interoperable with the Sun Microsystems naming services from releases 1.3 and
57   * releases 1.3 and 1.4, both transient <i>tnameserv</i> and persistent   * 1.4, both transient <i>tnameserv</i> and persistent <i>orbd</i>.
58   * <i>orbd</i>.   *
  *  
59   * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)   * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
60   */   */
61  public class NamingServiceTransient  public class NamingServiceTransient
# Line 67  public class NamingServiceTransient Line 67  public class NamingServiceTransient
67    public static final int PORT = 900;    public static final int PORT = 900;
68    
69    /**    /**
70     * Get the object key for the naming service. The default     * Get the object key for the naming service. The default key is the string
71     * key is the string "NameService" in ASCII.     * "NameService" in ASCII.
72     *     *
73     * @return the byte array.     * @return the byte array.
74     */     */
75    public static byte[] getDefaultKey()    public static byte[] getDefaultKey()
# Line 85  public class NamingServiceTransient Line 85  public class NamingServiceTransient
85    }    }
86    
87    /**    /**
88     * Start the naming service on the current host at the given port.     * Start the naming service on the current host at the given port. The
89     * The parameter  -org.omg.CORBA.ORBInitialPort NNN or     * parameter -org.omg.CORBA.ORBInitialPort NNN or -ORBInitialPort NNN, if
90     *  -ORBInitialPort NNN, if present, specifies the port, on that     * present, specifies the port, on that the service must be started. If this
91     * the service must be started. If this key is not specified,     * key is not specified, the service starts at the port 900.
92     * the service starts at the port 900.     *
93     *     * The parameter -ior FILE_NAME, if present, forces to store the ior string of
94     * The parameter -ior FILE_NAME, if present, forces to store the ior string     * this naming service to the specified file.
95     * of this naming service to the specified file.     *
    *  
96     * @param args the parameter string.     * @param args the parameter string.
97     */     */
98    public static void main(String[] args)    public static void main(String[] args)
# Line 108  public class NamingServiceTransient Line 107  public class NamingServiceTransient
107          if (args.length > 1)          if (args.length > 1)
108            for (int i = 0; i < args.length - 1; i++)            for (int i = 0; i < args.length - 1; i++)
109              {              {
110                if (args [ i ].endsWith("ORBInitialPort"))                if (args[i].endsWith("ORBInitialPort"))
111                  port = Integer.parseInt(args [ i + 1 ]);                  port = Integer.parseInt(args[i + 1]);
112    
113                if (args [ i ].equals("-ior"))                if (args[i].equals("-ior"))
114                  iorf = args [ i + 1 ];                  iorf = args[i + 1];
115              }              }
116    
117          Functional_ORB.setPort(port);          Functional_ORB.setPort(port);
118    
119          // Create the servant and register it with the ORB          // Create the servant and register it with the ORB
120          NamingContextExt namer = new Ext(new TransientContext());          NamingContextExt namer = new Ext(new TransientContext());
121          orb.connect(namer, getDefaultKey());  
122            // Case with the key "NameService".
123            orb.connect(namer, "NameService".getBytes());
124    
125          // Storing the IOR reference.          // Storing the IOR reference.
126          String ior = orb.object_to_string(namer);          String ior = orb.object_to_string(namer);
127            IOR iorr = IOR.parse(ior);
128          if (iorf != null)          if (iorf != null)
129            {            {
130              FileOutputStream f = new FileOutputStream(iorf);              FileOutputStream f = new FileOutputStream(iorf);
# Line 131  public class NamingServiceTransient Line 133  public class NamingServiceTransient
133              p.close();              p.close();
134            }            }
135    
136          System.out.println("GNU Classpath, transient naming service. " +          System.out.println("GNU Classpath transient naming service "
137                             "Copyright (C) 2005 Free Software Foundation\n" +            + "started at " + iorr.Internet.host + ":" + iorr.Internet.port
138                             "This tool comes with ABSOLUTELY NO WARRANTY. " +            + " key 'NameService'.\n\n"
139                             "This is free software, and you are\nwelcome to " +            + "Copyright (C) 2005 Free Software Foundation\n"
140                             "redistribute it under conditions, defined in " +            + "This tool comes with ABSOLUTELY NO WARRANTY. "
141                             "GNU Classpath license.\n\n" + ior            + "This is free software, and you are\nwelcome to "
142                            );            + "redistribute it under conditions, defined in "
143              + "GNU Classpath license.\n\n" + ior);
144    
145          new Thread()          new Thread()
146            {
147              public void run()
148            {            {
149              public void run()              // Wait for invocations from clients.
150              {              orb.run();
151                // Wait for invocations from clients.            }
152                orb.run();          }.start();
             }  
           }.start();  
153        }        }
154      catch (Exception e)      catch (Exception e)
155        {        {
# Line 154  public class NamingServiceTransient Line 157  public class NamingServiceTransient
157          e.printStackTrace(System.out);          e.printStackTrace(System.out);
158        }        }
159    
160      // Restore the default value for allocating ports for the subsequent objects.      // Restore the default value for allocating ports for the subsequent
161        // objects.
162      Functional_ORB.setPort(Functional_ORB.DEFAULT_INITIAL_PORT);      Functional_ORB.setPort(Functional_ORB.DEFAULT_INITIAL_PORT);
163    }    }
164  }  }

Legend:
Removed from v.1.1.2.2  
changed lines
  Added in v.1.1.2.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26