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.IRObject;
027: import org.omg.CORBA.ContainedOperations;
028: import org.omg.CORBA.ContainedPackage.Description;
029: import org.omg.CORBA.DefinitionKind;
030: import org.omg.CORBA.IDLType;
031: import org.omg.CORBA.IDLTypeHelper;
032: import org.omg.CORBA.AttributeDef;
033: import org.omg.CORBA.AttributeDefOperations;
034: import org.omg.CORBA.AttributeMode;
035: import org.omg.CORBA.AttributeDescription;
036: import org.omg.CORBA.AttributeDescriptionHelper;
037: import org.omg.CORBA.AttributeDefPOATie;
038: import org.omg.CORBA.BAD_INV_ORDER;
039:
040: /**
041: * Attribute IR object.
042: *
043: * @author <a href="mailto:osh@sparre.dk">Ole Husgaard</a>
044: * @version $Revision: 57194 $
045: */
046: public class AttributeDefImpl extends ContainedImpl implements
047: AttributeDefOperations {
048: // Constants -----------------------------------------------------
049:
050: // Attributes ----------------------------------------------------
051:
052: // Static --------------------------------------------------------
053:
054: // Constructors --------------------------------------------------
055:
056: AttributeDefImpl(String id, String name, String version,
057: AttributeMode mode, TypeCode typeCode,
058: LocalContainer defined_in, RepositoryImpl repository) {
059: super (id, name, version, defined_in,
060: DefinitionKind.dk_Attribute, repository);
061:
062: this .mode = mode;
063: this .typeCode = typeCode;
064: }
065:
066: // Public --------------------------------------------------------
067:
068: // LocalIRObject implementation ---------------------------------
069:
070: public IRObject getReference() {
071: if (ref == null) {
072: ref = org.omg.CORBA.AttributeDefHelper
073: .narrow(servantToReference(new AttributeDefPOATie(
074: this )));
075: }
076: return ref;
077: }
078:
079: public void allDone() throws IRConstructionException {
080: // Get my type definition: It should have been created now.
081: type_def = IDLTypeImpl.getIDLType(typeCode, repository);
082:
083: getReference();
084: }
085:
086: // AttributeDefOperations implementation ----------------------------
087:
088: public TypeCode type() {
089: return typeCode;
090: }
091:
092: public IDLType type_def() {
093: return IDLTypeHelper.narrow(type_def.getReference());
094: }
095:
096: public void type_def(IDLType arg) {
097: throw new BAD_INV_ORDER("Cannot change RMI/IIOP mapping.");
098: }
099:
100: public AttributeMode mode() {
101: return mode;
102: }
103:
104: public void mode(AttributeMode arg) {
105: throw new BAD_INV_ORDER("Cannot change RMI/IIOP mapping.");
106: }
107:
108: // ContainedImpl implementation ----------------------------------
109:
110: public Description describe() {
111: String defined_in_id = "IR";
112:
113: if (defined_in instanceof ContainedOperations)
114: defined_in_id = ((ContainedOperations) defined_in).id();
115:
116: AttributeDescription d = new AttributeDescription(name, id,
117: defined_in_id, version, typeCode, mode);
118:
119: Any any = getORB().create_any();
120:
121: AttributeDescriptionHelper.insert(any, d);
122:
123: return new Description(DefinitionKind.dk_Attribute, any);
124: }
125:
126: // Y overrides ---------------------------------------------------
127:
128: // Package protected ---------------------------------------------
129:
130: // Protected -----------------------------------------------------
131:
132: // Private -------------------------------------------------------
133:
134: /**
135: * My CORBA reference.
136: */
137: private AttributeDef ref = null;
138:
139: /**
140: * My mode.
141: */
142: private AttributeMode mode;
143:
144: /**
145: * My TypeCode.
146: */
147: private TypeCode typeCode;
148:
149: /**
150: * My type definition.
151: */
152: private LocalIDLType type_def;
153:
154: // Inner classes -------------------------------------------------
155: }
|