zoukankan      html  css  js  c++  java
  • groovy

    1、加载和卸载(每次都新建一个GroovyClassLoader 实例,然后使用新建的classloader去加载)

    try {
                GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
                Class<?> clazz = groovyClassLoader.parseClass(orchestrationUnitDesc);
                GroovyObject unit = (GroovyObject) clazz.newInstance();
                result.setSuccess(true);
                result.setResult(unit);
                return result;
            } catch (InstantiationException e) {
                result.setSuccess(false);
                result.setErrorMsg("groovy:InstantiationException:" + e.getMessage());
                DataExchangeLogger.errorLog("", "", "groovy:InstantiationException", e);
            } catch (IllegalAccessException e) {
                result.setSuccess(false);
                result.setErrorMsg("groovy:IllegalAccessException:" + e.getMessage());
                DataExchangeLogger.errorLog("", "", "groovy:IllegalAccessException", e);
            } catch (Exception e) {
                result.setSuccess(false);
                result.setErrorMsg("groovy:Exception:" + e.getMessage());
                DataExchangeLogger.errorLog("", "", "groovy:Exception", e);
            }

    2、执行

       上面得到一个GroovyObject对象,执行方法就是调用GroovyObject的invokeMethod方法

    // > 获取编排单元
            GroovyObject unit = (GroovyObject) ServiceOrchestrationConfigManager.getOrchestrationUnit(message.getMsgType());
    
            if (unit == null) {
                result.setErrorCode(OpenErrorCode.S07.name());
                result.setErrorMsg("orchestrationScript is null.");
                result.setSuccess(false);
                return result;
            }
    
            // > 调用服务编排
            try {
                unit.invokeMethod("setDoc", CustomXmlUtil.parseText2Doc(message.getRequestString()));
                result = (SendResult) unit.invokeMethod("execute", message);
                if (result == null) {
                    result = new SendResult();
                    result.setErrorCode(OpenErrorCode.S07.name());
                    result.setErrorMsg("下发编排脚本执行,返回为空");
                    result.setSuccess(false);
                }
            } catch (DocumentException e) {
                result.setErrorCode(OpenErrorCode.S07.name());
                result.setErrorMsg("请求报文转docment对象异常" + e.getMessage());
                result.setSuccess(false);
                DataExchangeLogger.errorLog(message.getBizId(), message.getMsgType(),
                        "call service orchestration parseText2Doc error.", e);
                return result;
            } catch (Exception e) {
                result.setErrorCode(OpenErrorCode.S07.name());
                result.setErrorMsg("下发编排脚本执行异常" + e.getMessage());
                result.setSuccess(false);
                DataExchangeLogger.errorLog(message.getBizId(), message.getMsgType(),
                        "call service orchestration excute script error. ", e);
            }
  • 相关阅读:
    我的博客开通啦
    (转载)IOS- Instruments使用之使用Leaks检测内存泄漏
    IOS Xcode -> instruments -> Leaks
    (转载) ios内存泄漏检查-leaks使用
    (转载)浅析MySQL中concat以及group_concat的使用
    内存分析工具 MAT 的使用 (转载)
    接口测试 -- 保存 requests 的 cookies
    接口测试 -- 关闭 requests 打开的 file
    SoapUI、Jmeter、Postman三种接口测试工具的比较分析
    postman使用技巧
  • 原文地址:https://www.cnblogs.com/YDDMAX/p/5464440.html
Copyright © 2011-2022 走看看