Class LdapConnectionPoolConfigurer
- All Implemented Interfaces:
io.micronaut.context.event.BeanCreatedEventListener<LdapConfiguration>, EventListener
LdapConfiguration whose manager context is pooled.
The JDK configures its pool with system properties only, read once when the first pooled connection of
the JVM is opened, and leaves the pool unbounded by default. This listener runs when an
LdapConfiguration bean is created, which precedes the creation of its
LdapAuthenticationProvider and therefore the first pooled connection
Micronaut Security opens, and, for an enabled configuration, applies LdapConfiguration.ContextConfiguration.PoolConfiguration
as the com.sun.jndi.ldap.connect.pool.maxsize, com.sun.jndi.ldap.connect.pool.prefsize
and com.sun.jndi.ldap.connect.pool.timeout system properties. A configured value always wins; a
value that is not configured keeps a system property that is already set and otherwise falls back to the
default.
- Since:
- 5.5.2
- Author:
- Sergio del Amo
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringJNDI environment property, set on the pooled context itself, holding the milliseconds a context waits for a pooled connection when the pool is saturated and the time allowed to open a new connection.static final StringSystem property holding the milliseconds after which an idle pooled connection is closed.static final StringSystem property holding the maximum number of pooled connections per connection identity.static final StringSystem property holding the preferred number of pooled connections per connection identity. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidapplyConnectTimeout(Map<? super String, ? super String> environment, @Nullable Duration connectTimeout) Adds the connect timeout of a pooled context to its JNDI environment, unless the environment already sets it.static voidApplies the default bound to every pool system property that is not set.onCreated(io.micronaut.context.event.BeanCreatedEvent<LdapConfiguration> event)
-
Field Details
-
MAX_SIZE_PROPERTY
System property holding the maximum number of pooled connections per connection identity.- See Also:
-
PREF_SIZE_PROPERTY
System property holding the preferred number of pooled connections per connection identity.- See Also:
-
IDLE_TIMEOUT_PROPERTY
System property holding the milliseconds after which an idle pooled connection is closed.- See Also:
-
CONNECT_TIMEOUT_PROPERTY
JNDI environment property, set on the pooled context itself, holding the milliseconds a context waits for a pooled connection when the pool is saturated and the time allowed to open a new connection. Without it the JDK waits indefinitely.- See Also:
-
-
Constructor Details
-
LdapConnectionPoolConfigurer
public LdapConnectionPoolConfigurer()
-
-
Method Details
-
applyDefaults
public static void applyDefaults()Applies the default bound to every pool system property that is not set.DefaultContextBuildercalls this before opening a pooled context, so that a pooled context built outside anLdapConfiguration, throughContextBuilder.build(String, String, String, String, boolean), never uses an unbounded pool either. Properties that are already set, by this listener or on the command line, are left untouched. -
applyConnectTimeout
public static void applyConnectTimeout(Map<? super String, ? super String> environment, @Nullable Duration connectTimeout) Adds the connect timeout of a pooled context to its JNDI environment, unless the environment already sets it.- Parameters:
environment- The JNDI environment of a pooled contextconnectTimeout- The configured connect timeout, or null for the default
-
onCreated
public LdapConfiguration onCreated(io.micronaut.context.event.BeanCreatedEvent<LdapConfiguration> event) - Specified by:
onCreatedin interfaceio.micronaut.context.event.BeanCreatedEventListener<LdapConfiguration>
-