directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lyndon Washington <lyndon.washing...@gmail.com>
Subject Re: Adding a Custom Partition Context
Date Tue, 01 Nov 2005 21:38:36 GMT
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.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()':
<snippet>
public synchronized void addContextPartition( ContextPartitionConfiguration
config ) throws NamingException
{
ContextPartition partition = config.getContextPartition();

// Turn on default indices
MutableContextPartitionConfiguration mcfg =
new MutableContextPartitionConfiguration();
mcfg.setName( config.getName() );
mcfg.setSuffix( config.getSuffix() );
mcfg.setContextEntry( config.getContextEntry() );
mcfg.setContextPartition( partition );

Set indexedAttrs = 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 = 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 = rootDSE.get( NAMINGCTXS_ATTR );
namingContexts.add( partition.getSuffix( false ).toString() );
}
</snippet>

-Lyndon-


On 11/1/05, Alex Karasulu <aok123@bellsouth.net> 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 test
> > 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:
>
> ...
>
> <bean id="examplePartitionConfiguration"
> class="org.apache.ldap.server.configu
> ration.MutableDirectoryPartitionConfiguration">
> <property name="name"><value>example</value></property>
> <property name="suffix"><value>dc=example,dc=com</value></property>
> <property name="indexedAttributes">
> <set>
> <value>dc</value>
> <value>ou</value>
> <value>objectClass</value>
> <value>krb5PrincipalName</value>
> <value>uid</value>
> </set>
> </property>
> <property name="contextEntry">
> <value>
> objectClass: top
> objectClass: domain
> objectClass: extensibleObject
> dc: example
> </value>
> </property>
> </bean>
>
> ...
>
> So if your configuration class is com.example.MyParititionConfig then it
> would look like so:
>
> ...
>
> <bean id="examplePartitionConfiguration"
> class="com.example.MyPartitionConfig">
> <property name="name"><value>example</value></property>
> <property name="suffix"><value>dc=example,dc=com</value></property>
> <property name="indexedAttributes">
> <set>
> <value>dc</value>
> <value>ou</value>
> <value>objectClass</value>
> <value>krb5PrincipalName</value>
> <value>uid</value>
> </set>
> </property>
> <property name="contextEntry">
> <value>
> objectClass: top
> objectClass: domain
> objectClass: extensibleObject
> dc: example
> </value>
> </property>
> </bean>
>
> ...
>
> 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

Mime
View raw message