@@ -33,11 +33,15 @@ final class MemcachedConfigurationBuilder {
3333 */
3434 private static final MemcachedConfigurationBuilder INSTANCE = new MemcachedConfigurationBuilder ();
3535
36+ private static final String SYSTEM_PROPERTY_MEMCACHED_PROPERTIES_FILENAME = "memcached.properties.filename" ;
37+
3638 /**
3739 *
3840 */
3941 private static final String MEMCACHED_RESOURCE = "memcached.properties" ;
4042
43+ private final String memcachedPropertiesFilename ;
44+
4145 /**
4246 * Return this class instance.
4347 *
@@ -56,6 +60,8 @@ public static MemcachedConfigurationBuilder getInstance() {
5660 * Hidden constructor, this class can't be instantiated.
5761 */
5862 private MemcachedConfigurationBuilder () {
63+ memcachedPropertiesFilename = System .getProperty (SYSTEM_PROPERTY_MEMCACHED_PROPERTIES_FILENAME , MEMCACHED_RESOURCE );
64+
5965 settersRegistry .add (new StringPropertySetter ("org.mybatis.caches.memcached.keyprefix" , "keyPrefix" , "_mybatis_" ));
6066
6167 settersRegistry .add (new IntegerPropertySetter ("org.mybatis.caches.memcached.expiration" , "expiration" , 60 * 60 * 24 * 30 ));
@@ -88,13 +94,13 @@ public MemcachedConfiguration parseConfiguration(ClassLoader classLoader) {
8894 Properties config = new Properties ();
8995
9096 // load the properties specified from /memcached.properties, if present
91- InputStream input = classLoader .getResourceAsStream (MEMCACHED_RESOURCE );
97+ InputStream input = classLoader .getResourceAsStream (memcachedPropertiesFilename );
9298 if (input != null ) {
9399 try {
94100 config .load (input );
95101 } catch (IOException e ) {
96102 throw new RuntimeException ("An error occurred while reading classpath property '"
97- + MEMCACHED_RESOURCE
103+ + memcachedPropertiesFilename
98104 + "', see nested exceptions" , e );
99105 } finally {
100106 try {
0 commit comments