I have a requirement to configure MBeans to expose LDAP Connection Pooling. I have created a custom MBean and added LDAP Pooling. My configuration looks as follows
<bean id="contextSourceTarget" class="org.springframework.ldap.core.support.LdapC ontextSource">
<property name="url" value="myURL" />
<property name="userDn" value="myUserDN"/>
<property name="password" value="myPassword" />
<property name="pooled" value="false"/>
</bean>
Then I added a pooling context source bean
<bean id="contextSourcePooled" class="org.springframework.ldap.pool.factory.Pooli ngContextSource">
<property name="contextSource" ref="contextSourceTarget" />
<property name="dirContextValidator" ref="dirContextValidator" />
<property name="testOnBorrow" value="true" />
<property name="testOnReturn" value="false" />
<property name="testWhileIdle" value="true" />
<property name="timeBetweenEvictionRunsMillis" value="-1" />
<property name="minEvictableIdleTimeMillis" value="1800000" />
<property name="maxWait" value="-1" />
<property name="maxTotal" value="-1" />
<property name="whenExhaustedAction" value="1" />
<property name="maxActive" value="8" />
<property name="maxIdle" value="8" />
<property name="minIdle" value="0" />
<property name="numTestsPerEvictionRun" value="3" />
</bean>
<bean id="dirContextValidator" class="org.springframework.ldap.pool.validation.De faultDirContextValidator" />
<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate" >
<constructor-arg ref="contextSourceTarget" />
</bean>
My MBean configuration looks
<bean id="mbeanExporter" class="org.springframework.jmx.export.MBeanExporte r" lazy-init="false">
<property name="registrationBehaviorName" value="REGISTRATION_REPLACE_EXISTING" />
<property name="assembler" ref="assembler"/>
<property name="namingStrategy" ref="namingStrategy"/>
<property name="autodetect" value="true"/>
<property name="server" ref="mbeanServerFactory" />
<property name="beans">
<map>
<entry key="org.springframework.ldap:name=ldapPoolStatist icsbean" value-ref="ldapJMXMBean" />
</map>
</property>
</bean>
<bean id="mbeanServerFactory" class="org.springframework.jmx.support.MBeanServer FactoryBean">
<property name="locateExistingServerIfPossible" value="true" />
</bean>
<bean id="jmxAttributeSource" class="org.springframework.jmx.export.annotation.A nnotationJmxAttributeSource"/>
<bean id="assembler" class="org.springframework.jmx.export.assembler.Me tadataMBeanInfoAssembler">
<property name="attributeSource" ref="jmxAttributeSource"/>
</bean>
<bean id="namingStrategy" class="org.springframework.jmx.export.naming.Metad ataNamingStrategy">
<property name="attributeSource" ref="jmxAttributeSource"/>
</bean>
<bean id="ldapJMXMBean" class="com.ldap.jmx.LdapJMXMBean">
<property name="contextSource" ref="contextSourcePooled" />
</bean>
I could see the MBeans in Jconsole. But the values are not changing at runtime. The Mbeans are loaded with the default values which I set for the beans. Could anyone suggest me a way to resolve this
Seems like if we call any method on the org.springframework.ldap.pool.factory.PoolingConte xtSource object(contextSource) - ie contextSource.getNumActive() will always returns the default values. But whenever we click on Jconsole the corresponding Custom MBean's method gets invoked; but always returns 0. Any suggestions
Screenshot.jpg




Reply With Quote
