Package org.webharvest.runtime.scripting

Examples of org.webharvest.runtime.scripting.ScriptEngine


    public ScriptEngine getScriptEngine() {
        return runningFunctions.size() > 0 ? getRunningFunction().getScriptEngine() : this.scriptEngine;
    }

    public synchronized ScriptEngine getScriptEngine(String engineType) {
        ScriptEngine engine = (ScriptEngine) this.usedScriptEngines.get(engineType);
        if (engine == null) {
            engine = configuration.createScriptEngine(this.context, engineType);
            this.usedScriptEngines.put(engineType, engine);
        }
View Full Code Here


        // releases script engines
        if (this.usedScriptEngines != null) {
            Iterator iterator = this.usedScriptEngines.values().iterator();
            while (iterator.hasNext()) {
                ScriptEngine engine = (ScriptEngine) iterator.next();
                if (engine != null) {
                    engine.dispose();
                }
            }
        }

        this.logger.removeAllAppenders();
       
        Iterator iterator = usedScriptEngines.values().iterator();
        while (iterator.hasNext()) {
            ScriptEngine engine = (ScriptEngine) iterator.next();
            engine.dispose();
        }
    }
View Full Code Here

        super(httpHeaderDef);
        this.httpHeaderDef = httpHeaderDef;
    }

    public Variable execute(Scraper scraper, ScraperContext context) {
        ScriptEngine scriptEngine = scraper.getScriptEngine();
        String name = BaseTemplater.execute( httpHeaderDef.getName(), scriptEngine);
      Variable value = getBodyTextContent(httpHeaderDef, scraper, context);
       
      HttpProcessor httpProcessor = scraper.getRunningHttpProcessor();
      if (httpProcessor != null) {
View Full Code Here

        super(regexpDef);
        this.regexpDef = regexpDef;
    }

    public Variable execute(Scraper scraper, ScraperContext context) {
        ScriptEngine scriptEngine = scraper.getScriptEngine();

        BaseElementDef patternDef = regexpDef.getRegexpPatternDef();
        Variable patternVar = getBodyTextContent(patternDef, scraper, context, true);
        debug(patternDef, scraper, patternVar);
View Full Code Here

            language = language.toLowerCase();
        }

        String returnExpression = scriptDef.getReturnExpression();

        ScriptEngine scriptEngine = language == null ? scraper.getScriptEngine() : scraper.getScriptEngine(language);
        scriptEngine.eval( scriptText.toString() );

        if (returnExpression != null) {
            String returnExpressionEvaluated = BaseTemplater.execute( scriptDef.getReturnExpression(), scraper.getScriptEngine());
            Object returnValue = scriptEngine.eval(returnExpressionEvaluated);
            return CommonUtil.createVariable(returnValue);
        } else {
            return new EmptyVariable();
        }
       
View Full Code Here

    }

    public Variable execute(Scraper scraper, ScraperContext context) {
        String workingDir = scraper.getWorkingDir();

        ScriptEngine scriptEngine = scraper.getScriptEngine();
        String action = BaseTemplater.execute( fileDef.getAction(), scriptEngine);
        String filePath = BaseTemplater.execute( fileDef.getPath(), scriptEngine);
        String type = BaseTemplater.execute( fileDef.getType(), scriptEngine);
        String charset = BaseTemplater.execute( fileDef.getCharset(), scriptEngine);
        if (charset == null) {
View Full Code Here

        Variable body = getBodyTextContent(htmlToXmlDef, scraper, context);

        HtmlCleaner cleaner = new HtmlCleaner();
        CleanerProperties properties = cleaner.getProperties();

        final ScriptEngine scriptEngine = scraper.getScriptEngine();

        final String advancedXmlEscape = BaseTemplater.execute( htmlToXmlDef.getAdvancedXmlEscape(), scriptEngine);
        if ( advancedXmlEscape != null) {
            properties.setAdvancedXmlEscape(CommonUtil.isBooleanTrue(advancedXmlEscape) );
        }
View Full Code Here

    }

    public Variable execute(Scraper scraper, ScraperContext context) {
      scraper.setRunningHttpProcessor(this);

        ScriptEngine scriptEngine = scraper.getScriptEngine();
        String url = BaseTemplater.execute( httpDef.getUrl(), scriptEngine);
        String method = BaseTemplater.execute( httpDef.getMethod(), scriptEngine);
        String multipart = BaseTemplater.execute( httpDef.getMultipart(), scriptEngine);
        boolean isMultipart = CommonUtil.getBooleanValue(multipart, false);
        String specifiedCharset = BaseTemplater.execute( httpDef.getCharset(), scriptEngine);
View Full Code Here

        String language = BaseTemplater.execute( templateDef.getLanguage(), scraper.getScriptEngine());
        if (language != null) {
            language = language.toLowerCase();
        }
        ScriptEngine scriptEngine = language == null ? scraper.getScriptEngine() : scraper.getScriptEngine(language);

        String result = BaseTemplater.execute(body.toString(), scriptEngine);
       
        return new NodeVariable(result);
    }
View Full Code Here

        super(whileDef);
        this.whileDef = whileDef;
    }

    public Variable execute(Scraper scraper, ScraperContext context) {
        ScriptEngine scriptEngine = scraper.getScriptEngine();
        String index = BaseTemplater.execute( whileDef.getIndex(), scriptEngine);
        String maxLoopsString = BaseTemplater.execute( whileDef.getMaxLoops(), scriptEngine);
        boolean isEmpty = CommonUtil.getBooleanValue( BaseTemplater.execute(whileDef.getEmpty(), scriptEngine), false );

        double maxLoops = Constants.DEFAULT_MAX_LOOPS;
View Full Code Here

TOP

Related Classes of org.webharvest.runtime.scripting.ScriptEngine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.