Reworked CatalogManager. The code no longer assumes that there will be one static manager. Each manager can have its own settings and carries its own debug object around with it. Almost all of the old methods are deprecated now that there are proper get/set methods for most of the properties.
git-svn-id: https://svn.apache.org/repos/asf/xml/commons/trunk@226006 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
87b64a669f
commit
32de5fd9df
@ -70,6 +70,9 @@ import java.net.MalformedURLException;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import org.apache.xml.resolver.helpers.Debug;
|
||||||
|
import org.apache.xml.resolver.Catalog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>CatalogManager provides an interface to the catalog properties.</p>
|
* <p>CatalogManager provides an interface to the catalog properties.</p>
|
||||||
*
|
*
|
||||||
@ -166,43 +169,102 @@ public class CatalogManager {
|
|||||||
private static String pClassname = "xml.catalog.className";
|
private static String pClassname = "xml.catalog.className";
|
||||||
private static String pIgnoreMissing = "xml.catalog.ignoreMissing";
|
private static String pIgnoreMissing = "xml.catalog.ignoreMissing";
|
||||||
|
|
||||||
|
/** A static CatalogManager instance for sharing */
|
||||||
|
private static CatalogManager staticManager = new CatalogManager();
|
||||||
|
|
||||||
/** Flag to ignore missing property files and/or properties */
|
/** Flag to ignore missing property files and/or properties */
|
||||||
private static boolean ignoreMissingProperties
|
private boolean ignoreMissingProperties
|
||||||
= (System.getProperty(pIgnoreMissing) != null
|
= (System.getProperty(pIgnoreMissing) != null
|
||||||
|| System.getProperty(pFiles) != null);
|
|| System.getProperty(pFiles) != null);
|
||||||
|
|
||||||
/** Holds the resources after they are loaded from the file. */
|
/** Holds the resources after they are loaded from the file. */
|
||||||
private static ResourceBundle resources;
|
private ResourceBundle resources;
|
||||||
|
|
||||||
/** The name of the CatalogManager properties file. */
|
/** The name of the CatalogManager properties file. */
|
||||||
private static String propertyFile = "CatalogManager.properties";
|
private String propertyFile = "CatalogManager.properties";
|
||||||
|
|
||||||
/** The location of the propertyFile */
|
/** The location of the propertyFile */
|
||||||
private static URL propertyFileURI = null;
|
private URL propertyFileURI = null;
|
||||||
|
|
||||||
/** Default catalog files list. */
|
/** Default catalog files list. */
|
||||||
private static String defaultCatalogFiles = "./xcatalog";
|
private String defaultCatalogFiles = "./xcatalog";
|
||||||
|
|
||||||
|
/** Current catalog files list. */
|
||||||
|
private String catalogFiles = null;
|
||||||
|
|
||||||
|
/** Did the catalgoFiles come from the properties file? */
|
||||||
|
private boolean fromPropertiesFile = false;
|
||||||
|
|
||||||
/** Default verbosity level if there is no property setting for it. */
|
/** Default verbosity level if there is no property setting for it. */
|
||||||
private static int defaultVerbosity = 1;
|
private int defaultVerbosity = 1;
|
||||||
|
|
||||||
|
/** Current verbosity level. */
|
||||||
|
private Integer verbosity = null;
|
||||||
|
|
||||||
/** Default preference setting. */
|
/** Default preference setting. */
|
||||||
private static boolean defaultPreferPublic = true;
|
private boolean defaultPreferPublic = true;
|
||||||
|
|
||||||
|
/** Current preference setting. */
|
||||||
|
private Boolean preferPublic = null;
|
||||||
|
|
||||||
/** Default setting of the static catalog flag. */
|
/** Default setting of the static catalog flag. */
|
||||||
private static boolean defaultStaticCatalog = true;
|
private boolean defaultUseStaticCatalog = true;
|
||||||
|
|
||||||
|
/** Current setting of the static catalog flag. */
|
||||||
|
private Boolean useStaticCatalog = null;
|
||||||
|
|
||||||
|
/** The static catalog used by this manager. */
|
||||||
|
private static Catalog staticCatalog = null;
|
||||||
|
|
||||||
/** Default setting of the oasisXMLCatalogPI flag. */
|
/** Default setting of the oasisXMLCatalogPI flag. */
|
||||||
private static boolean defaultOasisXMLCatalogPI = true;
|
private boolean defaultOasisXMLCatalogPI = true;
|
||||||
|
|
||||||
|
/** Current setting of the oasisXMLCatalogPI flag. */
|
||||||
|
private Boolean oasisXMLCatalogPI = null;
|
||||||
|
|
||||||
/** Default setting of the relativeCatalogs flag. */
|
/** Default setting of the relativeCatalogs flag. */
|
||||||
private static boolean defaultRelativeCatalogs = true;
|
private boolean defaultRelativeCatalogs = true;
|
||||||
|
|
||||||
|
/** Current setting of the relativeCatalogs flag. */
|
||||||
|
private Boolean relativeCatalogs = null;
|
||||||
|
|
||||||
|
/** Current catalog class name. */
|
||||||
|
private String catalogClassName = null;
|
||||||
|
|
||||||
|
/** The manager's debug object. Used for printing debugging messages.
|
||||||
|
*
|
||||||
|
* <p>This field is public so that objects that have access to this
|
||||||
|
* CatalogManager can use this debug object.</p>
|
||||||
|
*/
|
||||||
|
public Debug debug = null;
|
||||||
|
|
||||||
|
/** Constructor. */
|
||||||
|
public CatalogManager() {
|
||||||
|
debug = new Debug();
|
||||||
|
// Note that we don't setDebug() here; we do that lazily. Either the
|
||||||
|
// user will set it explicitly, or we'll do it automagically if they
|
||||||
|
// read from the propertyFile for some other reason. That way, there's
|
||||||
|
// no attempt to read from the file before the caller has had a chance
|
||||||
|
// to avoid it.
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Constructor that specifies an explicit property file. */
|
||||||
|
public CatalogManager(String propertyFile) {
|
||||||
|
this.propertyFile = propertyFile;
|
||||||
|
|
||||||
|
debug = new Debug();
|
||||||
|
// Note that we don't setDebug() here; we do that lazily. Either the
|
||||||
|
// user will set it explicitly, or we'll do it automagically if they
|
||||||
|
// read from the propertyFile for some other reason. That way, there's
|
||||||
|
// no attempt to read from the file before the caller has had a chance
|
||||||
|
// to avoid it.
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Load the properties from the propertyFile and build the
|
* Load the properties from the propertyFile and build the
|
||||||
* resources from it.</p>
|
* resources from it.
|
||||||
*/
|
*/
|
||||||
private synchronized static void readProperties() {
|
private synchronized void readProperties() {
|
||||||
try {
|
try {
|
||||||
propertyFileURI = CatalogManager.class.getResource("/"+propertyFile);
|
propertyFileURI = CatalogManager.class.getResource("/"+propertyFile);
|
||||||
InputStream in =
|
InputStream in =
|
||||||
@ -210,6 +272,8 @@ public class CatalogManager {
|
|||||||
if (in==null) {
|
if (in==null) {
|
||||||
if (!ignoreMissingProperties) {
|
if (!ignoreMissingProperties) {
|
||||||
System.err.println("Cannot find "+propertyFile);
|
System.err.println("Cannot find "+propertyFile);
|
||||||
|
// there's no reason to give this warning more than once
|
||||||
|
ignoreMissingProperties = true;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -223,26 +287,71 @@ public class CatalogManager {
|
|||||||
System.err.println("Failure trying to read "+propertyFile);
|
System.err.println("Failure trying to read "+propertyFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is a bit of a hack. After we've successfully read the properties,
|
||||||
|
// use them to set the default debug level, if the user hasn't already set
|
||||||
|
// the default debug level.
|
||||||
|
if (verbosity == null) {
|
||||||
|
try {
|
||||||
|
String verbStr = resources.getString("verbosity");
|
||||||
|
int verb = Integer.parseInt(verbStr.trim());
|
||||||
|
debug.setDebug(verb);
|
||||||
|
verbosity = new Integer(verb);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// nop
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Tell the CatalogManager how to handle missing properties</p>
|
* Allow access to the static CatalogManager
|
||||||
|
*/
|
||||||
|
public static CatalogManager getStaticManager() {
|
||||||
|
return staticManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How are missing properties handled?
|
||||||
|
*
|
||||||
|
* <p>If true, missing or unreadable property files will
|
||||||
|
* not be reported. Otherwise, a message will be sent to System.err.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public boolean getIgnoreMissingProperties() {
|
||||||
|
return ignoreMissingProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How should missing properties be handled?
|
||||||
*
|
*
|
||||||
* <p>If ignore is true, missing or unreadable property files will
|
* <p>If ignore is true, missing or unreadable property files will
|
||||||
* not be reported. Otherwise, a message will be sent to System.err.
|
* not be reported. Otherwise, a message will be sent to System.err.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public static void ignoreMissingProperties(boolean ignore) {
|
public void setIgnoreMissingProperties(boolean ignore) {
|
||||||
ignoreMissingProperties = ignore;
|
ignoreMissingProperties = ignore;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Obtain the verbosity setting from the properties.</p>
|
* How are missing properties handled?
|
||||||
|
*
|
||||||
|
* <p>If ignore is true, missing or unreadable property files will
|
||||||
|
* not be reported. Otherwise, a message will be sent to System.err.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @deprecated No longer static; use get/set methods.
|
||||||
|
*/
|
||||||
|
public void ignoreMissingProperties(boolean ignore) {
|
||||||
|
setIgnoreMissingProperties(ignore);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain the verbosity setting from the properties.
|
||||||
*
|
*
|
||||||
* @returns The verbosity level from the propertyFile or the
|
* @returns The verbosity level from the propertyFile or the
|
||||||
* defaultVerbosity.
|
* defaultVerbosity.
|
||||||
*/
|
*/
|
||||||
public static int verbosity () {
|
private int queryVerbosity () {
|
||||||
String verbStr = System.getProperty(pVerbosity);
|
String verbStr = System.getProperty(pVerbosity);
|
||||||
|
|
||||||
if (verbStr == null) {
|
if (verbStr == null) {
|
||||||
@ -265,7 +374,56 @@ public class CatalogManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Obtain the relativeCatalogs setting from the properties.</p>
|
* What is the current verbosity?
|
||||||
|
*/
|
||||||
|
public int getVerbosity() {
|
||||||
|
if (verbosity == null) {
|
||||||
|
verbosity = new Integer(queryVerbosity());
|
||||||
|
}
|
||||||
|
|
||||||
|
return verbosity.intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the current verbosity.
|
||||||
|
*/
|
||||||
|
public void setVerbosity (int verbosity) {
|
||||||
|
this.verbosity = new Integer(verbosity);
|
||||||
|
debug.setDebug(verbosity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What is the current verbosity?
|
||||||
|
*
|
||||||
|
* @deprecated No longer static; use get/set methods.
|
||||||
|
*/
|
||||||
|
public int verbosity () {
|
||||||
|
return getVerbosity();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain the relativeCatalogs setting from the properties.
|
||||||
|
*
|
||||||
|
* @returns The relativeCatalogs setting from the propertyFile or the
|
||||||
|
* defaultRelativeCatalogs.
|
||||||
|
*/
|
||||||
|
private boolean queryRelativeCatalogs () {
|
||||||
|
if (resources==null) readProperties();
|
||||||
|
|
||||||
|
if (resources==null) return defaultRelativeCatalogs;
|
||||||
|
|
||||||
|
try {
|
||||||
|
String allow = resources.getString("relative-catalogs");
|
||||||
|
return (allow.equalsIgnoreCase("true")
|
||||||
|
|| allow.equalsIgnoreCase("yes")
|
||||||
|
|| allow.equalsIgnoreCase("1"));
|
||||||
|
} catch (MissingResourceException e) {
|
||||||
|
return defaultRelativeCatalogs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the relativeCatalogs setting.
|
||||||
*
|
*
|
||||||
* <p>This property is used when the catalogFiles property is
|
* <p>This property is used when the catalogFiles property is
|
||||||
* interrogated. If true, then relative catalog entry file names
|
* interrogated. If true, then relative catalog entry file names
|
||||||
@ -284,34 +442,43 @@ public class CatalogManager {
|
|||||||
* @returns The relativeCatalogs setting from the propertyFile or the
|
* @returns The relativeCatalogs setting from the propertyFile or the
|
||||||
* defaultRelativeCatalogs.
|
* defaultRelativeCatalogs.
|
||||||
*/
|
*/
|
||||||
public static boolean relativeCatalogs () {
|
public boolean getRelativeCatalogs () {
|
||||||
if (resources==null) readProperties();
|
if (relativeCatalogs == null) {
|
||||||
|
relativeCatalogs = new Boolean(queryRelativeCatalogs());
|
||||||
if (resources==null) return defaultRelativeCatalogs;
|
|
||||||
|
|
||||||
try {
|
|
||||||
String allow = resources.getString("relative-catalogs");
|
|
||||||
return (allow.equalsIgnoreCase("true")
|
|
||||||
|| allow.equalsIgnoreCase("yes")
|
|
||||||
|| allow.equalsIgnoreCase("1"));
|
|
||||||
} catch (MissingResourceException e) {
|
|
||||||
return defaultRelativeCatalogs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return relativeCatalogs.booleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Obtain the list of catalog files from the properties.</p>
|
* Set the relativeCatalogs setting.
|
||||||
*
|
*
|
||||||
* <p>Note that the list of catalog files is always a semicolon
|
* @returns The relativeCatalogs setting from the propertyFile or the
|
||||||
* delimited list, even on Unix systems where a colon delimited list
|
* defaultRelativeCatalogs.
|
||||||
* might be considered more natural.</p>
|
|
||||||
*
|
*
|
||||||
* @returns A vector of the catalog file names or null if no catalogs
|
* @see #getRelativeCatalogs()
|
||||||
* are available in the properties.
|
|
||||||
*/
|
*/
|
||||||
public static Vector catalogFiles () {
|
public void setRelativeCatalogs (boolean relative) {
|
||||||
|
relativeCatalogs = new Boolean(relative);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the relativeCatalogs setting.
|
||||||
|
*
|
||||||
|
* @deprecated No longer static; use get/set methods.
|
||||||
|
*/
|
||||||
|
public boolean relativeCatalogs () {
|
||||||
|
return getRelativeCatalogs();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain the list of catalog files from the properties.
|
||||||
|
*
|
||||||
|
* @returns A semicolon delimited list of catlog file URIs
|
||||||
|
*/
|
||||||
|
private String queryCatalogFiles () {
|
||||||
String catalogList = System.getProperty(pFiles);
|
String catalogList = System.getProperty(pFiles);
|
||||||
boolean fromPropertiesFile = false;
|
fromPropertiesFile = false;
|
||||||
|
|
||||||
if (catalogList == null) {
|
if (catalogList == null) {
|
||||||
if (resources == null) readProperties();
|
if (resources == null) readProperties();
|
||||||
@ -330,7 +497,21 @@ public class CatalogManager {
|
|||||||
catalogList = defaultCatalogFiles;
|
catalogList = defaultCatalogFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringTokenizer files = new StringTokenizer(catalogList, ";");
|
return catalogList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the current list of catalog files.
|
||||||
|
*
|
||||||
|
* @returns A vector of the catalog file names or null if no catalogs
|
||||||
|
* are available in the properties.
|
||||||
|
*/
|
||||||
|
public Vector getCatalogFiles() {
|
||||||
|
if (catalogFiles == null) {
|
||||||
|
catalogFiles = queryCatalogFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
StringTokenizer files = new StringTokenizer(catalogFiles, ";");
|
||||||
Vector catalogs = new Vector();
|
Vector catalogs = new Vector();
|
||||||
while (files.hasMoreTokens()) {
|
while (files.hasMoreTokens()) {
|
||||||
String catalogFile = files.nextToken();
|
String catalogFile = files.nextToken();
|
||||||
@ -347,11 +528,32 @@ public class CatalogManager {
|
|||||||
|
|
||||||
catalogs.add(catalogFile);
|
catalogs.add(catalogFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
return catalogs;
|
return catalogs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Obtain the preferPublic setting from the properties.</p>
|
* Set the list of catalog files.
|
||||||
|
*/
|
||||||
|
public void setCatalogFiles(String fileList) {
|
||||||
|
catalogFiles = fileList;
|
||||||
|
fromPropertiesFile = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the current list of catalog files.
|
||||||
|
*
|
||||||
|
* @returns A vector of the catalog file names or null if no catalogs
|
||||||
|
* are available in the properties.
|
||||||
|
*
|
||||||
|
* @deprecated No longer static; use get/set methods.
|
||||||
|
*/
|
||||||
|
public Vector catalogFiles() {
|
||||||
|
return getCatalogFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain the preferPublic setting from the properties.
|
||||||
*
|
*
|
||||||
* <p>In the properties, a value of 'public' is true,
|
* <p>In the properties, a value of 'public' is true,
|
||||||
* anything else is false.</p>
|
* anything else is false.</p>
|
||||||
@ -359,7 +561,7 @@ public class CatalogManager {
|
|||||||
* @returns True if prefer is public or the
|
* @returns True if prefer is public or the
|
||||||
* defaultPreferSetting.
|
* defaultPreferSetting.
|
||||||
*/
|
*/
|
||||||
public static boolean preferPublic () {
|
private boolean queryPreferPublic () {
|
||||||
String prefer = System.getProperty(pPrefer);
|
String prefer = System.getProperty(pPrefer);
|
||||||
|
|
||||||
if (prefer == null) {
|
if (prefer == null) {
|
||||||
@ -380,29 +582,61 @@ public class CatalogManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Obtain the static-catalog setting from the properties.</p>
|
* Return the current prefer public setting.
|
||||||
|
*
|
||||||
|
* @returns True if public identifiers are preferred.
|
||||||
|
*/
|
||||||
|
public boolean getPreferPublic () {
|
||||||
|
if (preferPublic == null) {
|
||||||
|
preferPublic = new Boolean(queryPreferPublic());
|
||||||
|
}
|
||||||
|
return preferPublic.booleanValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the prefer public setting.
|
||||||
|
*
|
||||||
|
* @returns True if public identifiers are preferred.
|
||||||
|
*/
|
||||||
|
public void setPreferPublic (boolean preferPublic) {
|
||||||
|
this.preferPublic = new Boolean(preferPublic);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the current prefer public setting.
|
||||||
|
*
|
||||||
|
* @returns True if public identifiers are preferred.
|
||||||
|
*
|
||||||
|
* @deprecated No longer static; use get/set methods.
|
||||||
|
*/
|
||||||
|
public boolean preferPublic () {
|
||||||
|
return getPreferPublic();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain the static-catalog setting from the properties.
|
||||||
*
|
*
|
||||||
* <p>In the properties, a value of 'yes', 'true', or '1' is considered
|
* <p>In the properties, a value of 'yes', 'true', or '1' is considered
|
||||||
* true, anything else is false.</p>
|
* true, anything else is false.</p>
|
||||||
*
|
*
|
||||||
* @returns The static-catalog setting from the propertyFile or the
|
* @returns The static-catalog setting from the propertyFile or the
|
||||||
* defaultStaticCatalog.
|
* defaultUseStaticCatalog.
|
||||||
*/
|
*/
|
||||||
public static boolean staticCatalog () {
|
private boolean queryUseStaticCatalog () {
|
||||||
String staticCatalog = System.getProperty(pStatic);
|
String staticCatalog = System.getProperty(pStatic);
|
||||||
|
|
||||||
if (staticCatalog == null) {
|
if (useStaticCatalog == null) {
|
||||||
if (resources==null) readProperties();
|
if (resources==null) readProperties();
|
||||||
if (resources==null) return defaultStaticCatalog;
|
if (resources==null) return defaultUseStaticCatalog;
|
||||||
try {
|
try {
|
||||||
staticCatalog = resources.getString("static-catalog");
|
staticCatalog = resources.getString("static-catalog");
|
||||||
} catch (MissingResourceException e) {
|
} catch (MissingResourceException e) {
|
||||||
return defaultStaticCatalog;
|
return defaultUseStaticCatalog;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (staticCatalog == null) {
|
if (staticCatalog == null) {
|
||||||
return defaultStaticCatalog;
|
return defaultUseStaticCatalog;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (staticCatalog.equalsIgnoreCase("true")
|
return (staticCatalog.equalsIgnoreCase("true")
|
||||||
@ -410,6 +644,106 @@ public class CatalogManager {
|
|||||||
|| staticCatalog.equalsIgnoreCase("1"));
|
|| staticCatalog.equalsIgnoreCase("1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current use static catalog setting.
|
||||||
|
*/
|
||||||
|
public boolean getUseStaticCatalog() {
|
||||||
|
if (useStaticCatalog == null) {
|
||||||
|
useStaticCatalog = new Boolean(queryUseStaticCatalog());
|
||||||
|
}
|
||||||
|
|
||||||
|
return useStaticCatalog.booleanValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the use static catalog setting.
|
||||||
|
*/
|
||||||
|
public void setUseStaticCatalog(boolean useStatic) {
|
||||||
|
useStaticCatalog = new Boolean(useStatic);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current use static catalog setting.
|
||||||
|
*
|
||||||
|
* @deprecated No longer static; use get/set methods.
|
||||||
|
*/
|
||||||
|
public boolean staticCatalog() {
|
||||||
|
return getUseStaticCatalog();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a new catalog instance.
|
||||||
|
*
|
||||||
|
* This method always returns a new instance of the underlying catalog class.
|
||||||
|
*/
|
||||||
|
public Catalog getPrivateCatalog() {
|
||||||
|
Catalog catalog = staticCatalog;
|
||||||
|
|
||||||
|
if (useStaticCatalog == null) {
|
||||||
|
useStaticCatalog = new Boolean(getUseStaticCatalog());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (catalog == null || !useStaticCatalog.booleanValue()) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
String catalogClassName = getCatalogClassName();
|
||||||
|
|
||||||
|
if (catalogClassName == null) {
|
||||||
|
catalog = new Catalog();
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
catalog = (Catalog) Class.forName(catalogClassName).newInstance();
|
||||||
|
} catch (ClassNotFoundException cnfe) {
|
||||||
|
debug.message(1,"Catalog class named '"
|
||||||
|
+ catalogClassName
|
||||||
|
+ "' could not be found. Using default.");
|
||||||
|
catalog = new Catalog();
|
||||||
|
} catch (ClassCastException cnfe) {
|
||||||
|
debug.message(1,"Class named '"
|
||||||
|
+ catalogClassName
|
||||||
|
+ "' is not a Catalog. Using default.");
|
||||||
|
catalog = new Catalog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
catalog.setCatalogManager(this);
|
||||||
|
catalog.setupReaders();
|
||||||
|
catalog.loadSystemCatalogs();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useStaticCatalog.booleanValue()) {
|
||||||
|
staticCatalog = catalog;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return catalog;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a catalog instance.
|
||||||
|
*
|
||||||
|
* If this manager uses static catalogs, the same static catalog will
|
||||||
|
* always be returned. Otherwise a new catalog will be returned.
|
||||||
|
*/
|
||||||
|
public Catalog getCatalog() {
|
||||||
|
Catalog catalog = staticCatalog;
|
||||||
|
|
||||||
|
if (useStaticCatalog == null) {
|
||||||
|
useStaticCatalog = new Boolean(getUseStaticCatalog());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (catalog == null || !useStaticCatalog.booleanValue()) {
|
||||||
|
catalog = getPrivateCatalog();
|
||||||
|
if (useStaticCatalog.booleanValue()) {
|
||||||
|
staticCatalog = catalog;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return catalog;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Obtain the oasisXMLCatalogPI setting from the properties.</p>
|
* <p>Obtain the oasisXMLCatalogPI setting from the properties.</p>
|
||||||
*
|
*
|
||||||
@ -419,7 +753,7 @@ public class CatalogManager {
|
|||||||
* @returns The oasisXMLCatalogPI setting from the propertyFile or the
|
* @returns The oasisXMLCatalogPI setting from the propertyFile or the
|
||||||
* defaultOasisXMLCatalogPI.
|
* defaultOasisXMLCatalogPI.
|
||||||
*/
|
*/
|
||||||
public static boolean allowOasisXMLCatalogPI () {
|
public boolean queryAllowOasisXMLCatalogPI () {
|
||||||
String allow = System.getProperty(pAllowPI);
|
String allow = System.getProperty(pAllowPI);
|
||||||
|
|
||||||
if (allow == null) {
|
if (allow == null) {
|
||||||
@ -441,11 +775,38 @@ public class CatalogManager {
|
|||||||
|| allow.equalsIgnoreCase("1"));
|
|| allow.equalsIgnoreCase("1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current XML Catalog PI setting.
|
||||||
|
*/
|
||||||
|
public boolean getAllowOasisXMLCatalogPI () {
|
||||||
|
if (oasisXMLCatalogPI == null) {
|
||||||
|
oasisXMLCatalogPI = new Boolean(queryAllowOasisXMLCatalogPI());
|
||||||
|
}
|
||||||
|
|
||||||
|
return oasisXMLCatalogPI.booleanValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the XML Catalog PI setting
|
||||||
|
*/
|
||||||
|
public void setAllowOasisXMLCatalogPI(boolean allowPI) {
|
||||||
|
oasisXMLCatalogPI = new Boolean(allowPI);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current XML Catalog PI setting.
|
||||||
|
*
|
||||||
|
* @deprecated No longer static; use get/set methods.
|
||||||
|
*/
|
||||||
|
public boolean allowOasisXMLCatalogPI() {
|
||||||
|
return getAllowOasisXMLCatalogPI();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Obtain the Catalog class name setting from the properties.</p>
|
* <p>Obtain the Catalog class name setting from the properties.</p>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static String catalogClassName () {
|
public String queryCatalogClassName () {
|
||||||
String className = System.getProperty(pClassname);
|
String className = System.getProperty(pClassname);
|
||||||
|
|
||||||
if (className == null) {
|
if (className == null) {
|
||||||
@ -460,4 +821,31 @@ public class CatalogManager {
|
|||||||
|
|
||||||
return className;
|
return className;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current Catalog class name.
|
||||||
|
*/
|
||||||
|
public String getCatalogClassName() {
|
||||||
|
if (catalogClassName == null) {
|
||||||
|
catalogClassName = queryCatalogClassName();
|
||||||
|
}
|
||||||
|
|
||||||
|
return catalogClassName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the Catalog class name.
|
||||||
|
*/
|
||||||
|
public void setCatalogClassName(String className) {
|
||||||
|
catalogClassName = className;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current Catalog class name.
|
||||||
|
*
|
||||||
|
* @deprecated No longer static; use get/set methods.
|
||||||
|
*/
|
||||||
|
public String catalogClassName() {
|
||||||
|
return getCatalogClassName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user