CN108170407A - A kind of method and device for obtaining target data - Google Patents
A kind of method and device for obtaining target data Download PDFInfo
- Publication number
- CN108170407A CN108170407A CN201611103938.1A CN201611103938A CN108170407A CN 108170407 A CN108170407 A CN 108170407A CN 201611103938 A CN201611103938 A CN 201611103938A CN 108170407 A CN108170407 A CN 108170407A
- Authority
- CN
- China
- Prior art keywords
- target data
- data
- processing function
- entry point
- calling
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/20—Software design
- G06F8/22—Procedural
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
Abstract
Description
技术领域technical field
本发明涉及数据业务领域,尤指一种获取目标数据的方法及装置。The invention relates to the field of data services, in particular to a method and device for acquiring target data.
背景技术Background technique
随着互联网应用如业务查询和网络支付的快速发展,互联网用户的数量得到了快速增长,互联网技术同样得到了飞速地发展;其中,表述性状态转移(RepresentationalState Transfer,REST)技术因优先考虑模块的分布性和扩展性的特点,在互联网领域有着广泛的应用。With the rapid development of Internet applications such as business query and network payment, the number of Internet users has grown rapidly, and Internet technology has also developed rapidly; among them, Representational State Transfer (REST) technology is due to the priority of module The characteristics of distribution and scalability have a wide range of applications in the Internet field.
然而,在现有的技术中对于以软件Jersey框架实现的REST服务,往往因缺乏良好的模块维护性和良好的模块化,导致大量的代码冗余;以查询余额为例,在接收到客户端发送的查询请求后,需要首先获取用户凭证,然后在各个接口处加入大量关于是否获取到用户凭证的判断,造成代码的大量冗余。However, in the existing technology, for the REST service implemented by the software Jersey framework, it often lacks good module maintenance and good modularization, resulting in a lot of code redundancy; taking balance query as an example, after receiving the client After sending the query request, you need to obtain the user credentials first, and then add a lot of judgments on whether to obtain the user credentials at each interface, resulting in a lot of redundancy in the code.
目前,在互联网领域中现有的公知技术除了REST技术,还包括:控制反转(Inversion of Control,IoC)容器技术,面向切面编程(Aspect Oriented Programming,AOP)技术,数据库技术等;其中,IoC容器技术是一个拥有控制反转,具有依赖注入功能的容器,负责实例化应用程序中的对象及建立这些对象之间的依赖,IoC是一个重要的面向对象编程的法则来削减计算机程序的耦合问题,也是轻量级的软件Spring框架的核心;AOP技术通过预编译方式和运行期动态代理实现程序功能的统一维护的一种技术,它是面向对象编程(Object Oriented Programming,OOP)的延续,是Spring框架中的一个重要内容,是函数式编程的一种衍生范型,利用AOP技术可以实现对业务逻辑的各个部分进行隔离,从而降低业务逻辑各部分之间的耦合度,提高程序的可重用性,同时提高开发的效率。At present, in addition to the REST technology, the existing known technologies in the Internet field also include: Inversion of Control (IoC) container technology, aspect-oriented programming (Aspect Oriented Programming, AOP) technology, database technology, etc.; among them, IoC Container technology is a container with inversion of control and dependency injection function, which is responsible for instantiating objects in the application and establishing dependencies between these objects. IoC is an important object-oriented programming law to reduce the coupling of computer programs. , is also the core of the lightweight software Spring framework; AOP technology is a technology that realizes unified maintenance of program functions through pre-compilation and runtime dynamic proxy. It is a continuation of Object Oriented Programming (OOP) and is An important content in the Spring framework is a derivative paradigm of functional programming. AOP technology can be used to isolate various parts of the business logic, thereby reducing the coupling degree between the various parts of the business logic and improving the reusability of the program. performance while improving development efficiency.
基于此,如何利用现有的公知技术,在获取目标数据时,解决大量代码冗余的问题,清晰化模块,实现模块的高内聚低耦合,是本领域技术人员亟待解决的技术问题。Based on this, how to use the existing known technology to solve the problem of a large number of code redundancy when acquiring target data, clarify the module, and realize the high cohesion and low coupling of the module is a technical problem to be solved urgently by those skilled in the art.
发明内容Contents of the invention
本发明实施例提供一种获取目标数据的方法及装置,用以解决如何利用现有的公知技术,在获取目标数据时,解决大量代码冗余的问题,清晰化模块,实现模块的高内聚低耦合。The embodiment of the present invention provides a method and device for obtaining target data, which is used to solve the problem of a large number of redundant codes when obtaining target data by using existing known technologies, clarify modules, and realize high cohesion of modules low coupling.
本发明实施例提供了一种获取目标数据的方法,包括:An embodiment of the present invention provides a method for acquiring target data, including:
接收客户端发送的获取目标数据请求;Receive the target data acquisition request sent by the client;
调用预先设定的环绕通知内与所述目标数据对应的切入点处理函数;Calling the pointcut processing function corresponding to the target data in the preset surrounding advice;
确定调用所述切入点处理函数后接收到的数据是否符合预设的与所述目标数据匹配的规则;determining whether the data received after invoking the pointcut processing function complies with a preset rule matching the target data;
在确定调用所述切入点处理函数后接收到的数据符合预设的与所述目标数据匹配的规则时,确定所述接收到的数据为目标数据,并向所述客户端反馈所述目标数据。When it is determined that the data received after calling the pointcut processing function conforms to the preset rule matching the target data, determine that the received data is target data, and feed back the target data to the client .
在一种可能的实施方式中,在本发明实施例提供的上述获取目标数据的方法中,所述确定调用所述切入点处理函数后接收到的数据是否符合预设的与所述目标数据匹配的规则,具体包括:In a possible implementation manner, in the above-mentioned method for acquiring target data provided by the embodiment of the present invention, the determination of whether the data received after calling the entry point processing function conforms to the preset match with the target data rules, including:
确定调用所述切入点处理函数后接收到的数据的标记是否与预设的目标数据的标记一致。It is determined whether the label of the data received after calling the pointcut processing function is consistent with the preset target data label.
在一种可能的实施方式中,在本发明实施例提供的上述获取目标数据的方法中,在确定调用所述切入点处理函数后接收到的数据不符合预设的与所述目标数据匹配的规则时,还包括:In a possible implementation manner, in the above-mentioned method for acquiring target data provided by the embodiment of the present invention, after it is determined that the entry point processing function is called, the received data does not conform to the preset Rules also include:
向远程服务端申请用户凭证;Apply for user credentials from the remote server;
在确定申请到所述用户凭证时,根据所述用户凭证再次调用所述切入点处理函数获取目标数据。When it is determined that the user credential has been applied for, the entry point processing function is called again according to the user credential to acquire target data.
在一种可能的实施方式中,在本发明实施例提供的上述获取目标数据的方法中,所述接收客户端发送的获取目标数据请求之前,还包括:In a possible implementation manner, in the above-mentioned method for obtaining target data provided by the embodiment of the present invention, before receiving the request for obtaining target data sent by the client, further includes:
分别配置控制反转IoC容器、面向切面编程AOP、以及表述性状态传递REST风格架构的软件框架Jersey;Separately configure the software framework Jersey of inversion of control IoC container, aspect-oriented programming AOP, and representational state transfer REST style architecture;
根据所述Jersey的REST的特点,确定用于获取数据的函数;According to the characteristics of the REST of Jersey, determine the function used to obtain the data;
根据所述确定出的用于获取数据的函数,确定切面内包含需要申请用户凭证的各切入点及环绕通知。According to the determined function for obtaining data, it is determined that each entry point that needs to apply for user credentials and surrounding notifications are included in the cut plane.
在一种可能的实施方式中,在本发明实施例提供的上述获取目标数据的方法中,还包括:In a possible implementation manner, the above-mentioned method for acquiring target data provided in the embodiment of the present invention further includes:
当业务确定不再需要申请用户凭证时,在所述IoC容器内移除相应的切面。When the service determines that it is no longer necessary to apply for user credentials, the corresponding aspect is removed in the IoC container.
本发明实施例还提供了一种获取目标数据的装置,包括:The embodiment of the present invention also provides a device for acquiring target data, including:
接收模块,用于接收客户端发送的获取目标数据请求;The receiving module is used to receive the request for obtaining target data sent by the client;
调用模块,用于调用预先设定的环绕通知内与所述目标数据对应的切入点处理函数;A calling module, used to call the entry point processing function corresponding to the target data in the preset surround notification;
确定模块,用于确定调用所述切入点处理函数后接收到的数据是否符合预设的与所述目标数据匹配的规则;在确定调用所述切入点处理函数后接收到的数据符合预设的与所述目标数据匹配的规则时,确定所述接收到的数据为目标数据,并向所述客户端反馈所述目标数据。A determining module, configured to determine whether the data received after calling the entry point processing function conforms to the preset rule matching the target data; after determining that the data received after calling the entry point processing function meets the preset When a rule matches the target data, determine that the received data is target data, and feed back the target data to the client.
在一种可能的实施方式中,在本发明实施例提供的上述获取目标数据的装置中,所述确定模块,具体用于确定调用所述切入点处理函数后接收到的数据的标记是否与预设的目标数据的标记一致。In a possible implementation manner, in the above-mentioned device for acquiring target data provided by the embodiment of the present invention, the determination module is specifically configured to determine whether the label of the data received after calling the entry point processing function is consistent with the predetermined The labeling of the target data set is the same.
在一种可能的实施方式中,在本发明实施例提供的上述获取目标数据的装置中,还包括:In a possible implementation manner, the above-mentioned device for acquiring target data provided in the embodiment of the present invention further includes:
申请模块,用于向远程服务端申请用户凭证;The application module is used to apply for user credentials from the remote server;
获取模块,用于在确定申请到所述用户凭证时,根据所述用户凭证再次调用所述切入点处理函数获取目标数据。The acquiring module is configured to call the entry point processing function again according to the user credential to acquire target data when it is determined that the user credential is applied for.
在一种可能的实施方式中,在本发明实施例提供的上述获取目标数据的装置中,还包括:In a possible implementation manner, the above-mentioned device for acquiring target data provided in the embodiment of the present invention further includes:
预处理模块,用于分别配置控制反转IoC容器、面向切面编程AOP、以及REST风格架构的软件框架Jersey;根据所述Jersey的REST的特点,确定用于获取数据的函数;根据所述确定出的用于获取数据的函数,确定切面内包含需要申请用户凭证的各切入点及环绕通知。The preprocessing module is used to respectively configure the software framework Jersey of the inversion of control IoC container, the aspect-oriented programming AOP, and the REST style architecture; according to the characteristics of the REST of the Jersey, determine the function used to obtain the data; determine according to the described The function used to obtain data, and determine that the aspect contains each entry point and surrounding notification that need to apply for user credentials.
在一种可能的实施方式中,在本发明实施例提供的上述获取目标数据的装置中,还包括:In a possible implementation manner, the above-mentioned device for acquiring target data provided in the embodiment of the present invention further includes:
移除模块,用于当业务确定不再需要申请用户凭证时,在所述IoC容器内移除相应的切面。The removal module is used to remove the corresponding aspect in the IoC container when the service determines that it is no longer necessary to apply for the user certificate.
本发明有益效果如下:The beneficial effects of the present invention are as follows:
本发明实施例提供的一种获取目标数据的方法及装置,在接收到客户端发送的获取目标数据请求后,进入相应切面的环绕通知内,通过调用环绕通知内与目标数据对应的切入点处理函数,确定调用切入点处理函数后接收到的数据是否符合预设的与目标数据匹配的规则;在确定符合时,即可确定接收到的数据为目标数据,并向客户端反馈目标数据;因此,在获取目标数据的过程中首先需要确定的是调用切入点处理函数后接收到的数据是否为目标数据,而不是首先去判断是否需要申请用户凭证,可以有效减小在各接口处加入的确定是否申请用户凭证的数量,解决了大量代码冗余的问题;同时,由于切面化的模块设计,如果业务上不再需要申请用户凭证,可以以组件的方式直接将其从代码中移除,不会修改其它的模块代码,使得模块更加清晰化,实现了模块的高内聚低耦合。A method and device for acquiring target data provided by the embodiments of the present invention, after receiving the request for acquiring target data sent by the client, enters the surrounding notification of the corresponding aspect, and processes the data by calling the entry point corresponding to the target data in the surrounding notification Function to determine whether the data received after calling the pointcut processing function conforms to the preset rules matching the target data; when it is determined to match, it can be determined that the received data is the target data, and the target data is fed back to the client; therefore , in the process of obtaining the target data, the first thing to determine is whether the data received after calling the entry point processing function is the target data, instead of first judging whether to apply for user credentials, which can effectively reduce the determination of adding at each interface Whether or not to apply for the number of user credentials solves the problem of a large number of code redundancy; at the same time, due to the aspect-based module design, if the business no longer needs to apply for user credentials, it can be directly removed from the code in the form of components. The code of other modules will be modified to make the module clearer and achieve high cohesion and low coupling of the module.
附图说明Description of drawings
图1为本发明实施例中提供的一种获取目标数据的方法的流程图之一;FIG. 1 is one of the flowcharts of a method for acquiring target data provided in an embodiment of the present invention;
图2为本发明实施例中提供的一种获取目标数据的方法的流程图之二;FIG. 2 is the second flowchart of a method for acquiring target data provided in an embodiment of the present invention;
图3为本发明实施例中提供的一种获取目标数据的方法的流程图之三;FIG. 3 is the third flowchart of a method for acquiring target data provided in an embodiment of the present invention;
图4为本发明实施例中提供的实施例一的流程示意图;FIG. 4 is a schematic flowchart of Embodiment 1 provided in the embodiments of the present invention;
图5为本发明实施例中提供的一种获取目标数据的装置的结构示意图。FIG. 5 is a schematic structural diagram of an apparatus for acquiring target data provided in an embodiment of the present invention.
具体实施方式Detailed ways
下面将结合附图,对本发明实施例提供的一种获取目标数据的方法及装置的具体实施方式进行详细地说明。需要说明的是,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The specific implementation manners of a method and device for acquiring target data provided by the embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be noted that the described embodiments are only some of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.
本发明实施例提供了一种获取目标数据的方法,如图1所示,可以具体包括以下几个步骤:The embodiment of the present invention provides a method for acquiring target data, as shown in FIG. 1 , which may specifically include the following steps:
S101、接收客户端发送的获取目标数据请求;S101. Receive the target data acquisition request sent by the client;
S102、调用预先设定的环绕通知内与目标数据对应的切入点处理函数;S102. Invoking a pre-set entry point processing function corresponding to the target data in the surround notification;
S103、确定调用切入点处理函数后接收到的数据是否符合预设的与目标数据匹配的规则;若符合,则执行步骤S104;S103. Determine whether the data received after calling the entry point processing function conforms to the preset rule matching the target data; if so, execute step S104;
S104、确定接收到的数据为目标数据;S104. Determine that the received data is target data;
S105、向客户端反馈目标数据。S105. Feedback the target data to the client.
本发明实施例提供的上述获取目标数据的方法,在获取目标数据的过程中首先需要确定的是调用切入点处理函数后接收到的数据是否为目标数据,而不是首先去判断是否需要申请用户凭证,可以有效减小在各接口处加入的确定是否申请用户凭证的数量,解决了大量代码冗余的问题;同时,由于切面化的模块设计,如果业务上不再需要申请用户凭证,可以以组件的方式直接将其从代码中移除,不会修改其它的模块代码,使得模块更加清晰化,实现了模块的高内聚低耦合。In the above-mentioned method for obtaining target data provided by the embodiments of the present invention, in the process of obtaining target data, the first thing to determine is whether the data received after calling the entry point processing function is the target data, rather than first judging whether it is necessary to apply for a user certificate , which can effectively reduce the number of user certificates added at each interface to determine whether to apply for user certificates, and solve the problem of a large number of code redundancy; at the same time, due to the aspect-based module design, if there is no need to apply for user certificates in business, you can use components It is directly removed from the code without modifying other module codes, which makes the module clearer and realizes high cohesion and low coupling of the module.
在具体实施时,为了完成对环绕通知的预先设定,在本发明实施例提供的上述获取目标数据的方法中的步骤S101,在接收客户端发送的获取目标数据请求之前,如图2所示,可以包括以下几个步骤:In actual implementation, in order to complete the presetting of the surrounding notification, in step S101 of the method for acquiring target data provided by the embodiment of the present invention, before receiving the request for acquiring target data sent by the client, as shown in FIG. 2 , can include the following steps:
S201、分别配置控制反转IoC容器、面向切面编程AOP、以及REST风格架构的软件框架Jersey;S201, respectively configuring the IoC container for inversion of control, the aspect-oriented programming AOP, and the software framework Jersey of the REST style architecture;
S202、根据Jersey的REST的特点,确定用于获取数据的函数;S202. According to the characteristics of REST of Jersey, determine a function for obtaining data;
S203、根据确定出的用于获取数据的函数,确定切面内包含需要申请用户凭证的各切入点及环绕通知。S203. According to the determined function for obtaining data, determine that each entry point and surrounding notification that need to apply for a user credential are included in the aspect.
具体地,为了能够获取到数据,在本发明实施例提供的上述获取目标数据的方法中的步骤S202,在实际的处理过程中,可以根据Jersey的REST的特点,并按照一定的规则,编写函数,用于获取远程中存储的数据。Specifically, in order to be able to obtain data, in step S202 of the method for obtaining target data provided by the embodiment of the present invention, in the actual processing process, the function can be written according to the characteristics of Jersey's REST and according to certain rules , used to get the data stored in the remote.
具体地,为了能够利用环绕通知获取用户凭证,在本发明实施例提供的上述获取目标数据的方法中的步骤S203,需要确定切面内的各切入点,当然,此处的切入点包括需要申请用户凭证的切入点,还包括不需要申请用户凭证的切入点,在确定切面时这些切入点均需要配置;另外,除了确定切面内的各切入点,还需要确定包含需要申请用户凭证的切入点的环绕通知,用于申请用户凭证。Specifically, in order to be able to obtain user credentials by using surrounding notifications, in step S203 of the method for obtaining target data provided by the embodiment of the present invention, it is necessary to determine each entry point in the cut plane. Of course, the entry point here includes the user who needs to apply for Credential entry points also include entry points that do not need to apply for user credentials. These entry points need to be configured when determining the aspect; in addition, in addition to determining each entry point in the aspect, it is also necessary to determine the entry points that need to apply for user credentials. Surround notification for requesting user credentials.
其中,以@Around("execution(*cmcc.hq.cmri.bgdt.service.QAService.get*(..))")为例,@Around表示环绕通知,"execution(*cmcc.hq.cmri.bgdt.service.QAService.get*(..))"表示切入点,该切入点同时也是步骤S202中确定的用于获取数据的函数。Among them, take @Around("execution(*cmcc.hq.cmri.bgdt.service.QAService.get*(..))") as an example, @Around means surround notification, "execution(*cmcc.hq.cmri. bgdt.service.QAService.get*(..))" indicates an entry point, which is also a function for obtaining data determined in step S202.
具体地,在本发明实施例提供的上述获取目标数据的方法中的步骤S101,在接收客户端发送的获取目标数据请求后,由此可以进入相应切面的环绕通知内,进行下一步的操作。Specifically, in step S101 of the above-mentioned method for obtaining target data provided by the embodiment of the present invention, after receiving the request for obtaining target data sent by the client, it is possible to enter the surrounding notification of the corresponding aspect to perform the next operation.
具体地,在本发明实施例提供的上述获取目标数据的方法中的步骤S102,调用预先设定的环绕通知内与目标数据对应的切入点处理函数,可以具体包括:Specifically, in step S102 of the method for acquiring target data provided by the embodiment of the present invention, calling the entry point processing function corresponding to the target data in the preset surround notification may specifically include:
首先,触发与目标数据对应的切入点;First, trigger the pointcut corresponding to the target data;
其次,调用环绕通知;Second, call surround notification;
之后,进入环绕通知内,调用与目标数据对应的切入点处理函数。After that, enter the surrounding advice and call the pointcut processing function corresponding to the target data.
具体地,为了能够确定接收到的数据与目标数据是否匹配,在本发明实施例提供的上述获取目标数据的方法中的步骤S103,确定调用切入点处理函数后接收到的数据是否符合预设的与目标数据匹配的规则,可以具体包括:Specifically, in order to be able to determine whether the received data matches the target data, in step S103 of the method for acquiring target data provided by the embodiment of the present invention, it is determined whether the received data conforms to the preset The rules matching the target data can specifically include:
确定调用切入点处理函数后接收到的数据的标记是否与预设的目标数据的标记一致。It is determined whether the mark of the data received after calling the pointcut processing function is consistent with the mark of the preset target data.
当然,接收到的数据的标记与目标数据的标记均是预先设定的,根据标记的对比,确定接收到的数据是否符合预设的与目标数据匹配的规则,即确定接收到的数据是否为目标数据;其中,标记可以是数字,字符等其他可以用于标记的任何形式,在此不作限定。Of course, the marks of the received data and the marks of the target data are pre-set. According to the comparison of the marks, it is determined whether the received data conforms to the preset rule of matching the target data, that is, it is determined whether the received data is Target data; wherein, the mark can be any form such as numbers and characters that can be used for marking, which is not limited here.
在具体实施时,在本发明实施例提供的上述获取目标数据的方法中的步骤S103,在确定调用切入点处理函数后接收到的数据不符合预设的与目标数据匹配的规则之后,如图3所示,还可以包括:In specific implementation, in step S103 of the method for acquiring target data provided by the embodiment of the present invention, after it is determined that the data received after calling the entry point processing function does not conform to the preset rule matching the target data, as shown in the figure 3, may also include:
S106、向远程服务端申请用户凭证;S106. Apply for a user certificate from the remote server;
S107、在确定申请到用户凭证时,根据用户凭证再次调用切入点处理函数获取目标数据。S107. When it is determined that the user credential has been applied for, the entry point processing function is called again according to the user credential to obtain the target data.
在具体实施时,在向用户申请凭证之后,有可能申请到用户凭证,当然,也有可能未申请到用户凭证,在确定申请到用户凭证时,根据用户凭证再次调用切入点处理函数获取目标数据;在确定未申请到用户凭证时,从环绕通知内部抛出异常。In actual implementation, after applying for a certificate from the user, it is possible to apply for the user certificate, of course, it is also possible not to apply for the user certificate. When it is confirmed that the user certificate is applied, the entry point processing function is called again according to the user certificate to obtain the target data; An exception is thrown from within the surrounding notification when it is determined that no user credentials have been requested.
在具体实施时,在本发明实施例提供的上述获取目标数据的方法中,还可以包括:During specific implementation, in the above-mentioned method for acquiring target data provided by the embodiments of the present invention, it may also include:
当业务确定不再需要申请用户凭证时,在IoC容器内移除相应的切面。When the business determines that it is no longer necessary to apply for user credentials, remove the corresponding aspect in the IoC container.
具体地,根据与远程服务端协商的结果,对于客户端发送的获取目标数据的请求,有时可以不需要申请用户凭证便能够获取到目标数据并发送至客户端,即无需再调用切面环绕通知逻辑,此时可以通过IoC容器将预先设定的用于申请用户凭证的切面取消掉,不执行此切面;当然,在需要申请用户凭证时,即需要调用切面环绕通知逻辑,还可以通过IoC容器对预先设定的用于申请用户凭证的切面进行重新注解;因此,通过IoC容器,可以实现对切面的取消和注解,如此可以摆脱侵入式的编程,避免对其他代码的影响,便于组装和拆卸,有利于实现模块的高内聚低耦合。Specifically, according to the result of negotiation with the remote server, for the request sent by the client to obtain the target data, sometimes the target data can be obtained and sent to the client without applying for user credentials, that is, there is no need to call the aspect surround notification logic , at this time, the preset aspect for applying for user credentials can be canceled through the IoC container, and this aspect is not executed; of course, when it is necessary to apply for user credentials, the aspect needs to be called to surround the notification logic, and the IoC container can also be used to The pre-set aspects used to apply for user credentials are re-annotated; therefore, through the IoC container, the cancellation and annotation of the aspects can be realized, so as to get rid of intrusive programming, avoid the impact on other codes, and facilitate assembly and disassembly. It is beneficial to realize high cohesion and low coupling of modules.
当然,本发明实施例提供的上述获取目标数据的方法,不仅可以应用到余额查询,积分查询之类的查询业务中,还可以应用到其他需要申请用户凭证及需要条件查询的业务中,在此不作限定。Of course, the above-mentioned method for obtaining target data provided by the embodiment of the present invention can not only be applied to query services such as balance query and points query, but also can be applied to other services that require user certificate application and condition query. Not limited.
另外,在实际的业务处理过程中,具体的获取目标数据的系统可以具体包括:业务逻辑单元,切面单元,以及框架单元;其中,业务逻辑单元,用于构建获取目标数据的业务逻辑;切面单元,用于编写切面逻辑内的各切入点及环绕通知;框架单元,用于构建获取目标数据系统的框架;因此,通过在获取目标数据的系统中加入相应的切面,从切面的角度分析,确定是否申请用户凭证,较大地减少了各接口处判断是否申请用户凭证的数量,实现了系统的高内聚。In addition, in the actual business processing process, the specific system for obtaining target data may specifically include: business logic unit, aspect unit, and framework unit; among them, the business logic unit is used to construct the business logic for obtaining target data; the aspect unit , used to write each entry point and surrounding notification in the aspect logic; the frame unit is used to construct the framework of the system for obtaining the target data; Whether to apply for user certificates greatly reduces the number of judgments at each interface whether to apply for user certificates, and achieves high cohesion of the system.
下面将通过具体实施例详细说明本发明实施例提供的上述获取目标数据的方法。The above-mentioned method for acquiring target data provided by the embodiments of the present invention will be described in detail below through specific embodiments.
实施例一:Embodiment one:
以客户端发送的“查询余额”请求为例,在获取查询余额数据的过程中,确定需要调用切面环绕通知时,如图4所示,可以包括以下步骤:Taking the "check balance" request sent by the client as an example, in the process of obtaining the check balance data, when it is determined that the aspect surround notification needs to be invoked, as shown in Figure 4, the following steps may be included:
S401、接收客户端发送的查询余额请求;S401. Receive a balance inquiry request sent by the client;
S402、触发与查询余额数据对应的切入点;S402, triggering an entry point corresponding to query balance data;
S403、调用环绕通知;S403. Invoke surround notification;
S404、调用环绕通知内与查询余额数据对应的切入点处理函数;S404. Call the entry point processing function corresponding to the query balance data in the surround notification;
S405、确定调用切入点处理函数后接收到的数据的标记是否与预设的查询余额数据的标记一致;若一致,则执行步骤S406;若不一致,则执行步骤S407;S405. Determine whether the mark of the data received after calling the entry point processing function is consistent with the mark of the preset query balance data; if they are consistent, execute step S406; if not, execute step S407;
S406、确定接收到的数据是查询余额数据,并向客户端反馈查询余额数据,结束流程;S406. Determine that the received data is balance query data, and feed back the balance query data to the client, and end the process;
S407、确定获取查询余额数据失败;S407. It is determined that the acquisition of query balance data fails;
S408、向远程服务端申请用户凭证;S408. Apply for a user certificate from the remote server;
S409、确定是否申请到用户凭证;若未申请到,则执行步骤S410;若申请到,则执行步骤S411;S409. Determine whether the user certificate has been applied; if not, execute step S410; if apply, execute step S411;
S410、从环绕通知内部抛出异常,结束流程;S410. Throw an exception from inside the surround notification, and end the process;
S411、根据用户凭证再次调用切入点处理函数获取目标数据;S411. Call the entry point processing function again according to the user credentials to obtain the target data;
S412、将获取到的目标数据反馈至客户端。S412. Feed back the acquired target data to the client.
基于同一发明构思,本发明实施例还提供了一种获取目标数据的装置,由于该装置解决问题的原理与前述一种获取目标数据的方法相似,因此该装置的实施可以参见方法的实施,重复之处不再赘述。Based on the same inventive concept, the embodiment of the present invention also provides a device for obtaining target data. Since the problem-solving principle of the device is similar to the aforementioned method for obtaining target data, the implementation of the device can refer to the implementation of the method, repeat The place will not be repeated.
具体地,本发明实施例提供了一种获取目标数据的装置,如图5所示,可以具体包括以下几个模块:Specifically, an embodiment of the present invention provides an apparatus for acquiring target data, as shown in FIG. 5 , which may specifically include the following modules:
接收模块501,用于接收客户端发送的获取目标数据请求;A receiving module 501, configured to receive a request for acquiring target data sent by a client;
调用模块502,用于调用预先设定的环绕通知内与目标数据对应的切入点处理函数;The calling module 502 is used to call the entry point processing function corresponding to the target data in the preset surround notification;
确定模块503,用于确定调用切入点处理函数后接收到的数据是否符合预设的与目标数据匹配的规则;在确定调用切入点处理函数后接收到的数据符合预设的与目标数据匹配的规则时,确定接收到的数据为目标数据,并向客户端反馈目标数据。The determining module 503 is used to determine whether the data received after calling the entry point processing function conforms to the preset rule matching the target data; after determining that the data received after calling the entry point processing function conforms to the preset When specifying the rules, determine that the received data is the target data, and feed back the target data to the client.
在具体实施时,在本发明实施例提供的上述获取目标数据的装置中,确定模块503,具体用于确定调用切入点处理函数后接收到的数据的标记是否与预设的目标数据的标记一致。During specific implementation, in the above-mentioned device for obtaining target data provided by the embodiment of the present invention, the determination module 503 is specifically used to determine whether the mark of the data received after calling the entry point processing function is consistent with the mark of the preset target data .
在具体实施时,在本发明实施例提供的上述获取目标数据的装置中,如图5所示,还可以包括:During specific implementation, in the above-mentioned device for acquiring target data provided in the embodiment of the present invention, as shown in FIG. 5 , it may also include:
申请模块504,用于向远程服务端申请用户凭证;An application module 504, configured to apply for a user certificate to the remote server;
获取模块505,用于在确定申请到用户凭证时,根据用户凭证再次调用切入点处理函数获取目标数据。The acquiring module 505 is configured to call the entry point processing function again to acquire the target data according to the user credentials when it is determined that the user credentials are applied for.
在具体实施时,在本发明实施例提供的上述获取目标数据的装置中,如图5所示,还可以包括:During specific implementation, in the above-mentioned device for acquiring target data provided in the embodiment of the present invention, as shown in FIG. 5 , it may also include:
预处理模块506,用于分别配置控制反转IoC容器、面向切面编程AOP、以及REST风格架构的软件框架Jersey;根据Jersey的REST的特点,确定用于获取数据的函数;根据确定出的用于获取数据的函数,确定切面内包含需要申请用户凭证的各切入点及环绕通知。The preprocessing module 506 is used to respectively configure the control inversion IoC container, the aspect-oriented programming AOP, and the software framework Jersey of the REST style architecture; according to the characteristics of Jersey's REST, determine the function used to obtain data; The function of obtaining data, and confirming that the aspect contains each entry point and surrounding notification that need to apply for user credentials.
在具体实施时,在本发明实施例提供的上述获取目标数据的装置中,如图5所示,还可以包括:During specific implementation, in the above-mentioned device for acquiring target data provided in the embodiment of the present invention, as shown in FIG. 5 , it may also include:
移除模块507,用于当业务确定不再需要申请用户凭证时,在IoC容器内移除相应的切面。The removal module 507 is configured to remove the corresponding aspect in the IoC container when the service determines that it is no longer necessary to apply for user credentials.
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器和光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of the present application may be provided as methods, systems, or computer program products. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) having computer-usable program code embodied therein.
本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present application is described with reference to flowcharts and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present application. It should be understood that each procedure and/or block in the flowchart and/or block diagram, and a combination of procedures and/or blocks in the flowchart and/or block diagram can be realized by computer program instructions. These computer program instructions may be provided to a general purpose computer, special purpose computer, embedded processor, or processor of other programmable data processing equipment to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing equipment produce a An apparatus for realizing the functions specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions The device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device, causing a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, thereby The instructions provide steps for implementing the functions specified in the flow chart or blocks of the flowchart and/or the block or blocks of the block diagrams.
尽管已描述了本发明的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。While preferred embodiments of the invention have been described, additional changes and modifications to these embodiments can be made by those skilled in the art once the basic inventive concept is appreciated. Therefore, it is intended that the appended claims be construed to cover the preferred embodiment as well as all changes and modifications which fall within the scope of the invention.
本发明实施例提供了一种获取目标数据的方法及装置,在接收到客户端发送的获取目标数据请求后,进入相应切面的环绕通知内,通过调用环绕通知内与目标数据对应的切入点处理函数,确定调用切入点处理函数后接收到的数据是否符合预设的与目标数据匹配的规则;在确定符合时,即可确定接收到的数据为目标数据,并向客户端反馈目标数据;因此,在获取目标数据的过程中首先需要确定的是调用切入点处理函数后接收到的数据是否为目标数据,而不是首先去判断是否需要申请用户凭证,可以有效减小在各接口处加入的确定是否申请用户凭证的数量,解决了大量代码冗余的问题;同时,由于切面化的模块设计,如果业务上不再需要申请用户凭证,可以以组件的方式直接将其从代码中移除,不会修改其它的模块代码,使得模块更加清晰化,实现了模块的高内聚低耦合。The embodiment of the present invention provides a method and device for obtaining target data. After receiving the request for obtaining target data sent by the client, it enters the surrounding notification of the corresponding aspect, and processes the data by calling the entry point corresponding to the target data in the surrounding notification Function to determine whether the data received after calling the pointcut processing function conforms to the preset rules matching the target data; when it is determined to match, it can be determined that the received data is the target data, and the target data is fed back to the client; therefore , in the process of obtaining the target data, the first thing to determine is whether the data received after calling the entry point processing function is the target data, instead of first judging whether to apply for user credentials, which can effectively reduce the determination of adding at each interface Whether or not to apply for the number of user credentials solves the problem of a large number of code redundancy; at the same time, due to the aspect-based module design, if the business no longer needs to apply for user credentials, it can be directly removed from the code in the form of components. The code of other modules will be modified to make the module clearer and achieve high cohesion and low coupling of the module.
显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalent technologies, the present invention also intends to include these modifications and variations.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201611103938.1A CN108170407B (en) | 2016-12-05 | 2016-12-05 | A method and device for acquiring target data |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201611103938.1A CN108170407B (en) | 2016-12-05 | 2016-12-05 | A method and device for acquiring target data |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN108170407A true CN108170407A (en) | 2018-06-15 |
| CN108170407B CN108170407B (en) | 2020-12-29 |
Family
ID=62525919
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201611103938.1A Active CN108170407B (en) | 2016-12-05 | 2016-12-05 | A method and device for acquiring target data |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN108170407B (en) |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2009088749A2 (en) * | 2008-01-02 | 2009-07-16 | Harmonic, Inc. | Methods and system for efficient data transfer over hybrid fiber coax infrastructure |
| CN103049684A (en) * | 2012-12-21 | 2013-04-17 | 大唐软件技术股份有限公司 | Data authority control method and data authority control system based on RBAC (role-based access control) model extension |
| CN103618762A (en) * | 2013-11-08 | 2014-03-05 | 中标软件有限公司 | System and method for enterprise service bus state pretreatment based on AOP |
| CN103905526A (en) * | 2014-03-05 | 2014-07-02 | 深圳市同洲电子股份有限公司 | Dispatching method and server |
-
2016
- 2016-12-05 CN CN201611103938.1A patent/CN108170407B/en active Active
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2009088749A2 (en) * | 2008-01-02 | 2009-07-16 | Harmonic, Inc. | Methods and system for efficient data transfer over hybrid fiber coax infrastructure |
| CN103049684A (en) * | 2012-12-21 | 2013-04-17 | 大唐软件技术股份有限公司 | Data authority control method and data authority control system based on RBAC (role-based access control) model extension |
| CN103618762A (en) * | 2013-11-08 | 2014-03-05 | 中标软件有限公司 | System and method for enterprise service bus state pretreatment based on AOP |
| CN103905526A (en) * | 2014-03-05 | 2014-07-02 | 深圳市同洲电子股份有限公司 | Dispatching method and server |
Non-Patent Citations (1)
| Title |
|---|
| WEIXIN_34068198: "Spring-AOP的五种通知和切面的优先级、通知变量申明", 《CSDN博客 HTTPS://BLOG.CSDN.NET/WEIXIN_34068198/ARTICLE/DETAILS/93784501》 * |
Also Published As
| Publication number | Publication date |
|---|---|
| CN108170407B (en) | 2020-12-29 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN112333239B (en) | Business audit notification method, gateway, electronic equipment and readable medium | |
| CN111163129B (en) | A resource processing method and device based on a cross-chain network | |
| CN113220431B (en) | Cross-cloud distributed data task scheduling method, device and storage medium | |
| CN115668147A (en) | Preventing unauthorized deployment of packages in a cluster | |
| US20140366000A1 (en) | Platform for enabling creation and use of an API for a specific solution | |
| US20080235665A1 (en) | System and method for automated safe reprogramming of software radios | |
| CN111752587B (en) | Batch processing method and device for small programs, electronic equipment and readable storage medium | |
| US20030216927A1 (en) | System and method for automated safe reprogramming of software radios | |
| CN108243188B (en) | Interface access, interface call and interface verification processing method and device | |
| CN111062028B (en) | Authority management method and device, storage medium and electronic equipment | |
| US11108871B2 (en) | Dynamic generation of network routing configuration with service requirements | |
| US9922181B2 (en) | Security model for network information service | |
| CN112835916B (en) | API-based business processing method, device, and computer-readable storage medium | |
| US11017072B2 (en) | Scalable authentication between heterogeneous services | |
| KR102651156B1 (en) | Transaction check notification methods and gateways, electronic devices, readable media, and computer program products | |
| CN112764726A (en) | Data synthesis method and device | |
| CN111857736A (en) | Cloud computing product generation method, device, equipment and storage medium | |
| CN115237459A (en) | Software development kit generation method, device, equipment, storage medium and product | |
| US8645957B2 (en) | Optimized datacenter management by centralized task execution through dependency inversion | |
| CN114329369B (en) | Rights management method and device, electronic equipment and computer readable medium | |
| JP6340308B2 (en) | Parallel processing system, method, and program | |
| EP4278289A1 (en) | Method and system for providing access control governance | |
| CN111367867B (en) | Log information processing method and device, electronic equipment and storage medium | |
| CN108170407A (en) | A kind of method and device for obtaining target data | |
| CN107733709A (en) | Date storage method, device and electronic equipment |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |