首页 文章 精选 留言 我的

精选列表

搜索[包依赖隔离],共10000篇文章
优秀的个人博客,低调大师

ABAP模拟Java Spring依赖注入(Dependency injection)的一个尝试

Recently I will deliver a session regarding dependency inversion principle to my team. As Java Spring is already widely used in all other Java development teams in my site, some ABAPers are not well aware of its idea and implementation under the hood. In order for ABAPers to easily understand the mechanism of Java Spring dependency inversion, I wrote a prototype in ABAP after going through related Java source code of Spring. Before I start, I perform the search in SCN. There are already several excellent blogs written regarding dependency injection in ABAP: (1) ABAP Dependency Injection – An implementation approach(2) Shoot Me Up ABAP(3) Dependency Injection for ABAP(4) MockA in github Thanks a lot for efforts spent by authors of them!Compared with those blogs, the advantage of my prototype is: it follows exactly the design of Java Spring, it is not needed for users to do any other manual dependency registration except a single annotation @Inject. So it is useful for ABAPers to understand Spring dependency internal implementation. Let me begin with a simple example. In real world I have a switch. By pressing it, the lamp connected by that switch is turned on. With switch pressed for second time, the lamp is turned off. That’s all. Implementation without using Dependency injection I have an interface ZIF_SWITCHABLE with two simple methods: And a ZCL_LAMP which simply implements this interface: CLASS ZCL_LAMP IMPLEMENTATION. method ZIF_SWITCHABLE~OFF. WRITE: / 'lamp off'. endmethod. method ZIF_SWITCHABLE~ON. WRITE: / 'lamp on'. endmethod. ENDCLASS. And a switch which internally maintains the current switch status and a reference to ZIF_SWITCHABLE: The switch has a push method to toggle: METHOD push. IF isswitchon = abap_true. mo_switchable->off( ). isswitchon = abap_false. ELSE. mo_switchable->on( ). isswitchon = abap_true. ENDIF. ENDMETHOD. And a setter method is needed to inject the switchable instance: method SET_SWITCHABLE. mo_switchable = io_switchable. endmethod. These two classes and one interface are put to the following package: Consumer code – version one without using dependency injection Here the ZCL_SWITCH has tight dependency on ZCL_LAMP: it has to manually inject this dependency via setter method in line 11. Let’s summarize how many manual / unnecessary operations are done by consumer: (1) line 8: create lamp instance(2) line 9: create switch instance(3) line 11: connect switch with lamp Implementation using ABAP Summer I call my prototype as ABAP Summer just to show my admire on Java Spring When the same requirement is implemented in Java Spring, the logic in line 11 could completely be avoided, with help of various powerful annotation like @Autowired, @Named, @Inject etc. Thanks to Java Spring container, lots of labor work has been done by it under the hood, saving lots of routine effort from application developers so that they can only concentrate on the core business logic. For example, in Java using Spring, all developers need to do is to add annotation @Inject on top of attribute switchable – in the runtime Spring will guarantee that the annotated implementation for this interface is instantiated automatically. How can we simulate the similar logic of Spring now in ABAP Summer? (1) Add the annotation @Inject to attribute mo_switchable, which tells ABAP summer “hey, I would like this attribute to be automatically injected with proper implementation in the runtime”.Since I have no other way to add metadata in class attribute in ABAP – there is no first class annotation supported in ABAP – I have to use description field for simulation. (2) And below is my consumer code, no more manual instance initialization and manual setter call. Very clean, isn’t it? data(summer) = zcl_summer=>get_instance( ). data(lo_switch) = cast zcl_switch( summer->get_bean( EXPORTING iv_bean_name = 'ZCL_SWITCH' ) ). lo_switch->push( ). lo_switch->push( ). Let’s make comparison. By using ABAP summer, consumer can simply get switch instance from container by passing bean technical name ( here again, I use Spring terminology “bean” to name those ABAP classes which owns an injected member attribute with @Inject ). This is exactly the way a Java developer doing daily work using Java Spring: How does ABAP summer work? There are lots of books written to illustrate the design of Java Spring, I read one of them listed below, and wrote this ABAP summer based on my understanding. I draw a diagram below to explain the core method init of ABAP summer: Last by not least, when you try this demo, after you copy the source code of ZCL_SWITCH to your system and activate it, NEVER forget to add this annotation in description field manually, as in ABAP, the attribute description is not stored in source code but in DB table. More thought on ABAP annotation The annotation in Java is a form of metadata which could be defined by application developer and are available in the runtime by Java reflection. It is a built-in language feature supported by JVM. In ABAP there is no such first-class annotation supported. In CDS view, there are some grammar which have annotation-like style. You can append lots of annotation defined in SAP help to a CDS view. However those annotation are not first-class annotation supported by ABAP language itself as well. It is just CDS view framework which parses the source code of these annotation and react accordingly. For details please see these two blogs of mine: (1) My CDS view self study tutorial – Part 3 how is view source in Eclipse converted to ABAP view in the backend(2) My CDS view self study tutorial – Part 4 how does annotation @OData.publish work 本文来自云栖社区合作伙伴“汪子熙”,了解相关信息可以关注微信公众号"汪子熙"。

