-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHelloClient.java
40 lines (33 loc) · 1.21 KB
/
HelloClient.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import HelloApp.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.CORBA.*;
import java.util.*;
public class HelloClient
{
static Hello helloImpl;
public static void main(String args[]){
try{
// create and initialize the ORB
ORB orb = ORB.init(args, null);
// get the root naming context
org.omg.CORBA.Object objRef =
orb.resolve_initial_references("NameService");
// Use NamingContextExt instead of NamingContext. This is
// part of the Interoperable naming Service.
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
// resolve the Object Reference in Naming
String name = "Hello";
helloImpl = HelloHelper.narrow(ncRef.resolve_str(name));
System.out.println("Obtained a handle on server object: " + helloImpl);
Scanner sc = new Scanner(System.in);
System.out.println("Enter a string to see if it is an integer:");
String temp = sc.nextLine();
System.out.println(helloImpl.judgeInt(temp));
helloImpl.shutdown();
}catch(Exception e){
System.out.println("ERROR : " + e) ;
e.printStackTrace(System.out);
}
}
}