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

📄 xmlparticipantmap.java

📁 一个工作流设计及定义的系统,可以直接与数据库结合进行系统工作流程的定义及应用.
💻 JAVA
字号:
/* * Copyright (c) 2005, John Mettraux, OpenWFE.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: *  * . Redistributions of source code must retain the above copyright notice, this *   list of conditions and the following disclaimer.   *  * . 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. *  * . Neither the name of the "OpenWFE" nor the names of its contributors may be *   used to endorse or promote products derived from this software without *   specific prior written permission. *  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"  * AND ANY EXPRESS 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 COPYRIGHT OWNER OR 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. * * $Id: XmlParticipantMap.java,v 1.12 2005/06/25 08:31:43 jmettraux Exp $ *///// XmlParticipantMap.java//// jmettraux@openwfe.org//// generated with // jtmpl 1.0.04 20.11.2001 John Mettraux (jmettraux@openwfe.org)//package openwfe.org.engine.impl.participants;import openwfe.org.Utils;import openwfe.org.MapUtils;import openwfe.org.Parameters;import openwfe.org.ApplicationContext;import openwfe.org.ServiceException;import openwfe.org.xconf.XconfBuilder;import openwfe.org.xconf.XconfElementBuilder;import openwfe.org.engine.participants.Participant;import openwfe.org.engine.participants.RefParticipant;import openwfe.org.engine.participants.LeafParticipant;import openwfe.org.engine.participants.CompositeParticipant;import openwfe.org.engine.participants.AbstractParticipantMap;/** * The standard participant map described as an XML file * * <p><font size=2>CVS Info : * <br>$Author: jmettraux $ * <br>$Date: 2005/06/25 08:31:43 $ * <br>$Id: XmlParticipantMap.java,v 1.12 2005/06/25 08:31:43 jmettraux Exp $ </font> * * @author jmettraux@openwfe.org */public class XmlParticipantMap    extends AbstractParticipantMap    implements XconfElementBuilder{    private final static org.apache.log4j.Logger log = org.apache.log4j.Logger        .getLogger(XmlParticipantMap.class.getName());    //    // CONSTANTS (definitions)    private final static String E_PARTICIPANT        = "participant";    private final static String A_NAME        = "name";    private final static String A_REGEX        = "regex";    private final static String A_REF        = "ref";    private final static String A_CLASS        = "class";    /**     * Use this parameter to tell the XmlParticipantMap where the XML     * participant map file is.     */    public final static String P_PARTICIPANT_MAP_FILE        = "participantMapFile";    //    // FIELDS    private XconfBuilder builder = null;    //    // CONSTRUCTORS    /**     * Initialization method of this OpenWFE service.     */    public void init         (final String serviceName,          final ApplicationContext context,          final java.util.Map serviceParams)    throws         ServiceException    {        super.init(serviceName, context, serviceParams);        String url = MapUtils.getAsString            (serviceParams,              P_PARTICIPANT_MAP_FILE,              "etc/engine/participant-map.xml");        url = Utils.expandUrl(context.getApplicationDirectory(), url);        log.debug("init() url is "+url);        this.builder = new XconfBuilder(url, this);        this.builder.buildConfig();    }    //    // METHODS from XconfElementBuilder    /**     * Clears the participant map. This method should and is only called by     * the XconfBuilder helper class.     */    public void clearConfig ()    {        setParticipants(new java.util.ArrayList());    }    /**     * XconfBuilder calls this method when parsing a config file. It should     * only be used by XconfBuilder.     */    public void parseElement         (final XconfBuilder builder, final org.jdom.Element elt)    throws         ServiceException    {        buildParticipant(elt);    }    //    // METHODS from ParticipantMap    /**     * Calls in turn the refreshConfig() method of the inner XconfBuilder.     */    public void refreshMap ()        throws ServiceException    {        this.builder.refreshConfig();    }    //    // METHODS from Service    //    // METHODS    /**     * Turns an xml element into the participant it represents     */    protected Participant buildParticipant (final org.jdom.Element elt)    {        if ( ! elt.getName().equals(E_PARTICIPANT)) return null;        String regex = elt.getAttributeValue(A_REGEX);        if (regex == null) regex = elt.getAttributeValue(A_NAME);        final java.util.Map params = Parameters.extractParamsAndAttributes(elt);        log.debug("buildParticipant() building '"+regex+"'");        if (elt.getChild(E_PARTICIPANT) != null)        {            return buildCompositeParticipant(elt, regex, params);        }        //        // determine participant class        String className = null;        final String ref = elt.getAttributeValue(A_REF);        if (ref != null)             className = RefParticipant.class.getName();        final String specifiedClassName = (String)params.get(A_CLASS);        if (specifiedClassName != null)            className = specifiedClassName;        //        // instantiate participant        Participant p = null;        try        {            Class participantClass = LeafParticipant.class;            if (className != null)                participantClass = Class.forName(className);            p = (Participant)participantClass.newInstance();        }        catch (final Throwable t)        {            log.warn                ("buildParticipant() cannot build from class "+className+                 ". falling back to "+LeafParticipant.class.getName());            log.debug                ("buildParticipant() cannot build from class "+className+                 ". falling back to "+LeafParticipant.class.getName(),                 t);            p = new LeafParticipant();        }        log.debug            ("buildParticipant() of class '"+p.getClass().getName()+"'");        p.init(this, regex, params);        return p;    }    /**     * Parses a composite participant     */    protected CompositeParticipant buildCompositeParticipant         (final org.jdom.Element elt,         final String regex,         final java.util.Map params)    {        final CompositeParticipant cp = new CompositeParticipant();        cp.init(this, regex, params);        final java.util.Iterator it =             elt.getChildren(E_PARTICIPANT).iterator();        while (it.hasNext())            cp.add(buildParticipant((org.jdom.Element)it.next()));        return cp;    }    //    // STATUS    /**     * Returns the current status of this participant map.     */    public org.jdom.Element getStatus ()    {        final org.jdom.Element result = new org.jdom.Element(this.getName());        result.setAttribute            ("source-url",              this.builder.getSourceUrl().toString());        return result;    }}

⌨️ 快捷键说明

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