corba/src/share/classes/com/sun/corba/se/impl/naming/cosnaming/NamingContextImpl.java
author ohair
Tue, 25 May 2010 15:52:11 -0700
changeset 5555 b2b5ed3f0d0d
parent 4 02bb8761fcce
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     1
/*
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     2
 * Copyright (c) 1996, 2003, Oracle and/or its affiliates. All rights reserved.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
02bb8761fcce Initial load
duke
parents:
diff changeset
     4
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
02bb8761fcce Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    10
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
02bb8761fcce Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
02bb8761fcce Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
02bb8761fcce Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
02bb8761fcce Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
02bb8761fcce Initial load
duke
parents:
diff changeset
    16
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
02bb8761fcce Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
02bb8761fcce Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
02bb8761fcce Initial load
duke
parents:
diff changeset
    20
 *
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    23
 * questions.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    24
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    25
02bb8761fcce Initial load
duke
parents:
diff changeset
    26
package com.sun.corba.se.impl.naming.cosnaming;
02bb8761fcce Initial load
duke
parents:
diff changeset
    27
02bb8761fcce Initial load
duke
parents:
diff changeset
    28
// Imports for Logging
02bb8761fcce Initial load
duke
parents:
diff changeset
    29
import java.util.logging.Logger;
02bb8761fcce Initial load
duke
parents:
diff changeset
    30
import java.util.logging.Level;
02bb8761fcce Initial load
duke
parents:
diff changeset
    31
import com.sun.corba.se.impl.orbutil.LogKeywords;
02bb8761fcce Initial load
duke
parents:
diff changeset
    32
02bb8761fcce Initial load
duke
parents:
diff changeset
    33
// Import general CORBA classes
02bb8761fcce Initial load
duke
parents:
diff changeset
    34
import org.omg.CORBA.Object;
02bb8761fcce Initial load
duke
parents:
diff changeset
    35
import org.omg.CORBA.BAD_PARAM;
02bb8761fcce Initial load
duke
parents:
diff changeset
    36
import org.omg.CORBA.INTERNAL;
02bb8761fcce Initial load
duke
parents:
diff changeset
    37
import org.omg.CORBA.CompletionStatus;
02bb8761fcce Initial load
duke
parents:
diff changeset
    38
import org.omg.PortableServer.POA;
02bb8761fcce Initial load
duke
parents:
diff changeset
    39
import org.omg.PortableServer.Servant;
02bb8761fcce Initial load
duke
parents:
diff changeset
    40
02bb8761fcce Initial load
duke
parents:
diff changeset
    41
// Import org.omg.CosNaming classes
02bb8761fcce Initial load
duke
parents:
diff changeset
    42
import org.omg.CosNaming.BindingType;
02bb8761fcce Initial load
duke
parents:
diff changeset
    43
import org.omg.CosNaming.BindingTypeHolder;
02bb8761fcce Initial load
duke
parents:
diff changeset
    44
import org.omg.CosNaming.BindingListHolder;
02bb8761fcce Initial load
duke
parents:
diff changeset
    45
import org.omg.CosNaming.BindingIteratorHolder;
02bb8761fcce Initial load
duke
parents:
diff changeset
    46
import org.omg.CosNaming.NameComponent;
02bb8761fcce Initial load
duke
parents:
diff changeset
    47
import org.omg.CosNaming.NamingContextHelper;
02bb8761fcce Initial load
duke
parents:
diff changeset
    48
import org.omg.CosNaming.NamingContext;
02bb8761fcce Initial load
duke
parents:
diff changeset
    49
import org.omg.CosNaming.NamingContextPackage.*;
02bb8761fcce Initial load
duke
parents:
diff changeset
    50
import org.omg.CosNaming._NamingContextImplBase;
02bb8761fcce Initial load
duke
parents:
diff changeset
    51
import org.omg.CosNaming.NamingContextExtHelper;
02bb8761fcce Initial load
duke
parents:
diff changeset
    52
import org.omg.CosNaming.NamingContextExt;
02bb8761fcce Initial load
duke
parents:
diff changeset
    53
import org.omg.CosNaming.NamingContextExtPOA;
02bb8761fcce Initial load
duke
parents:
diff changeset
    54
import org.omg.CosNaming.NamingContextExtPackage.*;
02bb8761fcce Initial load
duke
parents:
diff changeset
    55
import org.omg.CosNaming.NamingContextPackage.NotFound;
02bb8761fcce Initial load
duke
parents:
diff changeset
    56
02bb8761fcce Initial load
duke
parents:
diff changeset
    57
import com.sun.corba.se.impl.naming.cosnaming.NamingContextDataStore;
02bb8761fcce Initial load
duke
parents:
diff changeset
    58
02bb8761fcce Initial load
duke
parents:
diff changeset
    59
import com.sun.corba.se.impl.naming.namingutil.INSURLHandler;
02bb8761fcce Initial load
duke
parents:
diff changeset
    60
import com.sun.corba.se.spi.logging.CORBALogDomains;
02bb8761fcce Initial load
duke
parents:
diff changeset
    61
import com.sun.corba.se.impl.logging.NamingSystemException ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    62
02bb8761fcce Initial load
duke
parents:
diff changeset
    63
import com.sun.corba.se.spi.orb.ORB;
02bb8761fcce Initial load
duke
parents:
diff changeset
    64
02bb8761fcce Initial load
duke
parents:
diff changeset
    65
/**
02bb8761fcce Initial load
duke
parents:
diff changeset
    66
 * Class NamingContextImpl implements the org.omg.CosNaming::NamingContext
02bb8761fcce Initial load
duke
parents:
diff changeset
    67
 * interface, but does not implement the methods associated with
02bb8761fcce Initial load
duke
parents:
diff changeset
    68
 * maintaining the "table" of current bindings in a NamingContext.
02bb8761fcce Initial load
duke
parents:
diff changeset
    69
 * Instead, this implementation assumes that the derived implementation
02bb8761fcce Initial load
duke
parents:
diff changeset
    70
 * implements the NamingContextDataStore interface, which has the necessary
02bb8761fcce Initial load
duke
parents:
diff changeset
    71
 * methods. This allows multiple
02bb8761fcce Initial load
duke
parents:
diff changeset
    72
 * NamingContext implementations that differ in storage of the bindings,
02bb8761fcce Initial load
duke
parents:
diff changeset
    73
 * as well as implementations of interfaces derived from
02bb8761fcce Initial load
duke
parents:
diff changeset
    74
 * CosNaming::NamingContext that still reuses the implementation.
02bb8761fcce Initial load
duke
parents:
diff changeset
    75
 * <p>
02bb8761fcce Initial load
duke
parents:
diff changeset
    76
 * The operations bind(), rebind(), bind_context() and rebind_context()
02bb8761fcce Initial load
duke
parents:
diff changeset
    77
 * are all really implemented by doBind(). resolve() is really implemented
02bb8761fcce Initial load
duke
parents:
diff changeset
    78
 * by doResolve(), unbind() by doUnbind(). list(), new_context() and
02bb8761fcce Initial load
duke
parents:
diff changeset
    79
 * destroy() uses the NamingContextDataStore interface directly. All the
02bb8761fcce Initial load
duke
parents:
diff changeset
    80
 * doX() methods are public static.
02bb8761fcce Initial load
duke
parents:
diff changeset
    81
 * They synchronize on the NamingContextDataStore object.
02bb8761fcce Initial load
duke
parents:
diff changeset
    82
 * <p>
02bb8761fcce Initial load
duke
parents:
diff changeset
    83
 * An implementation a NamingContext must extend this class and implement
02bb8761fcce Initial load
duke
parents:
diff changeset
    84
 * the NamingContextDataStore interface with the operations:
02bb8761fcce Initial load
duke
parents:
diff changeset
    85
 * Bind(), Resolve(),
02bb8761fcce Initial load
duke
parents:
diff changeset
    86
 * Unbind(), List(), NewContext() and Destroy(). Calls
02bb8761fcce Initial load
duke
parents:
diff changeset
    87
 * to these methods are synchronized; these methods should
02bb8761fcce Initial load
duke
parents:
diff changeset
    88
 * therefore not be synchronized.
02bb8761fcce Initial load
duke
parents:
diff changeset
    89
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    90
public abstract class NamingContextImpl
02bb8761fcce Initial load
duke
parents:
diff changeset
    91
    extends NamingContextExtPOA
02bb8761fcce Initial load
duke
parents:
diff changeset
    92
    implements NamingContextDataStore
02bb8761fcce Initial load
duke
parents:
diff changeset
    93
{
02bb8761fcce Initial load
duke
parents:
diff changeset
    94
02bb8761fcce Initial load
duke
parents:
diff changeset
    95
    protected POA nsPOA;
02bb8761fcce Initial load
duke
parents:
diff changeset
    96
    private Logger readLogger, updateLogger, lifecycleLogger;
02bb8761fcce Initial load
duke
parents:
diff changeset
    97
    private NamingSystemException wrapper ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    98
    private static NamingSystemException staticWrapper =
02bb8761fcce Initial load
duke
parents:
diff changeset
    99
        NamingSystemException.get( CORBALogDomains.NAMING_UPDATE ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   100
02bb8761fcce Initial load
duke
parents:
diff changeset
   101
    // The grammer for Parsing and Building Interoperable Stringified Names
02bb8761fcce Initial load
duke
parents:
diff changeset
   102
    // are implemented in this class
02bb8761fcce Initial load
duke
parents:
diff changeset
   103
    private InterOperableNamingImpl insImpl;
02bb8761fcce Initial load
duke
parents:
diff changeset
   104
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   105
     * Create a naming context servant.
02bb8761fcce Initial load
duke
parents:
diff changeset
   106
     * Runs the super constructor.
02bb8761fcce Initial load
duke
parents:
diff changeset
   107
     * @param orb an ORB object.
02bb8761fcce Initial load
duke
parents:
diff changeset
   108
     * @exception java.lang.Exception a Java exception.
02bb8761fcce Initial load
duke
parents:
diff changeset
   109
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   110
    public NamingContextImpl(ORB orb, POA poa) throws java.lang.Exception {
02bb8761fcce Initial load
duke
parents:
diff changeset
   111
        super();
02bb8761fcce Initial load
duke
parents:
diff changeset
   112
        this.orb = orb;
02bb8761fcce Initial load
duke
parents:
diff changeset
   113
        wrapper = NamingSystemException.get( orb,
02bb8761fcce Initial load
duke
parents:
diff changeset
   114
            CORBALogDomains.NAMING_UPDATE ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   115
02bb8761fcce Initial load
duke
parents:
diff changeset
   116
        insImpl = new InterOperableNamingImpl( );
02bb8761fcce Initial load
duke
parents:
diff changeset
   117
        this.nsPOA = poa;
02bb8761fcce Initial load
duke
parents:
diff changeset
   118
        readLogger = orb.getLogger( CORBALogDomains.NAMING_READ);
02bb8761fcce Initial load
duke
parents:
diff changeset
   119
        updateLogger = orb.getLogger( CORBALogDomains.NAMING_UPDATE);
02bb8761fcce Initial load
duke
parents:
diff changeset
   120
        lifecycleLogger = orb.getLogger(
02bb8761fcce Initial load
duke
parents:
diff changeset
   121
            CORBALogDomains.NAMING_LIFECYCLE);
02bb8761fcce Initial load
duke
parents:
diff changeset
   122
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   123
02bb8761fcce Initial load
duke
parents:
diff changeset
   124
    public POA getNSPOA( ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   125
        return nsPOA;
02bb8761fcce Initial load
duke
parents:
diff changeset
   126
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   127
02bb8761fcce Initial load
duke
parents:
diff changeset
   128
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   129
     * Bind an object under a name in this NamingContext. If the name
02bb8761fcce Initial load
duke
parents:
diff changeset
   130
     * contains multiple (n) components, n-1 will be resolved in this
02bb8761fcce Initial load
duke
parents:
diff changeset
   131
     * NamingContext and the object bound in resulting NamingContext.
02bb8761fcce Initial load
duke
parents:
diff changeset
   132
     * An exception is thrown if a binding with the supplied name already
02bb8761fcce Initial load
duke
parents:
diff changeset
   133
     * exists. If the
02bb8761fcce Initial load
duke
parents:
diff changeset
   134
     * object to be bound is a NamingContext it will not participate in
02bb8761fcce Initial load
duke
parents:
diff changeset
   135
     * a recursive resolve.
02bb8761fcce Initial load
duke
parents:
diff changeset
   136
     * @param n a sequence of NameComponents which is the name under which
02bb8761fcce Initial load
duke
parents:
diff changeset
   137
     * the object will be bound.
02bb8761fcce Initial load
duke
parents:
diff changeset
   138
     * @param obj the object reference to be bound.
02bb8761fcce Initial load
duke
parents:
diff changeset
   139
     * @exception org.omg.CosNaming.NamingContextPackage.NotFound A name with
02bb8761fcce Initial load
duke
parents:
diff changeset
   140
     * multiple components was supplied, but the first component could not be
02bb8761fcce Initial load
duke
parents:
diff changeset
   141
     * resolved.
02bb8761fcce Initial load
duke
parents:
diff changeset
   142
     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Could
02bb8761fcce Initial load
duke
parents:
diff changeset
   143
     * not proceed in resolving the n-1 components of the supplied name.
02bb8761fcce Initial load
duke
parents:
diff changeset
   144
     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName The
02bb8761fcce Initial load
duke
parents:
diff changeset
   145
     * supplied name is invalid (i.e., has length less than 1).
02bb8761fcce Initial load
duke
parents:
diff changeset
   146
     * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound An object
02bb8761fcce Initial load
duke
parents:
diff changeset
   147
     * is already bound under the supplied name.
02bb8761fcce Initial load
duke
parents:
diff changeset
   148
     * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA
02bb8761fcce Initial load
duke
parents:
diff changeset
   149
     * system exceptions.
02bb8761fcce Initial load
duke
parents:
diff changeset
   150
     * @see doBind
02bb8761fcce Initial load
duke
parents:
diff changeset
   151
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   152
    public void bind(NameComponent[] n, org.omg.CORBA.Object obj)
02bb8761fcce Initial load
duke
parents:
diff changeset
   153
        throws org.omg.CosNaming.NamingContextPackage.NotFound,
02bb8761fcce Initial load
duke
parents:
diff changeset
   154
               org.omg.CosNaming.NamingContextPackage.CannotProceed,
02bb8761fcce Initial load
duke
parents:
diff changeset
   155
               org.omg.CosNaming.NamingContextPackage.InvalidName,
02bb8761fcce Initial load
duke
parents:
diff changeset
   156
               org.omg.CosNaming.NamingContextPackage.AlreadyBound
02bb8761fcce Initial load
duke
parents:
diff changeset
   157
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   158
        if( obj == null )
02bb8761fcce Initial load
duke
parents:
diff changeset
   159
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   160
            updateLogger.warning( LogKeywords.NAMING_BIND +
02bb8761fcce Initial load
duke
parents:
diff changeset
   161
                " unsuccessful because NULL Object cannot be Bound " );
02bb8761fcce Initial load
duke
parents:
diff changeset
   162
            throw wrapper.objectIsNull() ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   163
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   164
        // doBind implements all four flavors of binding
02bb8761fcce Initial load
duke
parents:
diff changeset
   165
        NamingContextDataStore impl = (NamingContextDataStore)this;
02bb8761fcce Initial load
duke
parents:
diff changeset
   166
        doBind(impl,n,obj,false,BindingType.nobject);
02bb8761fcce Initial load
duke
parents:
diff changeset
   167
        if( updateLogger.isLoggable( Level.FINE  ) ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   168
            // isLoggable call to make sure that we save some precious
02bb8761fcce Initial load
duke
parents:
diff changeset
   169
            // processor cycles, if there is no need to log.
02bb8761fcce Initial load
duke
parents:
diff changeset
   170
            updateLogger.fine( LogKeywords.NAMING_BIND_SUCCESS + " Name = " +
02bb8761fcce Initial load
duke
parents:
diff changeset
   171
                NamingUtils.getDirectoryStructuredName( n ) );
02bb8761fcce Initial load
duke
parents:
diff changeset
   172
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   173
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   174
02bb8761fcce Initial load
duke
parents:
diff changeset
   175
02bb8761fcce Initial load
duke
parents:
diff changeset
   176
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   177
     * Bind a NamingContext under a name in this NamingContext. If the name
02bb8761fcce Initial load
duke
parents:
diff changeset
   178
     * contains multiple (n) components, n-1 will be resolved in this
02bb8761fcce Initial load
duke
parents:
diff changeset
   179
     * NamingContext and the object bound in resulting NamingContext.
02bb8761fcce Initial load
duke
parents:
diff changeset
   180
     * An exception is thrown if a binding with the supplied name already
02bb8761fcce Initial load
duke
parents:
diff changeset
   181
     * exists. The NamingContext will participate in recursive resolving.
02bb8761fcce Initial load
duke
parents:
diff changeset
   182
     * @param n a sequence of NameComponents which is the name under which
02bb8761fcce Initial load
duke
parents:
diff changeset
   183
     * the object will be bound.
02bb8761fcce Initial load
duke
parents:
diff changeset
   184
     * @param obj the NamingContect object reference to be bound.
02bb8761fcce Initial load
duke
parents:
diff changeset
   185
     * @exception org.omg.CosNaming.NamingContextPackage.NotFound A name with
02bb8761fcce Initial load
duke
parents:
diff changeset
   186
     * multiple components was supplied, but the first component could not be
02bb8761fcce Initial load
duke
parents:
diff changeset
   187
     * resolved.
02bb8761fcce Initial load
duke
parents:
diff changeset
   188
     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Could
02bb8761fcce Initial load
duke
parents:
diff changeset
   189
     * not proceed in resolving the n-1 components of the supplied name.
02bb8761fcce Initial load
duke
parents:
diff changeset
   190
     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName The
02bb8761fcce Initial load
duke
parents:
diff changeset
   191
     * supplied name is invalid (i.e., has length less than 1).
02bb8761fcce Initial load
duke
parents:
diff changeset
   192
     * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound An object
02bb8761fcce Initial load
duke
parents:
diff changeset
   193
     * is already bound under the supplied name.
02bb8761fcce Initial load
duke
parents:
diff changeset
   194
     * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA
02bb8761fcce Initial load
duke
parents:
diff changeset
   195
     * system exceptions.
02bb8761fcce Initial load
duke
parents:
diff changeset
   196
     * @see doBind
02bb8761fcce Initial load
duke
parents:
diff changeset
   197
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   198
    public void bind_context(NameComponent[] n, NamingContext nc)
02bb8761fcce Initial load
duke
parents:
diff changeset
   199
        throws org.omg.CosNaming.NamingContextPackage.NotFound,
02bb8761fcce Initial load
duke
parents:
diff changeset
   200
               org.omg.CosNaming.NamingContextPackage.CannotProceed,
02bb8761fcce Initial load
duke
parents:
diff changeset
   201
               org.omg.CosNaming.NamingContextPackage.InvalidName,
02bb8761fcce Initial load
duke
parents:
diff changeset
   202
               org.omg.CosNaming.NamingContextPackage.AlreadyBound
02bb8761fcce Initial load
duke
parents:
diff changeset
   203
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   204
        if( nc == null ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   205
            updateLogger.warning( LogKeywords.NAMING_BIND_FAILURE +
02bb8761fcce Initial load
duke
parents:
diff changeset
   206
                " NULL Context cannot be Bound " );
02bb8761fcce Initial load
duke
parents:
diff changeset
   207
            throw new BAD_PARAM( "Naming Context should not be null " );
02bb8761fcce Initial load
duke
parents:
diff changeset
   208
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   209
        // doBind implements all four flavors of binding
02bb8761fcce Initial load
duke
parents:
diff changeset
   210
        NamingContextDataStore impl = (NamingContextDataStore)this;
02bb8761fcce Initial load
duke
parents:
diff changeset
   211
        doBind(impl,n,nc,false,BindingType.ncontext);
02bb8761fcce Initial load
duke
parents:
diff changeset
   212
        if( updateLogger.isLoggable( Level.FINE ) ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   213
            // isLoggable call to make sure that we save some precious
02bb8761fcce Initial load
duke
parents:
diff changeset
   214
            // processor cycles, if there is no need to log.
02bb8761fcce Initial load
duke
parents:
diff changeset
   215
            updateLogger.fine( LogKeywords.NAMING_BIND_SUCCESS + " Name = " +
02bb8761fcce Initial load
duke
parents:
diff changeset
   216
                NamingUtils.getDirectoryStructuredName( n ) );
02bb8761fcce Initial load
duke
parents:
diff changeset
   217
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   218
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   219
02bb8761fcce Initial load
duke
parents:
diff changeset
   220
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   221
     * Bind an object under a name in this NamingContext. If the name
02bb8761fcce Initial load
duke
parents:
diff changeset
   222
     * contains multiple (n) components, n-1 will be resolved in this
02bb8761fcce Initial load
duke
parents:
diff changeset
   223
     * NamingContext and the object bound in resulting NamingContext.
02bb8761fcce Initial load
duke
parents:
diff changeset
   224
     * If a binding under the supplied name already exists it will be
02bb8761fcce Initial load
duke
parents:
diff changeset
   225
     * unbound first. If the
02bb8761fcce Initial load
duke
parents:
diff changeset
   226
     * object to be bound is a NamingContext it will not participate in
02bb8761fcce Initial load
duke
parents:
diff changeset
   227
     * a recursive resolve.
02bb8761fcce Initial load
duke
parents:
diff changeset
   228
     * @param n a sequence of NameComponents which is the name under which
02bb8761fcce Initial load
duke
parents:
diff changeset
   229
     * the object will be bound.
02bb8761fcce Initial load
duke
parents:
diff changeset
   230
     * @param obj the object reference to be bound.
02bb8761fcce Initial load
duke
parents:
diff changeset
   231
     * @exception org.omg.CosNaming.NamingContextPackage.NotFound A name with
02bb8761fcce Initial load
duke
parents:
diff changeset
   232
     * multiple components was supplied, but the first component could not be
02bb8761fcce Initial load
duke
parents:
diff changeset
   233
     * resolved.
02bb8761fcce Initial load
duke
parents:
diff changeset
   234
     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Could not
02bb8761fcce Initial load
duke
parents:
diff changeset
   235
     * proceed in resolving the n-1 components of the supplied name.
02bb8761fcce Initial load
duke
parents:
diff changeset
   236
     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName The
02bb8761fcce Initial load
duke
parents:
diff changeset
   237
     * supplied name is invalid (i.e., has length less than 1).
02bb8761fcce Initial load
duke
parents:
diff changeset
   238
     * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA
02bb8761fcce Initial load
duke
parents:
diff changeset
   239
     * system exceptions.
02bb8761fcce Initial load
duke
parents:
diff changeset
   240
     * @see doBind
02bb8761fcce Initial load
duke
parents:
diff changeset
   241
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   242
    public  void rebind(NameComponent[] n, org.omg.CORBA.Object obj)
02bb8761fcce Initial load
duke
parents:
diff changeset
   243
        throws       org.omg.CosNaming.NamingContextPackage.NotFound,
02bb8761fcce Initial load
duke
parents:
diff changeset
   244
                     org.omg.CosNaming.NamingContextPackage.CannotProceed,
02bb8761fcce Initial load
duke
parents:
diff changeset
   245
                     org.omg.CosNaming.NamingContextPackage.InvalidName
02bb8761fcce Initial load
duke
parents:
diff changeset
   246
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   247
        if( obj == null )
02bb8761fcce Initial load
duke
parents:
diff changeset
   248
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   249
            updateLogger.warning( LogKeywords.NAMING_REBIND_FAILURE +
02bb8761fcce Initial load
duke
parents:
diff changeset
   250
                " NULL Object cannot be Bound " );
02bb8761fcce Initial load
duke
parents:
diff changeset
   251
            throw wrapper.objectIsNull() ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   252
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   253
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   254
            // doBind implements all four flavors of binding
02bb8761fcce Initial load
duke
parents:
diff changeset
   255
            NamingContextDataStore impl = (NamingContextDataStore)this;
02bb8761fcce Initial load
duke
parents:
diff changeset
   256
            doBind(impl,n,obj,true,BindingType.nobject);
02bb8761fcce Initial load
duke
parents:
diff changeset
   257
        } catch (org.omg.CosNaming.NamingContextPackage.AlreadyBound ex) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   258
            updateLogger.warning( LogKeywords.NAMING_REBIND_FAILURE +
02bb8761fcce Initial load
duke
parents:
diff changeset
   259
                NamingUtils.getDirectoryStructuredName( n ) +
02bb8761fcce Initial load
duke
parents:
diff changeset
   260
                " is already bound to a Naming Context" );
02bb8761fcce Initial load
duke
parents:
diff changeset
   261
            // This should not happen
02bb8761fcce Initial load
duke
parents:
diff changeset
   262
            throw wrapper.namingCtxRebindAlreadyBound( ex ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   263
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   264
        if( updateLogger.isLoggable( Level.FINE  ) ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   265
            // isLoggable call to make sure that we save some precious
02bb8761fcce Initial load
duke
parents:
diff changeset
   266
            // processor cycles, if there is no need to log.
02bb8761fcce Initial load
duke
parents:
diff changeset
   267
            updateLogger.fine( LogKeywords.NAMING_REBIND_SUCCESS + " Name = " +
02bb8761fcce Initial load
duke
parents:
diff changeset
   268
                NamingUtils.getDirectoryStructuredName( n ) );
02bb8761fcce Initial load
duke
parents:
diff changeset
   269
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   270
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   271
02bb8761fcce Initial load
duke
parents:
diff changeset
   272
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   273
     * Bind a NamingContext under a name in this NamingContext. If the name
02bb8761fcce Initial load
duke
parents:
diff changeset
   274
     * contains multiple (n) components, the first n-1 components will be
02bb8761fcce Initial load
duke
parents:
diff changeset
   275
     * resolved in this NamingContext and the object bound in resulting
02bb8761fcce Initial load
duke
parents:
diff changeset
   276
     * NamingContext. If a binding under the supplied name already exists it
02bb8761fcce Initial load
duke
parents:
diff changeset
   277
     * will be unbound first. The NamingContext will participate in recursive
02bb8761fcce Initial load
duke
parents:
diff changeset
   278
     * resolving.
02bb8761fcce Initial load
duke
parents:
diff changeset
   279
     * @param n a sequence of NameComponents which is the name under which
02bb8761fcce Initial load
duke
parents:
diff changeset
   280
     * the object will be bound.
02bb8761fcce Initial load
duke
parents:
diff changeset
   281
     * @param obj the object reference to be bound.
02bb8761fcce Initial load
duke
parents:
diff changeset
   282
     * @exception org.omg.CosNaming.NamingContextPackage.NotFound A name with
02bb8761fcce Initial load
duke
parents:
diff changeset
   283
     * multiple components was supplied, but the first component could not be
02bb8761fcce Initial load
duke
parents:
diff changeset
   284
     * resolved.
02bb8761fcce Initial load
duke
parents:
diff changeset
   285
     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Could not
02bb8761fcce Initial load
duke
parents:
diff changeset
   286
     * proceed in resolving the n-1 components of the supplied name.
02bb8761fcce Initial load
duke
parents:
diff changeset
   287
     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName The
02bb8761fcce Initial load
duke
parents:
diff changeset
   288
     * supplied name is invalid (i.e., has length less than 1).
02bb8761fcce Initial load
duke
parents:
diff changeset
   289
     * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA
02bb8761fcce Initial load
duke
parents:
diff changeset
   290
     * system exceptions.
02bb8761fcce Initial load
duke
parents:
diff changeset
   291
     * @see doBind
02bb8761fcce Initial load
duke
parents:
diff changeset
   292
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   293
    public  void rebind_context(NameComponent[] n, NamingContext nc)
02bb8761fcce Initial load
duke
parents:
diff changeset
   294
        throws org.omg.CosNaming.NamingContextPackage.NotFound,
02bb8761fcce Initial load
duke
parents:
diff changeset
   295
               org.omg.CosNaming.NamingContextPackage.CannotProceed,
02bb8761fcce Initial load
duke
parents:
diff changeset
   296
               org.omg.CosNaming.NamingContextPackage.InvalidName
02bb8761fcce Initial load
duke
parents:
diff changeset
   297
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   298
        if( nc == null )
02bb8761fcce Initial load
duke
parents:
diff changeset
   299
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   300
            updateLogger.warning( LogKeywords.NAMING_REBIND_FAILURE +
02bb8761fcce Initial load
duke
parents:
diff changeset
   301
                " NULL Context cannot be Bound " );
02bb8761fcce Initial load
duke
parents:
diff changeset
   302
            throw wrapper.objectIsNull() ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   303
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   304
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   305
            // doBind implements all four flavors of binding
02bb8761fcce Initial load
duke
parents:
diff changeset
   306
            NamingContextDataStore impl = (NamingContextDataStore)this;
02bb8761fcce Initial load
duke
parents:
diff changeset
   307
            doBind(impl,n,nc,true,BindingType.ncontext);
02bb8761fcce Initial load
duke
parents:
diff changeset
   308
        } catch (org.omg.CosNaming.NamingContextPackage.AlreadyBound ex) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   309
            // This should not happen
02bb8761fcce Initial load
duke
parents:
diff changeset
   310
            updateLogger.warning( LogKeywords.NAMING_REBIND_FAILURE +
02bb8761fcce Initial load
duke
parents:
diff changeset
   311
                NamingUtils.getDirectoryStructuredName( n ) +
02bb8761fcce Initial load
duke
parents:
diff changeset
   312
                " is already bound to a CORBA Object" );
02bb8761fcce Initial load
duke
parents:
diff changeset
   313
            throw wrapper.namingCtxRebindctxAlreadyBound( ex ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   314
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   315
        if( updateLogger.isLoggable( Level.FINE ) ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   316
            // isLoggable call to make sure that we save some precious
02bb8761fcce Initial load
duke
parents:
diff changeset
   317
            // processor cycles, if there is no need to log.
02bb8761fcce Initial load
duke
parents:
diff changeset
   318
            updateLogger.fine( LogKeywords.NAMING_REBIND_SUCCESS + " Name = " +
02bb8761fcce Initial load
duke
parents:
diff changeset
   319
                NamingUtils.getDirectoryStructuredName( n ) );
02bb8761fcce Initial load
duke
parents:
diff changeset
   320
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   321
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   322
02bb8761fcce Initial load
duke
parents:
diff changeset
   323
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   324
     * Resolve a name in this NamingContext and return the object reference
02bb8761fcce Initial load
duke
parents:
diff changeset
   325
     * bound to the name. If the name contains multiple (n) components,
02bb8761fcce Initial load
duke
parents:
diff changeset
   326
     * the first component will be resolved in this NamingContext and the
02bb8761fcce Initial load
duke
parents:
diff changeset
   327
     * remaining components resolved in the resulting NamingContext, provided
02bb8761fcce Initial load
duke
parents:
diff changeset
   328
     * that the NamingContext bound to the first component of the name was
02bb8761fcce Initial load
duke
parents:
diff changeset
   329
     * bound with bind_context().
02bb8761fcce Initial load
duke
parents:
diff changeset
   330
     * @param n a sequence of NameComponents which is the name to be resolved.
02bb8761fcce Initial load
duke
parents:
diff changeset
   331
     * @return the object reference bound under the supplied name.
02bb8761fcce Initial load
duke
parents:
diff changeset
   332
     * @exception org.omg.CosNaming.NamingContextPackage.NotFound A name with
02bb8761fcce Initial load
duke
parents:
diff changeset
   333
     * multiple components was supplied, but the first component could not be
02bb8761fcce Initial load
duke
parents:
diff changeset
   334
     * resolved.
02bb8761fcce Initial load
duke
parents:
diff changeset
   335
     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Could not
02bb8761fcce Initial load
duke
parents:
diff changeset
   336
     * proceed in resolving the n-1 components of the supplied name.
02bb8761fcce Initial load
duke
parents:
diff changeset
   337
     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName The
02bb8761fcce Initial load
duke
parents:
diff changeset
   338
     * supplied name is invalid (i.e., has length less than 1).
02bb8761fcce Initial load
duke
parents:
diff changeset
   339
     * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA
02bb8761fcce Initial load
duke
parents:
diff changeset
   340
     * system exceptions.
02bb8761fcce Initial load
duke
parents:
diff changeset
   341
     * @see doResolve
02bb8761fcce Initial load
duke
parents:
diff changeset
   342
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   343
    public  org.omg.CORBA.Object resolve(NameComponent[] n)
02bb8761fcce Initial load
duke
parents:
diff changeset
   344
        throws org.omg.CosNaming.NamingContextPackage.NotFound,
02bb8761fcce Initial load
duke
parents:
diff changeset
   345
               org.omg.CosNaming.NamingContextPackage.CannotProceed,
02bb8761fcce Initial load
duke
parents:
diff changeset
   346
               org.omg.CosNaming.NamingContextPackage.InvalidName
02bb8761fcce Initial load
duke
parents:
diff changeset
   347
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   348
        // doResolve actually resolves
02bb8761fcce Initial load
duke
parents:
diff changeset
   349
        NamingContextDataStore impl = (NamingContextDataStore)this;
02bb8761fcce Initial load
duke
parents:
diff changeset
   350
        org.omg.CORBA.Object obj = doResolve(impl,n);
02bb8761fcce Initial load
duke
parents:
diff changeset
   351
        if( obj != null ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   352
            if( readLogger.isLoggable( Level.FINE ) ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   353
                 readLogger.fine( LogKeywords.NAMING_RESOLVE_SUCCESS +
02bb8761fcce Initial load
duke
parents:
diff changeset
   354
                 " Name: " + NamingUtils.getDirectoryStructuredName( n ) );
02bb8761fcce Initial load
duke
parents:
diff changeset
   355
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   356
        } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   357
             readLogger.warning( LogKeywords.NAMING_RESOLVE_FAILURE +
02bb8761fcce Initial load
duke
parents:
diff changeset
   358
                 " Name: " + NamingUtils.getDirectoryStructuredName( n ) );
02bb8761fcce Initial load
duke
parents:
diff changeset
   359
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   360
        return obj;
02bb8761fcce Initial load
duke
parents:
diff changeset
   361
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   362
02bb8761fcce Initial load
duke
parents:
diff changeset
   363
02bb8761fcce Initial load
duke
parents:
diff changeset
   364
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   365
     * Remove a binding from this NamingContext. If the name contains
02bb8761fcce Initial load
duke
parents:
diff changeset
   366
     * multiple (n) components, the first n-1 components will be resolved
02bb8761fcce Initial load
duke
parents:
diff changeset
   367
     * from this NamingContext and the final component unbound in
02bb8761fcce Initial load
duke
parents:
diff changeset
   368
     * the resulting NamingContext.
02bb8761fcce Initial load
duke
parents:
diff changeset
   369
     * @param n a sequence of NameComponents which is the name to be unbound.
02bb8761fcce Initial load
duke
parents:
diff changeset
   370
     * @exception org.omg.CosNaming.NamingContextPackage.NotFound A name with
02bb8761fcce Initial load
duke
parents:
diff changeset
   371
     * multiple components was supplied, but the first component could not be
02bb8761fcce Initial load
duke
parents:
diff changeset
   372
     * resolved.
02bb8761fcce Initial load
duke
parents:
diff changeset
   373
     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Could not
02bb8761fcce Initial load
duke
parents:
diff changeset
   374
     * proceed in resolving the n-1 components of the supplied name.
02bb8761fcce Initial load
duke
parents:
diff changeset
   375
     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName The
02bb8761fcce Initial load
duke
parents:
diff changeset
   376
     * supplied name is invalid (i.e., has length less than 1).
02bb8761fcce Initial load
duke
parents:
diff changeset
   377
     * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA
02bb8761fcce Initial load
duke
parents:
diff changeset
   378
     * system exceptions.
02bb8761fcce Initial load
duke
parents:
diff changeset
   379
     * @see doUnbind
02bb8761fcce Initial load
duke
parents:
diff changeset
   380
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   381
    public  void unbind(NameComponent[] n)
02bb8761fcce Initial load
duke
parents:
diff changeset
   382
        throws org.omg.CosNaming.NamingContextPackage.NotFound,
02bb8761fcce Initial load
duke
parents:
diff changeset
   383
               org.omg.CosNaming.NamingContextPackage.CannotProceed,
02bb8761fcce Initial load
duke
parents:
diff changeset
   384
               org.omg.CosNaming.NamingContextPackage.InvalidName
02bb8761fcce Initial load
duke
parents:
diff changeset
   385
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   386
        // doUnbind actually unbinds
02bb8761fcce Initial load
duke
parents:
diff changeset
   387
        NamingContextDataStore impl = (NamingContextDataStore)this;
02bb8761fcce Initial load
duke
parents:
diff changeset
   388
        doUnbind(impl,n);
02bb8761fcce Initial load
duke
parents:
diff changeset
   389
        if( updateLogger.isLoggable( Level.FINE ) ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   390
            // isLoggable call to make sure that we save some precious
02bb8761fcce Initial load
duke
parents:
diff changeset
   391
            // processor cycles, if there is no need to log.
02bb8761fcce Initial load
duke
parents:
diff changeset
   392
            updateLogger.fine( LogKeywords.NAMING_UNBIND_SUCCESS +
02bb8761fcce Initial load
duke
parents:
diff changeset
   393
                " Name: " + NamingUtils.getDirectoryStructuredName( n ) );
02bb8761fcce Initial load
duke
parents:
diff changeset
   394
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   395
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   396
02bb8761fcce Initial load
duke
parents:
diff changeset
   397
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   398
     * List the contents of this NamingContest. A sequence of bindings
02bb8761fcce Initial load
duke
parents:
diff changeset
   399
     * is returned (a BindingList) containing up to the number of requested
02bb8761fcce Initial load
duke
parents:
diff changeset
   400
     * bindings, and a BindingIterator object reference is returned for
02bb8761fcce Initial load
duke
parents:
diff changeset
   401
     * iterating over the remaining bindings.
02bb8761fcce Initial load
duke
parents:
diff changeset
   402
     * @param how_many The number of requested bindings in the BindingList.
02bb8761fcce Initial load
duke
parents:
diff changeset
   403
     * @param bl The BindingList as an out parameter.
02bb8761fcce Initial load
duke
parents:
diff changeset
   404
     * @param bi The BindingIterator as an out parameter.
02bb8761fcce Initial load
duke
parents:
diff changeset
   405
     * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA
02bb8761fcce Initial load
duke
parents:
diff changeset
   406
     * system exceptions.
02bb8761fcce Initial load
duke
parents:
diff changeset
   407
     * @see BindingListHolder
02bb8761fcce Initial load
duke
parents:
diff changeset
   408
     * @see BindingIteratorImpl
02bb8761fcce Initial load
duke
parents:
diff changeset
   409
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   410
    public  void list(int how_many, BindingListHolder bl,
02bb8761fcce Initial load
duke
parents:
diff changeset
   411
        BindingIteratorHolder bi)
02bb8761fcce Initial load
duke
parents:
diff changeset
   412
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   413
        // List actually generates the list
02bb8761fcce Initial load
duke
parents:
diff changeset
   414
        NamingContextDataStore impl = (NamingContextDataStore)this;
02bb8761fcce Initial load
duke
parents:
diff changeset
   415
        synchronized (impl) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   416
            impl.List(how_many,bl,bi);
02bb8761fcce Initial load
duke
parents:
diff changeset
   417
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   418
        if( readLogger.isLoggable( Level.FINE ) && (bl.value != null )) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   419
            // isLoggable call to make sure that we save some precious
02bb8761fcce Initial load
duke
parents:
diff changeset
   420
            // processor cycles, if there is no need to log.
02bb8761fcce Initial load
duke
parents:
diff changeset
   421
            readLogger.fine ( LogKeywords.NAMING_LIST_SUCCESS +
02bb8761fcce Initial load
duke
parents:
diff changeset
   422
                "list(" + how_many + ") -> bindings[" + bl.value.length +
02bb8761fcce Initial load
duke
parents:
diff changeset
   423
                "] + iterator: " + bi.value);
02bb8761fcce Initial load
duke
parents:
diff changeset
   424
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   425
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   426
02bb8761fcce Initial load
duke
parents:
diff changeset
   427
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   428
     * Create a NamingContext object and return its object reference.
02bb8761fcce Initial load
duke
parents:
diff changeset
   429
     * @return an object reference for a new NamingContext object implemented
02bb8761fcce Initial load
duke
parents:
diff changeset
   430
     * by this Name Server.
02bb8761fcce Initial load
duke
parents:
diff changeset
   431
     * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA
02bb8761fcce Initial load
duke
parents:
diff changeset
   432
     * system exceptions.
02bb8761fcce Initial load
duke
parents:
diff changeset
   433
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   434
    public synchronized NamingContext new_context()
02bb8761fcce Initial load
duke
parents:
diff changeset
   435
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   436
        // Create actually creates a new naming context
02bb8761fcce Initial load
duke
parents:
diff changeset
   437
        lifecycleLogger.fine( "Creating New Naming Context " );
02bb8761fcce Initial load
duke
parents:
diff changeset
   438
        NamingContextDataStore impl = (NamingContextDataStore)this;
02bb8761fcce Initial load
duke
parents:
diff changeset
   439
        synchronized (impl) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   440
            NamingContext nctx = impl.NewContext();
02bb8761fcce Initial load
duke
parents:
diff changeset
   441
            if( nctx != null ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   442
                lifecycleLogger.fine( LogKeywords.LIFECYCLE_CREATE_SUCCESS );
02bb8761fcce Initial load
duke
parents:
diff changeset
   443
            } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   444
                // If naming context is null, then that must be a serious
02bb8761fcce Initial load
duke
parents:
diff changeset
   445
                // error.
02bb8761fcce Initial load
duke
parents:
diff changeset
   446
                lifecycleLogger.severe ( LogKeywords.LIFECYCLE_CREATE_FAILURE );
02bb8761fcce Initial load
duke
parents:
diff changeset
   447
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   448
            return nctx;
02bb8761fcce Initial load
duke
parents:
diff changeset
   449
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   450
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   451
02bb8761fcce Initial load
duke
parents:
diff changeset
   452
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   453
     * Create a new NamingContext, bind it in this Naming Context and return
02bb8761fcce Initial load
duke
parents:
diff changeset
   454
     * its object reference. This is equivalent to using new_context() followed
02bb8761fcce Initial load
duke
parents:
diff changeset
   455
     * by bind_context() with the supplied name and the object reference for
02bb8761fcce Initial load
duke
parents:
diff changeset
   456
     * the newly created NamingContext.
02bb8761fcce Initial load
duke
parents:
diff changeset
   457
     * @param n a sequence of NameComponents which is the name to be unbound.
02bb8761fcce Initial load
duke
parents:
diff changeset
   458
     * @return an object reference for a new NamingContext object implemented
02bb8761fcce Initial load
duke
parents:
diff changeset
   459
     * by this Name Server, bound to the supplied name.
02bb8761fcce Initial load
duke
parents:
diff changeset
   460
     * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound An object
02bb8761fcce Initial load
duke
parents:
diff changeset
   461
     * is already bound under the supplied name.
02bb8761fcce Initial load
duke
parents:
diff changeset
   462
     * @exception org.omg.CosNaming.NamingContextPackage.NotFound A name with
02bb8761fcce Initial load
duke
parents:
diff changeset
   463
     * multiple components was supplied, but the first component could not be
02bb8761fcce Initial load
duke
parents:
diff changeset
   464
     * resolved.
02bb8761fcce Initial load
duke
parents:
diff changeset
   465
     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Could not
02bb8761fcce Initial load
duke
parents:
diff changeset
   466
     * proceed in resolving the n-1 components of the supplied name.
02bb8761fcce Initial load
duke
parents:
diff changeset
   467
     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName The
02bb8761fcce Initial load
duke
parents:
diff changeset
   468
     * supplied name is invalid (i.e., has length less than 1).
02bb8761fcce Initial load
duke
parents:
diff changeset
   469
     * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA
02bb8761fcce Initial load
duke
parents:
diff changeset
   470
     * system exceptions.
02bb8761fcce Initial load
duke
parents:
diff changeset
   471
     * @see new_context
02bb8761fcce Initial load
duke
parents:
diff changeset
   472
     * @see bind_context
02bb8761fcce Initial load
duke
parents:
diff changeset
   473
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   474
    public  NamingContext bind_new_context(NameComponent[] n)
02bb8761fcce Initial load
duke
parents:
diff changeset
   475
        throws org.omg.CosNaming.NamingContextPackage.NotFound,
02bb8761fcce Initial load
duke
parents:
diff changeset
   476
               org.omg.CosNaming.NamingContextPackage.AlreadyBound,
02bb8761fcce Initial load
duke
parents:
diff changeset
   477
               org.omg.CosNaming.NamingContextPackage.CannotProceed,
02bb8761fcce Initial load
duke
parents:
diff changeset
   478
               org.omg.CosNaming.NamingContextPackage.InvalidName
02bb8761fcce Initial load
duke
parents:
diff changeset
   479
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   480
        NamingContext nc = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   481
        NamingContext rnc = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   482
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   483
            if (debug)
02bb8761fcce Initial load
duke
parents:
diff changeset
   484
                dprint("bind_new_context " + nameToString(n));
02bb8761fcce Initial load
duke
parents:
diff changeset
   485
            // The obvious solution:
02bb8761fcce Initial load
duke
parents:
diff changeset
   486
            nc = this.new_context();
02bb8761fcce Initial load
duke
parents:
diff changeset
   487
            this.bind_context(n,nc);
02bb8761fcce Initial load
duke
parents:
diff changeset
   488
            rnc = nc;
02bb8761fcce Initial load
duke
parents:
diff changeset
   489
            nc = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   490
        } finally {
02bb8761fcce Initial load
duke
parents:
diff changeset
   491
            try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   492
                if(nc != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   493
                    nc.destroy();
02bb8761fcce Initial load
duke
parents:
diff changeset
   494
            } catch (org.omg.CosNaming.NamingContextPackage.NotEmpty e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   495
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   496
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   497
        if( updateLogger.isLoggable( Level.FINE ) ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   498
            // isLoggable call to make sure that we save some precious
02bb8761fcce Initial load
duke
parents:
diff changeset
   499
            // processor cycles, if there is no need to log.
02bb8761fcce Initial load
duke
parents:
diff changeset
   500
            updateLogger.fine ( LogKeywords.NAMING_BIND +
02bb8761fcce Initial load
duke
parents:
diff changeset
   501
                "New Context Bound To " +
02bb8761fcce Initial load
duke
parents:
diff changeset
   502
                NamingUtils.getDirectoryStructuredName( n ) );
02bb8761fcce Initial load
duke
parents:
diff changeset
   503
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   504
        return rnc;
02bb8761fcce Initial load
duke
parents:
diff changeset
   505
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   506
02bb8761fcce Initial load
duke
parents:
diff changeset
   507
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   508
     * Destroy this NamingContext object. If this NamingContext contains
02bb8761fcce Initial load
duke
parents:
diff changeset
   509
     * no bindings, the NamingContext is deleted.
02bb8761fcce Initial load
duke
parents:
diff changeset
   510
     * @exception org.omg.CosNaming.NamingContextPackage.NotEmpty This
02bb8761fcce Initial load
duke
parents:
diff changeset
   511
     * NamingContext is not empty (i.e., contains bindings).
02bb8761fcce Initial load
duke
parents:
diff changeset
   512
     * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA
02bb8761fcce Initial load
duke
parents:
diff changeset
   513
     * system exceptions.
02bb8761fcce Initial load
duke
parents:
diff changeset
   514
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   515
    public  void destroy()
02bb8761fcce Initial load
duke
parents:
diff changeset
   516
        throws org.omg.CosNaming.NamingContextPackage.NotEmpty
02bb8761fcce Initial load
duke
parents:
diff changeset
   517
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   518
        lifecycleLogger.fine( "Destroying Naming Context " );
02bb8761fcce Initial load
duke
parents:
diff changeset
   519
        NamingContextDataStore impl = (NamingContextDataStore)this;
02bb8761fcce Initial load
duke
parents:
diff changeset
   520
        synchronized (impl) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   521
            if (impl.IsEmpty() == true) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   522
                // The context is empty so it can be destroyed
02bb8761fcce Initial load
duke
parents:
diff changeset
   523
                impl.Destroy();
02bb8761fcce Initial load
duke
parents:
diff changeset
   524
                lifecycleLogger.fine ( LogKeywords.LIFECYCLE_DESTROY_SUCCESS );
02bb8761fcce Initial load
duke
parents:
diff changeset
   525
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   526
            else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   527
                // This context is not empty!
02bb8761fcce Initial load
duke
parents:
diff changeset
   528
                // Not a fatal error, warning should do.
02bb8761fcce Initial load
duke
parents:
diff changeset
   529
                lifecycleLogger.warning( LogKeywords.LIFECYCLE_DESTROY_FAILURE +
02bb8761fcce Initial load
duke
parents:
diff changeset
   530
                    " NamingContext children are not destroyed still.." );
02bb8761fcce Initial load
duke
parents:
diff changeset
   531
                throw new NotEmpty();
02bb8761fcce Initial load
duke
parents:
diff changeset
   532
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   533
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   534
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   535
02bb8761fcce Initial load
duke
parents:
diff changeset
   536
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   537
     * Implements all four flavors of binding. It uses Resolve() to
02bb8761fcce Initial load
duke
parents:
diff changeset
   538
     * check if a binding already exists (for bind and bind_context), and
02bb8761fcce Initial load
duke
parents:
diff changeset
   539
     * unbind() to ensure that a binding does not already exist.
02bb8761fcce Initial load
duke
parents:
diff changeset
   540
     * If the length of the name is 1, then Bind() is called with
02bb8761fcce Initial load
duke
parents:
diff changeset
   541
     * the name and the object to bind. Otherwise, the first component
02bb8761fcce Initial load
duke
parents:
diff changeset
   542
     * of the name is resolved in this NamingContext and the appropriate
02bb8761fcce Initial load
duke
parents:
diff changeset
   543
     * form of bind passed to the resulting NamingContext.
02bb8761fcce Initial load
duke
parents:
diff changeset
   544
     * This method is static for maximal reuse - even for extended naming
02bb8761fcce Initial load
duke
parents:
diff changeset
   545
     * context implementations where the recursive semantics still apply.
02bb8761fcce Initial load
duke
parents:
diff changeset
   546
     * @param impl an implementation of NamingContextDataStore
02bb8761fcce Initial load
duke
parents:
diff changeset
   547
     * @param n a sequence of NameComponents which is the name under which
02bb8761fcce Initial load
duke
parents:
diff changeset
   548
     * the object will be bound.
02bb8761fcce Initial load
duke
parents:
diff changeset
   549
     * @param obj the object reference to be bound.
02bb8761fcce Initial load
duke
parents:
diff changeset
   550
     * @param rebind Replace an existing binding or not.
02bb8761fcce Initial load
duke
parents:
diff changeset
   551
     * @param bt Type of binding (as object or as context).
02bb8761fcce Initial load
duke
parents:
diff changeset
   552
     * @exception org.omg.CosNaming.NamingContextPackage.NotFound A name with
02bb8761fcce Initial load
duke
parents:
diff changeset
   553
     * multiple components was supplied, but the first component could not be
02bb8761fcce Initial load
duke
parents:
diff changeset
   554
     * resolved.
02bb8761fcce Initial load
duke
parents:
diff changeset
   555
     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Could not     * proceed
02bb8761fcce Initial load
duke
parents:
diff changeset
   556
     * in resolving the first component of the supplied name.
02bb8761fcce Initial load
duke
parents:
diff changeset
   557
     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName The
02bb8761fcce Initial load
duke
parents:
diff changeset
   558
     * supplied name is invalid (i.e., has length less than 1).
02bb8761fcce Initial load
duke
parents:
diff changeset
   559
     * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound An object
02bb8761fcce Initial load
duke
parents:
diff changeset
   560
     * is already bound under the supplied name.
02bb8761fcce Initial load
duke
parents:
diff changeset
   561
     * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA
02bb8761fcce Initial load
duke
parents:
diff changeset
   562
     * system exceptions.
02bb8761fcce Initial load
duke
parents:
diff changeset
   563
     * @see resolve
02bb8761fcce Initial load
duke
parents:
diff changeset
   564
     * @see unbind
02bb8761fcce Initial load
duke
parents:
diff changeset
   565
     * @see bind
02bb8761fcce Initial load
duke
parents:
diff changeset
   566
     * @see bind_context
02bb8761fcce Initial load
duke
parents:
diff changeset
   567
     * @see rebind
02bb8761fcce Initial load
duke
parents:
diff changeset
   568
     * @see rebind_context
02bb8761fcce Initial load
duke
parents:
diff changeset
   569
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   570
    public static void doBind(NamingContextDataStore impl,
02bb8761fcce Initial load
duke
parents:
diff changeset
   571
                              NameComponent[] n,
02bb8761fcce Initial load
duke
parents:
diff changeset
   572
                              org.omg.CORBA.Object obj,
02bb8761fcce Initial load
duke
parents:
diff changeset
   573
                              boolean rebind,
02bb8761fcce Initial load
duke
parents:
diff changeset
   574
                              org.omg.CosNaming.BindingType bt)
02bb8761fcce Initial load
duke
parents:
diff changeset
   575
        throws org.omg.CosNaming.NamingContextPackage.NotFound,
02bb8761fcce Initial load
duke
parents:
diff changeset
   576
               org.omg.CosNaming.NamingContextPackage.CannotProceed,
02bb8761fcce Initial load
duke
parents:
diff changeset
   577
               org.omg.CosNaming.NamingContextPackage.InvalidName,
02bb8761fcce Initial load
duke
parents:
diff changeset
   578
               org.omg.CosNaming.NamingContextPackage.AlreadyBound
02bb8761fcce Initial load
duke
parents:
diff changeset
   579
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   580
        // Valid name?
02bb8761fcce Initial load
duke
parents:
diff changeset
   581
        if (n.length < 1)
02bb8761fcce Initial load
duke
parents:
diff changeset
   582
            throw new InvalidName();
02bb8761fcce Initial load
duke
parents:
diff changeset
   583
02bb8761fcce Initial load
duke
parents:
diff changeset
   584
    // At bottom level?
02bb8761fcce Initial load
duke
parents:
diff changeset
   585
        if (n.length == 1) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   586
            // The identifier must be set
02bb8761fcce Initial load
duke
parents:
diff changeset
   587
            if ( (n[0].id.length() == 0) && (n[0].kind.length() == 0 ) ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   588
                throw new InvalidName();
02bb8761fcce Initial load
duke
parents:
diff changeset
   589
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   590
02bb8761fcce Initial load
duke
parents:
diff changeset
   591
            // Ensure synchronization of backend
02bb8761fcce Initial load
duke
parents:
diff changeset
   592
            synchronized (impl) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   593
                // Yes: bind object in this context under the name
02bb8761fcce Initial load
duke
parents:
diff changeset
   594
                BindingTypeHolder bth = new BindingTypeHolder();
02bb8761fcce Initial load
duke
parents:
diff changeset
   595
                if (rebind) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   596
                    org.omg.CORBA.Object objRef = impl.Resolve( n[0], bth );
02bb8761fcce Initial load
duke
parents:
diff changeset
   597
                    if( objRef != null ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   598
                        // Refer Naming Service Doc:00-11-01 section 2.2.3.4
02bb8761fcce Initial load
duke
parents:
diff changeset
   599
                        // If there is an object already bound with the name
02bb8761fcce Initial load
duke
parents:
diff changeset
   600
                        // and the binding type is not ncontext a NotFound
02bb8761fcce Initial load
duke
parents:
diff changeset
   601
                        // Exception with a reason of not a context has to be
02bb8761fcce Initial load
duke
parents:
diff changeset
   602
                        // raised.
02bb8761fcce Initial load
duke
parents:
diff changeset
   603
                        // Fix for bug Id: 4384628
02bb8761fcce Initial load
duke
parents:
diff changeset
   604
                        if ( bth.value.value() == BindingType.nobject.value() ){
02bb8761fcce Initial load
duke
parents:
diff changeset
   605
                            if ( bt.value() == BindingType.ncontext.value() ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   606
                                throw new NotFound(
02bb8761fcce Initial load
duke
parents:
diff changeset
   607
                                    NotFoundReason.not_context, n);
02bb8761fcce Initial load
duke
parents:
diff changeset
   608
                            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   609
                        } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   610
                            // Previously a Context was bound and now trying to
02bb8761fcce Initial load
duke
parents:
diff changeset
   611
                            // bind Object. It is invalid.
02bb8761fcce Initial load
duke
parents:
diff changeset
   612
                            if ( bt.value() == BindingType.nobject.value() ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   613
                                throw new NotFound(
02bb8761fcce Initial load
duke
parents:
diff changeset
   614
                                    NotFoundReason.not_object, n);
02bb8761fcce Initial load
duke
parents:
diff changeset
   615
                            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   616
                        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   617
                        impl.Unbind(n[0]);
02bb8761fcce Initial load
duke
parents:
diff changeset
   618
                    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   619
02bb8761fcce Initial load
duke
parents:
diff changeset
   620
                } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   621
                    if (impl.Resolve(n[0],bth) != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   622
                        // "Resistence is futile." [Borg pickup line]
02bb8761fcce Initial load
duke
parents:
diff changeset
   623
                        throw new AlreadyBound();
02bb8761fcce Initial load
duke
parents:
diff changeset
   624
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   625
02bb8761fcce Initial load
duke
parents:
diff changeset
   626
                // Now there are no other bindings under this name
02bb8761fcce Initial load
duke
parents:
diff changeset
   627
                impl.Bind(n[0],obj,bt);
02bb8761fcce Initial load
duke
parents:
diff changeset
   628
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   629
        } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   630
            // No: bind in a different context
02bb8761fcce Initial load
duke
parents:
diff changeset
   631
            NamingContext context = resolveFirstAsContext(impl,n);
02bb8761fcce Initial load
duke
parents:
diff changeset
   632
02bb8761fcce Initial load
duke
parents:
diff changeset
   633
            // Compute tail
02bb8761fcce Initial load
duke
parents:
diff changeset
   634
            NameComponent[] tail = new NameComponent[n.length - 1];
02bb8761fcce Initial load
duke
parents:
diff changeset
   635
            System.arraycopy(n,1,tail,0,n.length-1);
02bb8761fcce Initial load
duke
parents:
diff changeset
   636
02bb8761fcce Initial load
duke
parents:
diff changeset
   637
      // How should we propagate the bind
02bb8761fcce Initial load
duke
parents:
diff changeset
   638
            switch (bt.value()) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   639
            case BindingType._nobject:
02bb8761fcce Initial load
duke
parents:
diff changeset
   640
                {
02bb8761fcce Initial load
duke
parents:
diff changeset
   641
                    // Bind as object
02bb8761fcce Initial load
duke
parents:
diff changeset
   642
                    if (rebind)
02bb8761fcce Initial load
duke
parents:
diff changeset
   643
                        context.rebind(tail,obj);
02bb8761fcce Initial load
duke
parents:
diff changeset
   644
                    else
02bb8761fcce Initial load
duke
parents:
diff changeset
   645
                        context.bind(tail,obj);
02bb8761fcce Initial load
duke
parents:
diff changeset
   646
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   647
                break;
02bb8761fcce Initial load
duke
parents:
diff changeset
   648
            case BindingType._ncontext:
02bb8761fcce Initial load
duke
parents:
diff changeset
   649
                {
02bb8761fcce Initial load
duke
parents:
diff changeset
   650
                    // Narrow to a naming context using Java casts. It must
02bb8761fcce Initial load
duke
parents:
diff changeset
   651
                    // work.
02bb8761fcce Initial load
duke
parents:
diff changeset
   652
                    NamingContext objContext = (NamingContext)obj;
02bb8761fcce Initial load
duke
parents:
diff changeset
   653
                    // Bind as context
02bb8761fcce Initial load
duke
parents:
diff changeset
   654
                    if (rebind)
02bb8761fcce Initial load
duke
parents:
diff changeset
   655
                        context.rebind_context(tail,objContext);
02bb8761fcce Initial load
duke
parents:
diff changeset
   656
                    else
02bb8761fcce Initial load
duke
parents:
diff changeset
   657
                        context.bind_context(tail,objContext);
02bb8761fcce Initial load
duke
parents:
diff changeset
   658
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   659
                break;
02bb8761fcce Initial load
duke
parents:
diff changeset
   660
            default:
02bb8761fcce Initial load
duke
parents:
diff changeset
   661
                // This should not happen
02bb8761fcce Initial load
duke
parents:
diff changeset
   662
                throw staticWrapper.namingCtxBadBindingtype() ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   663
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   664
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   665
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   666
02bb8761fcce Initial load
duke
parents:
diff changeset
   667
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   668
   * Implements resolving names in this NamingContext. The first component
02bb8761fcce Initial load
duke
parents:
diff changeset
   669
   * of the supplied name is resolved in this NamingContext by calling
02bb8761fcce Initial load
duke
parents:
diff changeset
   670
   * Resolve(). If there are no more components in the name, the
02bb8761fcce Initial load
duke
parents:
diff changeset
   671
   * resulting object reference is returned. Otherwise, the resulting object
02bb8761fcce Initial load
duke
parents:
diff changeset
   672
   * reference must have been bound as a context and be narrowable to
02bb8761fcce Initial load
duke
parents:
diff changeset
   673
   * a NamingContext. If this is the case, the remaining
02bb8761fcce Initial load
duke
parents:
diff changeset
   674
   * components of the name is resolved in the resulting NamingContext.
02bb8761fcce Initial load
duke
parents:
diff changeset
   675
   * This method is static for maximal reuse - even for extended naming
02bb8761fcce Initial load
duke
parents:
diff changeset
   676
   * context implementations where the recursive semantics still apply.
02bb8761fcce Initial load
duke
parents:
diff changeset
   677
   * @param impl an implementation of NamingContextDataStore
02bb8761fcce Initial load
duke
parents:
diff changeset
   678
   * @param n a sequence of NameComponents which is the name to be resolved.
02bb8761fcce Initial load
duke
parents:
diff changeset
   679
   * @return the object reference bound under the supplied name.
02bb8761fcce Initial load
duke
parents:
diff changeset
   680
   * @exception org.omg.CosNaming.NamingContextPackage.NotFound A name with
02bb8761fcce Initial load
duke
parents:
diff changeset
   681
   * multiple components was supplied, but the first component could not be
02bb8761fcce Initial load
duke
parents:
diff changeset
   682
   * resolved.
02bb8761fcce Initial load
duke
parents:
diff changeset
   683
   * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Could not
02bb8761fcce Initial load
duke
parents:
diff changeset
   684
   * proceed
02bb8761fcce Initial load
duke
parents:
diff changeset
   685
   * in resolving the first component of the supplied name.
02bb8761fcce Initial load
duke
parents:
diff changeset
   686
   * @exception org.omg.CosNaming.NamingContextPackage.InvalidName The supplied
02bb8761fcce Initial load
duke
parents:
diff changeset
   687
   * name is invalid (i.e., has length less than 1).
02bb8761fcce Initial load
duke
parents:
diff changeset
   688
   * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA system
02bb8761fcce Initial load
duke
parents:
diff changeset
   689
   * exceptions.
02bb8761fcce Initial load
duke
parents:
diff changeset
   690
   * @see resolve
02bb8761fcce Initial load
duke
parents:
diff changeset
   691
   */
