Recipe16.2.Declaring Inheritance Between Classes


Recipe 16.2. Declaring Inheritance Between Classes

Problem

You want to introduce a new inheritance relationship between two classes.

Solution

Use the declare parents statement to specify a particular class that extends from another class.

Discussion

Example 16-2 shows how a new inheritance relationship can be specified for the MyClass class.

Example 16-2. Adding a new inheritance relationship between classes
public aspect IntroduceInheritanceRecipe {                  declare  parents : MyClass extends AnotherClass; }

Figure 16-2 shows the class structure of the MyClass class before and after the aspect in Example 16-2 is applied.

Figure 16-2. The MyClass class before and after the aspect introduces a new inheritance relationship


See Also

Recipe 16.3 shows how to apply new interfaces to an existing class using aspects.



AspectJ Cookbook
Aspectj Cookbook
ISBN: 0596006543
EAN: 2147483647
Year: 2006
Pages: 203
Authors: Russ Miles

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net