zoukankan      html  css  js  c++  java
  • ABAP function group和Tomcat library重复加载问题

    ABAP

    ABAP help文档里对**LOAD-OF-PROGRAM"的关键字是这样描述的:

    This event keyword defines the program constructor of an executable program, a module pool, a function group, or a subroutine pool. The program constructor is an event block whose event is raised by the ABAP-runtime environment when one of the executable programs mentioned above is loaded into the internal session.

    以Function group为例,每当一个function group里的任意一个function module第一次被调用时,对应的ABAP program被加载到internal session里,同时ABAP运行时抛出LOAD-OF-PROGRAM, 执行应用程序员编写的事件处理逻辑。

    现在我有一个名为ZTOMCAT的function group。其LOAD-OF-PROGRAM就负责弹出调试器。

    我有两个report。Report 2的源代码:

    REPORT ZJERRY_RE2.
    
    call FUNCTION 'ZTEST_FM_1'.
    

    Report 1:

    CALL FUNCTION 'ZTEST_FM_1'.
    
    SUBMIT zjerry_re2 AND RETURN.
    

    那么我执行report1,断点会触发一次还是两次?

    答案是两次。

    LOAD-OF-PROGRAM在这种场景下的行为,ABAP help已经说的很清楚了:

    When a program is called using SUBMIT or using a transaction code, a new internal session is opened in every call and the event block is executed once in every call.

    每次program通过SUBMIT或者事务码的方式调用时,会起一个新的internal session,在此新的session里LOAD-OF-PROGRAM会触发一次。

    下图也直观表明了每次调用SUBMIT( calling programs)时会新起一个Internal Session。

    Tomcat 库文件的重复加载问题

    我的pom.xml里定义了一个gson的依赖关系,ABAPer可以把其类比成在我的Java代码里调用Google提供的gson API。


    打成war包之后,该库文件位于WEB-INF/lib文件夹下。

    那么如果我有多个Web应用都用到了gson, 则每个应用的WEB-INFlib文件夹下面都有gson的jar文件。

    问题:在运行时,Tomcat只会将一份gson.jar的内容加载到内存么?

    答案是不会。根据Tomcat的官方文档,Tomcat会为每个Web应用创建一个专属的ClassLoader实例,每个应用的WEB-INFlib下的资源,对于其他应用来说不可见,彼此隔离。


    当然如果想只用一份库文件,可以把它放到目录 [tomcat-installation-directory]/common/lib下面。更多细节参考stackoverflow上的讨论.

    要获取更多Jerry的原创技术文章,请关注公众号"汪子熙"或者扫描下面二维码:

  • 相关阅读:
    你真的知道async/await的好处嘛, 并且还会用好呢
    Python基本小程序
    猜数字小程序的实现
    Python第一周基本语句学习整理
    Python环境安装与配置
    作业
    Markdown的学习
    创建一个dynamics CRM workflow (四)
    Dynamics CRM 快速获取custom entity
    Dynamics email的subject标题出现 CRM:0000xxxx
  • 原文地址:https://www.cnblogs.com/sap-jerry/p/9191473.html
Copyright © 2011-2022 走看看