0% found this document useful (0 votes)
12 views

Exo Cosnaming

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Exo Cosnaming

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

#!

/bin/sh
# Try to find top−level directory
if test −f naming/src/com/ooc/CosNaming/Server.java
then top_srcdir=naming
elif test −f src/com/ooc/CosNaming/Server.java
then top_srcdir=.
elif test −f ../src/com/ooc/CosNaming/Server.java
then top_srcdir=..
elif test −f ../../src/com/ooc/CosNaming/Server.java
then top_srcdir=../..
elif test −f ../../../src/com/ooc/CosNaming/Server.java
then top_srcdir=../../..
elif test −f ../../../../src/com/ooc/CosNaming/Server.java
then top_srcdir=../../../..
else
$echo "$0: can’t find top−level directory"
exit
fi
# Run standard init script
. $top_srcdir/../config/sh.init
# Check for the C++ distribution
have_cpp=if test −n "$OB_CPP_DIST" −a −x "$OB_CPP_DIST/naming/bin/nameserv"
then have_cpp="yes"
fi
# JDK 1.2 users may encounter an IncompatibleClassChangeError exception due to an incompatibility
# with the JDK’s builtin stubs for the Naming Service. We’ll use the −Xbootclasspath option to
# avoid this problem.
java_version=‘$JAVA −version 2>&1‘
if ‘$echo $java_version | grep −q ’1\.2’‘
then
# For JDK 1.2, we can use the −Xbootclasspath/p option to prepend classes to the bootclasspath.
if test "$windows" = "yes"
then BOOTCLASSPATH="−Xbootclasspath/p:$top_srcdir/lib;$OB_LIB"
else BOOTCLASSPATH="−Xbootclasspath/p:$top_srcdir/lib:$OB_LIB"
fi
fi
# Set Java CLASSPATH
if test "$windows" = "yes"
then
CLASSPATH="$top_srcdir/demo/classes;$CLASSPATH"
CLASSPATH="$top_srcdir/lib;$CLASSPATH"
CLASSPATH="$OB_LIB;$CLASSPATH"
else
CLASSPATH="$top_srcdir/demo/classes:$CLASSPATH"
CLASSPATH="$top_srcdir/lib:$CLASSPATH"
CLASSPATH="$OB_LIB:$CLASSPATH"
fi
export CLASSPATH
# Print welcome message
$echo "* ORBacus NamingService Demo *"
# Ask for server
server=while test −z "$server"
do
$echo
$echo "Select NamingService to use:"
$echo
if test −n "$have_cpp"
then $echo "1: C++ NamingService"
else $echo "1: C++ NamingService (not available)"
fi
$echo "2: Java NamingService"
$echo
$echo "−−−> \c"
read num
if test "$num" = "1" −a −n "$have_cpp"
then server="$OB_CPP_DIST/naming/bin/nameserv${exe}"
fi
if test "$num" = "2"
then server="$JAVA $BOOTCLASSPATH com.ooc.CosNaming.Server"
fi
done
# Set name of reference file
ref=Naming.ref
# Function to deactivate the server
nsid=0
srvid=0
deactivate()
{
if test $nsid −ne 0
then kill $nsid
fi
if test $srvid −ne 0
then kill $srvid
fi
exit lance le serveur de nommage en arrière−
} plan avec récupération de la référence dans
# Start NamingService
$echo le fichier "Naming.ref"
$echo "Waiting for NamingService to start up... \c"
rm −f $ref
$server −−ior > $ref &
nsid=$!
trap deactivate 1 2 3 4 5 6 7 8 10 12 13 14 15
count=0
while test ! −s $ref −a $count −lt 6
do
sleep 1
count=‘expr $count + 1‘
done
if test ! −s $ref nom du service lancé avec
then les applications
$echo "Failed!" client/serveur, accompagné
$echo "(NamingService was not started)" de l’IOR associée.
exit
else $echo "OK!"
fi
# Start server
$JAVA $BOOTCLASSPATH naming.Server −ORBservice NameService ‘cat $ref‘ &
srvid=$!
sleep 3
# Start client
$JAVA $BOOTCLASSPATH naming.Client −ORBservice NameService ‘cat $ref‘
# Deactivate naming service and server
deactivate
// **********************************************************************
//
// .../JOB−4.0.4/naming/src/com/ooc/CosNaming/Server.java
//
// Ce fichier est appelé par le shell ’run" dans la démo du service de nommage ci−avant.
// **********************************************************************

