directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <david_jen...@yahoo.com>
Subject Simplified server configuration with xbean-spring
Date Thu, 28 Jun 2007 23:17:14 GMT
A while back there was some discussion of whether server.xml could be  
made to be more semantically meaningful with less generic cruft, and  
I suggested looking into xbean-spring.  So, I spent a bit of time on  
it and implemented this.  See https://issues.apache.org/jira/browse/ 
DIRSERVER-984

This was pretty easy to do, after fixing some problems in xbean.   
Basically all I did was add some javadoc "annotations" to tell xbean  
which classes to look at and what type collections contain, and  
change to the xbean application context from the plain spring one.

xbean generates a schema for the configurable objects so you can  
consult the schema to see what can be configured.  As you can see,  
you can mix regular spring configuration and the xbean style in the  
same server.xml.

There's a lot more customization possible, I basically did the  
minimum possible to get  it to work.  Pretty much anything can have a  
different name.  The main ugliness I see is the handling of  
properties that are lists (or sets) of strings.

So, at the risk of posting too large a message,  here's the shiny new  
server.xml (I removed some commented out bits) :

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
         "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>
<!-- bean I didn't convert -->
   <bean id="environment"  
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
     <property name="properties">
       <props>
         <!-- JNDI security properties used to get initial  
contexts.         -->
         <prop key="java.naming.security.authentication">simple</prop>
         <prop  
key="java.naming.security.principal">uid=admin,ou=system</prop>
         <prop key="java.naming.security.credentials">secret</prop>
       </props>
     </property>
   </bean>


   <mutableServerStartupConfiguration id="configuration"  
xmlns="http://apacheds.org/config/1.0"
                                      workingDirectory="example.com"
                                      synchPeriodMillis="5000"
                                      maxThreads="8"
                                      allowAnonymousAccess="false"
                                      accessControlEnabled="false"
                                      denormalizeOpAttrsEnabled="false"
           >
     <ntpConfiguration>
       <ntpConfiguration
               enabled="false"
               ipPort="123">
       </ntpConfiguration>
     </ntpConfiguration>

     <dnsConfiguration>
       <dnsConfiguration
               enabled="false"
               ipPort="53">
       </dnsConfiguration>
     </dnsConfiguration>

     <changePasswordConfiguration>
       <changePasswordConfiguration
               enabled="false"
               ipPort="464">
       </changePasswordConfiguration>
     </changePasswordConfiguration>

     <kdcConfiguration>
       <kdcConfiguration
               enabled="false"
               ipPort="88">
       </kdcConfiguration>
     </kdcConfiguration>

     <ldapConfiguration>
       <ldapConfiguration id="ldapConfiguration"
               ipPort="10389"
               allowAnonymousAccess="false"
               saslHost="ldap.example.com"
               saslPrincipal="ldap/ldap.example.com@EXAMPLE.COM"
               searchBaseDn="ou=users,ou=system"
               maxTimeLimit="15000"
               maxSizeLimit="1000">

         <!-- The list of supported authentication  
mechanisms.                   -->
         <supportedMechanisms>
           <value xmlns="http://www.springframework.org/schema/ 
beans">SIMPLE</value>
           <value xmlns="http://www.springframework.org/schema/ 
beans">CRAM-MD5</value>
           <value xmlns="http://www.springframework.org/schema/ 
beans">DIGEST-MD5</value>
           <!--<value xmlns="http://www.springframework.org/schema/ 
beans">GSSAPI</value>-->
         </supportedMechanisms>

         <!-- The desired quality-of-protection, used by DIGEST-MD5  
and GSSAPI.  -->
         <saslQop>
           <value xmlns="http://www.springframework.org/schema/ 
beans">auth</value>
           <value xmlns="http://www.springframework.org/schema/ 
beans">auth-int</value>
           <value xmlns="http://www.springframework.org/schema/ 
beans">auth-conf</value>
         </saslQop>

         <!-- The realms serviced by this SASL host, used by DIGEST- 
MD5 and GSSAPI. -->
         <saslRealms>
           <value xmlns="http://www.springframework.org/schema/ 
beans">example.com</value>
           <value xmlns="http://www.springframework.org/schema/ 
beans">apache.org</value>
         </saslRealms>

         <!-- the collection of extended operation handlers to  
install           -->
         <extendedOperationHandlers>
           <gracefulShutdownHandler/>
           <launchDiagnosticUiHandler/>
         </extendedOperationHandlers>
       </ldapConfiguration>
     </ldapConfiguration>

     <ldapsConfiguration>
       <ldapConfiguration id="ldapsConfiguration"
                          enabled="false"
                          ipPort="636"
                          enableLdaps="true">
       </ldapConfiguration>
     </ldapsConfiguration>

     <systemPartitionConfiguration>
       <!-- use the following partitionConfiguration to override  
defaults for  -->
       <!-- the system  
partition                                               -->
       <mutableBTreePartitionConfiguration  
