You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@depot.apache.org by aj...@apache.org on 2004/07/13 12:42:28 UTC
svn commit: rev 22873 - incubator/depot/trunk/update/src/java/org/apache/depot/update/config
Author: ajack
Date: Tue Jul 13 05:42:27 2004
New Revision: 22873
Added:
incubator/depot/trunk/update/src/java/org/apache/depot/update/config/UpdaterConfig.java
Removed:
incubator/depot/trunk/update/src/java/org/apache/depot/update/config/UpdateConfig.java
Log:
Fixing the rename.
Added: incubator/depot/trunk/update/src/java/org/apache/depot/update/config/UpdaterConfig.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/config/UpdaterConfig.java Tue Jul 13 05:42:27 2004
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.depot.update.config;
+
+import java.io.File;
+import java.io.InputStream;
+
+import org.apache.depot.common.log.Logger;
+import org.apache.depot.common.util.envsafe.ClassLoaderContext;
+import org.apache.depot.update.impl.ReferenceManager;
+import org.apache.depot.update.util.UpdateConstants;
+import org.apache.depot.update.util.text.MessageConstants;
+import org.apache.depot.update.util.text.Messages;
+import org.apache.depot.update.util.xml.XMLContext;
+import org.apache.depot.update.util.xml.XMLEntryTable;
+import org.apache.depot.update.util.xml.XMLParser;
+
+/**
+ * @author anou_mana
+ */
+public class UpdaterConfig {
+ private static boolean l_configured = false;
+
+ public static synchronized void configure(String resourceName) {
+ try {
+ XMLEntryTable xmlEntryTable = new ConfigXMLEntryTable();
+ XMLContext xmlContext = null;
+
+ ClassLoaderContext helper = new ClassLoaderContext(xmlEntryTable);
+
+ XMLParser parser = new XMLParser(xmlEntryTable, helper);
+
+ File configFile = new File(resourceName);
+ if (configFile.exists()) {
+ Logger.getLogger().info(
+ Messages.getString(
+ MessageConstants.CONFIG,
+ new Object[] { "file", resourceName }));
+ xmlContext = parser.parse(configFile);
+ }
+ else {
+ InputStream resource =
+ helper.getResourceAsStream(
+ resourceName);
+ if (resource == null) {
+ resource = ClassLoader.getSystemResourceAsStream(resourceName);
+ }
+
+ Logger.getLogger().info(
+ Messages.getString(
+ MessageConstants.CONFIG,
+ new Object[] { "resource", resourceName }));
+ xmlContext = parser.parse(resource);
+ }
+
+ if (null == xmlContext)
+ Logger.getLogger().error(
+ Messages.getString(
+ MessageConstants.UNABLE_TO_LOAD_CONFIG,
+ resourceName));
+
+ }
+ catch (Exception exp) {
+ Logger.getLogger().error(
+ Messages.getString(MessageConstants.CONFIG_PARSER_ERROR),
+ exp);
+ }
+ }
+
+ public static void configure() {
+ if (!l_configured) {
+ configure(UpdateConstants.DEFAULT_CONFIG_XML);
+ l_configured = true;
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ Logger.testInit();
+ UpdaterConfig.configure();
+ ReferenceManager.dump();
+ }
+}