001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.iiop.rmi.ir;
023:
024: import org.omg.CORBA.Any;
025: import org.omg.CORBA.TypeCode;
026: import org.omg.CORBA.TypeCodePackage.BadKind;
027: import org.omg.CORBA.IRObject;
028: import org.omg.CORBA.ContainedOperations;
029: import org.omg.CORBA.ContainedPackage.Description;
030: import org.omg.CORBA.IDLType;
031: import org.omg.CORBA.IDLTypeHelper;
032: import org.omg.CORBA.DefinitionKind;
033: import org.omg.CORBA.ValueMember;
034: import org.omg.CORBA.ValueMemberHelper;
035: import org.omg.CORBA.ValueMemberDef;
036: import org.omg.CORBA.ValueMemberDefOperations;
037: import org.omg.CORBA.ValueMemberDefHelper;
038: import org.omg.CORBA.ValueMemberDefPOATie;
039: import org.omg.CORBA.PUBLIC_MEMBER;
040: import org.omg.CORBA.PRIVATE_MEMBER;
041: import org.omg.CORBA.BAD_INV_ORDER;
042:
043: /**
044: * ValueMemberDef IR object.
045: *
046: * @author <a href="mailto:osh@sparre.dk">Ole Husgaard</a>
047: * @version $Revision: 57194 $
048: */
049: class ValueMemberDefImpl extends ContainedImpl implements
050: ValueMemberDefOperations {
051: // Constants -----------------------------------------------------
052:
053: // Attributes ----------------------------------------------------
054:
055: // Static --------------------------------------------------------
056:
057: // Constructors --------------------------------------------------
058:
059: ValueMemberDefImpl(String id, String name, String version,
060: TypeCode typeCode, boolean publicMember,
061: LocalContainer defined_in, RepositoryImpl repository) {
062: super (id, name, version, defined_in,
063: DefinitionKind.dk_ValueMember, repository);
064:
065: this .typeCode = typeCode;
066: this .publicMember = publicMember;
067: }
068:
069: // Public --------------------------------------------------------
070:
071: // LocalIRObject implementation ---------------------------------
072:
073: public IRObject getReference() {
074: if (ref == null) {
075: ref = org.omg.CORBA.ValueMemberDefHelper
076: .narrow(servantToReference(new ValueMemberDefPOATie(
077: this )));
078: }
079: return ref;
080: }
081:
082: public void allDone() throws IRConstructionException {
083: // Get my type definition: It should have been created now.
084: type_def = IDLTypeImpl.getIDLType(typeCode, repository);
085:
086: getReference();
087: }
088:
089: // ValueMemberDefOperations implementation --------------------------
090:
091: public TypeCode type() {
092: return typeCode;
093: }
094:
095: public IDLType type_def() {
096: return IDLTypeHelper.narrow(type_def.getReference());
097: }
098:
099: public void type_def(IDLType arg) {
100: throw new BAD_INV_ORDER("Cannot change RMI/IIOP mapping.");
101: }
102:
103: public short access() {
104: return (publicMember) ? PUBLIC_MEMBER.value
105: : PRIVATE_MEMBER.value;
106: }
107:
108: public void access(short arg) {
109: throw new BAD_INV_ORDER("Cannot change RMI/IIOP mapping.");
110: }
111:
112: // ContainedImpl implementation ----------------------------------
113:
114: public Description describe() {
115: String defined_in_id = "IR";
116:
117: if (defined_in instanceof ContainedOperations)
118: defined_in_id = ((ContainedOperations) defined_in).id();
119:
120: ValueMember d = new ValueMember(name, id, defined_in_id,
121: version, typeCode, type_def(), access());
122:
123: Any any = getORB().create_any();
124:
125: ValueMemberHelper.insert(any, d);
126:
127: return new Description(DefinitionKind.dk_ValueMember, any);
128: }
129:
130: // Package protected ---------------------------------------------
131:
132: // Private -------------------------------------------------------
133:
134: /**
135: * My CORBA reference.
136: */
137: private ValueMemberDef ref = null;
138:
139: /**
140: * My TypeCode.
141: */
142: private TypeCode typeCode;
143:
144: /**
145: * My type definition.
146: */
147: private LocalIDLType type_def;
148:
149: /**
150: * Flags that this member is public.
151: */
152: private boolean publicMember;
153: }
|