⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 actionrunner.java

📁 java系统通用框架 很实用的东东 一般人都看的懂,
💻 JAVA
字号:
/*****************************************************************************
* (C) Copyright 2004 。
* 保留对所有使用、复制、修改和发布整个软件和相关文档的权利。
* 本计算机程序受著作权法和国际公约的保护,未经授权擅自复制或
* 传播本程序的全部或部分,可能受到严厉的民事和刑事制裁,并
* 在法律允许的范围内受到最大可能的起诉。
*/

 /*****************************************************************************
  * @作者:Golden Peng
  * @版本: 1.0
  * @时间: 2002-10-08
  */
 /*****************************************************************************
  * 修改记录清单
  * 修改人  :
  * 修改记录:
  * 修改时间:
  * 修改描述:
  *
  */
package com.corp.bisc.ebiz.base;

/**
 * 此处插入类型描述。
 * 创建日期:(2002-5-15 20:49:45)
 * @author:Administrator
 */
import java.util.*;
import org.w3c.dom.*;
import com.corp.bisc.ebiz.util.XMLUtil;
import com.corp.bisc.ebiz.exception.InvalidConfigException;

public class ActionRunner extends ObjectBase
{
	protected Hashtable actionMap = new Hashtable();

/**
 * ActionRunner 构造子注解。
 */
public ActionRunner() {
	super();
}
	public ActionDef getAction(String actionName)
	{
		return (ActionDef)actionMap.get(actionName);
	}
	public void init(Node cfgNode) throws InvalidConfigException
	{
		enter("init(Node)");

		Node actionNode = XMLUtil.selectSingleNode2(cfgNode , "actions");
		if (actionNode == null)
			throw new InvalidConfigException(cfgNode.getNodeName());

		Node cmdNode = XMLUtil.selectSingleNode2(cfgNode , "commands");
		if (cmdNode == null)
			throw new InvalidConfigException(cfgNode.getNodeName());

		String defaultPkg = XMLUtil.selectSingleValue2(cmdNode , "@defaultPkg");
		if (defaultPkg == null)
			throw new InvalidConfigException("commands/@defaultPkg");

		NodeList nodes = cmdNode.getChildNodes();
		int size = nodes.getLength();
		Hashtable cmdMap = new Hashtable();

		for(int i = 0 ; i < size ; i ++)
		{
			Node node = nodes.item(i);
			if (node.getNodeType() != Node.ELEMENT_NODE) continue;

			String nodeName = node.getNodeName();
			if (!nodeName.equals("command")) throw new InvalidConfigException(nodeName);

			NamedNodeMap attribs = node.getAttributes();
			Node nameAttrib = attribs.getNamedItem("name");
			Node classAttrib = attribs.getNamedItem("class");

			if (nameAttrib == null)
				throw new InvalidConfigException("command/@name");

			if (classAttrib == null)
				throw new InvalidConfigException("command/@class");

			String className = classAttrib.getNodeValue();
			int dotIndex = className.indexOf('.');
			if (dotIndex == -1)
				className = defaultPkg + '.' + className;

			cmdMap.put(nameAttrib.getNodeValue() , className);
		}

		nodes = actionNode.getChildNodes();
		size = nodes.getLength();

		for(int i = 0 ; i < size ; i ++)
		{
			Node node = nodes.item(i);
			if (node.getNodeType() != Node.ELEMENT_NODE) continue;

			String nodeName = node.getNodeName();
			if (!nodeName.equals("action")) throw new InvalidConfigException(nodeName);

			ActionDef action = new ActionDef();
			action.init(node , cmdMap);

			actionMap.put(action.getActionName() , action);
		}
		/*
		Vector nodesSession = XMLUtil.selectNodes2(cfgNode , "action/commands/command/session-invalidate/key");
		int keySize = nodesSession.size();
		Hashtable sessionInvalidator = new Hashtable();

		for(int i = 0 ; i < keySize ; i ++)
		{
			Node nodeKey = (Node)nodesSession.elementAt(i);
			NamedNodeMap attribs = nodeKey.getAttributes();

			Node keyNode = attribs.getNamedItem("name");
			actionNode = attribs.getNamedItem("action");

			if (keyNode == null)
				throw new InvalidConfigException("action/commands/command/session-invalidate/key/@name");

			if (actionNode == null)
				throw new InvalidConfigException("action/commands/command/session-invalidate/key/@action");

			String key = keyNode.getNodeValue();
			String action = actionNode.getNodeValue();

			ActionDef actionDef = (ActionDef)actionMap.get(action);
			if (actionDef == null)
				throw new InvalidConfigException("action/commands/command/session-invalidate/key/[@action=" + action + "]");

			actionDef.addInvalidKey(key);
		}
		*/
		leave("init(Node)");
	}
}

⌨️ 快捷键说明

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