Update of /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper2/config
In directory sc8-pr-cvs1:/tmp/cvs-serv30481/src/java/core/org/krysalis/ruper2/config
Added Files:
ConfigXMLEntryTable.java RuperConfig.java
Log Message:
Avoid clash with existing Ruper...
--- NEW FILE: ConfigXMLEntryTable.java ---
/*
* Created on Sep 12, 2003
*/
package org.krysalis.ruper2.config;
import org.krysalis.ruper2.protocols.VirtualResourceLocator;
import org.krysalis.ruper2.repository.RepositoryAttribute;
import org.krysalis.ruper2.repository.RepositorySet;
import org.krysalis.ruper2.util.xml.XMLEntryTable;
import org.krysalis.ruper2.util.xml.XMLGrouperElement;
import org.krysalis.ruper2.util.xml.XMLTagConstants;
/**
* @author anou_mana
*/
public class ConfigXMLEntryTable extends XMLEntryTable {
/**
*
*/
public ConfigXMLEntryTable() {
super();
this.m_entryToClassMap.put(XMLTagConstants.CONFIG_TAG, XMLGrouperElement.XML_GROUPER_ELEMENT_CLASSNAME);
this.m_entryToClassMap.put(XMLTagConstants.REPOSITORYSET_TAG, RepositorySet.REPOSITORYSET_CLASSNAME);
this.m_entryToClassMap.put(XMLTagConstants.REPOSITORY_URL_TAG, VirtualResourceLocator.VRL_CLASSNAME);
this.m_entryToClassMap.put(XMLTagConstants.REPOSITORY_ACTIVE_TAG, RepositoryAttribute.REPOSITORY_ATTRIBUTE_CLASSNAME);
this.m_entryToClassMap.put(XMLTagConstants.REPOSITORY_REMOTE_TAG, RepositoryAttribute.REPOSITORY_ATTRIBUTE_CLASSNAME);
}
}
--- NEW FILE: RuperConfig.java ---
/*
* Created on Sep 9, 2003
*/
package org.krysalis.ruper2.config;
import java.io.File;
import java.io.InputStream;
import org.krysalis.ruper2.impl.ReferenceManager;
import org.krysalis.ruper2.log.Logger;
import org.krysalis.ruper2.util.ClassLoaderHelper;
import org.krysalis.ruper2.util.RuperConstants;
import org.krysalis.ruper2.util.text.MessageConstants;
import org.krysalis.ruper2.util.text.Messages;
import org.krysalis.ruper2.util.xml.XMLContext;
import org.krysalis.ruper2.util.xml.XMLEntryTable;
import org.krysalis.ruper2.util.xml.XMLParser;
/**
* @author anou_mana
*/
public class RuperConfig {
private static boolean l_configured = false;
public static void configure(String resourceName) {
try {
XMLEntryTable xmlEntryTable = new ConfigXMLEntryTable();
XMLParser parser = new XMLParser(xmlEntryTable);
XMLContext xmlContext = null;
File configFile = new File(resourceName);
if (configFile.exists()) {
Logger.getLog().info(
Messages.getString(
MessageConstants.CONFIG,
new Object[] { "file", resourceName }));
xmlContext = parser.parse(configFile);
}
else {
InputStream resource =
ClassLoaderHelper.getClassLoader().getResourceAsStream(
resourceName);
Logger.getLog().info(
Messages.getString(
MessageConstants.CONFIG,
new Object[] { "resource", resourceName }));
xmlContext = parser.parse(resource);
}
if (null == xmlContext)
Logger.getLog().error(
Messages.getString(
MessageConstants.UNABLE_TO_LOAD_CONFIG,
resourceName));
}
catch (Exception exp) {
Logger.getLog().error(
Messages.getString(MessageConstants.CONFIG_PARSER_ERROR),
exp);
}
}
public static void configure() {
if (!l_configured) {
configure(RuperConstants.DEFAULT_CONFIG_XML);
l_configured = true;
}
}
public static void main(String[] args) throws Exception {
Logger.testInit();
RuperConfig.configure();
ReferenceManager.dump();
}
}
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.