KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > corba > runtime > POAServiceImpl


1 // ====================================================================
2
//
3
// ECM: The Extensible Container Model
4
// Copyright (C) 2004 THALES
5
// Contact: openccm-ecm@objectweb.org
6
//
7
// This library is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU Lesser General Public
9
// License as published by the Free Software Foundation; either
10
// version 2.1 of the License, or any later version.
11
//
12
// This library is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
// Lesser General Public License for more details.
16
//
17
// You should have received a copy of the GNU Lesser General Public
18
// License along with this library; if not, write to the Free Software
19
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20
// USA
21
//
22
// Initial developer(s): Mathieu Vadet.
23
// Initial Funding: IST COACH European project (IST-2001-34445)
24
// http://www.ist-coach.org
25
//
26
// ====================================================================
27

28
29
30 package org.objectweb.corba.runtime;
31
32 /**
33  ** <p>Default implementation of the <tt>POAService</tt> system service.</p>
34  **/

35 public class POAServiceImpl
36 extends org.omg.CORBA.LocalObject JavaDoc
37 implements POAService
38 {
39     // poa service
40
static final private String JavaDoc _class_name = "POAServiceImpl";
41     static final private String JavaDoc _service_id = POAService.SERVICE_ID;
42     private ORBService _orb_service;
43     private org.omg.PortableServer.POA JavaDoc _poa;
44
45     // default constructor
46
public
47     POAServiceImpl(org.omg.PortableServer.POA JavaDoc poa)
48     {
49         // poa service
50
_orb_service = null;
51         _poa = poa;
52     }
53
54     //
55
// IDL:objectweb.org/corba/runtime/SystemComponent:1.0
56
//
57

58     final public void
59     system_configuration_complete(SystemConfiguration cfg)
60     {
61         POAConfiguration poacfg = (POAConfiguration)cfg;
62         _orb_service = poacfg.orb_service();
63     }
64
65     final public void
66     destroy()
67     {
68         // destroy the POA
69
// here, we have set:
70
// - 'etherealize_objects' param as true
71
// - 'wait_for_completion' param as true
72
_poa.destroy(true, true);
73     }
74
75     //
76
// IDL:objectweb.org/corba/runtime/SystemService:1.0
77
//
78

79     final public String JavaDoc
80     service_id()
81     {
82         return _service_id;
83     }
84
85     //
86
// IDL:objectweb.org/corba/runtime/POAService:1.0
87
//
88

89     final public void
90     activate_servant_with_id(Servant serv, byte[] oid)
91     {
92         // create a native service
93
org.omg.PortableServer.Servant JavaDoc nserv = null;
94         nserv = serv.as_native_servant();
95
96         // activate it on the wrapped POA
97
try {
98             _poa.activate_object_with_id(oid, nserv);
99         } catch (Exception JavaDoc ex) {
100             final String JavaDoc opname = "activate_servant_with_id";
101             TheLogger.error(_class_name, opname, "FAILED", ex);
102         }
103     }
104
105     final public void
106     deactivate_servant(byte[] oid)
107     {
108         // deactivate servant on the wrapped POA
109
try {
110             _poa.deactivate_object(oid);
111         } catch (Exception JavaDoc ex) {
112             final String JavaDoc opname = "deactivate_servant";
113             TheLogger.debug(_class_name, opname, "IGNORE", ex);
114         }
115     }
116
117     final public org.omg.CORBA.Object JavaDoc
118     create_ref(String JavaDoc repid)
119     {
120         // create a fake oid
121
byte[] oid = Double.toString(Math.random()).getBytes();
122
123         // create a ref
124
return _poa.create_reference_with_id(oid, repid);
125     }
126
127     final public org.omg.CORBA.Object JavaDoc
128     create_ref_with_id(byte[] oid, String JavaDoc repid)
129     {
130         // create a ref
131
return _poa.create_reference_with_id(oid, repid);
132     }
133
134     final public byte[]
135     get_id_from_ref(org.omg.CORBA.Object JavaDoc ref)
136     {
137         try {
138             return _poa.reference_to_id(ref);
139         } catch (Exception JavaDoc ex) {
140             final String JavaDoc opname = "get_id_from_ref";
141             TheLogger.error(_class_name, opname, "FAILED", ex);
142             return null;
143         }
144     }
145 }
146
Popular Tags