KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > iiop > rmi > ir > ConstantDefImpl


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software 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 software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.iiop.rmi.ir;
23
24 import org.omg.CORBA.Any JavaDoc;
25 import org.omg.CORBA.TypeCode JavaDoc;
26 import org.omg.CORBA.IRObject JavaDoc;
27 import org.omg.CORBA.ContainedOperations JavaDoc;
28 import org.omg.CORBA.ContainedPackage.Description;
29 import org.omg.CORBA.DefinitionKind JavaDoc;
30 import org.omg.CORBA.IDLType JavaDoc;
31 import org.omg.CORBA.IDLTypeHelper JavaDoc;
32 import org.omg.CORBA.ConstantDef JavaDoc;
33 import org.omg.CORBA.ConstantDefOperations JavaDoc;
34 import org.omg.CORBA.ConstantDescription JavaDoc;
35 import org.omg.CORBA.ConstantDescriptionHelper;
36 import org.omg.CORBA.ConstantDefPOATie;
37 import org.omg.CORBA.BAD_INV_ORDER JavaDoc;
38
39 /**
40  * Constant IR object.
41  *
42  * @author <a HREF="mailto:osh@sparre.dk">Ole Husgaard</a>
43  * @version $Revision: 37459 $
44  */

45 public class ConstantDefImpl
46    extends ContainedImpl
47    implements ConstantDefOperations JavaDoc
48 {
49    // Constants -----------------------------------------------------
50

51    // Attributes ----------------------------------------------------
52

53    // Static --------------------------------------------------------
54

55    private static final org.jboss.logging.Logger logger =
56                org.jboss.logging.Logger.getLogger(ConstantDefImpl.class);
57
58    // Constructors --------------------------------------------------
59

60    ConstantDefImpl(String JavaDoc id, String JavaDoc name, String JavaDoc version,
61                     TypeCode JavaDoc typeCode, Any JavaDoc value,
62                     LocalContainer defined_in, RepositoryImpl repository)
63    {
64       super(id, name, version, defined_in,
65             DefinitionKind.dk_Constant, repository);
66
67       this.typeCode = typeCode;
68       this.value = value;
69    }
70
71    // Public --------------------------------------------------------
72

73
74    // LocalIRObject implementation ---------------------------------
75

76    public IRObject JavaDoc getReference()
77    {
78       if (ref == null) {
79          ref = org.omg.CORBA.ConstantDefHelper.narrow(
80                             servantToReference(new ConstantDefPOATie(this)) );
81       }
82       return ref;
83    }
84
85    public void allDone()
86       throws IRConstructionException
87    {
88       // Get my type definition: It should have been created now.
89
type_def = IDLTypeImpl.getIDLType(typeCode, repository);
90       if (type_def == null)
91          logger.debug("Got type_def: [NULL]");
92       else
93          logger.debug("Got type_def: [" + type_def.toString() + "]");
94
95       getReference();
96    }
97
98
99    // ConstantDefOperations implementation ----------------------------
100

101    public TypeCode JavaDoc type()
102    {
103       logger.debug("ConstantDefImpl.type(): entered.");
104       return typeCode;
105    }
106
107    public IDLType JavaDoc type_def()
108    {
109       logger.debug("ConstantDefImpl.type_def(): entered.");
110       try {
111          return IDLTypeHelper.narrow(type_def.getReference());
112       } finally {
113          logger.debug("ConstantDefImpl.type_def(): returning.");
114       }
115    }
116
117    public void type_def(IDLType JavaDoc arg)
118    {
119       throw new BAD_INV_ORDER JavaDoc("Cannot change RMI/IIOP mapping.");
120    }
121
122    public Any JavaDoc value()
123    {
124       logger.debug("ConstantDefImpl.value(): entered.");
125       return value;
126    }
127
128    public void value(Any JavaDoc arg)
129    {
130       throw new BAD_INV_ORDER JavaDoc("Cannot change RMI/IIOP mapping.");
131    }
132
133
134    // ContainedImpl implementation ----------------------------------
135

136    public Description describe()
137    {
138       logger.debug("ConstantDefImpl.describe(): entered.");
139       String JavaDoc defined_in_id = "IR";
140  
141       if (defined_in instanceof ContainedOperations JavaDoc)
142          defined_in_id = ((ContainedOperations JavaDoc)defined_in).id();
143  
144       ConstantDescription JavaDoc d =
145                    new ConstantDescription JavaDoc(name, id, defined_in_id, version,
146                                             typeCode, value);
147  
148       Any JavaDoc any = getORB().create_any();
149
150       ConstantDescriptionHelper.insert(any, d);
151
152       return new Description(DefinitionKind.dk_Constant, any);
153    }
154
155    // Y overrides ---------------------------------------------------
156

157    // Package protected ---------------------------------------------
158

159    // Protected -----------------------------------------------------
160

161    // Private -------------------------------------------------------
162

163    /**
164     * My CORBA reference.
165     */

166    private ConstantDef JavaDoc ref = null;
167
168
169    /**
170     * My TypeCode.
171     */

172    private TypeCode JavaDoc typeCode;
173
174    /**
175     * My type definition.
176     */

177    private LocalIDLType type_def;
178
179    /**
180     * My value.
181     */

182    private Any JavaDoc value;
183
184
185    // Inner classes -------------------------------------------------
186
}
187
Popular Tags