02bb8761fcce Initial load
duke
parents:
diff changeset
   692
    public static org.omg.CORBA.Object doResolve(NamingContextDataStore impl,
02bb8761fcce Initial load
duke
parents:
diff changeset
   693
                                                 NameComponent[] n)
02bb8761fcce Initial load
duke
parents:
diff changeset
   694
        throws org.omg.CosNaming.NamingContextPackage.NotFound,
02bb8761fcce Initial load
duke
parents:
diff changeset
   695
               org.omg.CosNaming.NamingContextPackage.CannotProceed,
02bb8761fcce Initial load
duke
parents:
diff changeset
   696
               org.omg.CosNaming.NamingContextPackage.InvalidName
02bb8761fcce Initial load
duke
parents:
diff changeset
   697
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   698
        org.omg.CORBA.Object obj = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   699
        BindingTypeHolder bth = new BindingTypeHolder();
02bb8761fcce Initial load
duke
parents:
diff changeset
   700
02bb8761fcce Initial load
duke
parents:
diff changeset
   701
02bb8761fcce Initial load
duke
parents:
diff changeset
   702
        // Length must be greater than 0
02bb8761fcce Initial load
duke
parents:
diff changeset
   703
        if (n.length < 1)
02bb8761fcce Initial load
duke
parents:
diff changeset
   704
            throw new InvalidName();
