KickJava   Java API By Example, From Geeks To Geeks.

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


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