Return-Path: Delivered-To: apmail-directory-dev-archive@www.apache.org Received: (qmail 42558 invoked from network); 1 Nov 2005 21:45:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 1 Nov 2005 21:45:24 -0000 Received: (qmail 36188 invoked by uid 500); 1 Nov 2005 21:45:24 -0000 Delivered-To: apmail-directory-dev-archive@directory.apache.org Received: (qmail 35964 invoked by uid 500); 1 Nov 2005 21:45:23 -0000 Mailing-List: contact dev-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Apache Directory Developers List" Delivered-To: mailing list dev@directory.apache.org Received: (qmail 35951 invoked by uid 99); 1 Nov 2005 21:45:22 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Nov 2005 13:45:22 -0800 X-ASF-Spam-Status: No, hits=1.6 required=10.0 tests=HTML_MESSAGE,MAILTO_TO_SPAM_ADDR,RCVD_IN_BL_SPAMCOP_NET,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of lyndon.washington@gmail.com designates 66.249.82.198 as permitted sender) Received: from [66.249.82.198] (HELO xproxy.gmail.com) (66.249.82.198) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Nov 2005 13:45:18 -0800 Received: by xproxy.gmail.com with SMTP id s14so1358055wxc for ; Tue, 01 Nov 2005 13:45:01 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:references; b=nh+ncTkTYMwTvfewn+fyofbugRxRrD4c1VT2Vs4uDfqL6miGfXTX465LVdcdsbbAcVoR2/tz3wPGYWW2kgFXjOuLIBsOmoRfhpjEUxEC9zFwlH7nhPZWyXbMZmiizVETCRQihUG5JuVrz2WMReunGZ8Jl4odZMo+aK9z4tpHUMM= Received: by 10.65.225.8 with SMTP id c8mr1440424qbr; Tue, 01 Nov 2005 13:45:00 -0800 (PST) Received: by 10.65.124.13 with HTTP; Tue, 1 Nov 2005 13:45:00 -0800 (PST) Message-ID: <524960cd0511011345h6a3dcbeci79a6cc2b11a230c3@mail.gmail.com> Date: Tue, 1 Nov 2005 16:45:00 -0500 From: Lyndon Washington Sender: lyndon.washington@gmail.com To: Apache Directory Developers List Subject: Re: Adding a Custom Partition Context In-Reply-To: <524960cd0511011338s4bc889b2v9778b0f9900e0e51@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_11434_4271537.1130881500855" References: <524960cd0511011201h650ed011n19d4135d55cc9c0c@mail.gmail.com> <4367DD21.30100@bellsouth.net> <524960cd0511011338s4bc889b2v9778b0f9900e0e51@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_11434_4271537.1130881500855 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline oops! and to answer your question about what I am trying to achieve . . . I want a new configuration property for my partition so that it looks somewhat like . . . example dc=3Dexample,dc=3Dcom dc ou objectClass krb5PrincipalName uid objectClass: top objectClass: domain objectClass: extensibleObject dc: example org.fooorg.IntegrationProject On 11/1/05, Lyndon Washington wrote: > > Hi Alex, > > Thanks for the prompt reply. > > I have already tried that, and it fails to pass in my configuration objec= t > because as I stated earlier, the " > DefaultContextPartitionNexus.addContextPartition() creates a new > MutableContextPartitionConfiguration" rather than using the configuration > that was instantiated based on the properties file. > > I have also tried altering one of the JUnit test cases and adding the > configuration to a Hashtable and passing that to a JNDI context > intitialization . . . no joy there either. > > Here is the offending code, IMHO, which shows that the config that is > passed in is not the one that is ultimately passed to 'partition.init()': > > public synchronized void addContextPartition( > ContextPartitionConfiguration config ) throws NamingException > { > ContextPartition partition =3D config.getContextPartition(); > > // Turn on default indices > MutableContextPartitionConfiguration mcfg =3D > new MutableContextPartitionConfiguration(); > mcfg.setName( config.getName() ); > mcfg.setSuffix( config.getSuffix() ); > mcfg.setContextEntry( config.getContextEntry() ); > mcfg.setContextPartition( partition ); > > Set indexedAttrs =3D config.getIndexedAttributes(); > indexedAttrs.add( Oid.ALIAS ); > indexedAttrs.add( Oid.EXISTANCE ); > indexedAttrs.add( Oid.HIERARCHY ); > indexedAttrs.add( Oid.NDN ); > indexedAttrs.add( Oid.ONEALIAS ); > indexedAttrs.add( Oid.SUBALIAS ); > indexedAttrs.add( Oid.UPDN ); > mcfg.setIndexedAttributes( indexedAttrs ); > > String key =3D config.getSuffix(); > if( partitions.containsKey( key ) ) > { > throw new ConfigurationException( "Duplicate partition suffix: " + key ); > } > > partition.init( factoryCfg, mcfg ); > partitions.put( partition.getSuffix( true ).toString(), partition ); > > Attribute namingContexts =3D rootDSE.get( NAMINGCTXS_ATTR ); > namingContexts.add( partition.getSuffix( false ).toString() ); > } > > > -Lyndon- > > > On 11/1/05, Alex Karasulu wrote: > > > > Lyndon Washington wrote: > > > > ... > > > > > I have added my own CustomPartiton which extends > > > AbstractContextPartition. I have some configuration settings specific > > > to my partition, so I have also created a new > > > ContextPartitionConfiguration which extends > > > MutableContextPartitionConfiguration. > > > > > Ok can you state your specific goal with the custom partition so I have > > more of an understanding of what you're trying to do? > > > > > Unfortunately, in my CustomPartition.doInit() method I attempt to tes= t > > > if the configuration that is returned from > > > AbstractContextPartition.getConfiguration() is an instance of my new > > > configuration, and if it is I want to use the new configuration > > > settings to configure the custom partition. The implementation within > > > DefaultContextPartitionNexus.addContextPartition() creates a new > > > MutableContextPartitionConfiguration and copies the known values from > > > the config that was passed into that method, thus by the time my code > > > is called it is never an instance of my new configuration class. > > > > Ok I see. > > > > > Is this done to alleviate some known issue, or is it just an > > > oversight. If it is an oversight, I can fix my local sandbox with a > > > 'short sighted' implementation. If this is deliberately implemented > > > this way, how are you supposed to use a new type of > > > ContextPartitionConfiguration? > > > > In the server.xml you can set the bean class for the configuration > > object's class to use your own configuration class. Here's where you'd > > make the change: > > > > ... > > > > > class=3D"org.apache.ldap.server.configu > > ration.MutableDirectoryPartitionConfiguration"> > > example > > dc=3Dexample,dc=3Dcom > > > > > > dc > > ou > > objectClass > > krb5PrincipalName > > uid > > > > > > > > > > objectClass: top > > objectClass: domain > > objectClass: extensibleObject > > dc: example > > > > > > > > > > ... > > > > So if your configuration class is com.example.MyParititionConfig then i= t > > > > would look like so: > > > > ... > > > > > class=3D"com.example.MyPartitionConfig"> > > example > > dc=3Dexample,dc=3Dcom > > > > > > dc > > ou > > objectClass > > krb5PrincipalName > > uid > > > > > > > > > > objectClass: top > > objectClass: domain > > objectClass: extensibleObject > > dc: example > > > > > > > > > > ... > > > > Give that a try and let us know how it goes. > > > > Cheers, > > Alex > > > > > > > -- > -------------------------------- > Lyndon Washington > Snr. Software Engineer > lwashington@novell.com > 1.203.225.1815 (Shelton - CT) > 1.781.464.8735 (Waltham - MA) > > Novell, Inc. > Software for the Open Enterprise > http://www.novell.com/open > -- -------------------------------- Lyndon Washington Snr. Software Engineer lwashington@novell.com 1.203.225.1815 (Shelton - CT) 1.781.464.8735 (Waltham - MA) Novell, Inc. Software for the Open Enterprise http://www.novell.com/open ------=_Part_11434_4271537.1130881500855 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline oops! and to answer your question about what I am trying to achieve . . .
I want a new configuration property for my partition so that it looks somew= hat like . . .


<bean id=3D"examplePartitionConfigurat
ion"
class=3D"com.example.MyPartitionConfig&q= uot;>
   <property name=3D"name"><value= >example</value></property>
   <property na= me=3D"suffix"><value>dc=3Dexample,dc=3Dcom</value>= </property>
   <property name=3D"indexedAttributes">
=      <set>
       <value&g= t;dc</value>
       <value>ou</value= >
       <value>objectClass</value><= br>        <value>krb5PrincipalName</value>
       <value>uid</value>
  &= nbsp;  </set>
   </property>
  &nbs= p;<property name=3D"contextEntry">
     = <value>
       objectClass: top
  &n= bsp;    objectClass: domain
       objectClass: extensibleObject
  &n= bsp;    dc: example
     </value>
&n= bsp;  </property>
   <property name=3D"integrationServiceName">
      <value>org.fooorg.IntegrationProject&l= t;/value>
   </property>


On 11/1/05, Lyndon Washington <lyndon.washington@gmail.com> wrote:
Hi Alex,

Thanks for the prompt reply.

I have already tried that, and it fails to pass in my configuration object = because as I stated earlier, the "DefaultContextPartitionNexus.a= ddContextPartition() creates a new MutableContextPartitionConfiguration&quo= t; rather than using the configuration that was instantiated based on the p= roperties file.

I have also tried altering one of the JUnit test cases and adding the configuration to a Hashtable and passing that to a JNDI context intitialization . . . no joy there either.

Here is the offending code, IMHO, which shows that the config that is passed in is not the one that is ultimately passed to 'partition.init()':
<snippet>
    public synchronized void addContextPartition( ContextPar= titionConfiguration config ) throws NamingException
    {
        ContextPartition partition =3D c= onfig.getContextPartition();

        // Turn on default indices
        MutableContextPartitionConfigura= tion mcfg =3D
            new Muta= bleContextPartitionConfiguration();
        mcfg.setName( config.getName() )= ;
        mcfg.setSuffix( config.getSuffix= () );
        mcfg.setContextEntry( config.get= ContextEntry() );
        mcfg.setContextPartition( partit= ion );
       
        Set indexedAttrs =3D config.getI= ndexedAttributes();
        indexedAttrs.add( Oid.ALIAS );         indexedAttrs.add( Oid.EXISTANCE = );
        indexedAttrs.add( Oid.HIERARCHY = );
        indexedAttrs.add( Oid.NDN );
        indexedAttrs.add( Oid.ONEALIAS )= ;
        indexedAttrs.add( Oid.SUBALIAS )= ;
        indexedAttrs.add( Oid.UPDN );         mcfg.setIndexedAttributes( index= edAttrs );
       
        String key =3D config.getSuffix(= );
        if( partitions.containsKey( key = ) )
        {
            throw new ConfigurationException( "Duplicate partition suffix: " = + key );
        }

        partition.init( factoryCfg, mcfg= );
        partitions.put( partition.getSuf= fix( true ).toString(), partition );
       
        Attribute namingContexts =3D roo= tDSE.get( NAMINGCTXS_ATTR );
        namingContexts.add( partition.ge= tSuffix( false ).toString() );
    }
</snippet>

-Lyndon-


On 11/1/05, Alex Karasulu= < aok123@bellsouth.net> wrote:
Lyndon Washington wrote:

...

> I have added my own CustomP= artiton which extends
> AbstractContextPartition.  I have s= ome configuration settings specific
> to my partition, so I have also= created a new
> ContextPartitionConfiguration which extends
> MutableContext= PartitionConfiguration.
>
Ok can you state your specific goal with= the custom partition so I have
more of an understanding of what you're = trying to do?

> Unfortunately, in my CustomPartition.doInit() method I attempt= to test
> if the configuration that is returned from
> Abstrac= tContextPartition.getConfiguration() is an instance of my new
> confi= guration, and if it is I want to use the new configuration
> settings to configure the custom partition.  The impleme= ntation within
> DefaultContextPartitionNexus.addContextPartition() c= reates a new
> MutableContextPartitionConfiguration and copies the kn= own values from
> the config that was passed into that method, thus by the time my c= ode
> is called it is never an instance of my new configuration class= .

Ok I see.

> Is this done to alleviate some known issue, = or is it just an
> oversight.  If it is an oversight, I can fix my local sa= ndbox with a
> 'short sighted' implementation.  If this is = deliberately implemented
> this way, how are you supposed to use a ne= w type of
> ContextPartitionConfiguration?

In the server.xml you can set the bean class for the configuration<= br>object's class to use your own configuration class.  Here's wh= ere you'd
make the change:

...

  <bean id=3D&= quot;examplePartitionConfiguration"
class=3D"org.apache.ldap.server.configu
ration.MutableDirectory= PartitionConfiguration">
    <property na= me=3D"name"><value>example</value></property>= ;
    <property name=3D"suffix"><= value>dc=3Dexample,dc=3Dcom</value></property>
    <property name=3D"indexedAttributes&quo= t;>
      <set>
  &n= bsp;     <value>dc</value>
 &n= bsp;      <value>ou</value>
&n= bsp;       <value>objectClass</= value>
        <value>k= rb5PrincipalName</value>
        <value>uid</va= lue>
      </set>
  =   </property>
    <property name= =3D"contextEntry">
      <= value>
        objectClass: t= op
        objectClass: domain
        objectClass: extensible= Object
        dc: example
&n= bsp;     </value>
    = ;</property>
  </bean>

...

So if you= r configuration class is com.example.MyParititionConfig then it
would look like so:

...

  <bean id=3D"e= xamplePartitionConfiguration"
class=3D"com.example.MyPartition= Config">
    <property name=3D"name&= quot;><value>example</value></property>
    <property name=3D"suffix"><v= alue>dc=3Dexample,dc=3Dcom</value></property>
  = ;  <property name=3D"indexedAttributes">
 = ;     <set>
     = ;   <value>dc</value>
        <value>ou</val= ue>
        <value>obje= ctClass</value>
        &l= t;value>krb5PrincipalName</value>
     = ;   <value>uid</value>
   &nbs= p;  </set>
    </property>
    <property name=3D"contextEntry">= ;
      <value>
   = ;     objectClass: top
    =     objectClass: domain
    &nbs= p;   objectClass: extensibleObject
   &nbs= p;    dc: example
     &nbs= p;</value>
    </property>
  </bean><= br>
...

Give that a try and let us know how it goes.

Cheer= s,
Alex




--
--------------------------------
Lyndon Washington
Snr. Software Engineer
lwashington@novell.com
1.203.225.1815 (Shelton - CT) 1.781.464.8735 (Waltham - MA)

Novell, Inc.
Software for the Open = Enterprise
http://www.novell.com/open



--
-----------------------= ---------
Lyndon Washington
Snr. Software Engineer
lwashington@novell.com
1.203.225.1815 (Sh= elton - CT)
1.781.464.8735 (Waltham - MA)

Novell, Inc.
Software for the O= pen Enterprise
http://www.novell.= com/open
------=_Part_11434_4271537.1130881500855--