02bb8761fcce Initial load
duke
parents:
diff changeset
   705
02bb8761fcce Initial load
duke
parents:
diff changeset
   706
        // The identifier must be set
02bb8761fcce Initial load
duke
parents:
diff changeset
   707
        if (n.length == 1) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   708
            synchronized (impl) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   709
                // Resolve first level in this context
02bb8761fcce Initial load
duke
parents:
diff changeset
   710
                obj = impl.Resolve(n[0],bth);
02bb8761fcce Initial load
duke
parents:
diff changeset
   711
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   712
            if (obj == null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   713
                // Object was not found
02bb8761fcce Initial load
duke
parents:
diff changeset
   714
                throw new NotFound(NotFoundReason.missing_node,n);
02bb8761fcce Initial load
duke
parents:
diff changeset
   715
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   716
            return obj;
02bb8761fcce Initial load
duke
parents:
diff changeset
   717
        } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   718
            // n.length > 1
02bb8761fcce Initial load
duke
parents:
diff changeset
   719
            if ( (n[1].id.length() == 0) && (n[1].kind.length() == 0) ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   720
                throw new InvalidName();
02bb8761fcce Initial load
duke
parents:
diff changeset
   721
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   722
02bb8761fcce Initial load
duke
parents:
diff changeset
   723
            NamingContext context = resolveFirstAsContext(impl,n);
02bb8761fcce Initial load
duke
parents:
diff changeset
   724
02bb8761fcce Initial load
duke
parents:
diff changeset
   725
            // Compute restOfName = name[1..length]
02bb8761fcce Initial load
duke
parents:
diff changeset
   726
            NameComponent[] tail = new NameComponent[n.length -1];
02bb8761fcce Initial load
duke
parents:
diff changeset
   727
            System.arraycopy(n,1,tail,0,n.length-1);
02bb8761fcce Initial load
duke
parents:
diff changeset
   728
02bb8761fcce Initial load
duke
parents:
diff changeset
   729
            // Resolve rest of name in context
02bb8761fcce Initial load
duke
parents:
diff changeset
   730
            try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   731
                // First try to resolve using the local call, this should work
02bb8761fcce Initial load
duke
parents:
diff changeset
   732
                // most of the time unless there are federated naming contexts.
02bb8761fcce Initial load
duke
parents:
diff changeset
   733
                Servant servant = impl.getNSPOA().reference_to_servant(
02bb8761fcce Initial load
duke
parents:
diff changeset
   734
                    context );
02bb8761fcce Initial load
duke
parents:
diff changeset
   735
                return doResolve(((NamingContextDataStore)servant), tail) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   736
            } catch( Exception e ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   737
                return context.resolve(tail);
02bb8761fcce Initial load
duke
parents:
diff changeset
   738
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   739
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   740
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   741
02bb8761fcce Initial load
duke
parents:
diff changeset
   742
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   743
   * Implements unbinding bound names in this NamingContext. If the
02bb8761fcce Initial load
duke
parents:
diff changeset
   744
   * name contains only one component, the name is unbound in this
02bb8761fcce Initial load
duke
parents:
diff changeset
   745
   * NamingContext using Unbind(). Otherwise, the first component
02bb8761fcce Initial load
duke
parents:
diff changeset
   746
   * of the name is resolved in this NamingContext and
02bb8761fcce Initial load
duke
parents:
diff changeset
   747
   * unbind passed to the resulting NamingContext.
02bb8761fcce Initial load
duke
parents:
diff changeset
   748
   * This method is static for maximal reuse - even for extended naming
02bb8761fcce Initial load
duke
parents:
diff changeset
   749
   * context implementations where the recursive semantics still apply.
02bb8761fcce Initial load
duke
parents:
diff changeset
   750
   * @param impl an implementation of NamingContextDataStore
02bb8761fcce Initial load
duke
parents:
diff changeset
   751
   * @param n a sequence of NameComponents which is the name to be unbound.
02bb8761fcce Initial load
duke
parents:
diff changeset
   752
   * @exception org.omg.CosNaming.NamingContextPackage.NotFound A name with multiple
02bb8761fcce Initial load
duke
parents:
diff changeset
   753
   * components was supplied, but the first component could not be
02bb8761fcce Initial load
duke
parents:
diff changeset
   754
   * resolved.
02bb8761fcce Initial load
duke
parents:
diff changeset
   755
   * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Could not proceed
02bb8761fcce Initial load
duke
parents:
diff changeset
   756
   * in resolving the n-1 components of the supplied name.
02bb8761fcce Initial load
duke
parents:
diff changeset
   757
   * @exception org.omg.CosNaming.NamingContextPackage.InvalidName The supplied name
02bb8761fcce Initial load
duke
parents:
diff changeset
   758
   * is invalid (i.e., has length less than 1).
02bb8761fcce Initial load
duke
parents:
diff changeset
   759
   * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA system exceptions.
02bb8761fcce Initial load
duke
parents:
diff changeset
   760
   * @see resolve
02bb8761fcce Initial load
duke
parents:
diff changeset
   761
   */
02bb8761fcce Initial load
duke
parents:
diff changeset
   762
    public static void doUnbind(NamingContextDataStore impl,
02bb8761fcce Initial load
duke
parents:
diff changeset
   763
                                NameComponent[] n)
02bb8761fcce Initial load
duke
parents:
diff changeset
   764
        throws org.omg.CosNaming.NamingContextPackage.NotFound,
02bb8761fcce Initial load
duke
parents:
diff changeset
   765
               org.omg.CosNaming.NamingContextPackage.CannotProceed,
02bb8761fcce Initial load
duke
parents:
diff changeset
   766
               org.omg.CosNaming.NamingContextPackage.InvalidName
02bb8761fcce Initial load
duke
parents:
diff changeset
   767
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   768
        // Name valid?
02bb8761fcce Initial load
duke
parents:
diff changeset
   769
        if (n.length < 1)
02bb8761fcce Initial load
duke
parents:
diff changeset
   770
            throw new InvalidName();
02bb8761fcce Initial load
duke
parents:
diff changeset
   771
02bb8761fcce Initial load
duke
parents:
diff changeset
   772
    // Unbind here?
02bb8761fcce Initial load
duke
parents:
diff changeset
   773
        if (n.length == 1) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   774
            // The identifier must be set
02bb8761fcce Initial load
duke
parents:
diff changeset
   775
            if ( (n[0].id.length() == 0) && (n[0].kind.length() == 0 ) ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   776
                throw new InvalidName();
02bb8761fcce Initial load
duke
parents:
diff changeset
   777
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   778
02bb8761fcce Initial load
duke
parents:
diff changeset
   779
            org.omg.CORBA.Object objRef = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   780
            synchronized (impl) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   781
                // Yes: unbind in this context
02bb8761fcce Initial load
duke
parents:
diff changeset
   782
                objRef = impl.Unbind(n[0]);
02bb8761fcce Initial load
duke
parents:
diff changeset
   783
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   784
02bb8761fcce Initial load
duke
parents:
diff changeset
   785
            if (objRef == null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   786
                // It was not bound
02bb8761fcce Initial load
duke
parents:
diff changeset
   787
                throw new NotFound(NotFoundReason.missing_node,n);
02bb8761fcce Initial load
duke
parents:
diff changeset
   788
            // Done
02bb8761fcce Initial load
duke
parents:
diff changeset
   789
            return;
02bb8761fcce Initial load
duke
parents:
diff changeset
   790
        } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   791
            // No: unbind in a different context
02bb8761fcce Initial load
duke
parents:
diff changeset
   792
02bb8761fcce Initial load
duke
parents:
diff changeset
   793
      // Resolve first  - must be resolveable
02bb8761fcce Initial load
duke
parents:
diff changeset
   794
            NamingContext context = resolveFirstAsContext(impl,n);
02bb8761fcce Initial load
duke
parents:
diff changeset
   795
02bb8761fcce Initial load
duke
parents:
diff changeset
   796
            // Compute tail
02bb8761fcce Initial load
duke
parents:
diff changeset
   797
            NameComponent[] tail = new NameComponent[n.length - 1];
02bb8761fcce Initial load
duke
parents:
diff changeset
   798
            System.arraycopy(n,1,tail,0,n.length-1);
02bb8761fcce Initial load
duke
parents:
diff changeset
   799
02bb8761fcce Initial load
duke
parents:
diff changeset
   800
      // Propagate unbind to this context
02bb8761fcce Initial load
duke
parents:
diff changeset
   801
            context.unbind(tail);
02bb8761fcce Initial load
duke
parents:
diff changeset
   802
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   803
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   804
02bb8761fcce Initial load
duke
parents:
diff changeset
   805
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   806
   * Implements resolving a NameComponent in this context and
02bb8761fcce Initial load
duke
parents:
diff changeset
   807
   * narrowing it to CosNaming::NamingContext. It will throw appropriate
02bb8761fcce Initial load
duke
parents:
diff changeset
   808
   * exceptions if not found or not narrowable.
02bb8761fcce Initial load
duke
parents:
diff changeset
   809
   * @param impl an implementation of NamingContextDataStore
02bb8761fcce Initial load
duke
parents:
diff changeset
   810
   * @param n a NameComponents which is the name to be found.
02bb8761fcce Initial load
duke
parents:
diff changeset
   811
   * @exception org.omg.CosNaming.NamingContextPackage.NotFound The
02bb8761fcce Initial load
duke
parents:
diff changeset
   812
   * first component could not be resolved.
02bb8761fcce Initial load
duke
parents:
diff changeset
   813
   * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Could not proceed
02bb8761fcce Initial load
duke
parents:
diff changeset
   814
   * in resolving the first component of the supplied name.
02bb8761fcce Initial load
duke
parents:
diff changeset
   815
   * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA system exceptions.
02bb8761fcce Initial load
duke
parents:
diff changeset
   816
   * @see resolve
02bb8761fcce Initial load
duke
parents:
diff changeset
   817
   */
02bb8761fcce Initial load
duke
parents:
diff changeset
   818
    protected static NamingContext resolveFirstAsContext(NamingContextDataStore impl,
02bb8761fcce Initial load
duke
parents:
diff changeset
   819
                                                         NameComponent[] n)
02bb8761fcce Initial load
duke
parents:
diff changeset
   820
        throws org.omg.CosNaming.NamingContextPackage.NotFound {
02bb8761fcce Initial load
duke
parents:
diff changeset
   821
        org.omg.CORBA.Object topRef = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   822
        BindingTypeHolder bth = new BindingTypeHolder();
02bb8761fcce Initial load
duke
parents:
diff changeset
   823
        NamingContext context = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   824
02bb8761fcce Initial load
duke
parents:
diff changeset
   825
        synchronized (impl) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   826
            // Resolve first  - must be resolveable
02bb8761fcce Initial load
duke
parents:
diff changeset
   827
            topRef = impl.Resolve(n[0],bth);
02bb8761fcce Initial load
duke
parents:
diff changeset
   828
            if (topRef == null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   829
                // It was not bound
02bb8761fcce Initial load
duke
parents:
diff changeset
   830
                throw new NotFound(NotFoundReason.missing_node,n);
02bb8761fcce Initial load
duke
parents:
diff changeset
   831
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   832
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   833
02bb8761fcce Initial load
duke
parents:
diff changeset
   834
        // Was it bound as a context?
02bb8761fcce Initial load
duke
parents:
diff changeset
   835
        if (bth.value != BindingType.ncontext) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   836
            // It was not a context
02bb8761fcce Initial load
duke
parents:
diff changeset
   837
            throw new NotFound(NotFoundReason.not_context,n);
02bb8761fcce Initial load
duke
parents:
diff changeset
   838
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   839
02bb8761fcce Initial load
duke
parents:
diff changeset
   840
        // Narrow to a naming context
02bb8761fcce Initial load
duke
parents:
diff changeset
   841
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   842
            context = NamingContextHelper.narrow(topRef);
02bb8761fcce Initial load
duke
parents:
diff changeset
   843
        } catch (org.omg.CORBA.BAD_PARAM ex) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   844
            // It was not a context
02bb8761fcce Initial load
duke
parents:
diff changeset
   845
            throw new NotFound(NotFoundReason.not_context,n);
02bb8761fcce Initial load
duke
parents:
diff changeset
   846
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   847
02bb8761fcce Initial load
duke
parents:
diff changeset
   848
        // Hmm. must be ok
02bb8761fcce Initial load
duke
parents:
diff changeset
   849
        return context;
02bb8761fcce Initial load
duke
parents:
diff changeset
   850
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   851
02bb8761fcce Initial load
duke
parents:
diff changeset
   852
02bb8761fcce Initial load
duke
parents:
diff changeset
   853
   /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   854
    * This operation creates a stringified name from the array of Name
02bb8761fcce Initial load
duke
parents:
diff changeset
   855
    * components.
02bb8761fcce Initial load
duke
parents:
diff changeset
   856
    * @param n Name of the object <p>
02bb8761fcce Initial load
duke
parents:
diff changeset
   857
    * @exception org.omg.CosNaming.NamingContextExtPackage.InvalidName
02bb8761fcce Initial load
duke
parents:
diff changeset
   858
    * Indicates the name does not identify a binding.<p>
02bb8761fcce Initial load
duke
parents:
diff changeset
   859
    *
02bb8761fcce Initial load
duke
parents:
diff changeset
   860
    */
02bb8761fcce Initial load
duke
parents:
diff changeset
   861
    public String to_string(org.omg.CosNaming.NameComponent[] n)
02bb8761fcce Initial load
duke
parents:
diff changeset
   862
         throws org.omg.CosNaming.NamingContextPackage.InvalidName
02bb8761fcce Initial load
duke
parents:
diff changeset
   863
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   864
        // Name valid?
02bb8761fcce Initial load
duke
parents:
diff changeset
   865
        if ( (n == null ) || (n.length == 0) )
02bb8761fcce Initial load
duke
parents:
diff changeset
   866
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   867
                throw new InvalidName();
02bb8761fcce Initial load
duke
parents:
diff changeset
   868
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   869
        NamingContextDataStore impl = (NamingContextDataStore)this;
02bb8761fcce Initial load
duke
parents:
diff changeset
   870
02bb8761fcce Initial load
duke
parents:
diff changeset
   871
        String theStringifiedName = insImpl.convertToString( n );
02bb8761fcce Initial load
duke
parents:
diff changeset
   872
02bb8761fcce Initial load
duke
parents:
diff changeset
   873
        if( theStringifiedName == null )
02bb8761fcce Initial load
duke
parents:
diff changeset
   874
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   875
                throw new InvalidName();
02bb8761fcce Initial load
duke
parents:
diff changeset
   876
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   877
02bb8761fcce Initial load
duke
parents:
diff changeset
   878
        return theStringifiedName;
02bb8761fcce Initial load
duke
parents:
diff changeset
   879
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   880
02bb8761fcce Initial load
duke
parents:
diff changeset
   881
02bb8761fcce Initial load
duke
parents:
diff changeset
   882
   /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   883
    * This operation  converts a Stringified Name into an  equivalent array
02bb8761fcce Initial load
duke
parents:
diff changeset
   884
    * of Name Components.
02bb8761fcce Initial load
duke
parents:
diff changeset
   885
    * @param sn Stringified Name of the object <p>
02bb8761fcce Initial load
duke
parents:
diff changeset
   886
    * @exception org.omg.CosNaming.NamingContextExtPackage.InvalidName
02bb8761fcce Initial load
duke
parents:
diff changeset
   887
    * Indicates the name does not identify a binding.<p>
02bb8761fcce Initial load
duke
parents:
diff changeset
   888
    *
02bb8761fcce Initial load
duke
parents:
diff changeset
   889
    */
02bb8761fcce Initial load
duke
parents:
diff changeset
   890
    public org.omg.CosNaming.NameComponent[] to_name(String sn)
02bb8761fcce Initial load
duke
parents:
diff changeset
   891
         throws org.omg.CosNaming.NamingContextPackage.InvalidName
02bb8761fcce Initial load
duke
parents:
diff changeset
   892
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   893
        // Name valid?
02bb8761fcce Initial load
duke
parents:
diff changeset
   894
        if  ( (sn == null ) || (sn.length() == 0) )
02bb8761fcce Initial load
duke
parents:
diff changeset
   895
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   896
                throw new InvalidName();
02bb8761fcce Initial load
duke
parents:
diff changeset
   897
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   898
        NamingContextDataStore impl = (NamingContextDataStore)this;
02bb8761fcce Initial load
duke
parents:
diff changeset
   899
        org.omg.CosNaming.NameComponent[] theNameComponents =
02bb8761fcce Initial load
duke
parents:
diff changeset
   900
                insImpl.convertToNameComponent( sn );
02bb8761fcce Initial load
duke
parents:
diff changeset
   901
        if( ( theNameComponents == null ) || (theNameComponents.length == 0 ) )
02bb8761fcce Initial load
duke
parents:
diff changeset
   902
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   903
                throw new InvalidName();
02bb8761fcce Initial load
duke
parents:
diff changeset
   904
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   905
        for( int i = 0; i < theNameComponents.length; i++ ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   906
            // If there is a name component whose id and kind null or
02bb8761fcce Initial load
duke
parents:
diff changeset
   907
            // zero length string, then an invalid name exception needs to be
02bb8761fcce Initial load
duke
parents:
diff changeset
   908
            // raised.
02bb8761fcce Initial load
duke
parents:
diff changeset
   909
            if ( ( ( theNameComponents[i].id  == null )
02bb8761fcce Initial load
duke
parents:
diff changeset
   910
                 ||( theNameComponents[i].id.length() == 0 ) )
02bb8761fcce Initial load
duke
parents:
diff changeset
   911
               &&( ( theNameComponents[i].kind == null )
02bb8761fcce Initial load
duke
parents:
diff changeset
   912
                 ||( theNameComponents[i].kind.length() == 0 ) ) ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   913
                throw new InvalidName();
02bb8761fcce Initial load
duke
parents:
diff changeset
   914
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   915
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   916
        return theNameComponents;
02bb8761fcce Initial load
duke
parents:
diff changeset
   917
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   918
02bb8761fcce Initial load
duke
parents:
diff changeset
   919
   /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   920
    * This operation creates a URL based "iiopname://" format name
02bb8761fcce Initial load
duke
parents:
diff changeset
   921
    * from the Stringified Name of the object.
02bb8761fcce Initial load
duke
parents:
diff changeset
   922
    * @param addr internet based address of the host machine where
02bb8761fcce Initial load
duke
parents:
diff changeset
   923
    * Name Service is running <p>
02bb8761fcce Initial load
duke
parents:
diff changeset
   924
    * @param sn Stringified Name of the object <p>
02bb8761fcce Initial load
duke
parents:
diff changeset
   925
    * @exception org.omg.CosNaming.NamingContextExtPackage.InvalidName
02bb8761fcce Initial load
duke
parents:
diff changeset
   926
    * Indicates the name does not identify a binding.<p>
02bb8761fcce Initial load
duke
parents:
diff changeset
   927
    * @exception org.omg.CosNaming.NamingContextPackage.InvalidAddress
02bb8761fcce Initial load
duke
parents:
diff changeset
   928
    * Indicates the internet based address of the host machine is
02bb8761fcce Initial load
duke
parents:
diff changeset
   929
    * incorrect <p>
02bb8761fcce Initial load
duke
parents:
diff changeset
   930
    *
02bb8761fcce Initial load
duke
parents:
diff changeset
   931
    */
02bb8761fcce Initial load
duke
parents:
diff changeset
   932
02bb8761fcce Initial load
duke
parents:
diff changeset
   933
    public String to_url(String addr, String sn)
02bb8761fcce Initial load
duke
parents:
diff changeset
   934
        throws org.omg.CosNaming.NamingContextExtPackage.InvalidAddress,
02bb8761fcce Initial load
duke
parents:
diff changeset
   935
               org.omg.CosNaming.NamingContextPackage.InvalidName
02bb8761fcce Initial load
duke
parents:
diff changeset
   936
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   937
        // Name valid?
02bb8761fcce Initial load
duke
parents:
diff changeset
   938
        if  ( (sn == null ) || (sn.length() == 0) )
02bb8761fcce Initial load
duke
parents:
diff changeset
   939
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   940
            throw new InvalidName();
02bb8761fcce Initial load
duke
parents:
diff changeset
   941
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   942
        if( addr == null )
02bb8761fcce Initial load
duke
parents:
diff changeset
   943
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   944
            throw new
02bb8761fcce Initial load
duke
parents:
diff changeset
   945
                org.omg.CosNaming.NamingContextExtPackage.InvalidAddress();
02bb8761fcce Initial load
duke
parents:
diff changeset
   946
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   947
        NamingContextDataStore impl = (NamingContextDataStore)this;
02bb8761fcce Initial load
duke
parents:
diff changeset
   948
        String urlBasedAddress = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   949
        urlBasedAddress = insImpl.createURLBasedAddress( addr, sn );
02bb8761fcce Initial load
duke
parents:
diff changeset
   950
        // Extra check to see that corba name url created is valid as per
02bb8761fcce Initial load
duke
parents:
diff changeset
   951
        // INS spec grammer.
02bb8761fcce Initial load
duke
parents:
diff changeset
   952
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   953
            INSURLHandler.getINSURLHandler( ).parseURL( urlBasedAddress );
02bb8761fcce Initial load
duke
parents:
diff changeset
   954
        } catch( BAD_PARAM e ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   955
            throw new
02bb8761fcce Initial load
duke
parents:
diff changeset
   956
                org.omg.CosNaming.NamingContextExtPackage.InvalidAddress();
02bb8761fcce Initial load
duke
parents:
diff changeset
   957
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   958
        return urlBasedAddress;
02bb8761fcce Initial load
duke
parents:
diff changeset
   959
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   960
02bb8761fcce Initial load
duke
parents:
diff changeset
   961
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   962
     * This operation resolves the Stringified name into the object
02bb8761fcce Initial load
duke
parents:
diff changeset
   963
     * reference.
02bb8761fcce Initial load
duke
parents:
diff changeset
   964
     * @param sn Stringified Name of the object <p>
02bb8761fcce Initial load
duke
parents:
diff changeset
   965
     * @exception org.omg.CosNaming.NamingContextPackage.NotFound
02bb8761fcce Initial load
duke
parents:
diff changeset
   966
     * Indicates there is no object reference for the given name. <p>
02bb8761fcce Initial load
duke
parents:
diff changeset
   967
     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed
02bb8761fcce Initial load
duke
parents:
diff changeset
   968
     * Indicates that the given compound name is incorrect <p>
02bb8761fcce Initial load
duke
parents:
diff changeset
   969
     * @exception org.omg.CosNaming.NamingContextExtPackage.InvalidName
02bb8761fcce Initial load
duke
parents:
diff changeset
   970
     * Indicates the name does not identify a binding.<p>
02bb8761fcce Initial load
duke
parents:
diff changeset
   971
     * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound
02bb8761fcce Initial load
duke
parents:
diff changeset
   972
     * Indicates the name is already bound.<p>
02bb8761fcce Initial load
duke
parents:
diff changeset
   973
     *
02bb8761fcce Initial load
duke
parents:
diff changeset
   974
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   975
    public org.omg.CORBA.Object resolve_str(String sn)
02bb8761fcce Initial load
duke
parents:
diff changeset
   976
        throws org.omg.CosNaming.NamingContextPackage.NotFound,
02bb8761fcce Initial load
duke
parents:
diff changeset
   977
               org.omg.CosNaming.NamingContextPackage.CannotProceed,
02bb8761fcce Initial load
duke
parents:
diff changeset
   978
               org.omg.CosNaming.NamingContextPackage.InvalidName
02bb8761fcce Initial load
duke
parents:
diff changeset
   979
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   980
        org.omg.CORBA.Object theObject = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   981
        // Name valid?
02bb8761fcce Initial load
duke
parents:
diff changeset
   982
        if  ( (sn == null ) || (sn.length() == 0) )
02bb8761fcce Initial load
duke
parents:
diff changeset
   983
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   984
                throw new InvalidName();
02bb8761fcce Initial load
duke
parents:
diff changeset
   985
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   986
        NamingContextDataStore impl = (NamingContextDataStore)this;
02bb8761fcce Initial load
duke
parents:
diff changeset
   987
        org.omg.CosNaming.NameComponent[] theNameComponents =
02bb8761fcce Initial load
duke
parents:
diff changeset
   988
                insImpl.convertToNameComponent( sn );
02bb8761fcce Initial load
duke
parents:
diff changeset
   989
02bb8761fcce Initial load
duke
parents:
diff changeset
   990
        if( ( theNameComponents == null ) || (theNameComponents.length == 0 ) )
02bb8761fcce Initial load
duke
parents:
diff changeset
   991
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   992
                throw new InvalidName();
02bb8761fcce Initial load
duke
parents:
diff changeset
   993
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   994
        theObject = resolve( theNameComponents );
02bb8761fcce Initial load
duke
parents:
diff changeset
   995
        return theObject;
02bb8761fcce Initial load
duke
parents:
diff changeset
   996
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   997
02bb8761fcce Initial load
duke
parents:
diff changeset
   998
02bb8761fcce Initial load
duke
parents:
diff changeset
   999
    transient protected ORB orb;
02bb8761fcce Initial load
duke
parents:
diff changeset
  1000
02bb8761fcce Initial load
duke
parents:
diff changeset
  1001
    public static String nameToString(NameComponent[] name)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1002
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1003
        StringBuffer s = new StringBuffer("{");
02bb8761fcce Initial load
duke
parents:
diff changeset
  1004
        if (name != null || name.length > 0) {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1005
            for (int i=0;i<name.length;i++) {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1006
                if (i>0)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1007
                    s.append(",");
02bb8761fcce Initial load
duke
parents:
diff changeset
  1008
                s.append("[").
02bb8761fcce Initial load
duke
parents:
diff changeset
  1009
                    append(name[i].id).
02bb8761fcce Initial load
duke
parents:
diff changeset
  1010
                    append(",").
02bb8761fcce Initial load
duke
parents:
diff changeset
  1011
                    append(name[i].kind).
02bb8761fcce Initial load
duke
parents:
diff changeset
  1012
                    append("]");
02bb8761fcce Initial load
duke
parents:
diff changeset
  1013
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1014
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1015
        s.append("}");
02bb8761fcce Initial load
duke
parents:
diff changeset
  1016
        return s.toString();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1017
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1018
02bb8761fcce Initial load
duke
parents:
diff changeset
  1019
    // Debugging aids.
02bb8761fcce Initial load
duke
parents:
diff changeset
  1020
    public static final boolean debug = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
  1021
02bb8761fcce Initial load
duke
parents:
diff changeset
  1022
    private static void dprint(String msg) {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1023
        NamingUtils.dprint("NamingContextImpl("  +
02bb8761fcce Initial load
duke
parents:
diff changeset
  1024
                           Thread.currentThread().getName() + " at " +
02bb8761fcce Initial load
duke
parents:
diff changeset
  1025
                           System.currentTimeMillis() +
02bb8761fcce Initial load
duke
parents:
diff changeset
  1026
                           " ems): " + msg);
02bb8761fcce Initial load
duke
parents:
diff changeset
  1027
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1028
}