001: package org.jacorb.ir;
002:
003: /*
004: * JacORB - a free Java ORB
005: *
006: * Copyright (C) 1997-2004 Gerald Brose.
007: *
008: * This library is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU Library General Public
010: * License as published by the Free Software Foundation; either
011: * version 2 of the License, or (at your option) any later version.
012: *
013: * This library is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * Library General Public License for more details.
017: *
018: * You should have received a copy of the GNU Library General Public
019: * License along with this library; if not, write to the Free
020: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021: */
022:
023: import org.apache.avalon.framework.logger.Logger;
024: import org.omg.CORBA.INTF_REPOS;
025: import org.omg.PortableServer.POA;
026:
027: /**
028: * @author Gerald Brose
029: * @version $Id: ModuleDef.java,v 1.10 2006/06/15 16:43:14 alphonse.bendt Exp $
030: */
031: public class ModuleDef extends Contained implements
032: org.omg.CORBA.ModuleDefOperations, ContainerType {
033: private Container delegate;
034: private String path = null;
035: private Logger logger;
036:
037: public ModuleDef(String path, String full_name,
038: org.omg.CORBA.Container def_in,
039: org.omg.CORBA.Repository ir, ClassLoader loader, POA poa,
040: Logger logger) throws INTF_REPOS {
041: this .logger = logger;
042: this .path = path;
043: this .full_name = full_name;
044:
045: if (this .logger.isDebugEnabled()) {
046: this .logger.debug("New ModuleDef " + full_name + " path: "
047: + path);
048: }
049:
050: def_kind = org.omg.CORBA.DefinitionKind.dk_Module;
051: if (ir == null) {
052: throw new INTF_REPOS("No repository!");
053: }
054:
055: containing_repository = ir;
056: defined_in = def_in;
057:
058: try {
059: id(RepositoryID.toRepositoryID(full_name, false, loader));
060: if (full_name.indexOf(".") > 0) {
061: name(full_name
062: .substring(full_name.lastIndexOf(".") + 1));
063:
064: if (defined_in instanceof org.omg.CORBA.Contained) {
065: absolute_name = ((org.omg.CORBA.Contained) defined_in)
066: .absolute_name()
067: + "::" + name();
068:
069: if (this .logger.isDebugEnabled()) {
070: this .logger.debug("New ModuleDef 1a) name "
071: + name() + " absolute: "
072: + absolute_name);
073: }
074: } else {
075: absolute_name = "::" + name();
076:
077: if (this .logger.isDebugEnabled()) {
078: this .logger.debug("New ModuleDef 1b) name "
079: + name() + " absolute: "
080: + absolute_name + " defined_in : "
081: + defined_in.getClass().getName());
082: }
083: }
084: } else {
085: defined_in = containing_repository;
086: name(full_name);
087: absolute_name = "::" + name();
088:
089: if (this .logger.isDebugEnabled()) {
090: this .logger.debug("New ModuleDef 2) name " + name()
091: + " absolute:" + absolute_name);
092: }
093: }
094: delegate = new Container(this , path, full_name, loader,
095: poa, this .logger);
096:
097: } catch (Exception e) {
098: this .logger.error("Caught Exception", e);
099: throw new INTF_REPOS(ErrorMsg.IR_Not_Implemented,
100: org.omg.CORBA.CompletionStatus.COMPLETED_NO);
101: }
102: }
103:
104: public String path() {
105: return path;
106: }
107:
108: public void loadContents() {
109: if (this .logger.isDebugEnabled()) {
110: this .logger.debug("Module " + name() + " loading...");
111: }
112:
113: delegate.loadContents();
114:
115: if (this .logger.isDebugEnabled()) {
116: this .logger.debug("Module " + name() + " loaded");
117: }
118: }
119:
120: void define() {
121: delegate.define();
122: }
123:
124: public org.omg.CORBA.Contained lookup(/*ScopedName*/String name) {
125: if (this .logger.isDebugEnabled()) {
126: this .logger
127: .debug("Module " + this .name + " lookup " + name);
128: }
129:
130: return delegate.lookup(name);
131: }
132:
133: public org.omg.CORBA.Contained[] contents(
134: org.omg.CORBA.DefinitionKind limit_type,
135: boolean exclude_inherited) {
136: return delegate.contents(limit_type, exclude_inherited);
137: }
138:
139: public org.omg.CORBA.Contained[] lookup_name(String search_name,
140: int levels_to_search,
141: org.omg.CORBA.DefinitionKind limit_type,
142: boolean exclude_inherited) {
143: return delegate.lookup_name(search_name, levels_to_search,
144: limit_type, exclude_inherited);
145: }
146:
147: public org.omg.CORBA.ContainerPackage.Description[] describe_contents(
148: org.omg.CORBA.DefinitionKind limit_type,
149: boolean exclude_inherited, int max_returned_objs) {
150: return delegate.describe_contents(limit_type,
151: exclude_inherited, max_returned_objs);
152: }
153:
154: public org.omg.CORBA.ModuleDef create_module(String id,
155: String name, String version) {
156: return delegate.create_module(id, name, version);
157: }
158:
159: public org.omg.CORBA.ConstantDef create_constant(String id,
160: String name, String version, org.omg.CORBA.IDLType type,
161: org.omg.CORBA.Any value) {
162: return delegate.create_constant(id, name, version, type, value);
163: }
164:
165: public org.omg.CORBA.StructDef create_struct(String id,
166: String name, String version,
167: org.omg.CORBA.StructMember[] members) {
168: return delegate.create_struct(id, name, version, members);
169: }
170:
171: public org.omg.CORBA.UnionDef create_union(String id, String name,
172: String version, org.omg.CORBA.IDLType discriminator_type,
173: org.omg.CORBA.UnionMember[] members) {
174: return delegate.create_union(id, name, version,
175: discriminator_type, members);
176: }
177:
178: public org.omg.CORBA.EnumDef create_enum(String id, String name,
179: String version, String[] members) {
180: return delegate.create_enum(id, name, version, members);
181: }
182:
183: public org.omg.CORBA.AliasDef create_alias(String id, String name,
184: String version, org.omg.CORBA.IDLType original_type) {
185: return delegate.create_alias(id, name, version, original_type);
186: }
187:
188: public org.omg.CORBA.ExceptionDef create_exception(String id,
189: String name, String version,
190: org.omg.CORBA.StructMember[] member) {
191: return delegate.create_exception(id, name, version, member);
192: }
193:
194: /**
195: * not supported
196: */
197:
198: public org.omg.CORBA.InterfaceDef create_interface(String id,
199: String name, String version,
200: org.omg.CORBA.InterfaceDef[] base_interfaces,
201: boolean is_abstract) {
202: return delegate.create_interface(id, name, version,
203: base_interfaces, is_abstract);
204: }
205:
206: /**
207: * not supported
208: */
209:
210: public org.omg.CORBA.ValueBoxDef create_value_box(String id,
211: String name, String version, org.omg.CORBA.IDLType type) {
212: return delegate.create_value_box(id, name, version, type);
213: }
214:
215: /**
216: * not supported
217: */
218:
219: public org.omg.CORBA.ValueDef create_value(String id, String name,
220: String version, boolean is_custom, boolean is_abstract,
221: org.omg.CORBA.ValueDef base_value, boolean is_truncatable,
222: org.omg.CORBA.ValueDef[] abstract_base_values,
223: org.omg.CORBA.InterfaceDef[] supported_interfaces,
224: org.omg.CORBA.Initializer[] initializers) {
225: return delegate.create_value(id, name, version, is_custom,
226: is_abstract, base_value, is_truncatable,
227: abstract_base_values, supported_interfaces,
228: initializers);
229: }
230:
231: /**
232: * not supported
233: */
234:
235: public org.omg.CORBA.NativeDef create_native(java.lang.String id,
236: java.lang.String name, java.lang.String version) {
237: return delegate.create_native(id, name, version);
238: }
239:
240: // from Contained
241:
242: public org.omg.CORBA.ContainedPackage.Description describe() {
243: org.omg.CORBA.Any a = orb.create_any();
244: String defined_in_id = null;
245:
246: if (defined_in instanceof org.omg.CORBA.Contained)
247: defined_in_id = ((org.omg.CORBA.Contained) defined_in).id();
248: else
249: defined_in_id = "IR";
250:
251: org.omg.CORBA.ModuleDescription m = new org.omg.CORBA.ModuleDescription(
252: name, id, defined_in_id, version);
253:
254: org.omg.CORBA.ModuleDescriptionHelper.insert(a, m);
255: return new org.omg.CORBA.ContainedPackage.Description(
256: org.omg.CORBA.DefinitionKind.dk_Module, a);
257: }
258:
259: public void destroy() {
260: delegate.destroy();
261: }
262: }
|