qsp.java

来自「pos机交易实现源代码 含金融卡交易8583协议实现 开发环境:linux 」· Java 代码 · 共 499 行 · 第 1/2 页

JAVA
499
字号
/* * Copyright (c) 2000 jPOS.org.  All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in *    the documentation and/or other materials provided with the *    distribution. * * 3. The end-user documentation included with the redistribution, *    if any, must include the following acknowledgment: *    "This product includes software developed by the jPOS project  *    (http://www.jpos.org/)". Alternately, this acknowledgment may  *    appear in the software itself, if and wherever such third-party  *    acknowledgments normally appear. * * 4. The names "jPOS" and "jPOS.org" must not be used to endorse  *    or promote products derived from this software without prior  *    written permission. For written permission, please contact  *    license@jpos.org. * * 5. Products derived from this software may not be called "jPOS", *    nor may "jPOS" appear in their name, without prior written *    permission of the jPOS project. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.   * IN NO EVENT SHALL THE JPOS PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE  * POSSIBILITY OF SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the jPOS Project.  For more * information please see <http://www.jpos.org/>. */package org.jpos.apps.qsp;import java.io.File;import java.io.IOException;import java.util.Iterator;import java.util.ArrayList;import java.util.Collection;import org.apache.xerces.parsers.*;import org.xml.sax.SAXException;import org.xml.sax.SAXParseException;import org.w3c.dom.Document;import org.w3c.dom.Node;import org.w3c.dom.NodeList;import org.w3c.dom.NamedNodeMap;import org.xml.sax.ErrorHandler;import org.jpos.iso.ISOMUX;import org.jpos.util.SimpleLogListener;import org.jpos.util.SystemMonitor;import org.jpos.util.Logger;import org.jpos.util.LogEvent;import org.jpos.util.LogSource;import org.jpos.util.NameRegistrar;import org.jpos.core.Configuration;import org.jpos.core.SimpleConfiguration;import org.jpos.core.ConfigurationException;import org.jpos.apps.qsp.config.ConfigTask;import org.jpos.space.TransientSpace;import com.sun.management.jmx.Trace;import javax.management.ObjectName;import javax.management.MBeanServer;import javax.management.MBeanServerFactory;import javax.management.NotCompliantMBeanException;import javax.management.InstanceAlreadyExistsException;import javax.management.MBeanException;import javax.management.ReflectionException;import javax.management.MBeanRegistrationException;import javax.management.MalformedObjectNameException;import javax.management.InstanceAlreadyExistsException;/** * @author <a href="mailto:apr@cs.com.uy">Alejandro P. Revilla</a> * @version $Revision: 1.36 $ $Date: 2002/08/06 14:26:29 $ * @see <a href="http://www.cebik.com/qsig.html">QSP</a> */public class QSP implements ErrorHandler, LogSource, Runnable, QSPMBean {    public static final String NAMEREGISTRAR_PREFIX = "qsp.";    public static final String DEFAULT_NAME = "default";    Document config;    Logger logger;    String realm;    File configFile;    long lastModified;    static ControlPanel controlPanel = null;    long monitorConfigInterval = 60 * 1000;    Collection reconfigurables;    DOMParser parser;    Configuration cfg;    String[] extendedTags;    String[] supportedTags;    boolean validation;    protected MBeanServer server = null;    protected long startTime;    protected boolean newConfigFile;    public static String[] SUPPORTED_TAGS = 	{ "logger",	  "qsp-config",	  "log-listener",          "object",          "connection-pool",	  "persistent-engine",	  "sequencer",          "s-m-adapter",          "secure-key-store",	  "control-panel",	  "channel",	  "filter",	  "mux",	  "server",	  "request-listener",	  "card-agent",	  "dir-poll",	  "task",	  "daily-task"	};    public QSP () {	super();	reconfigurables = new ArrayList();        supportedTags = SUPPORTED_TAGS;        extendedTags = new String[0];        validation = true;        startTime = System.currentTimeMillis();    }    /**     * @param configFile XML based QSP config file     * @param supportedTags array of supported tags (default if null)     * @param extendedTags array of extended tags (none if null)     * @param validation true to validate XML file     */    public QSP (            String[] supportedTags,         String[] extendedTags,         boolean validation)    {	this();        if (supportedTags != null)            this.supportedTags = supportedTags;        if (extendedTags != null)            this.extendedTags = extendedTags;        this.validation = validation;    }    public long getElapsed () {        return System.currentTimeMillis() - startTime;    }    public MBeanServer getMBeanServer ()         throws IOException, MalformedObjectNameException,        InstanceAlreadyExistsException,         MBeanRegistrationException,        NotCompliantMBeanException,        MalformedObjectNameException    {        if (server == null)            createMBeanServer();        return server;    }    public void setSupportedTags (String[] supportedTags) {        this.supportedTags = supportedTags;    }    public String[] getSupportedTags () {        return supportedTags;    }    public void setExtendedTags (String[] extendedTags) {        this.extendedTags = extendedTags;    }    public String[] getExtendedTags () {        return extendedTags;    }    public void setValidation (boolean validation) {        this.validation = validation;    }    public boolean getValidation() {        return validation;    }    public void setParser (DOMParser parser) {        this.parser     = parser;    }    public void setConfig (Document config) {	this.config = config;    }    public void setConfigFile (String f) throws IOException {        File newFile = new File (f);        if (!newFile.equals (configFile)) {            if (this.configFile != null) {                this.newConfigFile = true;                Logger.log (new LogEvent (this, "set-config-file", f));            }            this.configFile = newFile;            this.lastModified = configFile.lastModified();            // this is causing problems on JDK1.4's AWT (when using panels)            // Thread.currentThread().interrupt ();        }    }    public void setMonitorConfigInterval (long l) {	monitorConfigInterval = l;        // this is causing problems on JDK1.4's AWT (when using panels)        // Thread.currentThread().interrupt ();    }    public long getMonitorConfigInterval () {        return monitorConfigInterval;    }    public String getConfigFile () {	return configFile.toString ();    }    public Collection getReConfigurables() {	return reconfigurables;    }    public ControlPanel initControlPanel (int rows, int cols) {	if (controlPanel == null) {	    synchronized (QSP.class) {		if (controlPanel == null) 		    controlPanel = new ControlPanel (this, rows, cols);	    }	}	return controlPanel;    }    public ControlPanel getControlPanel (){	return controlPanel;    }    public void warning (SAXParseException e) throws SAXException {	Logger.log (new LogEvent (this, "warning", e));	throw e;    }    public void error (SAXParseException e) throws SAXException {	Logger.log (new LogEvent (this, "error", e));	throw e;    }    public void fatalError (SAXParseException e) throws SAXException {

⌨️ 快捷键说明

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