Frames | No Frames |
1: /* TransientContextExt.java -- 2: Copyright (C) 2005, 2006 Free Software Foundation, Inc. 3: 4: This file is part of GNU Classpath. 5: 6: GNU Classpath is free software; you can redistribute it and/or modify 7: it under the terms of the GNU General Public License as published by 8: the Free Software Foundation; either version 2, or (at your option) 9: any later version. 10: 11: GNU Classpath is distributed in the hope that it will be useful, but 12: WITHOUT ANY WARRANTY; without even the implied warranty of 13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14: General Public License for more details. 15: 16: You should have received a copy of the GNU General Public License 17: along with GNU Classpath; see the file COPYING. If not, write to the 18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19: 02110-1301 USA. 20: 21: Linking this library statically or dynamically with other modules is 22: making a combined work based on this library. Thus, the terms and 23: conditions of the GNU General Public License cover the whole 24: combination. 25: 26: As a special exception, the copyright holders of this library give you 27: permission to link this library with independent modules to produce an 28: executable, regardless of the license terms of these independent 29: modules, and to copy and distribute the resulting executable under 30: terms of your choice, provided that you also meet, for each linked 31: independent module, the terms and conditions of the license of that 32: module. An independent module is a module which is not derived from 33: or based on this library. If you modify this library, you may extend 34: this exception to your version of the library, but you are not 35: obligated to do so. If you do not wish to do so, delete this 36: exception statement from your version. */ 37: 38: 39: package gnu.CORBA.NamingService; 40: 41: import gnu.CORBA.SafeForDirectCalls; 42: 43: import org.omg.CORBA.NO_IMPLEMENT; 44: import org.omg.CORBA.Object; 45: import org.omg.CORBA.portable.Delegate; 46: import org.omg.CORBA.portable.ObjectImpl; 47: import org.omg.CosNaming.BindingIteratorHolder; 48: import org.omg.CosNaming.BindingListHolder; 49: import org.omg.CosNaming.NameComponent; 50: import org.omg.CosNaming.NamingContext; 51: import org.omg.CosNaming.NamingContextPackage.AlreadyBound; 52: import org.omg.CosNaming.NamingContextPackage.CannotProceed; 53: import org.omg.CosNaming.NamingContextPackage.InvalidName; 54: import org.omg.CosNaming.NamingContextPackage.NotEmpty; 55: import org.omg.CosNaming.NamingContextPackage.NotFound; 56: import org.omg.CosNaming._NamingContextExtImplBase; 57: 58: /** 59: * This naming context that adds the the string based extensions, 60: * defined by {@link NamingContextExt}. The basic functionality 61: * is handled by the enclosed instance of the {@link NamingContext}. 62: * 63: * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) 64: */ 65: public class Ext 66: extends _NamingContextExtImplBase implements SafeForDirectCalls 67: { 68: /** 69: * The older version of the naming context, where all relevant calls 70: * are forwarded. 71: */ 72: private final NamingContext classic; 73: 74: /** 75: * The converter class converts between string and array form of the 76: * name. 77: */ 78: private NameTransformer converter = new NameTransformer(); 79: 80: /** 81: * Create the extensions for the given instance of the context. 82: * 83: * @param previous_version the previous version of the naming context. 84: */ 85: public Ext(NamingContext previous_version) 86: { 87: classic = previous_version; 88: } 89: 90: /** 91: * Sets a delegate to this context and, if appropriated, also 92: * sets the same delegate to the enclosing 'classic' context. 93: * 94: * @param a_delegate a delegate to set. 95: */ 96: public void _set_delegate(Delegate a_delegate) 97: { 98: super._set_delegate(a_delegate); 99: if (classic instanceof ObjectImpl) 100: ((ObjectImpl) classic)._set_delegate(a_delegate); 101: } 102: 103: /** {@inheritDoc} */ 104: public void bind(NameComponent[] a_name, Object an_object) 105: throws NotFound, CannotProceed, InvalidName, AlreadyBound 106: { 107: classic.bind(a_name, an_object); 108: } 109: 110: /** {@inheritDoc} */ 111: public void bind_context(NameComponent[] a_name, NamingContext context) 112: throws NotFound, CannotProceed, InvalidName, AlreadyBound 113: { 114: classic.bind_context(a_name, context); 115: } 116: 117: /** {@inheritDoc} */ 118: public NamingContext bind_new_context(NameComponent[] a_name) 119: throws NotFound, AlreadyBound, CannotProceed, 120: InvalidName 121: { 122: return classic.bind_new_context(a_name); 123: } 124: 125: /** {@inheritDoc} */ 126: public void destroy() 127: throws NotEmpty 128: { 129: classic.destroy(); 130: } 131: 132: /** {@inheritDoc} */ 133: public void list(int amount, BindingListHolder a_list, 134: BindingIteratorHolder an_iter 135: ) 136: { 137: classic.list(amount, a_list, an_iter); 138: } 139: 140: /** {@inheritDoc} */ 141: public NamingContext new_context() 142: { 143: return classic.new_context(); 144: } 145: 146: /** {@inheritDoc} */ 147: public void rebind(NameComponent[] a_name, Object an_object) 148: throws NotFound, CannotProceed, InvalidName 149: { 150: classic.rebind(a_name, an_object); 151: } 152: 153: /** {@inheritDoc} */ 154: public void rebind_context(NameComponent[] a_name, NamingContext context) 155: throws NotFound, CannotProceed, InvalidName 156: { 157: classic.rebind_context(a_name, context); 158: } 159: 160: /** {@inheritDoc} */ 161: public Object resolve(NameComponent[] a_name) 162: throws NotFound, CannotProceed, InvalidName 163: { 164: return classic.resolve(a_name); 165: } 166: 167: /** 168: * Resolves the name, represented in the form of the string. The name 169: * is first parsed into an array representation, then the call 170: * is forwarded to the {@link resolve(NameComponent[])}. 171: * 172: * @param a_name_string a name to resolve. 173: * 174: * @return the resolved object. 175: * 176: * @throws NotFound if the name cannot be resolved. 177: * @throws InvalidName if the name is invalid. 178: * @throws CannotProceed on unexpected circumstances. 179: */ 180: public Object resolve_str(String a_name_string) 181: throws NotFound, CannotProceed, InvalidName 182: { 183: return resolve(to_name(a_name_string)); 184: } 185: 186: /** 187: * Convert the name string representation into array representation. 188: * 189: * @param a_name_string a string to convert. 190: * @return a converted array of the name components 191: * 192: * @throws InvalidName on parsing error. 193: */ 194: public NameComponent[] to_name(String a_name_string) 195: throws InvalidName 196: { 197: return converter.toName(a_name_string); 198: } 199: 200: /** 201: * Convert a name component array representation into string representation. 202: * 203: * @param a_name a name to convert. 204: * 205: * @return a string form. 206: * 207: * @throws InvalidName if the passed name is invalid. 208: */ 209: public String to_string(NameComponent[] a_name) 210: throws InvalidName 211: { 212: return converter.toString(a_name); 213: } 214: 215: /** 216: * This method is not yet implemented. 217: * FIXME TODO implement it. 218: */ 219: public String to_url(String an_address, String a_name_string) 220: throws org.omg.CosNaming.NamingContextExtPackage.InvalidAddress, 221: InvalidName 222: { 223: throw new NO_IMPLEMENT("Method to_url() not yet implemented."); 224: } 225: 226: /** {@inheritDoc} */ 227: public void unbind(NameComponent[] a_name) 228: throws NotFound, CannotProceed, InvalidName 229: { 230: classic.unbind(a_name); 231: } 232: }