42
42
import org .springframework .amqp .rabbit .support .RabbitExceptionTranslator ;
43
43
import org .springframework .beans .factory .config .AbstractFactoryBean ;
44
44
import org .springframework .core .io .Resource ;
45
+ import org .springframework .core .io .ResourceLoader ;
45
46
import org .springframework .core .io .support .PathMatchingResourcePatternResolver ;
46
47
import org .springframework .lang .Nullable ;
48
+ import org .springframework .util .Assert ;
47
49
import org .springframework .util .StringUtils ;
48
50
49
51
import com .rabbitmq .client .ConnectionFactory ;
@@ -122,7 +124,7 @@ public class RabbitConnectionFactoryBean extends AbstractFactoryBean<ConnectionF
122
124
123
125
private final Properties sslProperties = new Properties ();
124
126
125
- private final PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver ();
127
+ private ResourceLoader resourceLoader = new PathMatchingResourcePatternResolver ();
126
128
127
129
private boolean useSSL ;
128
130
@@ -695,6 +697,27 @@ public void setTrustStoreAlgorithm(String trustStoreAlgorithm) {
695
697
this .trustStoreAlgorithm = trustStoreAlgorithm ;
696
698
}
697
699
700
+ /**
701
+ * Get the resource loader; used to resolve the key store and trust store {@link Resource}s
702
+ * to input streams.
703
+ * @return the resource loader.
704
+ * @since 2.3
705
+ */
706
+ protected ResourceLoader getResourceLoader () {
707
+ return this .resourceLoader ;
708
+ }
709
+
710
+ /**
711
+ * Set the resource loader; used to resolve the key store and trust store {@link Resource}s
712
+ * to input streams.
713
+ * @param resourceLoader the resource loader.
714
+ * @since 2.3
715
+ */
716
+ public void setResourceLoader (ResourceLoader resourceLoader ) {
717
+ Assert .notNull (resourceLoader , "'resourceLoader' cannot be null" );
718
+ this .resourceLoader = resourceLoader ;
719
+ }
720
+
698
721
/**
699
722
* Access the connection factory to set any other properties not supported by
700
723
* this factory bean.
@@ -791,7 +814,7 @@ protected KeyManager[] configureKeyManagers() throws KeyStoreException, IOExcept
791
814
KeyManager [] keyManagers = null ;
792
815
if (StringUtils .hasText (keyStoreName ) || this .keyStoreResource != null ) {
793
816
Resource resource = this .keyStoreResource != null ? this .keyStoreResource
794
- : this .resolver .getResource (keyStoreName );
817
+ : this .resourceLoader .getResource (keyStoreName );
795
818
KeyStore ks = KeyStore .getInstance (storeType );
796
819
ks .load (resource .getInputStream (), keyPassphrase );
797
820
KeyManagerFactory kmf = KeyManagerFactory .getInstance (this .keyStoreAlgorithm );
@@ -814,7 +837,7 @@ protected TrustManager[] configureTrustManagers()
814
837
TrustManager [] trustManagers = null ;
815
838
if (StringUtils .hasText (trustStoreName ) || this .trustStoreResource != null ) {
816
839
Resource resource = this .trustStoreResource != null ? this .trustStoreResource
817
- : this .resolver .getResource (trustStoreName );
840
+ : this .resourceLoader .getResource (trustStoreName );
818
841
KeyStore tks = KeyStore .getInstance (storeType );
819
842
tks .load (resource .getInputStream (), trustPassphrase );
820
843
TrustManagerFactory tmf = TrustManagerFactory .getInstance (this .trustStoreAlgorithm );
0 commit comments