The invention belongs to the field of computer technology, and discloses a method and related device for the internal behavior of the intervening object, and the behavior of the object is intervened by the behavioral trigger, and the extra action is executed before or after the internal behavior begins. The specific steps are to specify the type of the intervened object, at the same time, to specify the behavior and trigger of the intervention; to implement the intervener; to define the intervention interface; to automatically generate the derivative agent class; to instantiate the derivative agent class; to inject the intervener into the object via the intervention interface. Using this method, the internal behavior of the object can be intervened without destroying the encapsulation principle, and the object attribute change tracking and association delay loading can be further implemented.
【技术实现步骤摘要】
一种介入对象内部行为的方法及相关装置
本专利技术属于计算机
,具体为一种介入对象内部行为的方法及相关装置。
技术介绍
对象关系映射(ORM)是指在对象模型与关系模型之间实施双向映射。在将对象映射为关系数据时为了有针对性地修改关系字段需要知道对象的哪些属性(Attribute)发生过修改,即更改跟踪;在将关系数据映射为对象时,为提升性能通常不是在加载对象时随之加载其关联,而是延后到对象活动期间关联被访问时才加载,即延迟加载。作为独立于具体业务系统的第三方ORM程序,实现更改跟踪和延迟加载面临着一个障碍,即由于对象系统在设计时会遵循面向对象的封装性原则,修改属性和访问关联均属于对象内部行为,外部的ORM程序是无法感知这些行为的。因此,必须专利技术一种介入对象内部行为的方法,以便ORM程序可以在不破坏封装性原则的前提下捕获对象的内部行为。
技术实现思路
专利技术一种介入对象内部行为的方法,以便处于对象系统外部的ORM程序可以在不破坏面向对象封装性原则的前提下介入对象内部行为,从而实现对象属性更改跟踪和关联延迟加载。所采用的技术方案如下。1.一种介入对象内部行为的方法, ...
【技术保护点】
一种介入对象内部行为的方法,其特征在于包含以下步骤:作为输入参数,指定被介入对象的类型,同时指明需要介入的行为及其触发器,如果多个行为共用一个触发器,还需指明这些行为的介入优先级;实现介入者;定义介入接口;自动生成派生代理类;实例化派生代理类;经由介入接口将介入者注入对象内部。
【技术特征摘要】
1.一种介入对象内部行为的方法,其特征在于包含以下步骤:作为输入参数,指定被介入对象的类型,同时指明需要介入的行为及其触发器,如果多个行为共用一个触发器,还需指明这些行为的介入优先级;实现介入者;定义介入接口;自动生成派生代理类;实例化派生代理类;经由介入接口将介入者注入对象内部。2.如权利要求1所述的行为触发器,其特征在于可以定义三种类型的触发器,即:Public-Method触发器;Public-Property-getter触发器;Public-Property-setter触发器。3.如权利要求1所述的派生代理类,其特征在于实现了所述介入接口。4.如权利要求1所述的派生代理类,其特征还在于按以下步骤重写行为触发器:前置介入调用;调用原始类型定义的触发器逻辑;后置介入调用。5.如权利要求4所述的介入调用,其特征在于它是按如下步骤生成的调用清单:按触发器对输入的介入行为进行分类汇总...
还没有人留言评论。发表了对其他浏览者有用的留言会获得科技券。