@@ -1027,11 +1027,11 @@ public synchronized void reloadConfiguration() {
10271027 properties = null ; // trigger reload
10281028 finalParameters .clear (); // clear site-limits
10291029 }
1030-
1030+
10311031 private synchronized void addResourceObject (Resource resource ) {
10321032 resources .add (resource ); // add to resources
10331033 restrictSystemProps |= resource .isParserRestricted ();
1034- reloadConfiguration ( );
1034+ loadProps ( properties , resources . size () - 1 , false );
10351035 }
10361036
10371037 private static final int MAX_SUBST = 20 ;
@@ -2872,12 +2872,27 @@ public Set<String> getFinalParameters() {
28722872 protected synchronized Properties getProps () {
28732873 if (properties == null ) {
28742874 properties = new Properties ();
2875- Map <String , String []> backup = updatingResource != null ?
2876- new ConcurrentHashMap <String , String []>(updatingResource ) : null ;
2877- loadResources (properties , resources , quietmode );
2875+ loadProps (properties , 0 , true );
2876+ }
2877+ return properties ;
2878+ }
28782879
2880+ /**
2881+ * Loads the resource at a given index into the properties.
2882+ * @param props the object containing the loaded properties.
2883+ * @param startIdx the index where the new resource has been added.
2884+ * @param fullReload flag whether we do complete reload of the conf instead
2885+ * of just loading the new resource.
2886+ */
2887+ private synchronized void loadProps (final Properties props ,
2888+ final int startIdx , final boolean fullReload ) {
2889+ if (props != null ) {
2890+ Map <String , String []> backup =
2891+ updatingResource != null
2892+ ? new ConcurrentHashMap <>(updatingResource ) : null ;
2893+ loadResources (props , resources , startIdx , fullReload , quietmode );
28792894 if (overlay != null ) {
2880- properties .putAll (overlay );
2895+ props .putAll (overlay );
28812896 if (backup != null ) {
28822897 for (Map .Entry <Object , Object > item : overlay .entrySet ()) {
28832898 String key = (String ) item .getKey ();
@@ -2889,7 +2904,6 @@ protected synchronized Properties getProps() {
28892904 }
28902905 }
28912906 }
2892- return properties ;
28932907 }
28942908
28952909 /**
@@ -2991,14 +3005,16 @@ private XMLStreamReader parse(InputStream is, String systemIdStr,
29913005
29923006 private void loadResources (Properties properties ,
29933007 ArrayList <Resource > resources ,
3008+ int startIdx ,
3009+ boolean fullReload ,
29943010 boolean quiet ) {
2995- if (loadDefaults ) {
3011+ if (loadDefaults && fullReload ) {
29963012 for (String resource : defaultResources ) {
29973013 loadResource (properties , new Resource (resource , false ), quiet );
29983014 }
29993015 }
30003016
3001- for (int i = 0 ; i < resources .size (); i ++) {
3017+ for (int i = startIdx ; i < resources .size (); i ++) {
30023018 Resource ret = loadResource (properties , resources .get (i ), quiet );
30033019 if (ret != null ) {
30043020 resources .set (i , ret );
0 commit comments