catching errors using orb, nameService and Binding lists..

could you please let me know which are the most checks that i can do in the following code...

//create and initialize the ORB

ORB orb = ORB.init(argv,null);

//creates an object for the client's Servant and

//initializes it with the orb.

ServantClient theCallbackObjectRef =new ServantClient();

if (theCallbackObjectRef ==null){

System.out.println ("theCallbackObjectRef = null");

return;

}

//call orb and connect the object reference for the client's servant

orb.connect(theCallbackObjectRef);

// get the root naming context

org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");

if (objRef ==null){

System.out.println("nameService ObjRef = null");

return;

}

//narrow the objRef to NamingContext Ref

NamingContext ncRef = NamingContextHelper.narrow(objRef);

if (ncRef ==null){

System.out.println("NamingContext ncRef = null");

return;

}

//List all bindings in the naming context.

//The list method lists the bindings in the naming context. 100 bindings from the initial

//naming context will be returned in the BindingListHolder;

//any remaining bindings are returned in the BindingIteratorHolder.

BindingListHolder bl =new BindingListHolder();

BindingIteratorHolder blIt=new BindingIteratorHolder();

ncRef.list(100, bl, blIt);

//tale the array

Binding bindings[] = bl.value;

i searched a lot on the net and i couldn't find many many checks... many people dont even check if the objects are null or so..

have i missed some catches?

is there any site that explains can you check for run time errors on your code?

e.g. if you take string ...check if it is null before you print it or use it or sth like that..

[2923 byte] By [panosjava] at [2007-11-26 12:17:05]
# 1

ok since noone answers that i want to ask sth simpler...

if the NamingContext ncRef = NamingContextHelper.narrow(objRef);

returns a null object the execution will to a catch (i know that it doesn't exist in the code that i have put in here. OR the following has a meaning and should stay into the code as an extra check?

if (ncRef == null) {

System.out.println("NamingContext ncRef = null");

return;

}

panosjava at 2007-7-7 14:54:06 > top of Java-index,Archived Forums,Socket Programming...
# 2

The first question is answered by looking at the Javadoc, or by just compiling the program without any catches and seeing what the compiler wants you to catch.

I can barely understand the second question but if it means does PortableRemoteObject.narrow() return null the answer is again in the Javadoc.

ejp at 2007-7-7 14:54:06 > top of Java-index,Archived Forums,Socket Programming...