Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@
import org.springframework.amqp.rabbit.support.RabbitExceptionTranslator;
import org.springframework.beans.factory.config.AbstractFactoryBean;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

import com.rabbitmq.client.ConnectionFactory;
Expand Down Expand Up @@ -122,7 +124,7 @@ public class RabbitConnectionFactoryBean extends AbstractFactoryBean<ConnectionF

private final Properties sslProperties = new Properties();

private final PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
private ResourceLoader resourceLoader = new PathMatchingResourcePatternResolver();

private boolean useSSL;

Expand Down Expand Up @@ -695,6 +697,27 @@ public void setTrustStoreAlgorithm(String trustStoreAlgorithm) {
this.trustStoreAlgorithm = trustStoreAlgorithm;
}

/**
* Get the resource loader; used to resolve the key store and trust store {@link Resource}s
* to input streams.
* @return the resource loader.
* @since 2.3
*/
protected ResourceLoader getResourceLoader() {
return this.resourceLoader;
}

/**
* Set the resource loader; used to resolve the key store and trust store {@link Resource}s
* to input streams.
* @param resourceLoader the resource loader.
* @since 2.3
*/
public void setResourceLoader(ResourceLoader resourceLoader) {
Assert.notNull(resourceLoader, "'resourceLoader' cannot be null");
this.resourceLoader = resourceLoader;
}

/**
* Access the connection factory to set any other properties not supported by
* this factory bean.
Expand Down Expand Up @@ -791,7 +814,7 @@ protected KeyManager[] configureKeyManagers() throws KeyStoreException, IOExcept
KeyManager[] keyManagers = null;
if (StringUtils.hasText(keyStoreName) || this.keyStoreResource != null) {
Resource resource = this.keyStoreResource != null ? this.keyStoreResource
: this.resolver.getResource(keyStoreName);
: this.resourceLoader.getResource(keyStoreName);
KeyStore ks = KeyStore.getInstance(storeType);
ks.load(resource.getInputStream(), keyPassphrase);
KeyManagerFactory kmf = KeyManagerFactory.getInstance(this.keyStoreAlgorithm);
Expand All @@ -814,7 +837,7 @@ protected TrustManager[] configureTrustManagers()
TrustManager[] trustManagers = null;
if (StringUtils.hasText(trustStoreName) || this.trustStoreResource != null) {
Resource resource = this.trustStoreResource != null ? this.trustStoreResource
: this.resolver.getResource(trustStoreName);
: this.resourceLoader.getResource(trustStoreName);
KeyStore tks = KeyStore.getInstance(storeType);
tks.load(resource.getInputStream(), trustPassphrase);
TrustManagerFactory tmf = TrustManagerFactory.getInstance(this.trustStoreAlgorithm);
Expand Down