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