KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > demo > poa_monitor > root_poa > FooImpl


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