mcconnell    02/03/13 01:18:35

  Added:       enterprise/ins .cvsignore build.properties build.xml
               enterprise/ins/src/etc ins.mf
               enterprise/ins/src/idl CosNaming.idl OpenORB_Naming.idl
               enterprise/ins/src/java/org/apache/ins
                        BindingIteratorImpl.java CallbackManagerImpl.java
                        CallbackRegistration.java NamingContextExImpl.java
                        NamingProvider.java NamingProvider.xinfo
                        ReleaseInfo.java
               enterprise/ins/src/psdl ins.psdl
  Log:
  first cut on the INS
  
  Revision  Changes    Path
  1.1                  jakarta-avalon-apps/enterprise/ins/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  build
  dist
  local.properties
  pss
  ins.ior
  .cvsignore
  
  
  1.1                  jakarta-avalon-apps/enterprise/ins/build.properties
  
  Index: build.properties
  ===================================================================
  
  #
  # The pss.properties file is read in by the build.xml file.  
  #
  
  MAJOR=2
  MINOR=0
  MICRO=0
  
  project.title=Interoperable Naming Service
  
  #
  # demo configuration
  #
  demo.class=org.apache.ins.NamingProvider
  demo.verbose=false
  demo.priority=debug
  demo.disposal=true
  
  
  
  1.1                  jakarta-avalon-apps/enterprise/ins/build.xml
  
  Index: build.xml
  ===================================================================
  
  <project name="ins" default="help" basedir=".">
  
    <property file="local.properties"/>
    <property file="build.properties"/>
  
    <target name="help" >
      <echo>
  
        Description
        -----------
  
        ${project.title}
  
        Main Targets:
        -------------
  
        all              - cleans environment, builds distribution and examples
        help             - this message
  
        Support Targets:
        ----------------
  
        clean            - destroy the build directory
        build            - invokes the general build target
        dist             - executes build, javadoc and support file creation
        demo             - run the server though it's full lifecycle
        
      </echo>
    </target>
  
    <property name="VERSION" value="${MAJOR}.${MINOR}.${MICRO}"/>
  
    <property name="enterprise" value=".." />
    <property name="tools.path" value="${enterprise}/tools" />
    <property name="tools.lib.path" value="${tools.path}/lib" />
    <property name="orb.path"  value="${enterprise}/orb" />
    <property name="orb.lib.path"  value="${orb.path}/lib" />
    <property name="orb.dist.path"  value="${orb.path}/dist" />
    <property name="idl.class"  value="org.openorb.compiler.IdlCompiler" />
    <property name="pss.path"  value="${enterprise}/pss" />
    <property name="pss.dist.path"  value="${pss.path}/dist" />
    <property name="psdl.class"  value="org.apache.pss.compiler.PsdlCompiler" />
  
    <property name="project.jar" value="${ant.project.name}-${VERSION}.jar" />
  
    <property name="src" value="src" />
    <property name="idl" value="${src}/idl" />
    <property name="psdl" value="${src}/psdl" />
    <property name="etc" value="${src}/etc" />
    <property name="build"  value="build" />
    <property name="dist"  value="dist" />
    <property name="lib"  value="lib" />
  
    <property name="overview.html"  value="${etc}/overview.html" />
    <property name="javadoc.root.path"  value="${dist}/javadoc" />
    <property name="avalon.href"  value="http://jakarta.apache.org/avalon/api/"; 
/>
    <property name="jdk.href"  value="http://java.sun.com/j2se/1.4/docs/api/"; />
    <property name="orb.href"  value="../orb" />
  
    <path id="project.classpath">
        <fileset dir="${orb.lib.path}">
          <include name="openorb*.jar" />
        </fileset>
        <fileset dir="${orb.dist.path}">
          <include name="*.jar" />
        </fileset>
        <fileset dir="${tools.lib.path}">
          <include name="*.jar" />
        </fileset>
        <fileset dir="${pss.dist.path}">
          <include name="*.jar" />
        </fileset>
    </path>
  
    <!-- MAIN TARGETS -->
  
    <target name="all" depends="clean,dist,javadoc"/>
    <target name="dist" depends="build,support"/>
  
    <target name="clean">
       <delete dir="${build}"/>
       <delete dir="${dist}"/>
    </target>
  
    <!-- PREPARE -->
  
    <target name="prepare"  >
      <mkdir dir="${build}/ins/src" />
      <mkdir dir="${build}/ext/src" />
      <mkdir dir="${build}/pss/src" />
      <mkdir dir="${build}/lib" />
      <mkdir dir="${dist}" />
    </target>
  
    <!-- ORB BLOCK/MANGER -->
  
    <target name="context" depends="prepare">
      <uptodate property="main.uptodate" targetfile="${dist}/${project.jar}">
        <srcfiles dir="${src}/java">
           <include name="**/*.*"/>
        </srcfiles>
        <srcfiles dir="${idl}">
           <include name="**/*.*"/>
        </srcfiles>
        <srcfiles dir="${etc}">
           <include name="*.*"/>
        </srcfiles>
        <srcfiles dir="${build}/ins/src">
           <include name="**/*.*"/>
        </srcfiles>
        <srcfiles dir="${build}/ext/src">
           <include name="**/*.*"/>
        </srcfiles>
        <srcfiles dir="${build}/pss/src">
           <include name="**/*.*"/>
        </srcfiles>
      </uptodate>
      <uptodate property="ins.idl.modified" targetfile="${idl}/CosNaming.idl">
        <srcfiles dir="${build}/ins/src">
          <include name="**/*"/>
        </srcfiles>
      </uptodate>
      <uptodate property="ext.idl.modified" 
targetfile="${idl}/OpenORB_Naming.idl">
        <srcfiles dir="${build}/ext/src">
          <include name="**/*"/>
        </srcfiles>
      </uptodate>
      <uptodate property="psdl.modified" targetfile="${psdl}/ins.psdl">
        <srcfiles dir="${build}/pss/src">
          <include name="**/*"/>
        </srcfiles>
      </uptodate>
    </target>
  
    <target name="ins.idl" depends="context" if="ins.idl.modified">
        <java failonerror="true" classname="${idl.class}" fork="true">
            <classpath>
                <path refid="project.classpath"/>
            </classpath>
            <arg line="-silence"/>
            <arg line="-d ${build}/ins/src"/>
            <arg line="-I ${idl}"/>
            <arg line="CosNaming.idl" />
        </java>
    </target>
  
    <target name="ext.idl" depends="ins.idl" if="ext.idl.modified">
        <java failonerror="true" classname="${idl.class}" fork="true">
            <classpath>
                <path refid="project.classpath"/>
            </classpath>
            <arg line="-silence"/>
            <arg line="-d ${build}/ext/src"/>
            <arg line="-I ${idl}"/>
            <arg line="OpenORB_Naming.idl" />
        </java>
    </target>
  
    <target name="psdl" depends="ins.idl" if="psdl.modified">
        <echo message="Compiling INS PSDL"/>
        <java failonerror="true" classname="${psdl.class}" fork="true">
            <classpath>
                <path refid="project.classpath"/>
            </classpath>
            <arg line="-silence"/>
            <arg line="-nowrapper"/>
            <arg line="-d ${build}/pss/src"/>
            <arg line="-I ${idl}"/>
            <arg line="${psdl}/ins.psdl" />
        </java>
        <java failonerror="true" classname="${psdl.class}" fork="true">
            <classpath>
                <path refid="project.classpath"/>
            </classpath>
            <arg line="-silence"/>
            <arg line="-noapi -file -package file"/>
            <arg line="-d ${build}/pss/src"/>
            <arg line="-I ${idl}"/>
            <arg line="${psdl}/ins.psdl" />
        </java>
        <java failonerror="true" classname="${psdl.class}" fork="true">
            <classpath>
                <path refid="project.classpath"/>
            </classpath>
            <arg line="-silence"/>
            <arg line="-noapi -database -package database"/>
            <arg line="-d ${build}/pss/src"/>
            <arg line="-I ${idl}"/>
            <arg line="${psdl}/ins.psdl" />
        </java>
        <java failonerror="true" classname="${psdl.class}" fork="true">
            <classpath>
                <path refid="project.classpath"/>
            </classpath>
            <arg line="-silence"/>
            <arg line="-noapi -package memory"/>
            <arg line="-d ${build}/pss/src"/>
            <arg line="-I ${idl}"/>
            <arg line="${psdl}/ins.psdl" />
        </java>
    </target>
  
    <target name="build" depends="ext.idl,psdl" unless="main.uptodate" >
  
        <echo message="Building ${project.title}"/>
  
        <mkdir dir="${build}/lib"/>
  
        <javac debug="off" destdir="${build}/lib" deprecation="false" 
target="1.2">
          <classpath>
            <path refid="project.classpath" />
            <pathelement path="${build}/lib" />
          </classpath>
          <src path="${build}/ins/src" />
          <src path="${build}/ext/src" />
          <src path="${build}/pss/src" />
          <src path="${src}/java" />
          <include name="**"/>
        </javac>
  
        <copy todir="${build}/lib">
          <fileset dir="${src}/java">
            <include name="**/*.xinfo"/>
            <include name="**/*.xml"/>
          </fileset>
        </copy>
  
        <jar jarfile="${dist}/${project.jar}" basedir="${build}/lib" 
          manifest="${etc}/${ant.project.name}.mf" />
  
    </target>
  
    <!-- UTILITY TARGETS -->
  
    <target name="support">
      <copy todir="${dist}">
         <fileset dir="${etc}">
           <include name="README.TXT"/>
           <include name="LICENSE.TXT"/>
         </fileset>
      </copy>
    </target>
  
    <target name="javadoc" depends="prepare" >
      <mkdir dir="${javadoc.root.path}/${ant.project.name}" />
      <copy todir="${javadoc.root.path}/${ant.project.name}">
         <fileset dir="${etc}">
           <include name="LICENSE.HTML"/>
           <include name="license.css"/>
         </fileset>
      </copy>
      <javadoc destdir="${javadoc.root.path}/${ant.project.name}" 
        doctitle="&lt;h1&gt;${project.title}&lt;/h1&gt;" 
        noindex="false" author="false" 
        use="true"
        overview="${overview.html}"
        windowtitle="${project.title}" 
        bottom="&lt;a href='[EMAIL PROTECTED]/LICENSE.HTML'/&gt;License, 
Disclaimer and due credits.&lt;/a&gt;"
        additionalparam="-breakiterator -J-Xmx128m"
        packagenames="org.*" 
        >
          <sourcepath path="${src}/java"/>
          <sourcepath path="${build}/ins/src"/>
          <sourcepath path="${build}/ext/src"/>
          <classpath>
            <path refid="project.classpath" />
            <pathelement path="${dist}/${project.jar}" />
          </classpath>
          <link href="${jdk.href}" />
          <link href="${avalon.href}" />
          <link href="${orb.href}" />
      </javadoc>
    </target>
  
    <target name="demo" depends="loader.validation,build" if="merlin.available">
  
      <echo message="Executing ${project.title} demo."/>
  
      <!-- 
      After loading jar files declared under a fileset, apply lifecycle
      pipeline processing to the class referenced in the target attribute.
      -->
  
      <load target="${demo.class}" 
        priority="${demo.priority}" disposal="${demo.disposal}" 
verbose="${demo.verbose}">
        <fileset dir="${dist}">
           <include name="*.jar"/>
        </fileset>
        <fileset dir="${orb.lib.path}">
           <include name="*.jar"/>
        </fileset>
        <fileset dir="${orb.dist.path}">
           <include name="*.jar"/>
        </fileset>
        <fileset dir="${pss.dist.path}">
           <include name="*.jar"/>
        </fileset>
        <fileset dir="${tools.lib.path}">
           <include name="*.jar"/>
        </fileset>
      </load>
  
    </target>
  
    <target name="loader.context">
      <available property="merlin.available" file="${ant.home}/lib/merlin.jar"/>
    </target>
  
    <target name="loader.defintion" depends="loader.context" 
if="merlin.available">
      <taskdef resource="merlin.properties"/>
    </target>
   
    <target name="loader.validation" depends="loader.defintion" 
