DirStateFactory.Result res = DirectoryManager.getStateToBind( obj, name, this, env, null ); Attributes outAttrs = res.getAttributes();  if ( outAttrs != null ) { LdapDN target = buildTarget( name ); nexusProxy.add( target, outAttrs ); return; }   if ( obj instanceof Referenceable ) { throw new NamingException( "Do not know how to store Referenceables yet!" ); }   if ( obj instanceof Reference ) {  throw new NamingException( "Do not know how to store References yet!" ); } else if ( obj instanceof Serializable ) {  Attributes attributes = new LockableAttributesImpl(); if ( outAttrs != null && outAttrs.size() > 0 ) { NamingEnumeration list = outAttrs.getAll(); while ( list.hasMore() ) { attributes.put( ( Attribute ) list.next() ); } }  LdapDN target = buildTarget( name );   JavaLdapSupport.serialize( attributes, obj ); nexusProxy.add( target, attributes ); } else if ( obj instanceof DirContext ) {  Attributes attributes = ( ( DirContext ) obj ).getAttributes( "" ); if ( outAttrs != null && outAttrs.size() > 0 ) { NamingEnumeration list = outAttrs.getAll(); while ( list.hasMore() ) { attributes.put( ( Attribute ) list.next() ); } }  LdapDN target = buildTarget( name ); nexusProxy.add( target, attributes ); } else { throw new NamingException( "Can't find a way to bind: " + obj ); }
bind( new LdapDN( name ), obj );
    public void bind( Name name, Object obj ) throws NamingException    {        // First, use state factories to do a transformation        DirStateFactory.Result res = DirectoryManager.getStateToBind( obj, name, this, env, null );        Attributes outAttrs = res.getAttributes();        if ( outAttrs != null )        {            LdapDN target = buildTarget( name );            nexusProxy.add( target, outAttrs );            return;        }        // Check for Referenceable        if ( obj instanceof Referenceable )        {            throw new NamingException( "Do not know how to store Referenceables yet!" );        }        // Store different formats        if ( obj instanceof Reference )        {            // Store as ref and add outAttrs            throw new NamingException( "Do not know how to store References yet!" );        }        else if ( obj instanceof Serializable )        {            // Serialize and add outAttrs            Attributes attributes = new LockableAttributesImpl();            if ( outAttrs != null && outAttrs.size() > 0 )            {                NamingEnumeration list = outAttrs.getAll();                while ( list.hasMore() )                {                    attributes.put( ( Attribute ) list.next() );                }            }            LdapDN target = buildTarget( name );            // Serialize object into entry attributes and add it.            JavaLdapSupport.serialize( attributes, obj );            nexusProxy.add( target, attributes );        }        else if ( obj instanceof DirContext )        {            // Grab attributes and merge with outAttrs            Attributes attributes = ( ( DirContext ) obj ).getAttributes( "" );            if ( outAttrs != null && outAttrs.size() > 0 )            {                NamingEnumeration list = outAttrs.getAll();                while ( list.hasMore() )                {                    attributes.put( ( Attribute ) list.next() );                }            }            LdapDN target = buildTarget( name );            nexusProxy.add( target, attributes );        }        else        {            throw new NamingException( "Can't find a way to bind: " + obj );        }    }