scriptdefinitionparser.java

来自「提供ESB 应用mule源代码 提供ESB 应用mule源代码」· Java 代码 · 共 62 行

JAVA
62
字号
/* * $Id: ScriptDefinitionParser.java 12423 2008-07-29 19:38:10Z tcarlson $ * -------------------------------------------------------------------------------------- * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com * * The software in this package is published under the terms of the CPAL v1.0 * license, a copy of which has been included with this distribution in the * LICENSE.txt file. */package org.mule.module.scripting.config;import org.mule.config.spring.parsers.assembly.BeanAssembler;import org.mule.config.spring.parsers.generic.OptionalChildDefinitionParser;import org.mule.config.spring.parsers.processors.CheckRequiredAttributes;import org.mule.module.scripting.component.Scriptable;import org.mule.util.StringUtils;import org.springframework.beans.factory.xml.ParserContext;import org.w3c.dom.Element;import org.w3c.dom.Node;public class ScriptDefinitionParser extends OptionalChildDefinitionParser{    public ScriptDefinitionParser()    {        super("script", Scriptable.class);        addIgnored("name");        addAlias("engine", "scriptEngineName");        addAlias("file", "scriptFile");                // The "engine" attribute is required unless "file" is specified, in which case the         // file extension will be used to determine the appropriate script engine.        String[][] requiredAttributeSets = new String[2][];        requiredAttributeSets[0] = new String[]{"engine"};        requiredAttributeSets[1] = new String[]{"file"};        registerPreProcessor(new CheckRequiredAttributes(requiredAttributeSets));    }    protected void postProcess(ParserContext context, BeanAssembler assembler, Element element)    {        Node node = element.getFirstChild();        if (node != null)        {            String value = node.getNodeValue();            //Support CDATA for script text            if(node.getNextSibling()!=null && node.getNextSibling().getNodeType()== Node.CDATA_SECTION_NODE)            {                value = node.getNextSibling().getNodeValue();            }            if (!StringUtils.isBlank(value))            {                assembler.getBean().addPropertyValue("scriptText", value);            }        }        super.postProcess(context, assembler, element);    }}

⌨️ 快捷键说明

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