@@ -1005,11 +1005,11 @@ public synchronized void reloadConfiguration() {
10051005 properties = null ; // trigger reload
10061006 finalParameters .clear (); // clear site-limits
10071007 }
1008-
1008+
10091009 private synchronized void addResourceObject (Resource resource ) {
10101010 resources .add (resource ); // add to resources
10111011 restrictSystemProps |= resource .isParserRestricted ();
1012- reloadConfiguration ( );
1012+ loadProps ( properties , resources . size () - 1 , false );
10131013 }
10141014
10151015 private static final int MAX_SUBST = 20 ;
@@ -2843,12 +2843,27 @@ public Set<String> getFinalParameters() {
28432843 protected synchronized Properties getProps () {
28442844 if (properties == null ) {
28452845 properties = new Properties ();
2846- Map <String , String []> backup = updatingResource != null ?
2847- new ConcurrentHashMap <String , String []>(updatingResource ) : null ;
2848- loadResources (properties , resources , quietmode );
2846+ loadProps (properties , 0 , true );
2847+ }
2848+ return properties ;
2849+ }
28492850
2851+ /**
2852+ * Loads the resource at a given index into the properties.
2853+ * @param props the object containing the loaded properties.
2854+ * @param startIdx the index where the new resource has been added.
2855+ * @param fullReload flag whether we do complete reload of the conf instead
2856+ * of just loading the new resource.
2857+ */
2858+ private synchronized void loadProps (final Properties props ,
2859+ final int startIdx , final boolean fullReload ) {
2860+ if (props != null ) {
2861+ Map <String , String []> backup =
2862+ updatingResource != null
2863+ ? new ConcurrentHashMap <>(updatingResource ) : null ;
2864+ loadResources (props , resources , startIdx , fullReload , quietmode );
28502865 if (overlay != null ) {
2851- properties .putAll (overlay );
2866+ props .putAll (overlay );
28522867 if (backup != null ) {
28532868 for (Map .Entry <Object , Object > item : overlay .entrySet ()) {
28542869 String key = (String ) item .getKey ();
@@ -2860,7 +2875,6 @@ protected synchronized Properties getProps() {
28602875 }
28612876 }
28622877 }
2863- return properties ;
28642878 }
28652879
28662880 /**
@@ -2962,14 +2976,16 @@ private XMLStreamReader parse(InputStream is, String systemIdStr,
29622976
29632977 private void loadResources (Properties properties ,
29642978 ArrayList <Resource > resources ,
2979+ int startIdx ,
2980+ boolean fullReload ,
29652981 boolean quiet ) {
2966- if (loadDefaults ) {
2982+ if (loadDefaults && fullReload ) {
29672983 for (String resource : defaultResources ) {
29682984 loadResource (properties , new Resource (resource , false ), quiet );
29692985 }
29702986 }
29712987
2972- for (int i = 0 ; i < resources .size (); i ++) {
2988+ for (int i = startIdx ; i < resources .size (); i ++) {
29732989 Resource ret = loadResource (properties , resources .get (i ), quiet );
29742990 if (ret != null ) {
29752991 resources .set (i , ret );
0 commit comments