id="systemPartitionConfiguration"
         name="system"
         cacheSize="100"
         suffix="ou=system"
         optimizerEnabled="true"
         synchOnWrite="true">
         <indexedAttributes>
             <mutableIndexConfiguration
               attributeId="1.3.6.1.4.1.18060.0.4.1.2.1"
               cacheSize="100"/>
             <mutableIndexConfiguration
               attributeId="1.3.6.1.4.1.18060.0.4.1.2.2"
               cacheSize="100"/>
             <mutableIndexConfiguration
               attributeId="1.3.6.1.4.1.18060.0.4.1.2.3"
               cacheSize="100"/>
             <mutableIndexConfiguration
               attributeId="1.3.6.1.4.1.18060.0.4.1.2.4"
               cacheSize="100"/>
             <mutableIndexConfiguration
               attributeId="1.3.6.1.4.1.18060.0.4.1.2.5"
               cacheSize="10"/>
             <mutableIndexConfiguration
               attributeId="1.3.6.1.4.1.18060.0.4.1.2.6"
               cacheSize="10"/>
             <mutableIndexConfiguration
               attributeId="1.3.6.1.4.1.18060.0.4.1.2.7"
               cacheSize="10"/>
             <mutableIndexConfiguration
               attributeId="ou"
               cacheSize="100"/>
             <mutableIndexConfiguration
               attributeId="uid"
               cacheSize="100"/>
             <mutableIndexConfiguration
               attributeId="objectClass"
               cacheSize="100"/>
         </indexedAttributes>
         <contextEntry>
           <value xmlns="http://www.springframework.org/schema/beans">
             objectClass: top
             objectClass: organizationalUnit
             objectClass: extensibleObject
             ou: system
           </value>
         </contextEntry>
       </mutableBTreePartitionConfiguration>
     </systemPartitionConfiguration>

     <partitionConfigurations>
       <mutableBTreePartitionConfiguration  
id="examplePartitionConfiguration"
         name="example"
         cacheSize="100"
         suffix="dc=example,dc=com"
         optimizerEnabled="true"
         synchOnWrite="true">
         <indexedAttributes>
             <mutableIndexConfiguration
               attributeId="1.3.6.1.4.1.18060.0.4.1.2.1"
               cacheSize="100"/>
             <mutableIndexConfiguration
               attributeId="1.3.6.1.4.1.18060.0.4.1.2.2"
               cacheSize="100"/>
             <mutableIndexConfiguration
               attributeId="1.3.6.1.4.1.18060.0.4.1.2.3"
               cacheSize="100"/>
             <mutableIndexConfiguration
               attributeId="1.3.6.1.4.1.18060.0.4.1.2.4"
               cacheSize="100"/>
             <mutableIndexConfiguration
               attributeId="1.3.6.1.4.1.18060.0.4.1.2.5"
               cacheSize="10"/>
             <mutableIndexConfiguration
               attributeId="1.3.6.1.4.1.18060.0.4.1.2.6"
               cacheSize="10"/>
             <mutableIndexConfiguration
               attributeId="1.3.6.1.4.1.18060.0.4.1.2.7"
               cacheSize="10"/>
             <mutableIndexConfiguration
               attributeId="dc"
               cacheSize="100"/>
             <mutableIndexConfiguration
               attributeId="ou"
               cacheSize="100"/>
             <mutableIndexConfiguration
               attributeId="krb5PrincipalName"
               cacheSize="100"/>
             <mutableIndexConfiguration
               attributeId="uid"
               cacheSize="100"/>
             <mutableIndexConfiguration
               attributeId="objectClass"
               cacheSize="100"/>
         </indexedAttributes>
         <contextEntry>
           <value xmlns="http://www.springframework.org/schema/beans">
             objectClass: top
             objectClass: domain
             objectClass: extensibleObject
             dc: example
           </value>
         </contextEntry>
       </mutableBTreePartitionConfiguration>
     </partitionConfigurations>

     <interceptorConfigurations>
       <mutableInterceptorConfiguration
               name="normalizationService">
         <interceptor>
           <normalizationService/>
         </interceptor>
       </mutableInterceptorConfiguration>
       <mutableInterceptorConfiguration
               name="authenticationService">
         <interceptor>
           <authenticationService/>
         </interceptor>
       </mutableInterceptorConfiguration>
       <mutableInterceptorConfiguration
               name="referralService">
         <interceptor>
           <referralService/>
         </interceptor>
       </mutableInterceptorConfiguration>
       <mutableInterceptorConfiguration
               name="authorizationService">
         <interceptor>
           <authorizationService/>
         </interceptor>
       </mutableInterceptorConfiguration>
       <mutableInterceptorConfiguration
               name="defaultAuthorizationService">
         <interceptor>
           <defaultAuthorizationService/>
         </interceptor>
       </mutableInterceptorConfiguration>
       <mutableInterceptorConfiguration
               name="exceptionService">
         <interceptor>
           <exceptionService/>
         </interceptor>
       </mutableInterceptorConfiguration>
       <mutableInterceptorConfiguration
               name="operationalAttributeService">
         <interceptor>
           <operationalAttributeService/>
         </interceptor>
       </mutableInterceptorConfiguration>
       <mutableInterceptorConfiguration
               name="schemaService">
         <interceptor>
           <schemaService/>
         </interceptor>
       </mutableInterceptorConfiguration>
       <mutableInterceptorConfiguration
               name="subentryService">
         <interceptor>
           <subentryService/>
         </interceptor>
       </mutableInterceptorConfiguration>
       <mutableInterceptorConfiguration
               name="collectiveAttributeService">
         <interceptor>
           <collectiveAttributeService/>
         </interceptor>
       </mutableInterceptorConfiguration>
       <mutableInterceptorConfiguration
               name="eventService">
         <interceptor>
           <eventService/>
         </interceptor>
       </mutableInterceptorConfiguration>
       <mutableInterceptorConfiguration
               name="triggerService">
         <interceptor>
           <triggerService/>
         </interceptor>
       </mutableInterceptorConfiguration>

     </interceptorConfigurations>
   </mutableServerStartupConfiguration>


<!-- another bean I didn't convert -->
   <bean  
class="org.springframework.beans.factory.config.CustomEditorConfigurer">
     <property name="customEditors">
       <map>
         <entry key="javax.naming.directory.Attributes">
           <bean  
class="org.apache.directory.server.core.configuration.AttributesProperty 
Editor"/>
         </entry>
       </map>
     </property>
   </bean>
</beans>


Comments?

thanks
david jencks



Mime
View raw message