面向方面软件中的基础程序的结构信息发生变化后,会导致意外的连接点丢失问题.其原因在于连接点的定义紧紧地依赖于基础程序的结构,这种紧密的耦合严重阻碍了面向方面软件的演化.提出一种基于元数据和反射的面向方面软件演化方法.在连接点定义和基础程序之间加入概念层,以实现连接点定义和基础程序结构的解耦.概念层模型用于描述基础程序的逻辑信息、物理信息,以及这两类信息之间的映射关系.基于Java Annotation元数据机制在基础程序中使用逻辑信息对程序结构进行标注,同时,使用逻辑信息定义连接点.根据基础程序中定义的元数据对基础程序进行转换,自动生成元对象,基于反射机制实现基础程序演化后连接点的正确匹配.详细阐述了函数、构造函数的转换算法.该方法较好地解决了面向方面软件中由于基础程序结构信息的变化而导致的连接点丢失问题,有助于构建可适应的面向方面软件.
The change of base program structure in aspect-oriented software will lead to the accidental join point miss.The reason is that the definition of the join point is tightly dependent on the base program's structure.Such a close coupling hinders the evolution of the aspect-oriented software heavily.This paper proposes an approach to aspect-oriented software evolution based on metadata and reflection.A conceptual level is added between the join point definition and the base program's structure in order to achieve decoupling.The conceptual model is used to describe the logical information,physical information,as well as the relationship between the two kinds of information.The structure of base program is annotated by logical information based on Java annotation metadata.Simultaneously,join points are also defined by the logical information.The base program is transformed based on the defined metadata and meta objects are generated automatically.On the basis of reflection,the join points can be matched correctly after the evolution of base program.Transformation algorithms for method and constructor are described in detail.This approach solves the accidental join point miss problem effectively,and can be helpful to construct adaptable aspect-oriented software.