unless="merlin.available">
      <echo>
  
       Merlin is not installed in your Ant library.
       In order to use the "load" task the following jar files 
       must be added to your ${ant.home}/lib directory:
  
         - merlin.jar
         - avalon-framework.jar
         - logkit.jar
         - xerces.jar (pre JRE 1.4 only)
      </echo>
    </target>
  
  </project>
  
  
  
  1.1                  jakarta-avalon-apps/enterprise/ins/src/etc/ins.mf
  
  Index: ins.mf
  ===================================================================
  Manifest-Version: 1.0
  Implementation-Version: 1.3.0
  Specification-Title: Interoperable Naming Service
  Specification-Version: 1.1
  Main-Class: org.openorb.ins.NamingProvider
  Extension-Name: ins
  Created-By: Ant 1.4.1
  Class-Path: 
  Implementation-Vendor-Id: APACHE
  Implementation-Vendor: Appache Foundation
  Specification-Vendor: Object Management Group
  
  Name: org/apache/ins/NamingProvider.class
  Avalon-Block: true
  
  
  
  1.1                  jakarta-avalon-apps/enterprise/ins/src/idl/CosNaming.idl
  
  Index: CosNaming.idl
  ===================================================================
  /**
   * The INS ( Interoperable Naming Service ) is an extended version of
   * the standard name service. It provides a new interface
   * NamingContextEx that gives several methods to manage CORBA URL.
   *
   * @author Distributed Object Group
   * @version 2.0
   */
  
  #ifndef _INTEROPERABLE_NAMING_SERVICE_IDL_
  #define _INTEROPERABLE_NAMING_SERVICE_IDL_
  
  //
  // Interoperable Naming Service IDL Description
  // 
  // (c) 1999, Distributed Object Group
  // Developed by Jerome DANIEL
  //
  
  /**
   * This module provides all types and interfaces needed to bind,
   * rebind and resolve objects.
   */
  module CosNaming
  {
      typePrefix CosNaming "omg.org";
        
      /**
       * A simple string definition
       */
      typedef string Istring;
  
      /**
       * This struct provides a basic structure to named an element into
       * the naming graph.  Each node and object have are identified with
       * a NameComponent.
       */
      struct NameComponent
      {
          Istring id;
          Istring kind;
      };
      
      /**
       * To identify a specific node into the naming graph we use its name
       * ( which is in fact a path to the element ). A name is just a
       * sequence of NameComponent.
       */
      typedef sequence<NameComponent> Name;
  
      /**
       * The BindingType defines the possible node type. Indeed, it is
       * possible to have two kinds of nodes into the naming graph. An
       * object ( identify by nobject ) or a naming context ( identify by
       * ncontext ).
       */
      enum BindingType {nobject, ncontext};
  
      /**
       * This structure defines a naming graph node. A node is the
       * association of a name and a binding type.
       */
      struct Binding
      {
          Name binding_name;
          BindingType binding_type;
      };
        
      /**
       * This definition provides a sequence of bindind to symbolize the
       * naming graph path.
       */
      typedef sequence<Binding> BindingList;
  
      /**
       * A forward declaration for the binding iterator interface.
       */
      interface BindingIterator;
  
      /**
       * This interface provides all functions to bind, rebind and resolve
       * an object into the naming graph.
       */ 
      interface NamingContext
      {
  
          /**
           * This enum defines several constants to speficy an exception
           * reason for the NotFound exception. Its values are :
           *
           * - missing_node which implies that in the asked path a node is
           * invalid.
           *
           * - not_context which implies that the asked naming context is
           * not a naming context ( so, it is an object ).
           *
           * - not_object which implies that the asked object is not an
           * object ( but a naming context ).
           */
          enum NotFoundReason
          {
              missing_node,
              not_context,
              not_object
          };
  
          /**
           * This exception is raises when an object or a naming context is
           * not found. It provides additionnal information which are the
           * reason of this exception and the part of the name that the name
           * server was not able to use.
           */ 
          exception NotFound
          {
              NotFoundReason why;
              Name rest_of_name;
          };
  
          /**
           * This exception is raised when an operation was not possible on
           * a specific naming context. In this case, this exception
           * provides several additionnal information : the naming context
           * where the operation was not possible and the part of the name
           * that the name server was not able to use.
           */
          exception CannotProceed
          {
              NamingContext cxt;
              Name rest_of_name;
          };
  
          /**
           * This exception is raised if an invalid name is provide to a
           * name server operation.
           */
          exception InvalidName { };
                
          /**
           * This exception is raised when you try to bind a naming context
           * or an object and if it is already bound. In this case, if you
           * want to update this node information you have to use a rebind
           * operation.
           */
          exception AlreadyBound { };
  
          /**
           * This exception is raised if you try to destroy a naming context
           * and if this naming context is simply not empty.
           */
          exception NotEmpty { };
  
          /**
           * Creates a binding of a name and an object in the naming
           * context. Naming contexts that are bound using bind do not
           * participate in name resolution when compound names are passed
           * to be resolved.
           *
           * @param     n       The compound name for the object to bind
           * @param     obj     The object to bind
           * @exception NotFound      Indicates the name does not identify a 
binding.
           * @exception CannotProceed Indicates that the implementation has 
given up for some reason. 
           *                          The client, however, may be able to 
continue the operation at the
           *                          returned naming context.
           * @exception InvalidName   Indicates the name is invalid. (A name of 
length 0 is invalid; implementations may
           *                          place other restrictions on names.)
           * @exception AlreadyBound  Indicates an object is already bound to 
the specified name. Only one
           *                          object can be bound to a particular name 
in a context. The bind and
           *                          the bind_context operations raise the 
AlreadyBound exception if the name is bound in
           *                          the context; the rebind and rebind_context
           *                          operations unbind the name and rebind the 
name to the object passed as an argument.
           */
          void bind(in Name n, in Object obj)       
              raises(NotFound, CannotProceed, InvalidName, AlreadyBound);
  
          /**
           * Creates a binding of a name and an object in the naming context
           * even if the name is already bound in the context. Naming
           * contexts that are bound using rebind do not participate in name
           * resolution when compound names are passed to be resolved.
           *
           * @param     n       The compound name for the object to rebind
           * @param     obj     The object to rebind
           * @exception NotFound      Indicates the name does not identify a 
binding.
           * @exception CannotProceed Indicates that the implementation has
           *                          given up for some reason. The client, 
however,
           *                          may be able to continue the operation at 
the
           *                          returned naming context.
           * @exception InvalidName   Indicates the name is invalid. (A name
           *                          of length 0 is invalid; implementations 
may
           *                          place other restrictions on names.)
           * @exception AlreadyBound  Indicates an object is already bound to
           *                          the specified name. Only one object can 
be bound
           *                          to a particular name in a context. The 
bind and
           *                          the bind_context operations raise the
           *                          AlreadyBound exception if the name is 
bound in
           *                          the context; the rebind and rebind_context
           *                          operations unbind the name and rebind the 
name
           *                          to the object passed as an argument.
           */
          void rebind(in Name n, in Object obj)
              raises(NotFound, CannotProceed, InvalidName);
  
          /**
           * Names an object that is a naming context. Naming contexts that
           * are bound using bind_context() participate in name resolution
           * when compound names are passed to be resolved.
           * 
           * @param n   The compound name for the naming context to bind
           * @param obj The naming context to bind       
           * 
           * @exception NotFound      Indicates the name does not identify a 
binding.
           * @exception CannotProceed Indicates that the implementation has
           *                          given up for some reason. The client, 
however,
           *                          may be able to continue the operation at 
the
           *                          returned naming context.
           * @exception InvalidName   Indicates the name is invalid. (A name
           *                          of length 0 is invalid; implementations 
may
           *                          place other restrictions on names.)
           * @exception AlreadyBound  Indicates an object is already bound to
           *                          the specified name. Only one object can 
be bound
           *                          to a particular name in a context. The 
bind and
           *                          the bind_context operations raise the
           *                          AlreadyBound exception if the name is 
bound in
           *                          the context; the rebind and rebind_context
           *                          operations unbind the name and rebind the 
name
           *                          to the object passed as an argument.
           */
          void bind_context(in Name n, in NamingContext nc)
              raises(NotFound, CannotProceed, InvalidName, AlreadyBound);
  
          /**
           * Creates a binding of a name and a naming context in the naming
           * context even if the name is already bound in the
           * context. Naming contexts that are bound using rebind_context()
           * participate in name resolution when compound names are passed
           * to be resolved.
           * 
           * @param n   The compound name for the naming context to rebind
           * @param obj The naming context to rebind             
           * 
           * @exception NotFound Indicates the name does not identify a binding.
           * @exception CannotProceed Indicates that the implementation has
           *                          given up for some reason. The client, 
however,
           *                          may be able to continue the operation at 
the
           *                          returned naming context.
           * @exception InvalidName   Indicates the name is invalid. (A name
           *                          of length 0 is invalid; implementations 
may
           *                          place other restrictions on names.)
           * @exception AlreadyBound  Indicates an object is already bound to
           *                          the specified name. Only one object can 
be bound
           *                          to a particular name in a context. The 
bind and
           *                          the bind_context operations raise the
           *                          AlreadyBound exception if the name is 
bound in
           *                          the context; the rebind and rebind_context
           *                          operations unbind the name and rebind the 
name
           *                          to the object passed as an argument.
           */
          void rebind_context(in Name n, in NamingContext nc)
              raises(NotFound, CannotProceed, InvalidName);
  
          /**
           * Names can have multiple components; therefore, name resolution
           * can traverse multiple contexts.
           * 
           * @param n The compound name for the object to resolve.
           * @return the resolved object.
           * @exception NotFound      Indicates the name does not identify a 
binding.
           * @exception CannotProceed Indicates that the implementation has
           *                          given up for some reason. The client, 
however,
           *                          may be able to continue the operation at 
the
           *                          returned naming context.
           * @exception InvalidName   Indicates the name is invalid. (A name
           *                          of length 0 is invalid; implementations 
may
           *                          place other restrictions on names.)
           */
          Object resolve (in Name n)
              raises(NotFound, CannotProceed, InvalidName);
  
          /**
           * The unbind operation removes a name binding from a context.
           * 
           * @param n The compound name for the node to unbind ( an object or a 
naming context )
           * @exception NotFound      Indicates the name does not identify a 
binding.
           * @exception CannotProceed Indicates that the implementation has
           *                          given up for some reason. The client, 
however,
           *                          may be able to continue the operation at 
the
           *                          returned naming context.
           * @exception InvalidName   Indicates the name is invalid. (A name
           *                          of length 0 is invalid; implementations 
may
           *                          place other restrictions on names.)
           */
          void unbind(in Name n)
              raises(NotFound, CannotProceed, InvalidName);
  
          /**
           * This operation returns a naming context implemented by the same
           * naming server as the context on which the operation was
           * invoked. The new context is not bound to any name.
           * 
           * @return A new naming context ( this new naming context must be 
binded )
           */
          NamingContext new_context();
  
          /**
           * This operation creates a new context and binds it to the name
           * supplied as an argument. The newly-created context is
           * implemented by the same naming server as the context in which
           * it was bound (that is, the naming server that implements the
           * context denoted by the name argument excluding the last
           * component).
           * 
           * @param n The compound name for the naming context to create and to 
bind.
           * @exception NotFound      Indicates the name does not identify a 
binding.
           * @exception CannotProceed Indicates that the implementation has
           *                          given up for some reason. The client, 
however,
           *                          may be able to continue the operation at 
the
           *                          returned naming context.
           * @exception InvalidName   Indicates the name is invalid. (A name
           *                          of length 0 is invalid; implementations 
may
           *                          place other restrictions on names.)
           * @exception AlreadyBound  Indicates an object is already bound to
           *                          the specified name. Only one object can 
be bound
           *                          to a particular name in a context.
           */
          NamingContext bind_new_context(in Name n)
              raises(NotFound, AlreadyBound, CannotProceed, InvalidName);
  
          /**
           * The destroy operation deletes a naming context.
           * 
           * @exception NotEmpty If the naming context contains bindings,
           *                     the NotEmpty exception is raised.
           */
          void destroy()
              raises(NotEmpty);
  
          /**
           * The list operation allows a client to iterate through a set of
           * bindings in a naming context.
           * 
           * @param how_many Maximum number of elements into the binding list.
           * @param bl       This parameter returns a list that contains all 
node of the naming context
           * @param bi       This parameter returns a binding iterator to 
iterate in the list.
           * @return The list operation returns at most the requested number of 
bindings in BindingList bl.
           *         - If the naming context contains additional bindings,
           *           the list operation returns a BindingIterator with the
           *           additional bindings.
           *         - If the naming context does not contain additional
           *           bindings, the binding iterator is a nil object
           *           reference.
           */
          void list(in unsigned long how_many, out BindingList bl, out 
BindingIterator bi);
      };
  
      /**
       * This interface provides an iterator to navigate into a naming
       * context.
       */
      interface BindingIterator
      {
          /**
           * This operation returns the next binding.
           *
           * @return If there are no more bindings, false is returned.
           */
          boolean next_one(out Binding b);
  
          /**
           * This operation returns at most the requested number of bindings.
           */
          boolean next_n(in unsigned long how_many, out BindingList bl);
        
          /**
           * This operation destroys the iterator.
           */
          void destroy();
      };
      
      /**
       * This interface has been introduced for the Interoperable Name
       * Service. This interface extends NamingContext and provides
       * several new methods to manage CORBA URL.
       */
      interface NamingContextExt : NamingContext
      {
          /**
           * This typedef provides a data type for a stringified reference.
           */
          typedef string StringName;
  
          /**
           * This typedef defines a type to speficy an Address.
           */
          typedef string Address;
  
          /**
           * This typedef provides a data type for an URL string.
           */
          typedef string URLString;
  
          /**
           * This operation accepts Name and returns a stringified name. 
           *
           * @param n the name to stringified.
           * @exception InvalidName This exception is raised if the name is 
invalid.
           */
          StringName to_string( in Name n )raises( InvalidName );
  
          /**
           * This operation accepts a stringified name and returns a Name.      
 
           * 
           * @param sn The stringified name to transform to a name.
           * @exception InvalideName This exception is raised if the
           *                         stringified name is syntactically 
malformed or
           *                         violates an implementation limit.
           */
          Name to_name( in StringName sn ) raises( InvalidName );
                
          /**
           * This exception is raised if an Address is invalid.
           */
          exception InvalidAddress { };
  
          /**
           * This operation takes an URL address and performs any escapes
           * necessary on the stringified name and returns a fully formed
           * URL string.
           *
           * @param addr The address ( for example myhost.xyz.com )
           * @param sn The stringified name to add to the URL
           * @return the URL string format.
           * @exception InvalidAddress This exception is raises if a address
           *                           is invalid ( it means that the address 
does not
           *                           respect the address format ).
           * @exception InvalidName    This exception is raised if the
           *                           stringified name is syntactically 
malformed or
           *                           violates an implementation limit.
           */
          URLString to_url( in Address addr, in StringName sn )
              raises( InvalidAddress, InvalidName );
                
          /**
           * This is a convenience operation that performs a resolve in the
           * same manner as NamingContext::resolve. It accepts a
           * stringified name as an argument instead of a Name.
           *
           * @param n the stringified name of the object (or naming context) to 
resolve
         * @return the resolved object.
           * @exception NotFound      Indicates the name does not identify a 
binding.
           * @exception CannotProceed Indicates that the implementation has
           *                          given up for some reason. The client, 
however,
           *                          may be able to continue the operation at 
the
           *                          returned naming context.
           * @exception InvalidName   Indicates the name is invalid. (A name
           *                          of length 0 is invalid; implementations 
may
           *                          place other restrictions on names.)
           */
          Object resolve_str( in StringName n )
              raises( NotFound, CannotProceed, InvalidName );
      };
  };
  
  
  #endif
  
  
  
  1.1                  
jakarta-avalon-apps/enterprise/ins/src/idl/OpenORB_Naming.idl
  
  Index: OpenORB_Naming.idl
  ===================================================================
  /**
   * This IDL describes interfaces to plug a callback API to the OpenORB Name 
Server.
   */
  
  #ifndef _OPENORB_NAMING_IDL_
  #define _OPENORB_NAMING_IDL_
  
  #include <CosNaming.idl>
  #pragma prefix "ins.apache.org"
  
  module callback
  {
      /**
       * Enumerate all the name service event type
       */
      enum EventType
      {
          ADD, UPDATE, REMOVE
      };
  
      /**
       * This interface must be implemented by the NS listener which would like 
to receive NS events.
       */
      interface Callback
      {
          /**
           * This operation is invoked when an event is sent for an object
           */
          oneway void object_event( in CosNaming::Name name, in EventType 
event, in Object obj );
  
          /**
           * This operation is invoked when an event is sent for a naming 
context
           */
          oneway void naming_context_event( in CosNaming::Name name, in 
EventType event );                              
      };
  
      /**
       * This interface is used to add and to remove NS Callback objects.
       */
      interface CallbackManager
      {
          void add_callback( in Callback _callback );
          void remove_callback( in Callback _callback );
      };
  };
  
  #endif // _OPENORB_NAMING_IDL_
  
  
  
  1.1                  
