@@ -642,36 +642,36 @@ private Properties loadConfigurationFromClasspath(String fileName) throws Illega
642642 try {
643643 // try root
644644 String currentClasspathSearchLocation = "/ (root)" ;
645- in = loaders [i ].getResourceAsStream (fileName );
645+ in = loaders [i ].getResourceAsStream (DefaultSearchPath . ROOT . toString () );
646646
647647 // try resourceDirectory folder
648648 if (in == null ) {
649649 currentClasspathSearchLocation = resourceDirectory + "/" ;
650- in = currentLoader .getResourceAsStream (resourceDirectory + "/" + fileName );
650+ in = currentLoader .getResourceAsStream (DefaultSearchPath . RESOURCE_DIRECTORY + fileName );
651651 }
652652
653653 // try .esapi folder. Look here first for backward compatibility.
654654 if (in == null ) {
655655 currentClasspathSearchLocation = ".esapi/" ;
656- in = currentLoader .getResourceAsStream (".esapi/" + fileName );
656+ in = currentLoader .getResourceAsStream (DefaultSearchPath . DOT_ESAPI + fileName );
657657 }
658658
659659 // try esapi folder (new directory)
660660 if (in == null ) {
661661 currentClasspathSearchLocation = "esapi/" ;
662- in = currentLoader .getResourceAsStream ("esapi/" + fileName );
662+ in = currentLoader .getResourceAsStream (DefaultSearchPath . ESAPI + fileName );
663663 }
664664
665665 // try resources folder
666666 if (in == null ) {
667667 currentClasspathSearchLocation = "resources/" ;
668- in = currentLoader .getResourceAsStream ("resources/" + fileName );
668+ in = currentLoader .getResourceAsStream (DefaultSearchPath . RESOURCES + fileName );
669669 }
670670
671671 // try src/main/resources folder
672672 if (in == null ) {
673673 currentClasspathSearchLocation = "src/main/resources/" ;
674- in = currentLoader .getResourceAsStream ("src/main/resources/" + fileName );
674+ in = currentLoader .getResourceAsStream (DefaultSearchPath . SRC_MAIN_RESOURCES + fileName );
675675 }
676676
677677 // now load the properties
@@ -1347,4 +1347,26 @@ protected boolean shouldPrintProperties() {
13471347 protected Properties getESAPIProperties () {
13481348 return properties ;
13491349 }
1350+
1351+ public enum DefaultSearchPath {
1352+
1353+ RESOURCE_DIRECTORY ("resourceDirectory/" ),
1354+ SRC_MAIN_RESOURCES ("src/main/resources/" ),
1355+ ROOT ("/" ),
1356+ DOT_ESAPI (".esapi/" ),
1357+ ESAPI ("esapi/" ),
1358+ RESOURCES ("resources/" );
1359+
1360+ private final String path ;
1361+
1362+
1363+
1364+ private DefaultSearchPath (String s ){
1365+ this .path = s ;
1366+ }
1367+
1368+ public String value (){
1369+ return path ;
1370+ }
1371+ }
13501372}
0 commit comments