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.ContainedOperations;
025: import org.omg.CORBA.ContainedPackage.Description;
026: import org.omg.CORBA.DefinitionKind;
027: import org.omg.CORBA.Container;
028: import org.omg.CORBA.ContainerHelper;
029: import org.omg.CORBA.Contained;
030: import org.omg.CORBA.Repository;
031: import org.omg.CORBA.RepositoryHelper;
032: import org.omg.CORBA.BAD_INV_ORDER;
033:
034: import java.io.UnsupportedEncodingException;
035:
036: /**
037: * Abstract base class for all contained IR entities.
038: *
039: * @author <a href="mailto:osh@sparre.dk">Ole Husgaard</a>
040: * @version $Revision: 57194 $
041: */
042: abstract class ContainedImpl extends IRObjectImpl implements
043: LocalContained {
044: // Constants -----------------------------------------------------
045:
046: // Attributes ----------------------------------------------------
047:
048: // Static --------------------------------------------------------
049:
050: private static final org.jboss.logging.Logger logger = org.jboss.logging.Logger
051: .getLogger(ContainedImpl.class);
052:
053: // Constructors --------------------------------------------------
054:
055: ContainedImpl(String id, String name, String version,
056: LocalContainer defined_in, DefinitionKind def_kind,
057: RepositoryImpl repository) {
058: super (def_kind, repository);
059: this .id = id;
060: this .name = name;
061: this .version = version;
062: this .defined_in = defined_in;
063:
064: if (defined_in instanceof LocalContained)
065: this .absolute_name = ((LocalContained) defined_in)
066: .absolute_name()
067: + "::" + name;
068: else
069: // must be Repository
070: this .absolute_name = "::" + name;
071: }
072:
073: // Public --------------------------------------------------------
074:
075: // Z implementation ----------------------------------------------
076:
077: public java.lang.String id() {
078: logger.trace("ContainedImpl[" + id + "].id() entered.");
079: return id;
080: }
081:
082: public void id(java.lang.String id) {
083: throw new BAD_INV_ORDER("Cannot change RMI/IIOP mapping.");
084: }
085:
086: public java.lang.String name() {
087: logger.trace("ContainedImpl[" + id + "].name() entered.");
088: return name;
089: }
090:
091: public void name(java.lang.String name) {
092: throw new BAD_INV_ORDER("Cannot change RMI/IIOP mapping.");
093: }
094:
095: public java.lang.String version() {
096: logger.trace("ContainedImpl[" + id + "].version() entered.");
097: return version;
098: }
099:
100: public void version(java.lang.String version) {
101: throw new BAD_INV_ORDER("Cannot change RMI/IIOP mapping.");
102: }
103:
104: public Container defined_in() {
105: logger.debug("ContainedImpl[" + id + "].defined_in() entered.");
106: return ContainerHelper.narrow(defined_in.getReference());
107: }
108:
109: public java.lang.String absolute_name() {
110: logger.trace("ContainedImpl[" + id
111: + "].absolute_name() returning \"" + absolute_name
112: + "\".");
113: return absolute_name;
114: }
115:
116: public Repository containing_repository() {
117: logger.debug("ContainedImpl[" + id
118: + "].containing_repository() entered.");
119: return RepositoryHelper.narrow(repository.getReference());
120: }
121:
122: public abstract Description describe();
123:
124: public void move(Container new_container, String new_name,
125: String new_version) {
126: throw new BAD_INV_ORDER("Cannot change RMI/IIOP mapping.");
127: }
128:
129: // Y overrides ---------------------------------------------------
130:
131: // Package protected ---------------------------------------------
132:
133: // Protected -----------------------------------------------------
134:
135: /**
136: * The global repository ID of this object.
137: */
138: protected String id;
139:
140: /**
141: * The name of this object within its container.
142: */
143: protected String name;
144:
145: /**
146: * The version of this object. Defaults to 1.0.
147: */
148: protected String version = "1.0";
149:
150: /**
151: * The container this is defined in.
152: * This may not be the same as the container this is contained in.
153: */
154: protected LocalContainer defined_in;
155:
156: /**
157: * The absolute name of this object.
158: */
159: protected String absolute_name;
160:
161: /**
162: * Return the POA object ID of this IR object.
163: * Contained objects use the UTF-8 encoding of their id, prefixed by
164: * "repository_name:".
165: */
166: protected byte[] getObjectId() {
167: try {
168: return (getRepository().getObjectIdPrefix() + id)
169: .getBytes("UTF-8");
170: } catch (UnsupportedEncodingException ex) {
171: throw new RuntimeException("UTF-8 encoding not supported.");
172: }
173: }
174:
175: // Private -------------------------------------------------------
176:
177: // Inner classes -------------------------------------------------
178: }
|