KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > ir3 > ExtLocalInterfaceDef_impl


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA & USTL - LIFL - GOAL
5 Contact: openccm@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): Philippe Merle.
23 Contributor(s): Mathieu Vadet, Christophe Demarey.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.ir3;
28
29 // Package dependencies
30
import org.omg.CORBA.*;
31
32 /**
33  * Implementation of the CORBA::ExtLocalInterfaceDef interface.
34  *
35  * @author <a=href="Philippe.Merle@lifl.fr">Philippe Merle</a>
36  * <a=href="Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
37  *
38  * @version 0.3
39  */

40
41 public class ExtLocalInterfaceDef_impl
42        extends ExtInterfaceDef_impl
43        implements ExtLocalInterfaceDefOperations
44 {
45     // ==================================================================
46
//
47
// Constructors.
48
//
49
// ==================================================================
50

51     /**
52      * TODO
53      */

54     public
55     ExtLocalInterfaceDef_impl(IFR ifr,
56                               Container_impl container)
57     {
58         // call the InterfaceDef_impl constructor.
59
super(ifr, container, false);
60
61         // set the tie servant object.
62
setServant(new ExtLocalInterfaceDefPOATie(this));
63     }
64
65     // ==================================================================
66
//
67
// Internal state.
68
//
69
// ==================================================================
70

71     // ==================================================================
72
//
73
// Internal methods.
74
//
75
// ==================================================================
76

77     /**
78      * Obtain its CORBA::ExtLocalInterfaceDef object reference.
79      */

80     protected ExtLocalInterfaceDef
81     asExtLocalInterfaceDef()
82     {
83         return ExtLocalInterfaceDefHelper.narrow(asObject());
84     }
85
86     // ==================================================================
87
//
88
// Internal methods for IRObject_impl class.
89
//
90
// ==================================================================
91

92     /**
93      * TODO
94      */

95     protected boolean
96     isUnderDestruction()
97     {
98         // Returns true if this object is already in destruction.
99
if(super.isUnderDestruction()) return true;
100
101         // Tests if this local interface is the local mapping
102
// for a remote interface then remove it.
103
String JavaDoc name = name();
104         if ( name.startsWith("CCM_")
105           && base_interfaces_.length == 1
106           && base_interfaces_[0].getImpl().isUnderDestruction()
107           && name.substring(4).equals(base_interfaces_[0].getImpl().name()))
108     {
109             destroy();
110             return true;
111         }
112
113         // Else returns false.
114
return false;
115     }
116
117     // ==================================================================
118
//
119
// For CORBA::IRObject interface.
120
//
121
// ==================================================================
122

123     /**
124      * IDL:omg.org/CORBA/IRObject/def_kind:1.0
125      */

126     public DefinitionKind
127     def_kind()
128     {
129         return DefinitionKind.dk_LocalInterface;
130     }
131
132     // ==================================================================
133
//
134
// For CORBA::IDLType interface.
135
//
136
// ==================================================================
137

138     /**
139      * IDL:omg.org/CORBA/IDLType/type:1.0
140      */

141     public TypeCode
142     type()
143     {
144         // delegate to the TypeCodeFactory.
145

146         //
147
// TODO: need to change ORBacus
148
//
149
// return getIFR().getTCF().
150
// create_local_interface_tc(id(), name());
151

152         return getIFR().getTCF().create_interface_tc(id(), name());
153     }
154
155     // ==================================================================
156
//
157
// For CORBA::InterfaceDef interface.
158
//
159
// ==================================================================
160

161     /**
162      * IDL:omg.org/CORBA/InterfaceDef/base_interfaces:1.0
163      */

164     public void
165     base_interfaces(org.omg.CORBA.InterfaceDef JavaDoc[] itfs)
166     {
167         // Check that all itfs are InterfaceDef.
168
for(int i=0; i<itfs.length; i++)
169             if ((itfs[i].def_kind() != DefinitionKind.dk_Interface) &&
170                 (itfs[i].def_kind() != DefinitionKind.dk_LocalInterface))
171                 throw exceptionInvalidLocalInterfaceInheritance(
172                                                   itfs[i].absolute_name());
173
174         super.base_interfaces(itfs);
175     }
176
177     /**
178      * IDL:omg.org/CORBA/InterfaceDef/is_a:1.0
179      */

180     public boolean
181     is_a(String JavaDoc interface_id)
182     {
183         if(interface_id.equals(id()))
184             return true;
185
186         if(interface_id.equals("IDL:omg.org/CORBA/LocalObject:1.0"))
187             return true;
188
189         for(int i=0; i<base_interfaces_.length; i++)
190             if (base_interfaces_[i].getImpl().is_a(interface_id))
191                 return true;
192
193         return false;
194     }
195 }
196
Popular Tags