-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.java
72 lines (61 loc) · 1.86 KB
/
server.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* ABDELHAKIM KHAOUITI
* 20 SEP 2024
*/
import org.omg.CORBA.ORB;
import org.omg.CORBA.UserException;
import org.omg.PortableServer.POA;
import org.omg.PortableServer.POAHelper;
import org.omg.PortableServer.POAManager;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Properties;
public class server {
public static void main(String[] args) {
Properties props = System.getProperties();
int status = 0;
ORB orb = null;
try {
orb = ORB.init(args, props);
status = run(orb);
} catch (Exception ex) {
ex.printStackTrace();
status = 1;
}
if (orb != null) {
try {
orb.destroy();
} catch (Exception ex) {
ex.printStackTrace();
status = 1;
}
}
System.exit(status);
}
static int run(ORB orb) throws UserException, IOException {
POA rootPOA;
POAManager manager;
rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
manager = rootPOA.the_POAManager();
impl_compte_heritage compte_impl = new impl_compte_heritage(5000);
Compte compte = compte_impl._this(orb);
String ref = orb.object_to_string(compte);
String refFile = "reference";
try (FileOutputStream file = new FileOutputStream(refFile);
PrintWriter out = new PrintWriter(file)) {
out.println(ref);
System.out.println("server en attente des clients\nRef: "+ref);
} catch (Exception ignored) {}
try {
if (manager != null) {
manager.activate();
}
orb.run();
} catch (Exception e) {
e.printStackTrace();
return 1;
}
return 0;
}
}