优秀的个人博客,低调大师

Apache Fineract 1.3.0 修复了一个上游依赖安全漏洞

Apache Fineract 项目在 1.3.0 版本中修复了一个 Spring Security OAuth 安全漏洞CVE-2016-4977,该漏洞允许恶意用户远程执行代码。 NATIONAL VULNERABILITY DATABASE(NVD)介绍了该漏洞的具体情况,在 Spring Security OAuth 2.0.0-2.0.9 和 1.0.0-1.0.5 版本中使用 whitelabel 视图处理授权请求时,response_type 参数值作为 Spring SpEL 执行,这使恶意用户能够通过手工触发远程代码执行 response_type 的值。 Fineract 是一个用于核心银行系统平台化建设的系统,它为创业者、金融机构和服务提供商提供了一个可靠、健壮的金融服务解决方案。 通告查看: http://mail-archives.apache.org/mod_mbox/www-announce/201910.mbox/%3cCACqpLwJGBRp9cpyhVwxvc0SSrTbUoDxAr+YnywXjj=BRFhiyPw@mail.gmail.com%3e

优秀的个人博客,低调大师

人工智能依赖网络安全 传统安全厂商有优势

一、人工智能对网络安全需求度较高 兵马未动,粮草先行。人工智能是基于网络和大数据的,保护网络和数据安全是发展人工智能的前提,网络信息安全是人工智能的保镖。从产业周期角度看,科技越来越深入经济和社会,从简单的信息传递、游戏娱乐到为生活、工作做出决策。人工智能的角色从配角到主角,再到主演,对主演的保护要远胜配角。 Master横扫人类围棋高手,现在我们需要考虑的是人工智能的边界在哪里。所以,人工智能需要网络安全来限制其边界,实行保护式发展。最典型的案例就是无人机禁飞区,这种禁飞除了行政手段外,最有效的还是技术手段,用网络安全限制无人机。 二、网络安全需要人工智能提升防护能力 “人工智能+网络安全”出现频次急剧上升。2016年,“网络安全”、“人工智能”和“机器学习”这三个词汇的增长率基本相同。“网络安全”与“人工智能”共同出现在文章中的频率增加了。传统网络安全方法的核心是对网络划分边界,随着防护边界泛网络化后网络安全要利用人工智能技术应对网络泛化的数据安全。例如用户和实体行为分析(UEBA),特别是防止内部人员泄密。 三、人工智能网络安全成为创投并购重点 2017年才过去两个月,就有三家 AI网络安全创业企业被科技巨头重金收购。在打击网络犯罪领域,人工智能技术正变得越来越重要。2017年前2个月已经有3家关注AI的网络安全创业企业已被收购。这三家网络安全创业企业都针对机器学习技术,即一组用来训练机器从数据中学习并预测趋势和结果的算法。包括利用机器学习算法来进行自然语言处理、预测分析、图像识别等种种功能。另外,埃森哲于2月8日收购了AI网络安全公司Endgame的联邦服务部门。LRR Partners于1月9日收购了 BluVector。BluVector是从国防承包商诺斯罗普格鲁曼公司分离出的子公司,其使用机器学习算法来实时检测企业网络中的安全威胁。 四、传统安全厂商有优势 随着工业4.0实施,工控不再是相对独立的网络,而是完全融入互联网的一部分。要从传统互联网的角度维护工控安全,而非工控系统。所以我们认为,未来的工控安全领域,传统IT厂商启明星辰(002439)、绿盟科技(300369)等具有显著优势。 五、投资建议 我们推荐人工智能网络安全龙头启明星辰,对应2017-2018年PE分别为38倍、28.6倍。从历史PE(TTM)看,启明星辰市盈率大部分时间处于56-75倍之间,截止3月10日市盈率只有59倍,估值处于历史水平偏下。 本文转自d1net(转载)

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册