jakarta-avalon-apps/enterprise/ins/src/java/org/apache/ins/BindingIteratorImpl.java
  
  Index: BindingIteratorImpl.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.TXT file.
   *
   * Original contribution Copyright 2000 (C) Intalio Inc. All Rights Reserved.
  *
  * $Id: BindingIteratorImpl.java,v 1.1 2002/03/13 09:18:35 mcconnell Exp $
  *
  * Date         Author  Changes
  */
  
  package org.apache.ins;
  
  import org.apache.avalon.framework.logger.LogEnabled;
  import org.apache.avalon.framework.logger.Logger;
  
  /**
   * This class is the implementation of BindingIterator.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Marina Daniel &lt;[EMAIL 
PROTECTED]&gt;</a>
   * @version $Revision: 1.1 $ $Date: 2002/03/13 09:18:35 $ 
   */
  
  public class BindingIteratorImpl extends org.omg.CosNaming.BindingIteratorPOA
      implements LogEnabled
  {
      /**
       * Reference to the binding list
       */
      private java.util.Enumeration _bl;
  
      private Logger m_logger;
  
      /**
       * Constructor
       */
      public BindingIteratorImpl( org.omg.CORBA.ORB orb, java.util.Vector bl, 
Logger logger )
      {
  
          _bl = bl.elements();
          m_logger = logger;
  
          verbose( "bl size : " + bl.size() );
  
          ( ( org.omg.CORBA_2_3.ORB ) orb ).set_delegate( this );
  
          try
          {
              _default_POA().activate_object( this );
          }
          catch ( org.omg.PortableServer.POAPackage.ServantAlreadyActive ex )
          {
              System.out.println( "INS, warning n�9.1" );
          }
          catch ( org.omg.PortableServer.POAPackage.WrongPolicy ex )
          {
              System.out.println( "INS, warning n�9" );
          }
      }
  
      //=============================================================
      // LogEnabled
      //=============================================================
   
      public void enableLogging( Logger logger )
      {
          m_logger = logger;
      }
  
      protected Logger getLogger() 
      {
          return m_logger;
      }
  
      //=============================================================
      // etc
      //=============================================================
  
      /**
       * This operation returns the next binding. 
       * 
       * @return If there are no more bindings, false is returned.
       */
      public boolean next_one( org.omg.CosNaming.BindingHolder b )
      {
  
          verbose( "next_one" );
  
          try
          {
  
              b.value = ( org.omg.CosNaming.Binding ) _bl.nextElement();
  
              return true;
          }
          catch ( java.util.NoSuchElementException e )
          {
  
              b.value = new org.omg.CosNaming.Binding();
              b.value.binding_name = new org.omg.CosNaming.NameComponent[ 0 ];
              b.value.binding_type = org.omg.CosNaming.BindingType.nobject;
              return false;
          }
  
      }
  
      /**
       * This operation returns at most the requested number of bindings.
       */
      public boolean next_n( int how_many, org.omg.CosNaming.BindingListHolder 
bl )
      {
  
          verbose( "next_n" );
          verbose( "how_many : " + how_many );
          int max = how_many;
  
          if ( max == 0 )
              return false;
  
          java.util.Vector bindings = new java.util.Vector();
  
          for ( int i = 0; i < max; i++ )
          {
              org.omg.CosNaming.BindingHolder bh = new 
org.omg.CosNaming.BindingHolder();
  
              boolean result = next_one( bh );
              verbose( "result next_one :" + result );
  
              if ( !result )
              {
  
                  bl.value = new org.omg.CosNaming.Binding[ bindings.size() ];
  
                  for ( int k = 0; k < bindings.size() ; k++ )
                  {
                      bl.value[ k ] = ( org.omg.CosNaming.Binding ) 
bindings.elementAt( k );
                  }
  
                  if ( bindings.size() == 0 )
                      return false;
                  else
                      return true;
              }
              else
                  bindings.addElement( bh.value );
  
          }
  
  
          bl.value = new org.omg.CosNaming.Binding[ bindings.size() ];
  
          for ( int k = 0; k < bindings.size() ; k++ )
          {
              bl.value[ k ] = ( org.omg.CosNaming.Binding ) bindings.elementAt( 
k );
          }
  
          return true;
      }
  
      /**
       * This operation destroys the iterator.
       */
      public void destroy()
      {
          try
          {
              _poa().deactivate_object( _object_id() );
          }
          catch ( org.omg.PortableServer.POAPackage.ObjectNotActive ex )
          {
              System.out.println( "INS Warning n�1" );
          }
          catch ( org.omg.PortableServer.POAPackage.WrongPolicy ex )
          {
              System.out.println( "INS Warning n�2" );
          }
      }
  
      /**
       * This method is used to print information when the verbose mode is 
activated
       */
      private void verbose( String message )
      {
          if ( getLogger().isDebugEnabled() ) getLogger().debug(
              "[ ITERATOR " + message + " ]" );
      }
  
  }
  
  
  
  1.1                  
jakarta-avalon-apps/enterprise/ins/src/java/org/apache/ins/CallbackManagerImpl.java
  
  Index: CallbackManagerImpl.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.TXT file.
   *
   * Original contribution Copyright 2000 (C) Intalio Inc. All Rights Reserved.
  *
  * $Id: CallbackManagerImpl.java,v 1.1 2002/03/13 09:18:35 mcconnell Exp $
  *
  * Date         Author  Changes
  */
  
  package org.apache.ins;
  
  /**
   * This class implements the NS Callback Manager.
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]">Marina Daniel &lt;[EMAIL 
PROTECTED]&gt;</a>
   * @version $Revision: 1.1 $ $Date: 2002/03/13 09:18:35 $ 
   */
  
  public class CallbackManagerImpl extends 
org.apache.ins.callback.CallbackManagerPOA
  {
      /**
       * Callback list
       */
      private java.util.Vector _callback;
  
      public CallbackManagerImpl()
      {
          _callback = new java.util.Vector();
      }
  
      /**
       * Add a callback
       */
      public void add_callback( org.apache.ins.callback.Callback callback )
      {
          _callback.addElement( callback );
      }
  
      /**
       * Remove a callback
       */
      public void remove_callback( org.apache.ins.callback.Callback callback )
      {
          _callback.removeElement( callback );
      }
  
      /**
       * Report an object event to listener
       */
      public void report_object_event( org.omg.CosNaming.NameComponent [] name,
                                       org.apache.ins.callback.EventType event,
                                       org.omg.CORBA.Object obj )
      {
          for ( int i = 0; i < _callback.size(); i++ )
          {
              try
              {
                  org.apache.ins.callback.Callback callback = ( 
org.apache.ins.callback.Callback ) _callback.elementAt( i );
  
                  callback.object_event( name, event, obj );
              }
              catch ( org.omg.CORBA.SystemException ex )
              { }
  
          }
  
      }
  
      /**
       * Report a naming context event to listener
       */
      public void report_naming_context_event( org.omg.CosNaming.NameComponent 
[] name,
              org.apache.ins.callback.EventType event )
      {
          for ( int i = 0; i < _callback.size(); i++ )
          {
              try
              {
                  org.apache.ins.callback.Callback callback = ( 
org.apache.ins.callback.Callback ) _callback.elementAt( i );
  
                  callback.naming_context_event( name, event );
              }
              catch ( org.omg.CORBA.SystemException ex )
              { }
  
          }
  
      }
  
  }
  
  
  
  1.1                  
