KickJava   Java API By Example, From Geeks To Geeks.

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


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.IDLType JavaDoc;
30 import org.omg.CORBA.IDLTypeHelper JavaDoc;
31 import org.omg.CORBA.DefinitionKind JavaDoc;
32 import org.omg.CORBA.ValueMember JavaDoc;
33 import org.omg.CORBA.ValueMemberHelper JavaDoc;
34 import org.omg.CORBA.ValueMemberDef JavaDoc;
35 import org.omg.CORBA.ValueMemberDefOperations JavaDoc;
36 import org.omg.CORBA.ValueMemberDefPOATie;
37 import org.omg.CORBA.PUBLIC_MEMBER JavaDoc;
38 import org.omg.CORBA.PRIVATE_MEMBER JavaDoc;
39 import org.omg.CORBA.BAD_INV_ORDER JavaDoc;
40
41 /**
42  * ValueMemberDef IR object.
43  *
44  * @author <a HREF="mailto:osh@sparre.dk">Ole Husgaard</a>
45  * @version $Revision: 37459 $
46  */

47 class ValueMemberDefImpl
48    extends ContainedImpl
49    implements ValueMemberDefOperations JavaDoc
50 {
51    // Constants -----------------------------------------------------
52

53    // Attributes ----------------------------------------------------
54

55    // Static --------------------------------------------------------
56

57    // Constructors --------------------------------------------------
58

59    ValueMemberDefImpl(String JavaDoc id, String JavaDoc name, String JavaDoc version,
60                       TypeCode JavaDoc typeCode, boolean publicMember,
61                       LocalContainer defined_in, RepositoryImpl repository)
62    {
63       super(id, name, version, defined_in,
64             DefinitionKind.dk_ValueMember, repository);
65
66       this.typeCode = typeCode;
67       this.publicMember = publicMember;
68    }
69
70    // Public --------------------------------------------------------
71

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

74    public IRObject JavaDoc getReference()
75    {
76       if (ref == null) {
77          ref = org.omg.CORBA.ValueMemberDefHelper.narrow(
78                                 servantToReference(new ValueMemberDefPOATie(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    // ValueMemberDefOperations implementation --------------------------
93

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

121    public Description describe()
122    {
123       String JavaDoc defined_in_id = "IR";
124  
125       if (defined_in instanceof ContainedOperations JavaDoc)
126          defined_in_id = ((ContainedOperations JavaDoc)defined_in).id();
127  
128       ValueMember JavaDoc d =
129                    new ValueMember JavaDoc(name, id, defined_in_id, version,
130                                    typeCode, type_def(), access());
131  
132       Any JavaDoc any = getORB().create_any();
133  
134       ValueMemberHelper.insert(any, d);
135  
136       return new Description(DefinitionKind.dk_ValueMember, any);
137    }
138
139
140    // Package protected ---------------------------------------------
141

142    // Private -------------------------------------------------------
143

144    /**
145     * My CORBA reference.
146     */

147    private ValueMemberDef JavaDoc ref = null;
148
149    /**
150     * My TypeCode.
151     */

152    private TypeCode JavaDoc typeCode;
153  
154    /**
155     * My type definition.
156     */

157    private LocalIDLType type_def;
158
159    /**
160     * Flags that this member is public.
161     */

162    private boolean publicMember;
163 }
164
Popular Tags