如何验证Spring LDAP连接池配置?

问题描述 投票:0回答:1

我在Spring启动应用程序中为LDAP搜索(而不是LDAP绑定)配置了LDAP连接池。这是我的LDAP配置:

@Bean
public ContextSource poolingLdapContextSource() {

    PoolingContextSource poolingContextSource = new PoolingContextSource();
    poolingContextSource.setDirContextValidator(new DefaultDirContextValidator());
    poolingContextSource.setContextSource(ldapContextSource());

    return poolingContextSource;
}


@Bean
public LdapContextSource ldapContextSource() {
    LdapContextSource contextSource = new LdapContextSource();
    contextSource.setUrls(ldapUrls.toArray(new String[]{}));
    contextSource.setUserDn(ldapUsername);
    contextSource.setPassword(ldapPassword);
    contextSource.setPooled(false);

    return contextSource;
}


@Bean
public LdapTemplate ldapTemplate() throws Exception {
    return new LdapTemplate(poolingLdapContextSource());
}

我在application.yml中启用了调试日志记录,如下所示:

org.springframework.ldap:debug

org.springframework.ldap.pool:debug

在日志中,我看到以下内容:

17-10-10 16:11:12:976 DEBUG o.s.l.c.s.AbstractContextSource - AuthenticationSource not set - using default implementation 2017-10-10 16:11:12:976 DEBUG o.s.l.c.s.AbstractContextSource - **Not using LDAP pooling** 2017-10-10 16:11:12:976 DEBUG o.s.l.c.s.AbstractContextSource - Trying provider Urls: ldap://xxx:389 ldap://yyy:389

问题:

  1. 为什么日志说“不使用LDAP池”?
  2. 如何获得有关池的更详细日志记录,以便更深入地了解Spring何时打开新连接,存在多少活动连接等?
java spring ldap connection-pooling spring-ldap
1个回答
0
投票

一年或更长时间后,可能没有帮助你,但即使使用TRACE,也不会再有来自org.springframework.ldaporg.springframework.security的记录。

你可以通过另外两种方式证明这一点。

  • 不提供非汇集的LdapContextSource。只需以编程方式提供给PoolingContextSource.setContextSource()
  • 在调试中运行服务器并在PoolingContextSource.getContext()中放置一个断点。
© www.soinside.com 2019 - 2024. All rights reserved.