src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogManager.java

Print this page


   1 /*
   2  * reserved comment block
   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 // CatalogManager.java - Access CatalogManager.properties
   6 
   7 /*
   8  * Copyright 2001-2004 The Apache Software Foundation or its licensors,
   9  * as applicable.
  10  *
  11  * Licensed under the Apache License, Version 2.0 (the "License");
  12  * you may not use this file except in compliance with the License.
  13  * You may obtain a copy of the License at
  14  *
  15  *      http://www.apache.org/licenses/LICENSE-2.0
  16  *
  17  * Unless required by applicable law or agreed to in writing, software
  18  * distributed under the License is distributed on an "AS IS" BASIS,
  19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  20  * See the License for the specific language governing permissions and
  21  * limitations under the License.
  22  */
  23 
  24 package com.sun.org.apache.xml.internal.resolver;
  25 
  26 import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
  27 import com.sun.org.apache.xml.internal.resolver.helpers.BootstrapResolver;
  28 import com.sun.org.apache.xml.internal.resolver.helpers.Debug;
  29 import java.io.InputStream;
  30 import java.net.MalformedURLException;
  31 import java.net.URL;
  32 import java.util.MissingResourceException;
  33 import java.util.PropertyResourceBundle;
  34 import java.util.ResourceBundle;


 107  * <tr>
 108  * <td>xml.catalog.className</td>
 109  * <td>catalog-class-name</td>
 110  * <td>If you're using the convenience classes
 111  * <tt>com.sun.org.apache.xml.internal.resolver.tools.*</tt>), this setting
 112  * allows you to specify an alternate class name to use for the underlying
 113  * catalog.</td>
 114  * </tr>
 115  * </tbody>
 116  * </table>
 117  *
 118  * @see Catalog
 119  *
 120  * @author Norman Walsh
 121  * <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
 122  *
 123  * @version 1.0
 124  */
 125 
 126 public class CatalogManager {
 127   private static String pFiles         = "xml.catalog.files";
 128   private static String pVerbosity     = "xml.catalog.verbosity";
 129   private static String pPrefer        = "xml.catalog.prefer";
 130   private static String pStatic        = "xml.catalog.staticCatalog";
 131   private static String pAllowPI       = "xml.catalog.allowPI";
 132   private static String pClassname     = "xml.catalog.className";
 133   private static String pIgnoreMissing = "xml.catalog.ignoreMissing";
 134 
 135   /** A static CatalogManager instance for sharing */
 136   private static CatalogManager staticManager = new CatalogManager();
 137 
 138   /** The bootstrap resolver to use when loading XML Catalogs. */
 139   private BootstrapResolver bResolver = new BootstrapResolver();
 140 
 141   /** Flag to ignore missing property files and/or properties */
 142   private boolean ignoreMissingProperties
 143     = (SecuritySupport.getSystemProperty(pIgnoreMissing) != null
 144        || SecuritySupport.getSystemProperty(pFiles) != null);
 145 
 146   /** Holds the resources after they are loaded from the file. */
 147   private ResourceBundle resources;
 148 
 149   /** The name of the CatalogManager properties file. */
 150   private String propertyFile = "CatalogManager.properties";
 151 
 152   /** The location of the propertyFile */
 153   private URL propertyFileURI = null;
 154 
 155   /** Default catalog files list. */
 156   private String defaultCatalogFiles = "./xcatalog";


 163 
 164   /** Default verbosity level if there is no property setting for it. */
 165   private int defaultVerbosity = 1;
 166 
 167   /** Current verbosity level. */
 168   private Integer verbosity = null;
 169 
 170   /** Default preference setting. */
 171   private boolean defaultPreferPublic = true;
 172 
 173   /** Current preference setting. */
 174   private Boolean preferPublic = null;
 175 
 176   /** Default setting of the static catalog flag. */
 177   private boolean defaultUseStaticCatalog = true;
 178 
 179   /** Current setting of the static catalog flag. */
 180   private Boolean useStaticCatalog = null;
 181 
 182   /** The static catalog used by this manager. */
 183   private static Catalog staticCatalog = null;
 184 
 185   /** Default setting of the oasisXMLCatalogPI flag. */
 186   private boolean defaultOasisXMLCatalogPI = true;
 187 
 188   /** Current setting of the oasisXMLCatalogPI flag. */
 189   private Boolean oasisXMLCatalogPI = null;
 190 
 191   /** Default setting of the relativeCatalogs flag. */
 192   private boolean defaultRelativeCatalogs = true;
 193 
 194   /** Current setting of the relativeCatalogs flag. */
 195   private Boolean relativeCatalogs = null;
 196 
 197   /** Current catalog class name. */
 198   private String catalogClassName = null;
 199     /**
 200      * Indicates whether implementation parts should use
 201      *   service loader (or similar).
 202      * Note the default value (false) is the safe option..
 203      */


 214   public CatalogManager() {
 215     init();
 216   }
 217 
 218   /** Constructor that specifies an explicit property file. */
 219   public CatalogManager(String propertyFile) {
 220     this.propertyFile = propertyFile;
 221     init();
 222   }
 223 
 224   private void init() {
 225     debug = new Debug();
 226     // Note that we don't setDebug() here; we do that lazily. Either the
 227     // user will set it explicitly, or we'll do it automagically if they
 228     // read from the propertyFile for some other reason. That way, there's
 229     // no attempt to read from the file before the caller has had a chance
 230     // to avoid it.
 231     if (System.getSecurityManager() == null) {
 232         useServicesMechanism = true;
 233     }



 234   }
 235   /** Set the bootstrap resolver.*/



 236   public void setBootstrapResolver(BootstrapResolver resolver) {
 237     bResolver = resolver;
 238   }
 239 
 240   /** Get the bootstrap resolver.*/


 241   public BootstrapResolver getBootstrapResolver() {
 242     return bResolver;
 243   }
 244 














 245   /**
 246    * Load the properties from the propertyFile and build the
 247    * resources from it.
 248    */
 249   private synchronized void readProperties() {
 250     try {
 251       propertyFileURI = CatalogManager.class.getResource("/"+propertyFile);
 252       InputStream in =
 253         CatalogManager.class.getResourceAsStream("/"+propertyFile);
 254       if (in==null) {
 255         if (!ignoreMissingProperties) {
 256           System.err.println("Cannot find "+propertyFile);
 257           // there's no reason to give this warning more than once
 258           ignoreMissingProperties = true;
 259         }
 260         return;
 261       }
 262       resources = new PropertyResourceBundle(in);
 263     } catch (MissingResourceException mre) {
 264       if (!ignoreMissingProperties) {


 424    *
 425    * <p>This property is used when the catalogFiles property is
 426    * interrogated. If true, then relative catalog entry file names
 427    * are returned. If false, relative catalog entry file names are
 428    * made absolute with respect to the properties file before returning
 429    * them.</p>
 430    *
 431    * <p>This property <emph>only applies</emph> when the catalog files
 432    * come from a properties file. If they come from a system property or
 433    * the default list, they are never considered relative. (What would
 434    * they be relative to?)</p>
 435    *
 436    * <p>In the properties, a value of 'yes', 'true', or '1' is considered
 437    * true, anything else is false.</p>
 438    *
 439    * @return The relativeCatalogs setting from the propertyFile or the
 440    * defaultRelativeCatalogs.
 441    */
 442   public boolean getRelativeCatalogs () {
 443     if (relativeCatalogs == null) {
 444       relativeCatalogs = new Boolean(queryRelativeCatalogs());
 445     }
 446 
 447     return relativeCatalogs.booleanValue();
 448   }
 449 
 450   /**
 451    * Set the relativeCatalogs setting.
 452    *
 453    * @see #getRelativeCatalogs()
 454    */
 455   public void setRelativeCatalogs (boolean relative) {
 456     relativeCatalogs = new Boolean(relative);
 457   }
 458 
 459   /**
 460    * Get the relativeCatalogs setting.
 461    *
 462    * @deprecated No longer static; use get/set methods.
 463    */
 464   public boolean relativeCatalogs () {
 465     return getRelativeCatalogs();
 466   }
 467 
 468   /**
 469    * Obtain the list of catalog files from the properties.
 470    *
 471    * @return A semicolon delimited list of catlog file URIs
 472    */
 473   private String queryCatalogFiles () {
 474     String catalogList = SecuritySupport.getSystemProperty(pFiles);
 475     fromPropertiesFile = false;
 476 


 565         prefer = resources.getString("prefer");
 566       } catch (MissingResourceException e) {
 567         return defaultPreferPublic;
 568       }
 569     }
 570 
 571     if (prefer == null) {
 572       return defaultPreferPublic;
 573     }
 574 
 575     return (prefer.equalsIgnoreCase("public"));
 576   }
 577 
 578   /**
 579    * Return the current prefer public setting.
 580    *
 581    * @return True if public identifiers are preferred.
 582    */
 583   public boolean getPreferPublic () {
 584     if (preferPublic == null) {
 585       preferPublic = new Boolean(queryPreferPublic());
 586     }
 587     return preferPublic.booleanValue();
 588   }
 589 
 590   /**
 591    * Set the prefer public setting.
 592    */
 593   public void setPreferPublic (boolean preferPublic) {
 594     this.preferPublic = new Boolean(preferPublic);
 595   }
 596 
 597   /**
 598    * Return the current prefer public setting.
 599    *
 600    * @return True if public identifiers are preferred.
 601    *
 602    * @deprecated No longer static; use get/set methods.
 603    */
 604   public boolean preferPublic () {
 605     return getPreferPublic();
 606   }
 607 
 608   /**
 609    * Obtain the static-catalog setting from the properties.
 610    *
 611    * <p>In the properties, a value of 'yes', 'true', or '1' is considered
 612    * true, anything else is false.</p>
 613    *
 614    * @return The static-catalog setting from the propertyFile or the


 624         staticCatalog = resources.getString("static-catalog");
 625       } catch (MissingResourceException e) {
 626         return defaultUseStaticCatalog;
 627       }
 628     }
 629 
 630     if (staticCatalog == null) {
 631       return defaultUseStaticCatalog;
 632     }
 633 
 634     return (staticCatalog.equalsIgnoreCase("true")
 635             || staticCatalog.equalsIgnoreCase("yes")
 636             || staticCatalog.equalsIgnoreCase("1"));
 637   }
 638 
 639   /**
 640    * Get the current use static catalog setting.
 641    */
 642   public boolean getUseStaticCatalog() {
 643     if (useStaticCatalog == null) {
 644       useStaticCatalog = new Boolean(queryUseStaticCatalog());
 645     }
 646 
 647     return useStaticCatalog.booleanValue();
 648   }
 649 
 650   /**
 651    * Set the use static catalog setting.
 652    */
 653   public void setUseStaticCatalog(boolean useStatic) {
 654     useStaticCatalog = new Boolean(useStatic);
 655   }
 656 
 657   /**
 658    * Get the current use static catalog setting.
 659    *
 660    * @deprecated No longer static; use get/set methods.
 661    */
 662   public boolean staticCatalog() {
 663     return getUseStaticCatalog();
 664   }
 665 
 666   /**
 667    * Get a new catalog instance.
 668    *
 669    * This method always returns a new instance of the underlying catalog class.
 670    */
 671   public Catalog getPrivateCatalog() {
 672     Catalog catalog = staticCatalog;
 673 
 674     if (useStaticCatalog == null) {
 675       useStaticCatalog = new Boolean(getUseStaticCatalog());
 676     }
 677 
 678     if (catalog == null || !useStaticCatalog.booleanValue()) {
 679 
 680       try {
 681         String catalogClassName = getCatalogClassName();
 682 
 683         if (catalogClassName == null) {
 684           catalog = new Catalog();
 685         } else {
 686           try {
 687             catalog = (Catalog) ReflectUtil.forName(catalogClassName).newInstance();
 688           } catch (ClassNotFoundException cnfe) {
 689             debug.message(1,"Catalog class named '"
 690                           + catalogClassName
 691                           + "' could not be found. Using default.");
 692             catalog = new Catalog();
 693           } catch (ClassCastException cnfe) {
 694             debug.message(1,"Class named '"
 695                           + catalogClassName


 706       }
 707 
 708       if (useStaticCatalog.booleanValue()) {
 709         staticCatalog = catalog;
 710       }
 711     }
 712 
 713     return catalog;
 714   }
 715 
 716   /**
 717    * Get a catalog instance.
 718    *
 719    * If this manager uses static catalogs, the same static catalog will
 720    * always be returned. Otherwise a new catalog will be returned.
 721    */
 722   public Catalog getCatalog() {
 723     Catalog catalog = staticCatalog;
 724 
 725     if (useStaticCatalog == null) {
 726       useStaticCatalog = new Boolean(getUseStaticCatalog());
 727     }
 728 
 729     if (catalog == null || !useStaticCatalog.booleanValue()) {
 730       catalog = getPrivateCatalog();
 731       if (useStaticCatalog.booleanValue()) {
 732         staticCatalog = catalog;
 733       }
 734     }
 735 
 736     return catalog;
 737   }
 738 
 739   /**
 740    * <p>Obtain the oasisXMLCatalogPI setting from the properties.</p>
 741    *
 742    * <p>In the properties, a value of 'yes', 'true', or '1' is considered
 743    * true, anything else is false.</p>
 744    *
 745    * @return The oasisXMLCatalogPI setting from the propertyFile or the
 746    * defaultOasisXMLCatalogPI.


 755         allow = resources.getString("allow-oasis-xml-catalog-pi");
 756       } catch (MissingResourceException e) {
 757         return defaultOasisXMLCatalogPI;
 758       }
 759     }
 760 
 761     if (allow == null) {
 762       return defaultOasisXMLCatalogPI;
 763     }
 764 
 765     return (allow.equalsIgnoreCase("true")
 766             || allow.equalsIgnoreCase("yes")
 767             || allow.equalsIgnoreCase("1"));
 768   }
 769 
 770   /**
 771    * Get the current XML Catalog PI setting.
 772    */
 773   public boolean getAllowOasisXMLCatalogPI () {
 774     if (oasisXMLCatalogPI == null) {
 775       oasisXMLCatalogPI = new Boolean(queryAllowOasisXMLCatalogPI());
 776     }
 777 
 778     return oasisXMLCatalogPI.booleanValue();
 779   }
 780 
 781   public boolean useServicesMechanism() {
 782       return useServicesMechanism;
 783   }
 784   /**
 785    * Set the XML Catalog PI setting
 786    */
 787   public void setAllowOasisXMLCatalogPI(boolean allowPI) {
 788     oasisXMLCatalogPI = new Boolean(allowPI);
 789   }
 790 
 791   /**
 792    * Get the current XML Catalog PI setting.
 793    *
 794    * @deprecated No longer static; use get/set methods.
 795    */
 796   public boolean allowOasisXMLCatalogPI() {
 797     return getAllowOasisXMLCatalogPI();
 798   }
 799 
 800   /**
 801    * Obtain the Catalog class name setting from the properties.
 802    *
 803    */
 804   public String queryCatalogClassName () {
 805     String className = SecuritySupport.getSystemProperty(pClassname);
 806 
 807     if (className == null) {
 808       if (resources==null) readProperties();


   1 /*
   2  * Licensed to the Apache Software Foundation (ASF) under one or more
   3  * contributor license agreements.  See the NOTICE file distributed with
   4  * this work for additional information regarding copyright ownership.
   5  * The ASF licenses this file to You under the Apache License, Version 2.0
   6  * (the "License"); you may not use this file except in compliance with
   7  * the License.  You may obtain a copy of the License at


   8  *




   9  *      http://www.apache.org/licenses/LICENSE-2.0
  10  *
  11  * Unless required by applicable law or agreed to in writing, software
  12  * distributed under the License is distributed on an "AS IS" BASIS,
  13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14  * See the License for the specific language governing permissions and
  15  * limitations under the License.
  16  */
  17 
  18 package com.sun.org.apache.xml.internal.resolver;
  19 
  20 import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
  21 import com.sun.org.apache.xml.internal.resolver.helpers.BootstrapResolver;
  22 import com.sun.org.apache.xml.internal.resolver.helpers.Debug;
  23 import java.io.InputStream;
  24 import java.net.MalformedURLException;
  25 import java.net.URL;
  26 import java.util.MissingResourceException;
  27 import java.util.PropertyResourceBundle;
  28 import java.util.ResourceBundle;


 101  * <tr>
 102  * <td>xml.catalog.className</td>
 103  * <td>catalog-class-name</td>
 104  * <td>If you're using the convenience classes
 105  * <tt>com.sun.org.apache.xml.internal.resolver.tools.*</tt>), this setting
 106  * allows you to specify an alternate class name to use for the underlying
 107  * catalog.</td>
 108  * </tr>
 109  * </tbody>
 110  * </table>
 111  *
 112  * @see Catalog
 113  *
 114  * @author Norman Walsh
 115  * <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
 116  *
 117  * @version 1.0
 118  */
 119 
 120 public class CatalogManager {
 121     private static final String pFiles         = "xml.catalog.files";
 122     private static final String pVerbosity     = "xml.catalog.verbosity";
 123     private static final String pPrefer        = "xml.catalog.prefer";
 124     private static final String pStatic        = "xml.catalog.staticCatalog";
 125     private static final String pAllowPI       = "xml.catalog.allowPI";
 126     private static final String pClassname     = "xml.catalog.className";
 127     private static final String pIgnoreMissing = "xml.catalog.ignoreMissing";
 128 
 129     /** A static CatalogManager instance for sharing */
 130     private static final CatalogManager staticManager = new CatalogManager();
 131 
 132     /** The bootstrap resolver to use when loading XML Catalogs. */
 133     private BootstrapResolver bResolver = new BootstrapResolver();
 134 
 135     /** Flag to ignore missing property files and/or properties */
 136     private boolean ignoreMissingProperties
 137     = (SecuritySupport.getSystemProperty(pIgnoreMissing) != null
 138     || SecuritySupport.getSystemProperty(pFiles) != null);
 139 
 140     /** Holds the resources after they are loaded from the file. */
 141     private ResourceBundle resources;
 142 
 143     /** The name of the CatalogManager properties file. */
 144     private String propertyFile = "CatalogManager.properties";
 145 
 146     /** The location of the propertyFile */
 147     private URL propertyFileURI = null;
 148 
 149     /** Default catalog files list. */
 150     private String defaultCatalogFiles = "./xcatalog";


 157 
 158     /** Default verbosity level if there is no property setting for it. */
 159     private int defaultVerbosity = 1;
 160 
 161     /** Current verbosity level. */
 162     private Integer verbosity = null;
 163 
 164     /** Default preference setting. */
 165     private boolean defaultPreferPublic = true;
 166 
 167     /** Current preference setting. */
 168     private Boolean preferPublic = null;
 169 
 170     /** Default setting of the static catalog flag. */
 171     private boolean defaultUseStaticCatalog = true;
 172 
 173     /** Current setting of the static catalog flag. */
 174     private Boolean useStaticCatalog = null;
 175 
 176     /** The static catalog used by this manager. */
 177     private static volatile Catalog staticCatalog = null;
 178 
 179     /** Default setting of the oasisXMLCatalogPI flag. */
 180     private boolean defaultOasisXMLCatalogPI = true;
 181 
 182     /** Current setting of the oasisXMLCatalogPI flag. */
 183     private Boolean oasisXMLCatalogPI = null;
 184 
 185     /** Default setting of the relativeCatalogs flag. */
 186     private boolean defaultRelativeCatalogs = true;
 187 
 188     /** Current setting of the relativeCatalogs flag. */
 189     private Boolean relativeCatalogs = null;
 190 
 191     /** Current catalog class name. */
 192     private String catalogClassName = null;
 193     /**
 194      * Indicates whether implementation parts should use
 195      *   service loader (or similar).
 196      * Note the default value (false) is the safe option..
 197      */


 208     public CatalogManager() {
 209         init();
 210     }
 211 
 212     /** Constructor that specifies an explicit property file. */
 213     public CatalogManager(String propertyFile) {
 214         this.propertyFile = propertyFile;
 215         init();
 216   }
 217 
 218   private void init() {
 219         debug = new Debug();
 220     // Note that we don't setDebug() here; we do that lazily. Either the
 221     // user will set it explicitly, or we'll do it automagically if they
 222     // read from the propertyFile for some other reason. That way, there's
 223     // no attempt to read from the file before the caller has had a chance
 224     // to avoid it.
 225     if (System.getSecurityManager() == null) {
 226         useServicesMechanism = true;
 227     }
 228         // Make sure verbosity is set by xml.catalog.verbosity sysprop
 229         // setting, if defined.
 230         queryVerbosityFromSysProp();
 231     }
 232 
 233     /** Set the bootstrap resolver
 234      * @param resolver the bootstrap resolver
 235      */
 236     public void setBootstrapResolver(BootstrapResolver resolver) {
 237         bResolver = resolver;
 238     }
 239 
 240     /** Get the bootstrap resolver
 241      * @return the bootstrap resolver
 242      */
 243     public BootstrapResolver getBootstrapResolver() {
 244         return bResolver;
 245     }
 246 
 247     /** Query system property for verbosity level. */
 248     private void queryVerbosityFromSysProp() {
 249         String verbStr = SecuritySupport.getSystemProperty(pVerbosity);
 250         if (verbStr != null) {
 251             try {
 252                 int verb = Integer.parseInt(verbStr.trim());
 253                 verbosity = new Integer(verb);
 254                 debug.setDebug(verb);
 255             } catch (Exception e) {
 256                 System.err.println("Cannot parse verbosity: \"" + verbStr + "\"");
 257             }
 258         }
 259     }
 260 
 261     /**
 262      * Load the properties from the propertyFile and build the
 263      * resources from it.
 264      */
 265     private synchronized void readProperties() {
 266         try {
 267             propertyFileURI = CatalogManager.class.getResource("/"+propertyFile);
 268             InputStream in =
 269                     CatalogManager.class.getResourceAsStream("/"+propertyFile);
 270             if (in==null) {
 271                 if (!ignoreMissingProperties) {
 272                     System.err.println("Cannot find "+propertyFile);
 273                     // there's no reason to give this warning more than once
 274                     ignoreMissingProperties = true;
 275                 }
 276                 return;
 277             }
 278             resources = new PropertyResourceBundle(in);
 279         } catch (MissingResourceException mre) {
 280             if (!ignoreMissingProperties) {


 440      *
 441      * <p>This property is used when the catalogFiles property is
 442      * interrogated. If true, then relative catalog entry file names
 443      * are returned. If false, relative catalog entry file names are
 444      * made absolute with respect to the properties file before returning
 445      * them.</p>
 446      *
 447      * <p>This property <emph>only applies</emph> when the catalog files
 448      * come from a properties file. If they come from a system property or
 449      * the default list, they are never considered relative. (What would
 450      * they be relative to?)</p>
 451      *
 452      * <p>In the properties, a value of 'yes', 'true', or '1' is considered
 453      * true, anything else is false.</p>
 454      *
 455      * @return The relativeCatalogs setting from the propertyFile or the
 456      * defaultRelativeCatalogs.
 457      */
 458     public boolean getRelativeCatalogs () {
 459         if (relativeCatalogs == null) {
 460             relativeCatalogs = queryRelativeCatalogs() ? Boolean.TRUE : Boolean.FALSE;
 461         }
 462 
 463         return relativeCatalogs.booleanValue();
 464     }
 465 
 466     /**
 467      * Set the relativeCatalogs setting.
 468      *
 469      * @see #getRelativeCatalogs()
 470      */
 471     public void setRelativeCatalogs (boolean relative) {
 472         relativeCatalogs = relative ? Boolean.TRUE : Boolean.FALSE;
 473     }
 474 
 475     /**
 476      * Get the relativeCatalogs setting.
 477      *
 478      * @deprecated No longer static; use get/set methods.
 479      */
 480     public boolean relativeCatalogs () {
 481         return getRelativeCatalogs();
 482     }
 483 
 484     /**
 485      * Obtain the list of catalog files from the properties.
 486      *
 487      * @return A semicolon delimited list of catlog file URIs
 488      */
 489     private String queryCatalogFiles () {
 490         String catalogList = SecuritySupport.getSystemProperty(pFiles);
 491         fromPropertiesFile = false;
 492 


 581                 prefer = resources.getString("prefer");
 582             } catch (MissingResourceException e) {
 583                 return defaultPreferPublic;
 584             }
 585         }
 586 
 587         if (prefer == null) {
 588             return defaultPreferPublic;
 589         }
 590 
 591         return (prefer.equalsIgnoreCase("public"));
 592     }
 593 
 594     /**
 595      * Return the current prefer public setting.
 596      *
 597      * @return True if public identifiers are preferred.
 598      */
 599     public boolean getPreferPublic () {
 600         if (preferPublic == null) {
 601             preferPublic = queryPreferPublic() ? Boolean.TRUE : Boolean.FALSE;
 602         }
 603         return preferPublic.booleanValue();
 604     }
 605 
 606     /**
 607      * Set the prefer public setting.
 608      */
 609     public void setPreferPublic (boolean preferPublic) {
 610         this.preferPublic = preferPublic ? Boolean.TRUE : Boolean.FALSE;
 611     }
 612 
 613     /**
 614      * Return the current prefer public setting.
 615      *
 616      * @return True if public identifiers are preferred.
 617      *
 618      * @deprecated No longer static; use get/set methods.
 619      */
 620     public boolean preferPublic () {
 621         return getPreferPublic();
 622     }
 623 
 624     /**
 625      * Obtain the static-catalog setting from the properties.
 626      *
 627      * <p>In the properties, a value of 'yes', 'true', or '1' is considered
 628      * true, anything else is false.</p>
 629      *
 630      * @return The static-catalog setting from the propertyFile or the


 640                 staticCatalog = resources.getString("static-catalog");
 641             } catch (MissingResourceException e) {
 642                 return defaultUseStaticCatalog;
 643             }
 644         }
 645 
 646         if (staticCatalog == null) {
 647             return defaultUseStaticCatalog;
 648         }
 649 
 650         return (staticCatalog.equalsIgnoreCase("true")
 651                 || staticCatalog.equalsIgnoreCase("yes")
 652                 || staticCatalog.equalsIgnoreCase("1"));
 653     }
 654 
 655     /**
 656      * Get the current use static catalog setting.
 657      */
 658     public boolean getUseStaticCatalog() {
 659         if (useStaticCatalog == null) {
 660             useStaticCatalog = queryUseStaticCatalog() ? Boolean.TRUE : Boolean.FALSE;
 661         }
 662 
 663         return useStaticCatalog.booleanValue();
 664     }
 665 
 666     /**
 667      * Set the use static catalog setting.
 668      */
 669     public void setUseStaticCatalog(boolean useStatic) {
 670         useStaticCatalog = useStatic ? Boolean.TRUE : Boolean.FALSE;
 671     }
 672 
 673     /**
 674      * Get the current use static catalog setting.
 675      *
 676      * @deprecated No longer static; use get/set methods.
 677      */
 678     public boolean staticCatalog() {
 679         return getUseStaticCatalog();
 680     }
 681 
 682     /**
 683      * Get a new catalog instance.
 684      *
 685      * This method always returns a new instance of the underlying catalog class.
 686      */
 687     public Catalog getPrivateCatalog() {
 688         Catalog catalog = staticCatalog;
 689 
 690         if (useStaticCatalog == null) {
 691             useStaticCatalog = getUseStaticCatalog() ? Boolean.TRUE : Boolean.FALSE;
 692         }
 693 
 694         if (catalog == null || !useStaticCatalog.booleanValue()) {
 695 
 696             try {
 697                 String catalogClassName = getCatalogClassName();
 698 
 699                 if (catalogClassName == null) {
 700                     catalog = new Catalog();
 701                 } else {
 702                     try {
 703                         catalog = (Catalog) ReflectUtil.forName(catalogClassName).newInstance();
 704                     } catch (ClassNotFoundException cnfe) {
 705                         debug.message(1,"Catalog class named '"
 706                                 + catalogClassName
 707                                 + "' could not be found. Using default.");
 708                         catalog = new Catalog();
 709                     } catch (ClassCastException cnfe) {
 710                         debug.message(1,"Class named '"
 711                                 + catalogClassName


 722             }
 723 
 724             if (useStaticCatalog.booleanValue()) {
 725                 staticCatalog = catalog;
 726             }
 727         }
 728 
 729         return catalog;
 730     }
 731 
 732     /**
 733      * Get a catalog instance.
 734      *
 735      * If this manager uses static catalogs, the same static catalog will
 736      * always be returned. Otherwise a new catalog will be returned.
 737      */
 738     public Catalog getCatalog() {
 739         Catalog catalog = staticCatalog;
 740 
 741         if (useStaticCatalog == null) {
 742             useStaticCatalog = getUseStaticCatalog() ? Boolean.TRUE : Boolean.FALSE;
 743         }
 744 
 745         if (catalog == null || !useStaticCatalog.booleanValue()) {
 746             catalog = getPrivateCatalog();
 747             if (useStaticCatalog.booleanValue()) {
 748                 staticCatalog = catalog;
 749             }
 750         }
 751 
 752         return catalog;
 753     }
 754 
 755     /**
 756      * <p>Obtain the oasisXMLCatalogPI setting from the properties.</p>
 757      *
 758      * <p>In the properties, a value of 'yes', 'true', or '1' is considered
 759      * true, anything else is false.</p>
 760      *
 761      * @return The oasisXMLCatalogPI setting from the propertyFile or the
 762      * defaultOasisXMLCatalogPI.


 771                 allow = resources.getString("allow-oasis-xml-catalog-pi");
 772             } catch (MissingResourceException e) {
 773                 return defaultOasisXMLCatalogPI;
 774             }
 775         }
 776 
 777         if (allow == null) {
 778             return defaultOasisXMLCatalogPI;
 779         }
 780 
 781         return (allow.equalsIgnoreCase("true")
 782                 || allow.equalsIgnoreCase("yes")
 783                 || allow.equalsIgnoreCase("1"));
 784     }
 785 
 786     /**
 787      * Get the current XML Catalog PI setting.
 788      */
 789     public boolean getAllowOasisXMLCatalogPI () {
 790         if (oasisXMLCatalogPI == null) {
 791             oasisXMLCatalogPI = queryAllowOasisXMLCatalogPI() ? Boolean.TRUE : Boolean.FALSE;
 792         }
 793 
 794         return oasisXMLCatalogPI.booleanValue();
 795     }
 796 
 797     public boolean useServicesMechanism() {
 798         return useServicesMechanism;
 799     }
 800     /**
 801      * Set the XML Catalog PI setting
 802      */
 803     public void setAllowOasisXMLCatalogPI(boolean allowPI) {
 804         oasisXMLCatalogPI = allowPI ? Boolean.TRUE : Boolean.FALSE;
 805     }
 806 
 807     /**
 808      * Get the current XML Catalog PI setting.
 809      *
 810      * @deprecated No longer static; use get/set methods.
 811      */
 812     public boolean allowOasisXMLCatalogPI() {
 813         return getAllowOasisXMLCatalogPI();
 814     }
 815 
 816     /**
 817      * Obtain the Catalog class name setting from the properties.
 818      *
 819      */
 820     public String queryCatalogClassName () {
 821         String className = SecuritySupport.getSystemProperty(pClassname);
 822 
 823         if (className == null) {
 824             if (resources==null) readProperties();