package com.ooc.CosNaming;

import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import java.io.*;

final public class Server


{
static void
usage(String progName)
{
System.err.println("Usage:");
System.err.println(progName + " [options]\n" +
"\n" +
"Options:\n" +
"−h, −−help "+
"Show this message.\n" +
"−v, −−version "+
"Show Naming Service version.\n" +
"−i, −−ior "+
"Print IOR on standard output.\n" +
"−n, −−no−updates "+
"No automatic updates with ORBacus Names.\n" +
"−s, −−start "+
"Run for the first time.\n" +
"−d, −−database FILE "+
"Use FILE as the database.\n" +
"−t, −−timeout MINS "+
"Purge the database every MINS minutes.\n" +
" "+
"(The default is 5 minutes.)\n" +
"−c, −−callback−timeout SECS " +
"Timeout for callbacks in seconds.\n" +
" "+
"(The default is 5 seconds.)");
}

static int
run(org.omg.CORBA.ORB orb, String progName, String[] args,
java.util.Properties props)
{
//
// Get options
//
boolean ior = false;
NamingServiceOptions options = new NamingServiceOptions();

//
// Check properties first
//
String propRoot = "ooc.naming.";
java.util.Enumeration keys = props.propertyNames();
while(keys.hasMoreElements())
{
String key = (String)keys.nextElement();
if(!key.startsWith(propRoot))
continue;

String value = props.getProperty(key);

if(key.equals("ooc.naming.database"))
{
options.databaseName = value;
}
else if(key.equals("ooc.naming.timeout"))
{
try
{
options.databaseTimeout = Integer.parseInt(value);
}
catch(NumberFormatException ex)
{
System.err.println("Invalid value for ooc.naming.timeout");
return 1;
}
}
else if(key.equals("ooc.naming.callback_timeout"))
{
try
{
options.callbackTimeout = Integer.parseInt(value);
}
catch(NumberFormatException ex)
{
System.err.println(
"Invalid value for ooc.naming.callback_timeout");
return 1;
}
}
else if(key.equals("ooc.naming.no_updates"))
{
options.noUpdates = value.equals("true") ||
value.equals("TRUE") || value.equals("1");
}
else if(key.equals("ooc.naming.trace_level"))
{
options.traceLevel = Integer.parseInt(value);
}
else if(key.equals("ooc.naming.port"))
{
//
// Set the ooc.orb.oa.port property from this value
//
String oaPort = props.getProperty("ooc.orb.oa.port");
if (oaPort == null)
props.put("ooc.orb.oa.port", value);
}
else
{
System.err.println(progName + ": ‘" + key + "’: " +
"unknown property");
}
}

//
// Resolve Root POA
//
org.omg.CORBA.Object poaObj = null;
try
{
poaObj = orb.resolve_initial_references("RootPOA");
}
catch(org.omg.CORBA.ORBPackage.InvalidName ex)
{
throw new RuntimeException();
}
POA rootPOA = POAHelper.narrow(poaObj);

//
// Get a reference to the POA manager
//
POAManager manager = rootPOA.the_POAManager();

//
// The persistent poa
//
POA rootContextPOA = null;
POA contextPOA = null;
try
{
Policy[] policies = new org.omg.CORBA.Policy[2];
policies[0] =
rootPOA.create_lifespan_policy(
org.omg.PortableServer.LifespanPolicyValue.PERSISTENT);
policies[1] =
rootPOA.create_id_assignment_policy(
org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
rootContextPOA =
rootPOA.create_POA("RootContextPOA", manager, policies);

policies[1] =
rootPOA.create_id_assignment_policy(
org.omg.PortableServer.IdAssignmentPolicyValue.SYSTEM_ID);
contextPOA = rootPOA.create_POA("ContextPOA", manager, policies);
}
catch(org.omg.PortableServer.POAPackage.AdapterAlreadyExists ex)
{
}
catch(org.omg.PortableServer.POAPackage.InvalidPolicy ex)
{
}
com.ooc.OB.Assert.assert(rootContextPOA != null);
com.ooc.OB.Assert.assert(contextPOA != null);
for(int i = 0 ; i < args.length && args[i].startsWith("−") ; i++)
{
if(args[i].equals("−−help") || args[i].equals("−h"))
{
usage(progName);
return 0;
}
else if(args[i].equals("−−version") || args[i].equals("−v"))
{
System.err.println("ORBacus Names" +
com.ooc.OB.Version.version);
return 0;
}
else if(args[i].equals("−−ior") || args[i].equals("−i"))
{
ior = true;
}
else if(args[i].equals("−−no−updates") || args[i].equals("−n"))
{
options.noUpdates = true;
}
else if(args[i].equals("−−timeout") || args[i].equals("−t"))
{
++i;
if(i >= args.length)
{
System.err.println(progName + ": " + args[i − 1] +
"expects argument");
usage(progName);
return 1;
}

options.databaseTimeout = Integer.parseInt(args[i]);
}
else if(args[i].equals("−−callback−timeout") ||
args[i].equals("−c"))
{
++i;
if(i >= args.length)
{
System.err.println(progName + ": " + args[i − 1] +
"expects argument");
usage(progName);
return 1;
}

options.callbackTimeout = Integer.parseInt(args[i]);
}
else if(args[i].equals("−−database") ||
args[i].equals("−d"))
{
++i;
if(i >= args.length)
{
System.err.println(progName + ": " + args[i − 1] +
"expects argument");
usage(progName);
return 1;
}

options.databaseName = args[i];
}
else if(args[i].equals("−−start") || args[i].equals("−s"))
{
options.databaseExists = false;
}
else
{
System.err.println(progName + ": unknown option ‘"
+ args[i] + "’\n");
usage(progName);
return 1;
}
}

if(options.databaseTimeout <= 0)
{
System.err.println(progName + ": timeout value must be > 0");
return 1;
}

if(!options.databaseExists && options.databaseName == null)


{
System.err.println(progName + ": −−start (−s) requires the " +
"−−database (−d) option");
return 1;
}

//
// Initialize the naming service.
//
NamingService namingService = new NamingService(orb, rootContextPOA,
contextPOA, options);
namingService.initialize();
c’est la racine
// du contexte de
// Get the root naming context. nommage
//
org.omg.CosNaming.NamingContext root =
namingService.rootNamingContext();

//
// Add reference to boot manager permet de mettre des associations dans les
// tables internes, accessibles ensuite par
try "orb.resolve_initial_reference".
{
byte[] oid = ("NameService").getBytes();
com.ooc.OB.BootManager bootManager =
com.ooc.OB.BootManagerHelper.narrow(
orb.resolve_initial_references("BootManager"));
bootManager.add_binding(oid, root);
}
catch(org.omg.CORBA.ORBPackage.InvalidName ex)
{
throw new RuntimeException();
}
catch(com.ooc.OB.BootManagerPackage.AlreadyExists ex)
{
throw new RuntimeException();
}

//
// Print IOR on standard output
//
if(ior)
{
System.out.println(orb.object_to_string(root));
}

//
// Run implementation
//
try
{
manager.activate();
}
catch(org.omg.PortableServer.POAManagerPackage.AdapterInactive ex)
{
throw new RuntimeException();
}
orb.run();

return 0;
}

public static void


main(String args[])
{
java.util.Properties props = System.getProperties();
props.put("org.omg.CORBA.ORBClass", "com.ooc.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass",
"com.ooc.CORBA.ORBSingleton");

int status = 0;
org.omg.CORBA.ORB orb = null;

//
// Set the program name
//
String progName = "com.ooc.CosNaming.Server";

try
{
args = com.ooc.OBCORBA.ORB_impl.ParseArgs(args, props, null);

//
// Check to see if the concurrency model is usable for nested
// method invocations. Threaded/thread_per_request/thread_pool
// is needed.
//
String oaModel = props.getProperty("ooc.orb.oa.conc_model");
String orbModel = props.getProperty("ooc.orb.conc_model");
boolean valid;
if (oaModel != null && orbModel != null)
{
valid = (orbModel.equals("threaded") &&
(oaModel.equals("thread_per_request") ||
oaModel.equals("thread_pool")));
}
else
valid = false;

//
// Set the concurrency model to threaded/threaded if a valid
// concurrency model wasn’t selected
//
if(!valid)
{
props.put("ooc.orb.conc_model", "threaded");
props.put("ooc.orb.oa.conc_model", "thread_per_request");
}

//
// Create ORB
//
orb = ORB.init(args, props);
status = run(orb, progName, args, props);

}
catch(Exception ex)
{
ex.printStackTrace();
status = 1;
}

if(orb != null)
{
try
{
((com.ooc.CORBA.ORB)orb).destroy();
}
catch(Exception ex)
{
ex.printStackTrace();
status = 1;
}
}

System.exit(status);
}
}
//////////////////////////////// Client.java ////////////////////////////////////////////////////////////////////////////////////////////////
package naming;
import org.omg.CORBA.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;

public class Client {


public static void main(String args[]) {
java.util.Properties props = System.getProperties();
props.put("org.omg.CORBA.ORBClass", "com.ooc.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass",
"com.ooc.CORBA.ORBSingleton");
int status = 0;
ORB orb = null;
try {
// Create ORB
orb = ORB.init(args, props);
// Run tests
status = run(orb, args);
}
catch(Exception ex) { ex.printStackTrace(); status = 1; }
if(orb != null) {
try { ((com.ooc.CORBA.ORB)orb).destroy(); }
catch(Exception ex) { System.err.println(ex.getMessage()); ex.printStackTrace();
status = 1;
} } chemin d’accès et type
System.exit(status); de la liaison
}

static void printBinding(Binding b) {


int i;
for(i = 0 ; i < b.binding_name.length ; i++) {
if(i > 0) System.out.print(" ; ");
System.out.print(b.binding_name[i].id);
}
switch(b.binding_type.value()) {
case BindingType._nobject: System.out.println(" (object)"); break;
case BindingType._ncontext:System.out.println(" (context)"); break;
}
}

static int run(ORB orb, String args[]) {


// Get naming service
org.omg.CORBA.Object obj = null;
try { obj = orb.resolve_initial_references("NameService"); }
catch(org.omg.CORBA.ORBPackage.InvalidName ex) {
System.err.println("Can’t resolve ‘NameService’");
return 1;
}
if(obj == null) { System.err.println("‘NameService’ is a nil object reference"); return 1; }
NamingContext nc = null;
try { nc = NamingContextHelper.narrow(obj); }
catch(org.omg.CORBA.BAD_PARAM ex) {
System.err.println("‘NameService’ is not " + "a NamingContext object reference");
return 1;
}
// Get objects by name
try {
int i;
// Resolve names with the Naming Service
NameComponent[] aName = new NameComponent[1];
aName[0] = new NameComponent(); résolution de la référence
aName[0].id = "a"; d’objet à partir du nom.
aName[0].kind = "";
org.omg.CORBA.Object aObj = nc.resolve(aName);
Named a = NamedHelper.narrow(aObj);
System.out.println("Resolved ‘a’");

NameComponent[] nc1Name = new NameComponent[1]; il s’agit ici


nc1Name[0] = new NameComponent();
nc1Name[0].id = "nc1"; d’un contexte
nc1Name[0].kind = ""; de nommage
org.omg.CORBA.Object nc1Obj = nc.resolve(nc1Name); (répertoire).
NamingContext nc1 = NamingContextHelper.narrow(nc1Obj);
System.out.println("Resolved ‘nc1’");

NameComponent[] bName = new NameComponent[2];


bName[0] = new NameComponent();
bName[0].id = "nc1";
bName[0].kind = "";
bName[1] = new NameComponent();
bName[1].id = "b"; l’objet "b" est
bName[1].kind = ""; recherché dans
org.omg.CORBA.Object bObj = nc.resolve(bName); le contexte
Named b = NamedHelper.narrow(bObj);
System.out.println("Resolved ‘b’ in naming context ‘nc1’"); "nc1".

NameComponent[] nc2Name = new NameComponent[2];


nc2Name[0] = new NameComponent();
nc2Name[0].id = "nc1";
nc2Name[0].kind = "";
nc2Name[1] = new NameComponent();
nc2Name[1].id = "nc2";
nc2Name[1].kind = "";
org.omg.CORBA.Object nc2Obj = nc.resolve(nc2Name);
NamingContext nc2 = NamingContextHelper.narrow(nc2Obj);
System.out.println("Resolved ‘nc2’ in naming context ‘nc1’");

NameComponent[] cName = new NameComponent[3];


cName[0] = new NameComponent();
cName[0].id = "nc1";
cName[0].kind = "";
cName[1] = new NameComponent();
cName[1].id = "nc2";
cName[1].kind = "";
cName[2] = new NameComponent();
cName[2].id = "c";
cName[2].kind = "";
org.omg.CORBA.Object cObj = nc.resolve(cName);
Named c = NamedHelper.narrow(cObj);
System.out.println("Resolved ‘c’ in naming conext ‘nc2’" + "in naming context ‘nc’");
pour récupérer toutes les
System.out.println("Listing all bindings:"); associations
BindingListHolder bl = new BindingListHolder();
BindingIteratorHolder bi = new BindingIteratorHolder();
création et
nc.list(999999, bl, bi); mise en place
for(i = 0 ; i < bl.value.length ; i++) printBinding(bl.value[i]); d’un "itérateur"
if(bi == null) throw new RuntimeException();
ici on ne récupère
System.out.println("Now listing only two bindings:");
BindingListHolder bl2 = new BindingListHolder(); que deux
BindingIteratorHolder bi2 = new BindingIteratorHolder(); associations
nc.list(2, bl2, bi2);
for(i = 0 ; i < bl2.value.length ; i++) printBinding(bl2.value[i]);
if(bi2 == null) throw new RuntimeException();

System.out.println("Listing the rest with the binding iterator:" );


BindingListHolder bl3 = new BindingListHolder();
boolean bo = bi2.value.next_n(999999, bl3);
for(i = 0 ; i < bl3.value.length ; i++) printBinding(bl3.value[i]);
bi2.value.destroy();
}
catch(NotFound ex) {
System.err.print("Got a ‘NotFound’ exception (");
switch(ex.why.value()) {
case NotFoundReason._missing_node: System.err.print("missing node"); break;
case NotFoundReason._not_context: System.err.print("not context"); break;
case NotFoundReason._not_object: System.err.print("not object"); break;
}
System.err.println(")");
ex.printStackTrace();
return 1;
}
catch(CannotProceed ex) {
System.err.println("Got a ‘CannotProceed’ exception");
ex.printStackTrace();
return 1;
}
catch(InvalidName ex) {
System.err.println("Got an ‘InvalidName’ exception");
ex.printStackTrace();
return 1;
}
return 0;
}
}
//////////////////////////////// Server.java ////////////////////////////////////////////////////////////////////////////////////////////////
package naming;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import java.io.*;

public class Server {

public static void main(String args[]) {


java.util.Properties props = System.getProperties();
props.put("org.omg.CORBA.ORBClass", "com.ooc.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass", "com.ooc.CORBA.ORBSingleton");
int status = 0; lance
ORB orb = null;
lance le
l’ORB serveur
try { // Create ORB
orb = ORB.init(args, props); status = run(orb, args); }
catch(Exception ex) { ex.printStackTrace(); status = 1; }
if(orb != null) {
try { ((com.ooc.CORBA.ORB)orb).destroy(); }
catch(Exception ex) { System.err.println(ex.getMessage()); ex.printStackTrace(); status = 1;
}}
System.exit(status);
}

static int run(ORB orb, String args[]) {


// Parse command line arguments
String namingFile = null;
int argc = 0;
while(argc < args.length) {
if(args[argc].equals("−f")) {
if(argc + 1 < args.length) { argc++; namingFile = args[argc]; }
else usage();
}
else if(args[argc].equals("−h") || args[argc].equals("−−help")) usage();
argc++;
}
// Resolve Root POA
org.omg.CORBA.Object poaObj = null;
try { poaObj = orb.resolve_initial_references("RootPOA"); }
catch(org.omg.CORBA.ORBPackage.InvalidName ex)
{ throw new RuntimeException(); }

POA rootPOA = POAHelper.narrow(poaObj);


// Get a reference to the POA manager
POAManager manager = rootPOA.the_POAManager();
com.ooc.OBPortableServer.POAManager obManager =
com.ooc.OBPortableServer.POAManagerHelper.narrow(manager);
// Create some implementations
Named_impl implA = new Named_impl();
Named_impl implA1 = new Named_impl();
Named_impl implA2 = new Named_impl();
Named_impl implA3 = new Named_impl();
Named_impl implB = new Named_impl();
Named_impl implC = new Named_impl();
Named a = implA._this(orb);
Named a1 = implA1._this(orb);
Named a2 = implA2._this(orb);
Named a3 = implA3._this(orb);
Named b = implB._this(orb);
Named c = implC._this(orb);
dans le cas
// Get naming service
org.omg.CORBA.Object obj = null; où le
if(namingFile != null) { fichier n’est
try { pas vide
FileReader r = new FileReader(namingFile);
BufferedReader in = new BufferedReader(r);
String ref = in.readLine();
r.close();
obj = orb.string_to_object(ref); sinon on
}
catch(IOException e) { e.printStackTrace(); return 1; } utilise les
} noms
else { remarquables
try { obj = orb.resolve_initial_references("NameService"); }
catch(org.omg.CORBA.ORBPackage.InvalidName ex)
{ System.out.println("Can’t resolve ‘NameService’"); return 1; }
}
if(obj == null) { System.out.println("‘NameService’ is a nil object reference"); return 1; }
NamingContext nc = null;
try { nc = NamingContextHelper.narrow(obj); }
catch(org.omg.CORBA.BAD_PARAM ex) {
System.out.println("‘NameService’ is not " + "a NamingContext object reference");
return 1;
}
try {
// Create and bind some Naming Context
NameComponent[] nc1Name = new NameComponent[1];
nc1Name[0] = new NameComponent();
nc1Name[0].id = "nc1";
nc1Name[0].kind = "";
NamingContext nc1 = nc.bind_new_context(nc1Name);

NameComponent[] nc2Name = new NameComponent[2];


nc2Name[0] = new NameComponent();
nc2Name[0].id = "nc1";
nc2Name[0].kind = "";
nc2Name[1] = new NameComponent();
nc2Name[1].id = "nc2";
nc2Name[1].kind = "";
NamingContext nc2 = nc.bind_new_context(nc2Name);
// Bind names with the Naming Service
NameComponent[] aName = new NameComponent[1];
aName[0] = new NameComponent();
aName[0].id = "a";
aName[0].kind = "";
nc.bind(aName, a);

NameComponent[] a1Name = new NameComponent[1];


a1Name[0] = new NameComponent();
a1Name[0].id = "a1";
a1Name[0].kind = "";
nc.bind(a1Name, a1);

NameComponent[] a2Name = new NameComponent[1];


a2Name[0] = new NameComponent();
a2Name[0].id = "a2";
a2Name[0].kind = "";
nc.bind(a2Name, a2);

NameComponent[] a3Name = new NameComponent[1];


a3Name[0] = new NameComponent();
a3Name[0].id = "a3";
a3Name[0].kind = "";
nc.bind(a3Name, a3);

NameComponent[] bName = new NameComponent[2];


bName[0] = new NameComponent();
bName[0].id = "nc1";
bName[0].kind = "";
bName[1] = new NameComponent();
bName[1].id = "b";
bName[1].kind = "";
nc.bind(bName, b);

NameComponent[] cName = new NameComponent[3];


cName[0] = new NameComponent();
cName[0].id = "nc1";
cName[0].kind = "";
cName[1] = new NameComponent();
cName[1].id = "nc2";
cName[1].kind = "";
cName[2] = new NameComponent();
cName[2].id = "c";
cName[2].kind = "";
nc.bind(cName, c);

// Run implementation
try { manager.activate(); }
catch(org.omg.PortableServer.POAManagerPackage.AdapterInactive ex) {
throw new RuntimeException();
}
orb.run();

// Unregister names with the Naming Service


nc.unbind(cName);
nc.unbind(bName);
nc.unbind(aName);
nc.unbind(a1Name);
nc.unbind(a2Name);
nc.unbind(a3Name);
nc.unbind(nc2Name);
nc.unbind(nc1Name);
}
catch(NotFound ex) {
System.err.print("Got a ‘NotFound’ exception (");
switch(ex.why.value())
{
case NotFoundReason._missing_node: System.err.print("missing node"); break;
case NotFoundReason._not_context: System.err.print("not context"); break;
case NotFoundReason._not_object: System.err.print("not object"); break;
}
System.err.println(")");
ex.printStackTrace();
return 1;
}
catch(CannotProceed ex) {
System.err.println("Got a ‘CannotProceed’ exception");
ex.printStackTrace();
return 1;
}
catch(InvalidName ex) {
System.err.println("Got an ‘InvalidName’ exception");
ex.printStackTrace();
return 1;
}
catch(AlreadyBound ex) {
System.err.println("Got an ‘AlreadyBound’ exception");
ex.printStackTrace();
return 1;
}
return 0;
}

private static void usage() {


System.out.println("Usage: java naming.Server [options]\n\n" +
"Options:\n" +
"−f FILE Read the NamingService IOR from file FILE.\n" +
"−h, −−help Display this help message.");
System.exit(1);
}
}

You might also like