jakarta-avalon-apps/enterprise/ins/src/java/org/apache/ins/CallbackRegistration.java
  
  Index: CallbackRegistration.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.TXT file.
   *
   * Original contribution Copyright 2000 (C) Intalio Inc. All Rights Reserved.
  *
  * $Id: CallbackRegistration.java,v 1.1 2002/03/13 09:18:35 mcconnell Exp $
  *
  * Date         Author  Changes
  */
  
  package org.apache.ins;
  
  /**
   * This class initializes the callback manager in a specific thread
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]">Marina Daniel &lt;[EMAIL 
PROTECTED]&gt;</a>
   * @version $Revision: 1.1 $ $Date: 2002/03/13 09:18:35 $ 
   */
  
  public class CallbackRegistration extends java.lang.Thread
  {
  
      /**
       * The reference to the callback manager
       */
      private org.apache.ins.callback.CallbackManager callback;
  
      /**
       * Constructor
       */
      public CallbackRegistration( org.apache.ins.callback.CallbackManager 
callback )
      {
          this.callback = callback;
      }
  
      /**
       * execution of the thread
       */
      public void run()
      {
          org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init( new String[ 0 ], null 
);
          registration();
  
      }
  
      /**
       * register the callback manager into the Naming Context 
COS/NamingService/CallbackManager.
       */
      private void registration()
      {
          org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init( new String[ 0 ], null 
);
  
          org.omg.CosNaming.NamingContextExt nc = null;
          try
          {
              org.omg.CORBA.Object obj = orb.resolve_initial_references( 
"NameService" );
              nc = org.omg.CosNaming.NamingContextExtHelper.narrow( obj );
          }
          catch( org.omg.CORBA.ORBPackage.InvalidName ex )
          {
              System.out.println( "A NameService has not been registerd with 
the ORB. Try passing the following parameter to this app:" );
              System.out.println( "java org.openorb.ccs.Server -ORBInitRef 
NameService=corbaloc::HOST:PORT/NameService" );
              System.exit( -1 );
          }
  
          try
          {
              nc.rebind( nc.to_name( "COS/NamingService/CallbackManager" ), 
callback );
          }
          catch( Exception ex )
          {
              System.out.println (
                  " Cannot bind the CallbackManager."
                  + " Check whether your Naming Service is running ... " );
              System.exit( -1 );
          }
      }
  }
  
  
  
  1.1                  
jakarta-avalon-apps/enterprise/ins/src/java/org/apache/ins/NamingContextExImpl.java
  
  Index: NamingContextExImpl.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.TXT file.
   *
   * Original contribution Copyright 2000 (C) Intalio Inc. All Rights Reserved.
  *
  * $Id: NamingContextExImpl.java,v 1.1 2002/03/13 09:18:35 mcconnell Exp $
  *
  * Date         Author  Changes
  */
  
  package org.apache.ins;
  
  import namingPersistence.*;
  import org.apache.avalon.framework.logger.LogEnabled;
  import org.apache.avalon.framework.logger.Logger;
  
  /**
   * This class is the implementation of the NamingContextExt.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Marina Daniel &lt;[EMAIL 
PROTECTED]&gt;</a>
   * @version $Revision: 1.1 $ $Date: 2002/03/13 09:18:35 $ 
   */
  
  public class NamingContextExImpl extends org.omg.CosNaming.NamingContextExtPOA
      implements LogEnabled
  {
  
      /**
       * The reference to the orb
       */
      private org.omg.CORBA.ORB _orb;
  
      /**
       * The reference to the callback manager
       */
      private org.apache.ins.CallbackManagerImpl _callback;
  
      /**
       * the reference to the NamingContext factory to create and find 
persistent NamingContext
       */
      private namingPersistence.NamingContextHome _nc_home;
  
      /**
       * the reference to the NamingObject factory to create and find 
persistent NamingObject
       */
      private namingPersistence.NamingObjectHome _no_home;
  
      /**
       * The reference to the ProxyNamingContext factory to create and find 
persistent ProxyNamingContext
       */
      private namingPersistence.ProxyNamingContextHome _pnc_home;
  
      public static boolean _shutdown = false;
  
      public namingPersistence.NamingContext nc_root;
  
      private Logger m_logger;
  
  
      /**
       * Constructor
       */
      protected NamingContextExImpl( org.omg.CORBA.ORB orb,
        org.apache.ins.CallbackManagerImpl callback,
        namingPersistence.NamingContextHome nc_home,
        namingPersistence.NamingObjectHome no_home,
        namingPersistence.ProxyNamingContextHome pnc_home )
      {
          _orb = orb;
          _callback = callback;
          _nc_home = nc_home;
          _no_home = no_home;
          _pnc_home = pnc_home;
      }
  
      //=============================================================
      // LogEnabled
      //=============================================================
   
      public void enableLogging( Logger logger )
      {
          m_logger = logger;
      }
  
      protected Logger getLogger() 
      {
          return m_logger;
      }
  
      //=============================================================
      // Naming Context Interface
      //=============================================================
  
      /**
       * Creates a binding of a name and an object in the naming
       * context. Naming contexts that are bound using bind do not
       * participate in name resolution when compound names are passed to
       * be resolved.
       *
       * @param n The compound name for the object to bind
       * @param obj The object to bind
       *
       * @exception NotFound  Indicates the name does not identify a binding.
       * @exception CannotProceed Indicates that the implementation has
       *        given up for some reason. The client, however, may
       *        be able to continue the operation at the returned
       *        naming context.
       * @exception Indicates the name is invalid. (A name of length 0 is
       *        invalid; implementations may place other
       *        restrictions on names.)
       * @exception AlreadyBound Indicates an object is already bound to
       *        the specified name. Only one object can be bound
       *        to a particular name in a context. The bind and
       *        the bind_context operations raise the AlreadyBound
       *        exception if the name is bound in the context; the
       *        rebind and rebind_context operations unbind the
       *        name and rebind the name to the object passed as
       *        an argument.
       */
      public void bind( org.omg.CosNaming.NameComponent[] n, 
org.omg.CORBA.Object obj )
      throws org.omg.CosNaming.NamingContextPackage.NotFound, 
org.omg.CosNaming.NamingContextPackage.CannotProceed, 
org.omg.CosNaming.NamingContextPackage.InvalidName, 
org.omg.CosNaming.NamingContextPackage.AlreadyBound
      {
  
          if ( n.length == 0 )
              throw new org.omg.CosNaming.NamingContextPackage.InvalidName();
  
          verbose( "\nBind an object ( " + n[ n.length - 1 ].id + " )" );
  
  
          // get the complete component name of the object
          org.omg.CosNaming.NameComponent[] componentName = getNameComponent( n 
);
  
          String componentName_str = org.openorb.util.NamingUtils.to_string ( 
componentName );
  
          verbose( "componentName :" + componentName_str );
  
          try
          {
  
              // search whether the persistent naming object already exists
              namingPersistence.NamingObject no = 
_no_home.find_by_componentName( componentName_str );
              verbose( " NamingObject already bound " + componentName_str );
              throw new org.omg.CosNaming.NamingContextPackage.AlreadyBound();
  
          }
          catch ( org.omg.CosPersistentState.NotFound ex )
          {
  
              // create the persistent naming object
              namingPersistence.NamingObject no = ( ( NamingObjectHome ) 
_no_home ).create( componentName_str, obj );
  
              // add the object to the children list of its parent
              addNamingObject ( componentName );
  
              // Report event...
  
              _callback.report_object_event( getPath ( componentName ), 
org.apache.ins.callback.EventType.ADD, obj );
          }
  
      }
  
  
      /**
       * Creates a binding of a name and an object in the naming context
       * even if the name is already bound in the context. Naming contexts
       * that are bound using rebind do not participate in name resolution
       * when compound names are passed to be resolved.
        *
       * @param n The compound name for the object to rebind
       * @param obj The object to rebind
       *
       * @exception NotFound  Indicates the name does not identify a binding.
       * @exception CannotProceed Indicates that the implementation has
       *        given up for some reason. The client, however, may
       *        be able to continue the operation at the returned
       *        naming context.
       * @exception Indicates the name is invalid. (A name of length 0 is
       *        invalid; implementations may place other
       *        restrictions on names.)
       * @exception AlreadyBound Indicates an object is already bound to
       *        the specified name. Only one object can be bound
       *        to a particular name in a context. The bind and
       *        the bind_context operations raise the AlreadyBound
       *        exception if the name is bound in the context; the
       *        rebind and rebind_context operations unbind the
       *        name and rebind the name to the object passed as
       *        an argument.
       */
      public void rebind( org.omg.CosNaming.NameComponent[] n, 
org.omg.CORBA.Object obj )
      throws org.omg.CosNaming.NamingContextPackage.NotFound, 
org.omg.CosNaming.NamingContextPackage.CannotProceed, 
org.omg.CosNaming.NamingContextPackage.InvalidName
      {
  
          if ( n.length == 0 )
              throw new org.omg.CosNaming.NamingContextPackage.InvalidName();
  
          verbose( "\nRebind an object ( " + n[ n.length - 1 ].id + " )" );
  
          // get the complete componentName of the object to bind
          org.omg.CosNaming.NameComponent[] componentName = getNameComponent( n 
);
  
          String componentName_str = org.openorb.util.NamingUtils.to_string ( 
componentName );
  
          verbose( "componentName : " + componentName_str );
  
          try
          {
  
              // search whether the persistent naming object already exists
              namingPersistence.NamingObject no = 
_no_home.find_by_componentName( componentName_str );
              verbose( " NamingObject already exist " + componentName_str );
              no.namingObj ( obj );
  
          }
          catch ( org.omg.CosPersistentState.NotFound ex )
          {
              // create the persistent naming object
              namingPersistence.NamingObject namingObject = _no_home.create( 
componentName_str, obj );
  
              // add the object to the children list of its parent
              addNamingObject ( componentName );
          }
  
          // Report event...
          _callback.report_object_event( getPath ( componentName ), 
org.apache.ins.callback.EventType.UPDATE, obj ); // Modified 9/12/00
      }
  
  
      /**
       * Names an object that is a naming context. Naming contexts that
       * are bound using bind_context() participate in name resolution
       * when compound names are passed to be resolved.
       *
       * @param n The compound name for the naming context to bind
       * @param obj The naming context to bind 
       *
       * @exception NotFound  Indicates the name does not identify a binding.
       * @exception CannotProceed Indicates that the implementation has
       *        given up for some reason. The client, however, may
       *        be able to continue the operation at the returned
       *        naming context.
       * @exception Indicates the name is invalid. (A name of length 0 is
       *        invalid; implementations may place other
       *        restrictions on names.)
       * @exception AlreadyBound Indicates an object is already bound to
       *        the specified name. Only one object can be bound
       *        to a particular name in a context. The bind and
       *        the bind_context operations raise the AlreadyBound
       *        exception if the name is bound in the context; the
       *        rebind and rebind_context operations unbind the
       *        name and rebind the name to the object passed as
       *        an argument.
       */
      public void bind_context( org.omg.CosNaming.NameComponent[] n, 
org.omg.CosNaming.NamingContext nc )
      throws org.omg.CosNaming.NamingContextPackage.NotFound, 
org.omg.CosNaming.NamingContextPackage.CannotProceed, 
org.omg.CosNaming.NamingContextPackage.InvalidName, 
org.omg.CosNaming.NamingContextPackage.AlreadyBound
      {
  
          if ( n.length == 0 )
              throw new org.omg.CosNaming.NamingContextPackage.InvalidName();
  
          verbose( "Bind a context ( " + n[ n.length - 1 ].id + " )" );
  
          boolean is_local = ( ( org.omg.CORBA.portable.ObjectImpl ) nc 
)._is_local();
  
          verbose( "is local : " + is_local );
  
          // get the complete component name of the Naming context to bind
          org.omg.CosNaming.NameComponent[] componentName = getNameComponent( n 
);
  
          String componentName_str = org.openorb.util.NamingUtils.to_string ( 
componentName );
  
          verbose( "componentName : " + componentName_str );
  
          if ( is_local )
          {
  
              try
              {
                  // search whether the Naming context already exists
                  namingPersistence.NamingContext namingContext = 
_nc_home.find_by_componentName( componentName_str );
                  verbose ( " NamingContext already exist " + componentName_str 
);
                  throw new 
org.omg.CosNaming.NamingContextPackage.AlreadyBound();
  
              }
              catch ( org.omg.CosPersistentState.NotFound ex )
              {
  
                  try
                  {
                      // set the nameComponent to the namingContext
                      byte[] id = _poa().reference_to_id( nc );
                      namingPersistence.NamingContext namingContext = 
getNamingContext( id );
                      namingContext.componentName ( componentName_str );
  
                      // add the naming context to its parent
                      addNamingContext ( componentName );
                  }
                  catch ( org.omg.PortableServer.POAPackage.WrongAdapter e )
                  {
                      e.printStackTrace();
                  }
                  catch ( org.omg.PortableServer.POAPackage.WrongPolicy p )
                  {
                      p.printStackTrace();
                  }
  
              }
          }
          else
          {
  
              try
              {
                  // search whether the ProxyNamingContext already exists
                  namingPersistence.ProxyNamingContext no = 
_pnc_home.find_by_componentName( componentName_str );
                  verbose( " ProxyNamingContext already exist : " + 
componentName_str );
                  throw new 
org.omg.CosNaming.NamingContextPackage.AlreadyBound();
              }
              catch ( org.omg.CosPersistentState.NotFound ex )
              {
  
                  // create the ProxyNamingContext
                  _pnc_home.create( componentName_str , nc );
                  // add the Proxy Naming Context to its parent.
                  addProxyNamingContext ( componentName );
              }
          }
  
          // Report event...
          verbose( "CALLBACK BIND" );
  
          _callback.report_naming_context_event( getPath ( componentName ) , 
org.apache.ins.callback.EventType.ADD );
      }
  
      /**
       * Creates a binding of a name and a naming context in the naming
       * context even if the name is already bound in the context. Naming
       * contexts that are bound using rebind_context() participate in
       * name resolution when compound names are passed to be resolved.
       *
       * @param n The compound name for the naming context to rebind
       * @param obj The naming context to rebind   
       *
       * @exception NotFound  Indicates the name does not identify a binding.
       * @exception CannotProceed Indicates that the implementation has
       *        given up for some reason. The client, however, may
       *        be able to continue the operation at the returned
       *        naming context.
       * @exception InvalidName Indicates the name is invalid. (A name of
       *        length 0 is invalid; implementations may place
       *        other restrictions on names.)
       * @exception AlreadyBound Indicates an object is already bound to
       *        the specified name. Only one object can be bound
       *        to a particular name in a context. The bind and
       *        the bind_context operations raise the AlreadyBound
       *        exception if the name is bound in the context; the
       *        rebind and rebind_context operations unbind the
       *        name and rebind the name to the object passed as
       *        an argument.
       */
      public void rebind_context( org.omg.CosNaming.NameComponent[] n, 
org.omg.CosNaming.NamingContext nc )
      throws org.omg.CosNaming.NamingContextPackage.NotFound, 
org.omg.CosNaming.NamingContextPackage.CannotProceed, 
org.omg.CosNaming.NamingContextPackage.InvalidName
      {
          if ( n.length == 0 )
              throw new org.omg.CosNaming.NamingContextPackage.InvalidName();
  
          verbose( "Rebind a context ( " + n[ n.length - 1 ].id + " )" );
  
          // get the complete componentName of the NamingContext to rebind
          org.omg.CosNaming.NameComponent[] componentName = getNameComponent( n 
);
  
          String componentName_str = org.openorb.util.NamingUtils.to_string ( 
componentName );
  
          boolean is_local = ( ( org.omg.CORBA.portable.ObjectImpl ) nc 
)._is_local();
  
          if ( is_local )
          {
  
              try
              {
                  // search whether the Naming context already exists
                  namingPersistence.NamingContext namingContext = 
_nc_home.find_by_componentName( componentName_str );
                  verbose ( " NamingContext already exist " + componentName_str 
);
                  // if a naming context already exist, it must be unbound.
                  unbind( n );
  
              }
              catch ( org.omg.CosPersistentState.NotFound ex )
              {}
  
              try
              {
                  // set the nameComponent to the namingContext
                  byte[] id = _poa().reference_to_id( nc );
                  namingPersistence.NamingContext namingContext = 
getNamingContext( id );
                  // case of a rebind of a Naming Context that is already bound 
somewhere else.
                  if ( !namingContext.componentName().equals( "" ) )
                      throw new 
org.omg.CosNaming.NamingContextPackage.CannotProceed( nc, n );
  
                  namingContext.componentName ( componentName_str );
  
                  addNamingContext ( componentName );
              }
              catch ( org.omg.PortableServer.POAPackage.WrongAdapter e )
              {
                  e.printStackTrace();
              }
              catch ( org.omg.PortableServer.POAPackage.WrongPolicy p )
              {
                  p.printStackTrace();
              }
  
          }
          else
          {
  
              // create the Proxy naming context
              _pnc_home.create( componentName_str , nc );
              // add the Proxy Naming Context to its parent.
              addProxyNamingContext ( componentName );
          }
  
          // Report event...
          _callback.report_naming_context_event( getPath ( componentName ) , 
org.apache.ins.callback.EventType.UPDATE );
      }
  
      /**
       * Names can have multiple components; therefore, name resolution
       * can traverse multiple contexts.
       *
       * @param n The compound name for the object to resolve
       *
       * @exception NotFound  Indicates the name does not identify a binding.
       * @exception CannotProceed Indicates that the implementation has
       *        given up for some reason. The client, however, may
       *        be able to continue the operation at the returned
       *        naming context.
       * @exception InvalidName Indicates the name is invalid. (A name of
       *        length 0 is invalid; implementations may place
       *        other restrictions on names.)
       */
      public org.omg.CORBA.Object resolve( org.omg.CosNaming.NameComponent[] n )
      throws org.omg.CosNaming.NamingContextPackage.NotFound, 
org.omg.CosNaming.NamingContextPackage.CannotProceed, 
org.omg.CosNaming.NamingContextPackage.InvalidName
      {
  
          if ( n.length == 0 )
              throw new org.omg.CosNaming.NamingContextPackage.InvalidName();
  
          verbose( "Resolve an object ( " + n[ n.length - 1 ].id + " )" );
  
          // get the complete componentName of the persistent naming object to 
resolve
          org.omg.CosNaming.NameComponent[] componentName = getNameComponent( n 
);
  
          String componentName_str = org.openorb.util.NamingUtils.to_string ( 
componentName );
  
          verbose( "componentName : " + componentName_str );
  
          try
          {
              namingPersistence.NamingObject no = 
_no_home.find_by_componentName( componentName_str );
              return no.namingObj();
  
          }
          catch ( org.omg.CosPersistentState.NotFound e )
          {
              try
              {
                  namingPersistence.NamingContext nc = 
_nc_home.find_by_componentName( componentName_str );
                  return createReference( nc );
              }
              catch ( org.omg.CosPersistentState.NotFound ex )
              {
                  try
                  {
                      namingPersistence.ProxyNamingContext pnc = 
_pnc_home.find_by_componentName ( componentName_str );
                      return pnc.ctx();
                  }
                  catch ( org.omg.CosPersistentState.NotFound nf )
                  {
  
                      verbose( " Object not found " + componentName_str );
                      throw new 
org.omg.CosNaming.NamingContextPackage.NotFound( 
org.omg.CosNaming.NamingContextPackage.NotFoundReason.missing_node, n );
                  }
              }
          }
  
      }
  
      /**
       * The unbind operation removes a name binding from a context.
       *
       * @param n The compound name for the node to unbind ( an object or
       * a naming context )
       *
       * @exception NotFound  Indicates the name does not identify a binding.
       * @exception CannotProceed Indicates that the implementation has
       *        given up for some reason. The client, however, may
       *        be able to continue the operation at the returned
       *        naming context.
       * @exception InvalidName Indicates the name is invalid. (A name of
       *        length 0 is invalid; implementations may place
       *        other restrictions on names.)
       */
      public void unbind( org.omg.CosNaming.NameComponent[] n )
      throws org.omg.CosNaming.NamingContextPackage.NotFound, 
org.omg.CosNaming.NamingContextPackage.CannotProceed, 
org.omg.CosNaming.NamingContextPackage.InvalidName
      {
          if ( n.length == 0 )
              throw new org.omg.CosNaming.NamingContextPackage.InvalidName();
  
          verbose( "Unbind ( " + n[ n.length - 1 ].id + " )" );
  
          // get the complete component Name of the naming object to unbind
          org.omg.CosNaming.NameComponent[] componentName = getNameComponent( n 
);
  
          String componentName_str = org.openorb.util.NamingUtils.to_string ( 
componentName );
  
          verbose( "componentName_str : " + componentName_str );
  
          try
          {
  
              // find if the node to unbind is a NamingContext
              namingPersistence.NamingContext nc = 
_nc_home.find_by_componentName( componentName_str );
              verbose( "unbind the namingContext : " + componentName_str );
  
              // remove the naming context from the children list of its parent
              removeNamingContext ( componentName );
              nc.componentName( "" );
  
              //report event
              _callback.report_naming_context_event( getPath ( componentName ) 
, org.apache.ins.callback.EventType.REMOVE );
          }
          catch ( org.omg.CosPersistentState.NotFound ex )
          {
  
              try
              {
                  // find if the node to unbind is a ProxyNamingContext
                  namingPersistence.ProxyNamingContext pnc = 
_pnc_home.find_by_componentName( componentName_str );
                  verbose( "unbind the ProxyNamingContext : " + 
componentName_str );
  
                  // remove the proxy naming context from the children list of 
its parent
                  removeProxyNamingContext ( componentName );
                  pnc.destroy_object();
  
                  //report event
                  _callback.report_naming_context_event( getPath ( 
componentName ) , org.apache.ins.callback.EventType.REMOVE );
  
              }
              catch ( org.omg.CosPersistentState.NotFound e )
              {
  
                  try
                  {
  
                      // find if the node to unbind is a naming object
                      namingPersistence.NamingObject no = 
_no_home.find_by_componentName( componentName_str );
                      verbose( "unbind the naming object : " + 
componentName_str );
  
                      // remove the naming object from the children list of its 
parent
                      removeNamingObject ( componentName );
                      no.destroy_object();
  
                      //report event
                      _callback.report_naming_context_event( getPath ( 
componentName ), org.apache.ins.callback.EventType.REMOVE );
                  }
                  catch ( org.omg.CosPersistentState.NotFound e2 )
                  {
                      verbose( " node not found : " + componentName_str );
                      throw new 
org.omg.CosNaming.NamingContextPackage.NotFound( 
org.omg.CosNaming.NamingContextPackage.NotFoundReason.not_context, n );
                  }
              }
  
          }
  
      }
  
      /**
       * This operation returns a naming context implemented by the same
       * naming server as the context on which the operation was
       * invoked. The new context is not bound to any name.
       *
       * @return A new naming context ( this new naming context must be
       * binded )
       */
      public org.omg.CosNaming.NamingContext new_context()
      {
          verbose( "Create a new context" );
  
          namingPersistence.NamingContextRef[] nc_children = new 
namingPersistence.NamingContextRef[ 0 ];
          namingPersistence.NamingObjectRef[] no_children = new 
namingPersistence.NamingObjectRef[ 0 ];
          namingPersistence.ProxyNamingContextRef[] pnc_children = new 
namingPersistence.ProxyNamingContextRef[ 0 ];
  
          namingPersistence.NamingContext newNamingContext = _nc_home.create( 
"", nc_children, no_children, pnc_children );
          return createReference( newNamingContext );
  
      }
  
      /**
       * This operation creates a new context and binds it to the name
       * supplied as an argument. The newly-created context is implemented
       * by the same naming server as the context in which it was bound
       * (that is, the naming server that implements the context denoted
       * by the name argument excluding the last component).
       *
       * @param n The compound name for the naming context to create and to 
bind.
       *
       * @exception NotFound  Indicates the name does not identify a binding.
       * @exception CannotProceed Indicates that the implementation has
       *        given up for some reason. The client, however, may
       *        be able to continue the operation at the returned
       *        naming context.
       * @exception InvalidName Indicates the name is invalid. (A name of
       *        length 0 is invalid; implementations may place
       *        other restrictions on names.)
       * @exception AlreadyBound Indicates an object is already bound to
       *        the specified name. Only one object can be bound
       *        to a particular name in a context.
       */
      public org.omg.CosNaming.NamingContext bind_new_context( 
org.omg.CosNaming.NameComponent[] n )
      throws org.omg.CosNaming.NamingContextPackage.NotFound, 
org.omg.CosNaming.NamingContextPackage.AlreadyBound, 
org.omg.CosNaming.NamingContextPackage.CannotProceed, 
org.omg.CosNaming.NamingContextPackage.InvalidName
      {
  
          if ( n.length == 0 )
              throw new org.omg.CosNaming.NamingContextPackage.InvalidName();
  
          verbose( "bind_new_context : " + 
org.openorb.util.NamingUtils.to_string( n ) );
  
          org.omg.CosNaming.NamingContext nc = new_context();
  
          bind_context( n, nc );
  
          return nc;
      }
  
      /**
       * The destroy operation deletes a naming context.
       *
       * @exception NotEmpty If the naming context contains bindings, the
       * NotEmpty exception is raised.
       */
      public void destroy()
      throws org.omg.CosNaming.NamingContextPackage.NotEmpty
      {
          verbose( "Destroy a NamingContext" );
  
          namingPersistence.NamingContext nc = null;
  
          try
          {
  
              // Case of a destroy action on the root naming context
              nc = getNamingContext();
  
              if ( nc.equals ( nc_root ) )
              {
                  if ( _shutdown )
                  {
                      _orb().shutdown ( false );
                      return ;
                  }
  
                  throw new org.omg.CORBA.NO_PERMISSION();
  
              }
  
              // if the Naming context is local
              NamingContextRef[] nc_children = nc.nc_children();
  
              NamingObjectRef[] no_children = nc.no_children();
  
              ProxyNamingContextRef[] pnc_children = nc.pnc_children();
  
              if ( ( nc_children.length == 0 ) && ( no_children.length == 0 ) 
&& ( pnc_children.length == 0 ) )
              {
  
                  // if the Naming Context is not empty
                  String componentName_str = nc.componentName();
                  verbose( "componentName : " + componentName_str );
  
                  org.omg.CosNaming.NameComponent[] componentName = null;
  
                  try
                  {
                      componentName = org.openorb.util.NamingUtils.to_name( 
componentName_str );
                  }
                  catch ( org.omg.CosNaming.NamingContextPackage.InvalidName in 
)
                  {
                      System.out.println( "Invalid Name" );
                      return ;
                  }
  
  
                  // remove the reference of the Naming context from the list 
of children of the parent
                  removeNamingContext ( componentName );
  
                  // destroy the persistent object
                  nc.destroy_object();
  
                  //Report event ...
                  org.omg.CosNaming.NameComponent[] path = new 
org.omg.CosNaming.NameComponent[ componentName.length - 1 ];
  
                  for ( int k = 1; k < componentName.length ; k++ )
                  {
                      path[ k - 1 ] = componentName[ k ];
                  }
  
                  _callback.report_naming_context_event( path, 
org.apache.ins.callback.EventType.REMOVE );
              }
              else
              {
                  throw new org.omg.CosNaming.NamingContextPackage.NotEmpty();
  
              }
  
          }
          catch ( org.omg.CosNaming.NamingContextPackage.NotFound e )
          {
  
              // if the Naming context to destroy is a Proxy Naming Context
              namingPersistence.ProxyNamingContext pnc = null;
  
              try
              {
                  pnc = getProxyNamingContext();
                  // A Proxy Naming Context has no child ( It reprensents a 
distant Naming Context )
                  pnc.destroy_object();
  
                  // Report event ...
                  String componentName_str = nc.componentName();
                  verbose( "componentName : " + componentName_str );
  
                  org.omg.CosNaming.NameComponent[] componentName = null;
  
                  try
                  {
                      componentName = org.openorb.util.NamingUtils.to_name( 
componentName_str );
                  }
                  catch ( org.omg.CosNaming.NamingContextPackage.InvalidName in 
)
                  {
                      System.out.println( "Invalid Name" );
                      return ;
                  }
  
                  _callback.report_naming_context_event( getPath ( 
componentName ) , org.apache.ins.callback.EventType.REMOVE );
              }
              catch ( org.omg.CosNaming.NamingContextPackage.NotFound ex )
              {
                  System.out.println( " Binding not found ! " );
                  return ;
              }
  
          }
  
  
  
      }
  
      /**
       * The list operation allows a client to iterate through a set of
       * bindings in a naming context.
       *
       * @param how_many Maximum number of elements into the binding list.
       * @param bl This parameter returns a list that contains all node of
       *             the naming context
       * @param bi This parameter returns a binding iterator to iterate in
       *           the list.
       *
       * @return The list operation returns at most the requested number
       *    of bindings in BindingList bl. If the naming context
       *    contains additional bindings, the list operation returns a
       *    BindingIterator with the additional bindings. If the
       *    naming context does not contain additional bindings, the
       *    binding iterator is a nil object reference.
       */
      public void list( int how_many, org.omg.CosNaming.BindingListHolder bl, 
org.omg.CosNaming.BindingIteratorHolder bi )
      {
  
          verbose( "List all objects" );
  
          int max = 0;
          namingPersistence.NamingContext nc = null;
  
          try
          {
              nc = getNamingContext();
          }
          catch ( org.omg.CosNaming.NamingContextPackage.NotFound e )
          {
              e.printStackTrace();
              throw new org.omg.CORBA.OBJECT_NOT_EXIST();
          }
  
          verbose( "nc : " + nc.componentName() );
  
          namingPersistence.NamingObjectRef[] no_children = nc.no_children();
          namingPersistence.NamingContextRef[] nc_children = nc.nc_children();
          namingPersistence.ProxyNamingContextRef[] pnc_children = 
nc.pnc_children();
  
          int bindings_size = no_children.length + nc_children.length + 
pnc_children.length;
          verbose( "bindings_size " + bindings_size );
  
          org.omg.CosNaming.Binding[] bindings = new org.omg.CosNaming.Binding[ 
bindings_size ];
  
          for ( int i = 0 ; i < no_children.length ; i++ )
          {
  
              namingPersistence.NamingObjectRef child = no_children[ i ];
  
              namingPersistence.NamingObject namingObject = ( 
namingPersistence.NamingObject ) child.deref();
  
              bindings[ i ] = getBinding ( namingObject );
          }
  
          for ( int i = 0; i < nc_children.length; i++ )
          {
              namingPersistence.NamingContext namingContext = ( 
namingPersistence.NamingContext ) nc_children[ i ].deref();
              bindings[ i + no_children.length ] = getBinding ( namingContext );
          }
  
          for ( int i = 0; i < pnc_children.length; i++ )
          {
              namingPersistence.ProxyNamingContext proxyNamingContext = ( 
namingPersistence.ProxyNamingContext ) pnc_children[ i ].deref();
              bindings[ i - pnc_children.length ] = getBinding ( 
proxyNamingContext );
          }
  
  
  
          if ( bindings_size < how_many )
              max = bindings_size;
          else
              max = how_many;
  
          verbose( "max : " + max );
  
          bl.value = new org.omg.CosNaming.Binding[ max ];
  
          for ( int k = 0 ; k < max ; k++ )
          {
              bl.value[ k ] = bindings[ k ];
          }
  
          verbose( "how_many : " + how_many );
          verbose( "bindings_size : " + bindings_size );
  
          if ( how_many < bindings_size )
          {
              java.util.Vector next = new java.util.Vector();
  
              for ( int i = how_many; i < bindings_size; i++ )
              {
                  next.addElement( bindings[ i ] );
              }
  
              verbose( " next size : " + next.size() );
              BindingIteratorImpl b = new BindingIteratorImpl( _orb, next, 
getLogger() );
              bi.value = b._this();
          }
          else
          {
  
              bi.value = new BindingIteratorImpl ( _orb, new 
java.util.Vector(), getLogger() )._this();
  
          }
  
      }
  
  
      /**
       * This operation accepts Name and returns a stringified name.
       *
       * @param  n the name to stringified.
       * @exception InvalidName This exception is raised if the name is
       * invalid.
       */
      public java.lang.String to_string( org.omg.CosNaming.NameComponent[] n )
      throws org.omg.CosNaming.NamingContextPackage.InvalidName
      {
  
          return org.openorb.util.NamingUtils.to_string ( n );
      }
  
      /**
       * This operation accepts a stringified name and returns a Name.      
       *
       * @param  sn the stringified name to transform to a name.
       * @exception InvalideName This exception is raised if the
       *         stringified name is syntactically malformed or
       *         violates an implementation limit.
       */
      public org.omg.CosNaming.NameComponent[] to_name( java.lang.String sn )
      throws org.omg.CosNaming.NamingContextPackage.InvalidName
      {
          verbose( "to_name " + sn );
          return org.openorb.util.NamingUtils.to_name( sn );
      }
  
  
  
      /**
       * This operation takes an URL address and performs any escapes
       * necessary on the stringified name and returns a fully formed URL
       * string.
       *
       * @param  addr the address ( for example myhost.xyz.com )
       * @param  sn  the stringified name to add to the URL
       * @return  the URL string format.
       *
       * @exception InvalidAddress This exception is raises if a address
       *                is invalid ( it means that the address does not
       *                respect the address format ).
       * @exception InvalidName This exception is raised if the
       *         stringified name is syntactically malformed or
       *         violates an implementation limit.
       */
      public java.lang.String to_url( java.lang.String addr, java.lang.String 
sn )
      throws org.omg.CosNaming.NamingContextExtPackage.InvalidAddress, 
org.omg.CosNaming.NamingContextPackage.InvalidName
      {
          verbose( "Get an URL" );
  
          return org.openorb.util.NamingUtils.to_url( addr, sn );
      }
  
      /**
       * This is a convenience operation that performs a resolve in the
       * same manner as NamingContext::resolve.  It accepts a stringified
       * name as an argument instead of a Name.
       *
       * @param  n the stringified name of the object ( or naming context ) to 
resolve
       * @return  the resolved object.
       *
       * @exception  NotFound  Indicates the name does not identify a binding.
       * @exception  CannotProceed Indicates that the implementation has given 
up for some reason. The
       *         client, however, may be able to continue the operation at the 
returned
       *         naming context.
       * @exception  InvalidName  Indicates the name is invalid. (A name of 
length 0 is invalid;
       *         implementations may place other restrictions on names.)
       */
      public org.omg.CORBA.Object resolve_str( java.lang.String n )
      throws org.omg.CosNaming.NamingContextPackage.NotFound, 
org.omg.CosNaming.NamingContextPackage.CannotProceed, 
org.omg.CosNaming.NamingContextPackage.InvalidName
      {
          org.omg.CosNaming.NameComponent [] name = 
org.openorb.util.NamingUtils.to_name( n );
  
          return resolve( name );
      }
  
  
      /**
       * This function adapt a Name for a stringified form
       */
      private String adaptName( String n )
      {
          String str = "";
  
          for ( int i = 0; i < n.length(); i++ )
          {
              if ( n.charAt( i ) == '/' )
                  str = str + "\\/";
              else
                  if ( n.charAt( i ) == '.' )
                      str = str + "\\.";
                  else
                      str = str + n.charAt( i );
          }
  
          return str;
      }
  
      /**
       * This function removes extra information from string
       */
      private String removeExtra( String n )
      {
          String str = "";
  
          for ( int i = 0; i < n.length(); i++ )
          {
              if ( n.charAt( i ) == '\\' )
                  continue;
              else
                  str = str + n.charAt( i );
          }
  
          return str;
      }
  
      /**
       * This function checks a address format.
       */
      private String checkFormat( String addr )
      throws org.omg.CosNaming.NamingContextExtPackage.InvalidAddress
      {
          String ad;
          int index;
          java.util.Vector list = new java.util.Vector();
  
          try
          {
              // Get all path of the Addree
              int old = 0;
  
              while ( true )
              {
                  index = addr.indexOf( ",", old );
  
                  if ( index == -1 )
                  {
                      list.addElement( addr.substring( old ) );
  
                      break;
                  }
                  else
                  {
                      list.addElement( addr.substring( old, index ) );
  
                      old = index + 1;
                  }
              }
  
              // Now, check addresses to get the object
              for ( int i = 0; i < list.size(); i++ )
              {
                  ad = ( String ) list.elementAt( i );
  
                  index = addr.indexOf( "@" );
  
                  // Is there a version data ?
                  if ( index != -1 )
                  {
                      index = ad.substring( 0, index ).indexOf( "." );
  
                      if ( index == -1 )
                          throw new 
org.omg.CosNaming.NamingContextExtPackage.InvalidAddress();
                  }
              }
          }
          catch ( java.lang.Exception ex )
          {
              throw new 
org.omg.CosNaming.NamingContextExtPackage.InvalidAddress();
          }
  
          return addr;
      }
  
      /**
       * This function adapts a stringified named to a URL name.
       */
      private String adaptToURL( String sn )
      throws org.omg.CosNaming.NamingContextPackage.InvalidName
      {
          // To complete in future...
          return sn;
      }
  
      /**
       * Return the Name of this NamingContext
       */
      private org.omg.CosNaming.NameComponent [] getNameComponent( 
org.omg.CosNaming.NameComponent[] n )
      throws org.omg.CosNaming.NamingContextPackage.NotFound
      {
  
          namingPersistence.NamingContext p_namingContext = getNamingContext();
  
          try
          {
              org.omg.CosNaming.NameComponent [] currentName = 
org.openorb.util.NamingUtils.to_name( p_namingContext.componentName() );
  
              org.omg.CosNaming.NameComponent [] nameComponent = new 
org.omg.CosNaming.NameComponent[ n.length + currentName.length ];
  
              for ( int k = 0; k < currentName.length; k++ )
              {
                  nameComponent[ k ] = currentName[ k ];
              }
  
              for ( int k = 0; k < n.length ; k++ )
              {
                  nameComponent[ currentName.length + k ] = n[ k ];
              }
  
              return nameComponent;
          }
          catch ( org.omg.CosNaming.NamingContextPackage.InvalidName e )
          {
              e.printStackTrace();
              return null;
          }
      }
  
  
      /**
       * return the persistent naming context that correspond to this current 
naming context
       */
      private namingPersistence.NamingContext getNamingContext()
      throws org.omg.CosNaming.NamingContextPackage.NotFound
      {
  
          return getNamingContext ( this._object_id() );
  
      }
  
      /**
       * return the persistent naming context by pid
       * @param pid the pid of the naming context
       */
      private namingPersistence.NamingContext getNamingContext( byte[] pid )
      throws org.omg.CosNaming.NamingContextPackage.NotFound
      {
  
          verbose( "getNamingContext" );
  
          try
          {
              return ( namingPersistence.NamingContext ) 
_nc_home.get_catalog().find_by_pid ( pid );
          }
          catch ( org.omg.CosPersistentState.NotFound nf )
          {
              throw new org.omg.CosNaming.NamingContextPackage.NotFound( );
          }
      }
  
      /**
       * return the persistent proxy naming context 
       */
      private namingPersistence.ProxyNamingContext getProxyNamingContext()
      throws org.omg.CosNaming.NamingContextPackage.NotFound
      {
  
          byte[] nc_id = this._object_id();
  
          try
          {
              return ( namingPersistence.ProxyNamingContext ) 
_pnc_home.get_catalog().find_by_pid ( nc_id );
          }
          catch ( org.omg.CosPersistentState.NotFound nf )
          {
              throw new org.omg.CosNaming.NamingContextPackage.NotFound();
          }
  
      }
  
      /**
       * Add a naming context to the list of children that is stored in the 
parent object
       * @param the componentName of the object
       */
      private void addNamingContext ( org.omg.CosNaming.NameComponent[] 
componentName )
      {
  
          namingPersistence.NamingContext parent = null;
  
          try
          {
              verbose( "addNamingContext : " + 
org.openorb.util.NamingUtils.to_string( componentName ) );
              // get the parent of the NamingContext
              org.omg.CosNaming.NameComponent[] parentName = new 
org.omg.CosNaming.NameComponent[ componentName.length - 1 ];
  
              for ( int i = 0; i < parentName.length; i++ )
              {
                  parentName[ i ] = componentName[ i ];
              }
  
              verbose( "parent nameComponent : " + 
org.openorb.util.NamingUtils.to_string( parentName ) );
  
              parent = _nc_home.find_by_componentName ( 
org.openorb.util.NamingUtils.to_string( parentName ) );
  
          }
          catch ( org.omg.CosPersistentState.NotFound e )
          {
              e.printStackTrace();
              return ;
          }
          catch ( org.omg.CosNaming.NamingContextPackage.InvalidName ex )
          {
              ex.printStackTrace();
          }
  
          try
          {
  
              // get the reference of the naming context to add
              namingPersistence.NamingContextRef namingContextRef = 
_nc_home.find_ref_by_componentName( org.openorb.util.NamingUtils.to_string ( 
componentName ) );
  
              // store the new children list to the parent
  
              namingPersistence.NamingContextRef[] children = 
parent.nc_children();
              verbose( "parent children : " + children.length );
  
              namingPersistence.NamingContextRef[] update_children = new 
namingPersistence.NamingContextRef[ children.length + 1 ];
  
              for ( int k = 0 ; k < update_children.length - 1 ; k ++ )
              {
                  update_children[ k ] = children[ k ];
              }
  
              update_children[ update_children.length - 1 ] = namingContextRef;
  
              parent.nc_children( update_children );
          }
          catch ( org.omg.CosNaming.NamingContextPackage.InvalidName e )
          {
              e.printStackTrace();
          }
      }
  
  
      /**
       * Add a naming object to the list of children that is stored in the 
parent object
       * @param the componentName of the object
       */
      private void addNamingObject ( org.omg.CosNaming.NameComponent[] 
componentName )
      {
  
          namingPersistence.NamingContext parent = null;
  
          try
          {
  
              verbose( " addNamingObject " + 
org.openorb.util.NamingUtils.to_string( componentName ) );
  
              // get the parent of the object
              org.omg.CosNaming.NameComponent[] parentName = new 
org.omg.CosNaming.NameComponent[ componentName.length - 1 ];
  
              for ( int i = 0; i < parentName.length; i++ )
              {
                  parentName[ i ] = componentName[ i ];
              }
  
              String parentName_str = org.openorb.util.NamingUtils.to_string( 
parentName );
              verbose( "parentName : " + parentName_str );
  
              parent = _nc_home.find_by_componentName ( parentName_str );
          }
          catch ( org.omg.CosPersistentState.NotFound e )
          {
              e.printStackTrace();
          }
          catch ( org.omg.CosNaming.NamingContextPackage.InvalidName ex )
          {
              ex.printStackTrace();
          }
  
          try
          {
              // get the ref of the object
  
              namingPersistence.NamingObjectRef objectRef = 
_no_home.find_ref_by_componentName( org.openorb.util.NamingUtils.to_string( 
componentName ) );
  
              // store the new children list to the parent
  
              namingPersistence.NamingObjectRef[] children = 
parent.no_children();
  
              namingPersistence.NamingObjectRef[] update_children = new 
namingPersistence.NamingObjectRef[ children.length + 1 ];
  
              for ( int k = 0 ; k < update_children.length - 1 ; k ++ )
              {
                  update_children[ k ] = children[ k ];
              }
  
              update_children[ update_children.length - 1 ] = objectRef;
  
              parent.no_children( update_children );
          }
          catch ( org.omg.CosNaming.NamingContextPackage.InvalidName ex )
          {
              ex.printStackTrace();
          }
      }
  
      /**
       * Add the proxy naming context to the list of children that is stored in 
the parent object
       * @param the componentName of the object
       */
      private void addProxyNamingContext ( org.omg.CosNaming.NameComponent[] 
componentName )
      {
  
          // get the parent of the NamingContext
          org.omg.CosNaming.NameComponent[] parentName = new 
org.omg.CosNaming.NameComponent[ componentName.length - 1 ];
  
          for ( int i = 0; i < parentName.length; i++ )
          {
              parentName[ i ] = componentName[ i ];
          }
  
          namingPersistence.NamingContext parent = null;
  
          try
          {
              parent = _nc_home.find_by_componentName ( 
org.openorb.util.NamingUtils.to_string( parentName ) );
          }
          catch ( org.omg.CosPersistentState.NotFound e )
          {
              e.printStackTrace();
          }
          catch ( org.omg.CosNaming.NamingContextPackage.InvalidName ex )
          {
              ex.printStackTrace();
          }
  
          try
          {
              // get the reference of the proxy naming context to add
              namingPersistence.ProxyNamingContextRef proxyNamingContextRef = 
_pnc_home.find_ref_by_componentName( org.openorb.util.NamingUtils.to_string( 
componentName ) );
  
              // store the new children list to the parent
  
              namingPersistence.ProxyNamingContextRef[] children = 
parent.pnc_children();
  
              namingPersistence.ProxyNamingContextRef[] update_children = new 
namingPersistence.ProxyNamingContextRef[ children.length + 1 ];
  
              for ( int k = 0 ; k < update_children.length - 1 ; k ++ )
              {
                  update_children[ k ] = children[ k ];
              }
  
              update_children[ update_children.length - 1 ] = 
proxyNamingContextRef;
  
              parent.pnc_children ( update_children );
          }
          catch ( org.omg.CosNaming.NamingContextPackage.InvalidName ex )
          {
              ex.printStackTrace();
          }
      }
  
      /**
       * Remove the naming object from the list of children that is stored in 
the parent object
       * @param the componentName of the object
       */
      private void removeNamingObject ( org.omg.CosNaming.NameComponent[] 
componentName )
      {
  
          verbose( "removeNamingObject" );
          // get the parent of the object
          org.omg.CosNaming.NameComponent[] parentName = new 
org.omg.CosNaming.NameComponent[ componentName.length - 1 ];
  
          for ( int i = 0; i < parentName.length; i++ )
          {
              parentName[ i ] = componentName[ i ];
          }
  
          namingPersistence.NamingContext parent = null;
  
          try
          {
              parent = _nc_home.find_by_componentName ( 
org.openorb.util.NamingUtils.to_string( parentName ) );
          }
          catch ( org.omg.CosPersistentState.NotFound e )
          {
              e.printStackTrace();
          }
          catch ( org.omg.CosNaming.NamingContextPackage.InvalidName ex )
          {
              ex.printStackTrace();
          }
  
          try
          {
  
              // get the ref of the object
  
              namingPersistence.NamingObjectRef objectRef = 
_no_home.find_ref_by_componentName( org.openorb.util.NamingUtils.to_string ( 
componentName ) );
              String objectRefName = ( ( namingPersistence.NamingObject ) 
objectRef.deref() ).componentName();
  
              // remove the objectRef from the list of the children of the 
naming context
  
              namingPersistence.NamingObjectRef[] children = 
parent.no_children();
  
              namingPersistence.NamingObjectRef[] update_children = new 
namingPersistence.NamingObjectRef[ children.length - 1 ];
              int index = children.length - 1;
  
              for ( int k = 0; k < children.length - 1 ; k++ )
              {
                  String childrenName = ( ( namingPersistence.NamingObject ) 
children[ k ].deref() ).componentName();
  
                  if ( childrenName.equals( objectRefName ) )
                  {
                      index = k;
                      break;
                  }
                  else
                  {
                      update_children[ k ] = children[ k ];
                  }
              }
  
              for ( int i = index + 1; i < children.length ; i++ )
              {
                  update_children[ i - 1 ] = children[ i ];
              }
  
              parent.no_children ( update_children );
          }
          catch ( org.omg.CosNaming.NamingContextPackage.InvalidName ex )
          {
              ex.printStackTrace();
          }
      }
  
      /**
       * Remove the naming context from the list of children that is stored in 
the parent object
       * @param the componentName of the object
       */
      private void removeNamingContext ( org.omg.CosNaming.NameComponent[] 
componentName )
      {
  
          verbose( "removeNamingContext" );
          // get the parent of the object
          org.omg.CosNaming.NameComponent[] parentName = new 
org.omg.CosNaming.NameComponent[ componentName.length - 1 ];
  
          for ( int i = 0; i < parentName.length; i++ )
          {
              parentName[ i ] = componentName[ i ];
          }
  
          namingPersistence.NamingContext parent = null;
  
          try
          {
              parent = _nc_home.find_by_componentName ( 
org.openorb.util.NamingUtils.to_string( parentName ) );
  
          }
          catch ( org.omg.CosPersistentState.NotFound e )
          {
              e.printStackTrace();
          }
          catch ( org.omg.CosNaming.NamingContextPackage.InvalidName ex )
          {
              ex.printStackTrace();
          }
  
          try
          {
  
              // get the ref of the object
  
              namingPersistence.NamingContextRef objectRef = 
_nc_home.find_ref_by_componentName( org.openorb.util.NamingUtils.to_string( 
componentName ) );
              String objectRefName = ( ( namingPersistence.NamingContext ) 
objectRef.deref() ).componentName();
              verbose( "find ref  " + objectRefName );
              // remove the objectRef from the list of the children of the 
naming context
  
              namingPersistence.NamingContextRef[] children = 
parent.nc_children();
  
              namingPersistence.NamingContextRef[] update_children = new 
namingPersistence.NamingContextRef[ children.length - 1 ];
              int index = children.length - 1;
  
              for ( int k = 0; k < children.length - 1 ; k++ )
              {
                  String childrenName = ( ( namingPersistence.NamingContext ) 
children[ k ].deref() ).componentName();
                  verbose ( "children " + k + " " + childrenName );
  
                  if ( childrenName.equals( objectRefName ) )
                  {
                      index = k;
                      break;
                  }
                  else
                  {
                      update_children[ k ] = children[ k ];
                  }
              }
  
              verbose( "index : " + index );
  
              for ( int i = index + 1; i < children.length ; i++ )
              {
                  update_children[ i - 1 ] = children[ i ];
              }
  
              parent.nc_children ( update_children );
          }
          catch ( org.omg.CosNaming.NamingContextPackage.InvalidName ex )
          {
              ex.printStackTrace();
          }
      }
  
      /**
       * Remove the proxy naming context from the list of children that is 
stored in the parent object
       * @param the componentName of the object
       */
      private void removeProxyNamingContext ( org.omg.CosNaming.NameComponent[] 
componentName )
      {
  
          // get the parent of the object
          org.omg.CosNaming.NameComponent[] parentName = new 
org.omg.CosNaming.NameComponent[ componentName.length - 1 ];
  
          for ( int i = 0; i < parentName.length; i++ )
          {
              parentName[ i ] = componentName[ i ];
          }
  
          namingPersistence.NamingContext parent = null;
  
          try
          {
              parent = _nc_home.find_by_componentName ( 
org.openorb.util.NamingUtils.to_string ( parentName ) );
          }
          catch ( org.omg.CosPersistentState.NotFound e )
          {
              e.printStackTrace();
          }
          catch ( org.omg.CosNaming.NamingContextPackage.InvalidName ex )
          {
              ex.printStackTrace();
          }
  
          try
          {
              // get the ref of the object
  
              namingPersistence.ProxyNamingContextRef objectRef = 
_pnc_home.find_ref_by_componentName( org.openorb.util.NamingUtils.to_string( 
componentName ) );
              String objectRefName = ( ( namingPersistence.ProxyNamingContext ) 
objectRef.deref() ).componentName();
  
              // remove the objectRef from the list of the children of the 
naming context
  
              namingPersistence.ProxyNamingContextRef[] children = 
parent.pnc_children();
  
              namingPersistence.ProxyNamingContextRef[] update_children = new 
namingPersistence.ProxyNamingContextRef[ children.length - 1 ];
              int index = children.length - 1;
  
              for ( int k = 0; k < children.length - 1 ; k++ )
              {
                  String childrenName = ( ( 
namingPersistence.ProxyNamingContext ) children[ k ].deref() ).componentName();
  
                  if ( childrenName.equals( objectRefName ) )
                  {
                      index = k;
                      break;
                  }
                  else
                  {
                      update_children[ k ] = children[ k ];
                  }
              }
  
              for ( int i = index + 1; i < children.length ; i++ )
              {
                  update_children[ i - 1 ] = children[ i ];
              }
  
              parent.pnc_children ( update_children );
          }
          catch ( org.omg.CosNaming.NamingContextPackage.InvalidName ex )
          {
              ex.printStackTrace();
          }
      }
  
      /**
       * Create the naming context Corba reference from a persistent naming 
context 
       *   The pid of the Corba object correspond to the pid of the persistent 
object
       * @param the persistent naming context
       * @return the naming context
       */
      private org.omg.CosNaming.NamingContext createReference( 
namingPersistence.NamingContext nc )
      {
  
          verbose( "createReference" );
          byte[] nc_pid = nc.get_pid();
  
          org.omg.CORBA.Object ncObj = null;
  
          try
          {
  
              ncObj = _poa().create_reference_with_id( nc_pid, 
org.omg.CosNaming.NamingContextExtHelper.id() );
              return org.omg.CosNaming.NamingContextExtHelper.narrow( ncObj );
  
  
          }
  
          // SJM: replaced WrongPolicy exception with Exception catch
          catch ( Exception ex )
          {
              ex.printStackTrace();
              return null;
          }
      }
  
      /**
       * Create a binding object from a persistent naming object, specifying 
the binding_name and the binding_type
       * @param no the naming object
       * @return the binding object
       */
      private org.omg.CosNaming.Binding getBinding ( 
namingPersistence.NamingObject no )
      {
  
          verbose( "getBinding namingObject" );
          org.omg.CosNaming.Binding binding = new org.omg.CosNaming.Binding();
  
          try
          {
              org.omg.CosNaming.NameComponent[] name = new 
org.omg.CosNaming.NameComponent[ 1 ];
              org.omg.CosNaming.NameComponent[] componentName = 
org.openorb.util.NamingUtils.to_name ( no.componentName() );
              name[ 0 ] = componentName[ componentName.length - 1 ];
              binding.binding_name = name;
              binding.binding_type = org.omg.CosNaming.BindingType.nobject;
          }
          catch ( org.omg.CosNaming.NamingContextPackage.InvalidName e )
          {
              e.printStackTrace();
          }
  
          return binding;
  
      }
  
      /**
       * Create a binding object from a persistent naming context, specifying 
the binding_name and the binding_type
       * @param no the naming context
       * @return the binding object
       */
      private org.omg.CosNaming.Binding getBinding ( 
namingPersistence.NamingContext nc )
      {
  
          verbose( "getBinding namingContext" );
          org.omg.CosNaming.Binding binding = new org.omg.CosNaming.Binding();
  
          try
          {
              org.omg.CosNaming.NameComponent[] name = new 
org.omg.CosNaming.NameComponent[ 1 ];
              verbose( "componentName : " + nc.componentName() );
              org.omg.CosNaming.NameComponent[] componentName = 
org.openorb.util.NamingUtils.to_name ( nc.componentName() );
              name[ 0 ] = componentName[ componentName.length - 1 ];
              binding.binding_name = name;
              binding.binding_type = org.omg.CosNaming.BindingType.ncontext;
          }
          catch ( org.omg.CosNaming.NamingContextPackage.InvalidName e )
          {
              e.printStackTrace();
          }
  
          return binding;
      }
  
      /**
       * Create a binding object from a persistent proxy naming context, 
specifying the binding_name and the binding_type
       * @param no the proxy naming context
       * @return the binding object
       */
      private org.omg.CosNaming.Binding getBinding ( 
namingPersistence.ProxyNamingContext pnc )
      {
  
          org.omg.CosNaming.Binding binding = new org.omg.CosNaming.Binding();
  
          try
          {
  
              org.omg.CosNaming.NameComponent[] name = new 
org.omg.CosNaming.NameComponent[ 1 ];
              org.omg.CosNaming.NameComponent[] componentName = 
org.openorb.util.NamingUtils.to_name ( pnc.componentName() );
              name[ 0 ] = componentName[ componentName.length - 1 ];
              binding.binding_name = name;
              binding.binding_type = org.omg.CosNaming.BindingType.ncontext;
          }
          catch ( org.omg.CosNaming.NamingContextPackage.InvalidName e )
          {
              e.printStackTrace();
          }
  
          return binding;
      }
  
      /**
       * return the path of the naming context. 
       * The Name that is stored in persistence contains the root name 
"NameService"
       * The returned path correspond to that NameComponent without the root.
       * @param the componentName including the root node
       * @return the componentName without the root node
       */
      private org.omg.CosNaming.NameComponent[] getPath ( 
org.omg.CosNaming.NameComponent[] componentName )
      {
  
          org.omg.CosNaming.NameComponent[] path = new 
org.omg.CosNaming.NameComponent[ componentName.length - 1 ];
  
          for ( int k = 1; k < componentName.length ; k++ )
          {
              path[ k - 1 ] = componentName[ k ];
          }
  
          return path;
      }
  
      /**
       * This method is used to print information when the verbose mode is 
activated
       */
      private void verbose( String message )
      {
          if ( getLogger().isDebugEnabled() )
              getLogger().debug( "[ " + message + " ]" );
      }
  }
  
  
  
  1.1                  
jakarta-avalon-apps/enterprise/ins/src/java/org/apache/ins/NamingProvider.java
  
  Index: NamingProvider.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.TXT file.
   */
  
  package org.apache.ins;
  
  import org.apache.orb.ORB;
  import org.apache.orb.util.IOR;
  import org.apache.pss.Connector;
  import org.apache.pss.Session;
  
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.logger.Logger;
  import org.apache.avalon.framework.service.ServiceManager;
  import org.apache.avalon.framework.service.ServiceException;
  import org.apache.avalon.framework.service.Serviceable;
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.framework.activity.Startable;
  import org.apache.avalon.framework.activity.Executable;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.CascadingException;
  
  import org.omg.CORBA.Any;
  import org.omg.CORBA.LocalObject;
  import org.omg.CORBA.Policy;
  import org.omg.CosPersistentState.NotFound;
  import org.omg.CosPersistentState.StorageObject;
  import org.omg.CosPersistentState.ConnectorHelper;
  import org.omg.PortableServer.ServantLocator;
  import org.omg.PortableServer.Servant;
  import org.omg.PortableServer.POA;
  import org.omg.PortableServer.ServantLocatorPackage.CookieHolder ;
  import org.omg.PortableServer.ForwardRequest;
  import org.omg.PortableServer.POAHelper;
  import org.omg.PortableServer.IdAssignmentPolicyValue;
  import org.omg.PortableServer.RequestProcessingPolicyValue;
  import org.omg.PortableServer.ImplicitActivationPolicyValue;
  import org.omg.PortableServer.LifespanPolicyValue;
  import org.omg.PortableServer.IdUniquenessPolicyValue;
  import org.omg.PortableServer.ServantRetentionPolicyValue;
  import org.omg.CosNaming.NamingContextExt;
  import org.omg.CosNaming.NamingContextExtHelper;
  
  import namingPersistence.NamingContextHome;
  import namingPersistence.NamingObjectHome;
  import namingPersistence.ProxyNamingContextHome;
  import namingPersistence.NamingContext;
  import namingPersistence.NamingContextRef;
  import namingPersistence.NamingObjectRef;
  import namingPersistence.ProxyNamingContextRef;
  
  /**
   * Implementation of an INS Service Provider.
   */
  
  public class NamingProvider extends AbstractLogEnabled implements 
Configurable, Contextualizable, Serviceable, Initializable, Startable, 
Executable, Disposable
  {
  
      //=================================================================
      // state
      //=================================================================
      
     /**
      * Manager provided by the container - provides a PSS configured ORB.
      */
      private ServiceManager m_manager;
  
     /**
      * Configuration provided by the container.
      */
      private Configuration m_config;
  
     /**
      * Application context provided by the container.
      */
      private Context m_context;
  
     /**
      * Internal reference to the ORB provided by the manager.
      */
      private ORB m_orb;
  
      private POA m_poa;
  
      private POA m_root;
  
     /**
      * Reference to the PSS Connector.
      */
      private Connector m_connector;
  
     /**
      * Reference to the PSS Session.
      */
      private Session m_session;
  
      private NamingContextHome m_home;
  
      private NamingContext m_root_naming_context;
       
      private NamingContextExt m_naming;
  
      private boolean m_disposed = false;
  
      private boolean m_stopped = false;
  
      //=======================================================================
      // Configurable
      //=======================================================================
  
     /**
      * Used by a container to supply the static component configuration.
      * @param config the static configuration
      */    
      public void configure( final Configuration config )
      {
          if( getLogger().isDebugEnabled() ) getLogger().debug( "configuration" 
);
          m_config = config;
      }
  
  
      //=================================================================
      // Contextualizable
      //=================================================================
  
     /**
      * Set the application context.
      * @param context the application context
      */
      public void contextualize( Context context ) throws ContextException
      {
          if( getLogger().isDebugEnabled() ) getLogger().debug( "contextualize" 
);
          m_context = context;
      }
  
      //=================================================================
      // Serviceable
      //=================================================================
      
      /**
       * Pass the <code>ServiceManager</code> to the <code>Serviceable</code>.
       * The <code>Serviceable</code> implementation should use the supplied
       * <code>ServiceManager</code> to acquire the components it needs for
       * execution.
       *
       * @param manager The <code>ServiceManager</code> which this
       *                <code>Serviceable</code> uses.
       */
      public void service( ServiceManager manager ) throws ServiceException
      {
          if( getLogger().isDebugEnabled() ) getLogger().debug( "service");
          m_manager = manager;
          m_orb = (ORB) m_manager.lookup( "orb" );
      }
      
      //=======================================================================
      // Initializable
      //=======================================================================
      
     /**
      * Used by a container to initialize the component.
      * @exception Exception if an error occurs during component initialization
      */    
      public void initialize()
      throws Exception
      {
          if( getLogger().isDebugEnabled() ) getLogger().debug( 
"initialization" );
              
          try
          {
              Configuration pss = m_config.getChild("pss");
              String mode = 
pss.getChild("connector").getAttribute("value","file");
              org.omg.CORBA.Object object = m_orb.resolve_initial_references( 
"PSS:APACHE:" + mode );
              m_connector = (Connector) ConnectorHelper.narrow( object );
          }
          catch( Throwable e )
          {
              getLogger().error( "intialization failure", e );
              throw new CascadingException( "Client initization failed.", e);
          }
  
          //
          // create the POA
          //
  
          try
          {
              m_root = POAHelper.narrow( 
m_orb.resolve_initial_references("RootPOA") );
              m_poa = m_root.create_POA(
                "INS",
                m_root.the_POAManager(),
                new Policy[]{
                    m_root.create_request_processing_policy( 
                      RequestProcessingPolicyValue.USE_DEFAULT_SERVANT ),
                    m_root.create_servant_retention_policy( 
                      ServantRetentionPolicyValue.NON_RETAIN ),
                    m_root.create_id_uniqueness_policy( 
                      IdUniquenessPolicyValue.MULTIPLE_ID ),
                    m_root.create_id_assignment_policy( 
                      IdAssignmentPolicyValue.USER_ID )
                }
              );
  
          }
          catch( Throwable poaError )
          {
              String error = "unable to create the repository object reference";
              if( getLogger().isErrorEnabled() ) getLogger().error( error, 
poaError );
              throw new Exception( error, poaError );
          }
  
          //
          // storage system configuration
          //
  
          String mode = 
m_config.getChild("pss").getChild("connector").getAttribute("value","file");
  
          Configuration pss = m_config.getChild("pss");
          Configuration declarations = null;
          if( mode.equalsIgnoreCase("memory") )
          {
              declarations = pss.getChild("persistence").getChild("memory");
          }
          else if( mode.equalsIgnoreCase("database") )
          {
              declarations = pss.getChild("persistence").getChild("database");
          }
          else
          {
              declarations = pss.getChild("persistence").getChild("file");
          }
  
          try
          {
              if( getLogger().isDebugEnabled() ) 
getLogger().debug("registration");
              m_connector.register( declarations );
              if( getLogger().isDebugEnabled() ) getLogger().debug("session");
              m_session = m_connector.createBasicSession( 
pss.getChild("session") );
          }
          catch( Throwable throwable )
          {
              String error = "unable to establish storage home";
                if( getLogger().isErrorEnabled() ) getLogger().error( error, 
throwable );
                throw new Exception( error, throwable );
          }
  
          //
          // load PSS storage homes
          //
  
          try
          {
              m_home = ( NamingContextHome ) m_session.find_storage_home( 
                "PSDL:namingPersistence/NamingContextHomeBase:1.0" );
              NamingObjectHome no_home = ( NamingObjectHome ) 
m_session.find_storage_home ( 
                "PSDL:namingPersistence/NamingObjectHomeBase:1.0" );
              ProxyNamingContextHome pcn_home = ( ProxyNamingContextHome ) 
                m_session.find_storage_home ( 
                  "PSDL:namingPersistence/ProxyNamingContextHomeBase:1.0" );
  
              //
              // create and bind this object as the servant and create an 
              // object reference for publication
              //
                         
              CallbackManagerImpl callback = new CallbackManagerImpl();
              NamingContextExImpl default_naming = new NamingContextExImpl( 
                m_orb, callback, m_home, no_home, pcn_home );
              default_naming.enableLogging( getLogger() );
              m_poa.set_servant( default_naming );
  
          }
          catch( Throwable throwable )
          {
              String error = "failed to establish naming context 
implementation";
                throw new CascadingException( error, throwable );
          }
  
          //
          // make sure we have a root naming context
          //
  
          try
          {
              m_root_naming_context = m_home.find_by_componentName( 
"NameService" );
          }
          catch ( org.omg.CosPersistentState.NotFound e )
          {
              NamingContextRef[] nc_children = new NamingContextRef[ 0 ];
              NamingObjectRef[] no_children = new NamingObjectRef[ 0 ];
              ProxyNamingContextRef[] pnc_children = new ProxyNamingContextRef[ 
0 ];
              m_root_naming_context = m_home.create( 
                "NameService", nc_children, no_children, pnc_children );
          }
  
          try
          {
              byte[] pid = m_root_naming_context.get_pid();
              m_naming = NamingContextExtHelper.narrow(
                m_poa.create_reference_with_id( pid, 
NamingContextExtHelper.id() ) );
          }
          catch ( Throwable e )
          {
              String error = "failed to establish naming context root";
                throw new CascadingException( error, e );
          }
  
          //
          // handle the IOR publication
          //
  
          try
          {
              String ior = m_config.getChild("ior").getAttribute( "value" );
              IOR.writeIOR( m_orb, m_naming, ior );
              getLogger().debug( "publishing repository IOR to: " + ior );
          }
          catch (Exception e)
          {
              // IOR publication disabled
          }
  
          String message = "INS available";
          getLogger().debug( message );
      }
  
     /**
      * Starts the INS server.
      */
      public void start() throws Exception
      {
          m_root.the_POAManager().activate();
          m_orb.start();
          String banner = "Interoperable Naming Service available ";
          if( getLogger().isInfoEnabled() ) getLogger().info( banner );
      }
  
     /**
      * Prints the INS reference to the log.
      */
      public void execute() throws Exception
      {
          if( getLogger().isInfoEnabled() ) getLogger().info( "execution" );
          if( getLogger().isInfoEnabled() ) getLogger().info( "\n\n" + m_naming 
);
      }
  
     /**
      * Stops the INS server.
      */
      public void stop() throws Exception
      {
          if( m_stopped ) return;
          if( getLogger().isDebugEnabled() ) getLogger().debug("shutdown" );
          m_stopped = true;
          m_orb.shutdown( true );
          if( getLogger().isDebugEnabled() ) getLogger().debug("shutdown 
complete" );
      }
  
     /**
      * Invoked by the contained to signal request for disposal of the provider
      * and associated resources.
      */
      public void dispose()
      {
          if( m_disposed ) return;
          if( !m_stopped ) try
          {
              stop();
          }
          catch( Throwable e )
          {
              if( getLogger().isDebugEnabled() ) getLogger().debug(
                 "ignoring error while stopping provider" );
          }
          m_disposed = true;
          if( getLogger().isDebugEnabled() ) getLogger().debug("dispose" );
          m_orb = null;
          m_root = null;
          m_config = null;
          m_naming = null;
      }
  
     /**
      * Returns the INS service provider object reference.
      */
      protected NamingContextExt getProvider()
      {
          return m_naming;
      }
  
  }
  
  
  
  1.1                  
jakarta-avalon-apps/enterprise/ins/src/java/org/apache/ins/NamingProvider.xinfo
  
  Index: NamingProvider.xinfo
  ===================================================================
  <?xml version="1.0"?>
  
  <!--
   NamingProvider.info
  -->
  
  <blockinfo>
  
    <block name="ins">
      <version>1.0</version>
    </block>
  
    <services>
        <service name="org.omg.CosNaming.NamingContextExt" version="1.0" />
    </services>
  
    <dependencies>
        <dependency>
            <role>orb</role>
            <service name="org.apache.orb.ORB" version="2.4"/>
            <configuration>
              <property name="iiop.port" value="1024" />
              <initializer class="org.apache.pss.Initializer" name="pss"/>
            </configuration>
        </dependency>
    </dependencies>
  
    <configuration>
  
      <!--
      Service publication
      -->
  
      <ior value="ins.ior"/>
  
      <!--
      The PSS configuration.
      -->
  
      <pss>
  
        <connector value="file" />
  
        <session>
          <parameter name="PSS.File.DataStore.Directory" value="pss" />
          <parameter name="PSS.File.DataStore.Name" value="ins" />
        </session>
  
        <persistence>
          <file>
            <storage psdl="PSDL:namingPersistence/NamingContextBase:1.0"
              class="file.namingPersistence.NamingContextBase" />
            <home psdl="PSDL:namingPersistence/NamingContextHomeBase:1.0"
              class="file.namingPersistence.NamingContextHomeBase" />
            <storage psdl="PSDL:namingPersistence/NamingObjectBase:1.0"
              class="file.namingPersistence.NamingObjectBase" />
            <home psdl="PSDL:namingPersistence/NamingObjectHomeBase:1.0"
              class="file.namingPersistence.NamingObjectHomeBase" />
            <storage psdl="PSDL:namingPersistence/ProxyNamingContextBase:1.0"
              class="file.namingPersistence.ProxyNamingContextBase" />
            <home psdl="PSDL:namingPersistence/ProxyNamingContextHomeBase:1.0"
              class="file.namingPersistence.ProxyNamingContextHomeBase" />
          </file>
          <memory>
            <storage psdl="PSDL:namingPersistence/NamingContextBase:1.0"
              class="memory.namingPersistence.NamingContextBase" />
            <home psdl="PSDL:namingPersistence/NamingContextHomeBase:1.0"
              class="memory.namingPersistence.NamingContextHomeBase" />
            <storage psdl="PSDL:namingPersistence/NamingObjectBase:1.0"
              class="memory.namingPersistence.NamingObjectBase" />
            <home psdl="PSDL:namingPersistence/NamingObjectHomeBase:1.0"
              class="memory.namingPersistence.NamingObjectHomeBase" />
            <storage psdl="PSDL:namingPersistence/ProxyNamingContextBase:1.0"
              class="memory.namingPersistence.ProxyNamingContextBase" />
            <home psdl="PSDL:namingPersistence/ProxyNamingContextHomeBase:1.0"
              class="memory.namingPersistence.ProxyNamingContextHomeBase" />
          </memory>
          <database>
            <storage psdl="PSDL:namingPersistence/NamingContextBase:1.0"
              class="database.namingPersistence.NamingContextBase" />
            <home psdl="PSDL:namingPersistence/NamingContextHomeBase:1.0"
              class="database.namingPersistence.NamingContextHomeBase" />
            <storage psdl="PSDL:namingPersistence/NamingObjectBase:1.0"
              class="database.namingPersistence.NamingObjectBase" />
            <home psdl="PSDL:namingPersistence/NamingObjectHomeBase:1.0"
              class="database.namingPersistence.NamingObjectHomeBase" />
            <storage psdl="PSDL:namingPersistence/ProxyNamingContextBase:1.0"
              class="database.namingPersistence.ProxyNamingContextBase" />
            <home psdl="PSDL:namingPersistence/ProxyNamingContextHomeBase:1.0"
              class="database.namingPersistence.ProxyNamingContextHomeBase" />
          </database>
  
  
        </persistence>
  
      </pss>
  
    </configuration>
  
  </blockinfo>
  
  
  
  
  
  1.1                  
jakarta-avalon-apps/enterprise/ins/src/java/org/apache/ins/ReleaseInfo.java
  
  Index: ReleaseInfo.java
  ===================================================================
  package org.apache.ins;
  
  public class ReleaseInfo
  {
      public final static String NAME_LONG                 = "Interoperable 
Naming Service";
      public final static String NAME_SHORT                = "INS";
  
      public final static short  VERSION_MAJOR             = 1;        
      public final static short  VERSION_MINOR             = 3;
      public final static short  VERSION_MINOR_CHANGE      = 0;
      public final static String VERSION                   = "" + VERSION_MAJOR 
+ "." + VERSION_MINOR + "." + VERSION_MINOR_CHANGE;
  
      public final static short  SPEC_VERSION_MAJOR        = 1;
      public final static short  SPEC_VERSION_MINOR        = 1;
      public final static String SPEC_VERSION              = "" + 
SPEC_VERSION_MAJOR + "." + SPEC_VERSION_MINOR;
  
      public final static String RELEASE                   = NAME_LONG + " 
Version " + VERSION;
      public final static String RELEASE_TAG               = NAME_LONG + "_" + 
VERSION_MAJOR + "_" + VERSION_MINOR + "_" + VERSION_MINOR_CHANGE;
  
      public static void main(String[] args)
      {
          System.out.println(NAME_LONG + ":");
          System.out.println("\t" + NAME_LONG + " " + VERSION);
          System.out.println("\t" + RELEASE_TAG);
          System.out.println("\t${SPEC_NAME} " + SPEC_VERSION 
            + " (http://www.omg.org/cgi-bin/doc?formal/01-02-65)");
      }
  }
  
  
  
  
  1.1                  jakarta-avalon-apps/enterprise/ins/src/psdl/ins.psdl
  
  Index: ins.psdl
  ===================================================================
  // -------------------------------------------------------------------
  // OpenORB InteroperableNamingService PSDL description
  //
  // (c) 2000, Exolab Group
  // -------------------------------------------------------------------
  
  #include <CosNaming.idl>
  
  /**
   * PSDL definition for naming context persistence
   * @author Marina DANIEL ( [EMAIL PROTECTED] )
   */
  
  module namingPersistence
  {
        abstract storagetype NamingContext;
        typedef ref<NamingContext> NamingContextRef;
        typedef sequence<NamingContextRef> NamingContextRefSeq;
        
        abstract storagetype NamingObject;
        typedef ref<NamingObject> NamingObjectRef;
        typedef sequence<NamingObjectRef> NamingObjectRefSeq;
        
        abstract storagetype ProxyNamingContext;
        typedef ref<ProxyNamingContext> ProxyNamingContextRef;
        typedef sequence<ProxyNamingContextRef> ProxyNamingContextRefSeq;
        
        
                
        /**
         * This abstract storage type represents any of objects stored in the 
directory
         */
        abstract storagetype Binding
        {
                /**
                 * The name of the object from the root
                 */
                state string componentName;
                
                                                                
        };
        
        typedef sequence<ref<Binding>> BindingRefSeq;
        
        /**
         * This abstract storage type reprensents the persistent data of a 
namingContext
         */
        abstract storagetype NamingContext : Binding
        {
                                
                /**
                 * The list of NamingContext that are children of this naming 
context
                 */
                state NamingContextRefSeq nc_children;
                
                /**
                 * The list of NamingObjects that are children of this naming 
context
                 */
                state NamingObjectRefSeq no_children;
                
                /**
                 * the list of Proxy Naming Contexts that are children of this 
naimg context
                 */
                state ProxyNamingContextRefSeq pnc_children;
                
                                
                
                
        };
        
        /**
         * This abstract storage type represents a leaf in the directory
         */
        abstract storagetype NamingObject : Binding
        {
                state Object namingObj;
        };
        
        /** 
         * This abstract storage type represents a Naming Context that is not 
local
         */
         abstract storagetype ProxyNamingContext : Binding
         {
                state CosNaming::NamingContext ctx;
         };
        
        /**
         * The factory for the NamingContexts
         */
        abstract storagehome NamingContextHome of NamingContext
        {
                key componentName;
                
                factory create(componentName, nc_children, no_children, 
pnc_children);
        };
        
        /**
         * The factory for the NamingObject
         */
        abstract storagehome NamingObjectHome of NamingObject
        {
                key componentName;
                
                factory create(componentName, namingObj);
        };
        
        /**
         * The factory for the ProxyNamingContext
         */
         abstract storagehome ProxyNamingContextHome of ProxyNamingContext
         {
                key componentName;
                factory create(componentName, ctx);
         };
        
        
        storagetype BindingBase implements Binding
        {};
        
        /**
         * This storage type provides an implementation for the abstract 
storage type 'NamingObject'
         */
        storagetype NamingObjectBase implements NamingObject
        { };
        
        /**
         * This storage type provides an implementation for the abstract 
storage type 'ProxyNamingContext'
         */
        storagetype ProxyNamingContextBase implements ProxyNamingContext
        { };
        
        /**
         * This storage home implements the abstract storage home 
'NamingObjectHome' and manages a storage type 'NamingObjectBase'
         */ 
        storagehome NamingObjectHomeBase of NamingObjectBase implements 
NamingObjectHome
        { };
        
        
        
        /**
         * This storage home implements the abstract storage home 
'ProxyNamingContextHome' and manages a storage type 'ProxyNamingContextBase'
         */ 
        storagehome ProxyNamingContextHomeBase of ProxyNamingContextBase 
implements ProxyNamingContextHome
        { };
        
        /**
         * This storage type provides an implementation for the abstract 
storage type 'NamingContext'
         */
        storagetype NamingContextBase implements NamingContext
        {
                stores nc_children as ref<NamingContextBase>;
                stores no_children as ref<NamingObjectBase> scope 
NamingObjectHomeBase;
                stores pnc_children as ref<ProxyNamingContextBase> scope 
ProxyNamingContextHomeBase;
        };
        
        /**
         * This storage home implements the abstract storage home 
'NamingContextHome' and manages a storage type 'NamingContextBase'
         */ 
        storagehome NamingContextHomeBase of NamingContextBase implements 
NamingContextHome
        { };
        
        
        
        
        
        
  };
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to