|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2023 the original author or authors. |
| 2 | + * Copyright 2012-2025 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
14 | 14 | * limitations under the License.
|
15 | 15 | */
|
16 | 16 |
|
17 |
| -package org.springframework.boot.autoconfigure.ldap.embedded; |
| 17 | +package org.springframework.boot.ldap.autoconfigure.embedded; |
18 | 18 |
|
19 | 19 | import java.io.InputStream;
|
20 | 20 | import java.util.Collections;
|
|
28 | 28 | import com.unboundid.ldap.sdk.LDAPException;
|
29 | 29 | import com.unboundid.ldap.sdk.schema.Schema;
|
30 | 30 | import com.unboundid.ldif.LDIFReader;
|
31 |
| -import jakarta.annotation.PreDestroy; |
32 | 31 |
|
33 | 32 | import org.springframework.aot.hint.RuntimeHints;
|
34 | 33 | import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
| 34 | +import org.springframework.beans.factory.DisposableBean; |
35 | 35 | import org.springframework.boot.autoconfigure.AutoConfiguration;
|
36 | 36 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
37 | 37 | import org.springframework.boot.autoconfigure.condition.ConditionMessage;
|
|
40 | 40 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
41 | 41 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
42 | 42 | import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
|
43 |
| -import org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration; |
44 |
| -import org.springframework.boot.autoconfigure.ldap.LdapProperties; |
45 |
| -import org.springframework.boot.autoconfigure.ldap.embedded.EmbeddedLdapAutoConfiguration.EmbeddedLdapAutoConfigurationRuntimeHints; |
46 | 43 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
47 | 44 | import org.springframework.boot.context.properties.bind.Bindable;
|
48 | 45 | import org.springframework.boot.context.properties.bind.Binder;
|
| 46 | +import org.springframework.boot.ldap.autoconfigure.LdapAutoConfiguration; |
| 47 | +import org.springframework.boot.ldap.autoconfigure.LdapProperties; |
| 48 | +import org.springframework.boot.ldap.autoconfigure.embedded.EmbeddedLdapAutoConfiguration.EmbeddedLdapAutoConfigurationRuntimeHints; |
49 | 49 | import org.springframework.context.ApplicationContext;
|
50 | 50 | import org.springframework.context.ConfigurableApplicationContext;
|
51 | 51 | import org.springframework.context.annotation.Bean;
|
|
70 | 70 | * @author Eddú Meléndez
|
71 | 71 | * @author Mathieu Ouellet
|
72 | 72 | * @author Raja Kolli
|
73 |
| - * @since 1.5.0 |
| 73 | + * @since 4.0.0 |
74 | 74 | */
|
75 | 75 | @AutoConfiguration(before = LdapAutoConfiguration.class)
|
76 | 76 | @EnableConfigurationProperties({ LdapProperties.class, EmbeddedLdapProperties.class })
|
77 | 77 | @ConditionalOnClass(InMemoryDirectoryServer.class)
|
78 | 78 | @Conditional(EmbeddedLdapAutoConfiguration.EmbeddedLdapCondition.class)
|
79 | 79 | @ImportRuntimeHints(EmbeddedLdapAutoConfigurationRuntimeHints.class)
|
80 |
| -public class EmbeddedLdapAutoConfiguration { |
| 80 | +public class EmbeddedLdapAutoConfiguration implements DisposableBean { |
81 | 81 |
|
82 | 82 | private static final String PROPERTY_SOURCE_NAME = "ldap.ports";
|
83 | 83 |
|
@@ -167,8 +167,8 @@ private Map<String, Object> getLdapPorts(MutablePropertySources sources) {
|
167 | 167 | return (Map<String, Object>) propertySource.getSource();
|
168 | 168 | }
|
169 | 169 |
|
170 |
| - @PreDestroy |
171 |
| - public void close() { |
| 170 | + @Override |
| 171 | + public void destroy() throws Exception { |
172 | 172 | if (this.server != null) {
|
173 | 173 | this.server.shutDown(true);
|
174 | 174 | }
|
|
0 commit comments