01: package demo.poa_monitor.user_poa;
02:
03: import org.omg.PortableServer.*;
04:
05: import org.omg.PortableServer.POAPackage.*;
06:
07: import demo.poa_monitor.foox.*;
08:
09: public class FooImpl extends FooPOA {
10:
11: private String id;
12:
13: public FooImpl(String _id) {
14:
15: id = _id;
16:
17: }
18:
19: public void compute(int time) {
20:
21: try {
22:
23: for (int i = 1; i <= time; i = i + 100) {
24:
25: Thread.currentThread().sleep(100);
26:
27: }
28:
29: } catch (InterruptedException e) {
30:
31: }
32:
33: }
34:
35: public void deactivate() {
36:
37: try
38:
39: {
40:
41: org.omg.PortableServer.Current current =
42:
43: org.omg.PortableServer.CurrentHelper.narrow(_orb()
44: .resolve_initial_references("POACurrent"));
45:
46: POA myPOA = current.get_POA();
47:
48: byte[] myoid = current.get_object_id();
49:
50: myPOA.deactivate_object(myoid);
51:
52: }
53:
54: catch (org.omg.CORBA.ORBPackage.InvalidName in)
55:
56: {
57:
58: System.out
59: .println("[ object deactivation fails: POACurrent not available ]");
60:
61: }
62:
63: catch (org.omg.PortableServer.CurrentPackage.NoContext nc)
64:
65: {
66:
67: System.out
68: .println("[ object deactivation fails: no invocation context ]");
69:
70: }
71:
72: catch (ObjectNotActive na)
73:
74: {
75:
76: System.out
77: .println("[ object deactivation fails: object not active ]");
78:
79: }
80:
81: catch (WrongPolicy wp)
82:
83: {
84:
85: System.out
86: .println("[ object deactivation fails: wrong poa policy ]");
87:
88: }
89:
90: }
91:
92: }
|