KickJava   Java API By Example, From Geeks To Geeks.

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


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.AttributeDef JavaDoc;
33 import org.omg.CORBA.AttributeDefOperations JavaDoc;
34 import org.omg.CORBA.AttributeMode JavaDoc;
35 import org.omg.CORBA.AttributeDescription JavaDoc;
36 import org.omg.CORBA.AttributeDescriptionHelper;
37 import org.omg.CORBA.AttributeDefPOATie;
38 import org.omg.CORBA.BAD_INV_ORDER JavaDoc;
39
40 /**
41  * Attribute IR object.
42  *
43  * @author <a HREF="mailto:osh@sparre.dk">Ole Husgaard</a>
44  * @version $Revision: 37459 $
45  */

46 public class AttributeDefImpl
47    extends ContainedImpl
48    implements AttributeDefOperations JavaDoc
49 {
50    // Constants -----------------------------------------------------
51

52    // Attributes ----------------------------------------------------
53

54    // Static --------------------------------------------------------
55

56    // Constructors --------------------------------------------------
57

58    AttributeDefImpl(String JavaDoc id, String JavaDoc name, String JavaDoc version,
59                     AttributeMode JavaDoc mode, TypeCode JavaDoc typeCode,
60                     LocalContainer defined_in, RepositoryImpl repository)
61    {
62       super(id, name, version, defined_in,
63             DefinitionKind.dk_Attribute, repository);
64
65       this.mode = mode;
66       this.typeCode = typeCode;
67    }
68
69    // Public --------------------------------------------------------
70

71
72    // LocalIRObject implementation ---------------------------------
73

74    public IRObject JavaDoc getReference()
75    {
76       if (ref == null) {
77          ref = org.omg.CORBA.AttributeDefHelper.narrow(
78                             servantToReference(new AttributeDefPOATie(this)) );
79       }
80       return ref;
81    }
82
83    public void allDone()
84       throws IRConstructionException
85    {
86       // Get my type definition: It should have been created now.
87
type_def = IDLTypeImpl.getIDLType(typeCode, repository);
88
89       getReference();
90    }
91
92
93    // AttributeDefOperations implementation ----------------------------
94

95    public TypeCode JavaDoc type()
96    {
97       return typeCode;
98    }
99
100    public IDLType JavaDoc type_def()
101    {
102       return IDLTypeHelper.narrow(type_def.getReference());
103    }
104
105    public void type_def(IDLType JavaDoc arg)
106    {
107       throw new BAD_INV_ORDER JavaDoc("Cannot change RMI/IIOP mapping.");
108    }
109
110    public AttributeMode JavaDoc mode()
111    {
112       return mode;
113    }
114
115    public void mode(AttributeMode JavaDoc arg)
116    {
117       throw new BAD_INV_ORDER JavaDoc("Cannot change RMI/IIOP mapping.");
118    }
119
120
121    // ContainedImpl implementation ----------------------------------
122

123    public Description describe()
124    {
125       String JavaDoc defined_in_id = "IR";
126  
127       if (defined_in instanceof ContainedOperations JavaDoc)
128          defined_in_id = ((ContainedOperations JavaDoc)defined_in).id();
129  
130       AttributeDescription JavaDoc d =
131                    new AttributeDescription JavaDoc(name, id, defined_in_id, version,
132                                             typeCode, mode);
133  
134       Any JavaDoc any = getORB().create_any();
135
136       AttributeDescriptionHelper.insert(any, d);
137
138       return new Description(DefinitionKind.dk_Attribute, any);
139    }
140
141    // Y overrides ---------------------------------------------------
142

143    // Package protected ---------------------------------------------
144

145    // Protected -----------------------------------------------------
146

147    // Private -------------------------------------------------------
148

149    /**
150     * My CORBA reference.
151     */

152    private AttributeDef JavaDoc ref = null;
153
154
155    /**
156     * My mode.
157     */

158    private AttributeMode JavaDoc mode;
159
160    /**
161     * My TypeCode.
162     */

163    private TypeCode JavaDoc typeCode;
164
165    /**
166     * My type definition.
167     */

168    private LocalIDLType type_def;
169
170
171    // Inner classes -------------------------------------------------
172
}
173
174
Popular Tags