configurationsettings.java

来自「一个用struts tiles的在线影院web系统」· Java 代码 · 共 56 行

JAVA
56
字号
package com.eline.vod.security.configuration;

import java.util.Hashtable;

import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class ConfigurationSettings {
	private static ConfigurationSettings settings = null;

	private Hashtable _settings = new Hashtable();

	public static ConfigurationSettings getInstance() {
		if (settings == null)
			settings = new ConfigurationSettings();
		return settings;
	}

	public void loadValuesFromConfigurationXml(Element root) {
		Node configSectionNode = root.getElementsByTagName("authentication").item(0);
		NodeList nodes = configSectionNode.getChildNodes();

		for (int i = 0; i < nodes.getLength(); i ++) {
			Node node = nodes.item(i);
			if (node != null && node instanceof Element) {
				String key = node.getNodeName();
				// System.out.println("key=" + key);
				try {
					// 默认操作
					_settings.put(key, node.getFirstChild().getNodeValue());
				} catch (Exception e) {
					continue;
				}
			}
		}
	
	}

	private ConfigurationSettings() {
	}

	public synchronized String getProperty(String key) {
		return (String)_settings.get(key);
	}
	
	public String getDataSource() {
		System.out.println("getDataSource()="+getProperty("dbDataSource"));
		return getProperty("dbDataSource");
	}
	
	public String getDataProviderType() {
		return getProperty("dataProvider");
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?