[[kernel:0.8.5m2]] | |||||||||
Table of Contents
0.8.5M2 Release NotesImportant upgrade information:Gotchas:
If you are updgrading from a version earlier then:
Latest public build detailed information: Click here. See also for known limitations and bugs of current version. Major Changes for latest build:1. Refining ClassesRefining classes are an alternative to an inline implementation in the connector for implementing a refinable method. Refining classes implement logic for a specific target type and thus allow for aspectual polymorphism. The following code fragment shows an example persistence aspect that uses a refinable method for fetching data from the target object of an encountered joinpoint: class TestAspect { hook TestHook { TestHook(method(..args)) { execution(method); } refinable public Object getData(); before() { ... getData() ... ; } public void iAmRefining(String s) { ... } } } Now, depending on the encountered type, different manners for fetching data might be appropriate. The following code fragments show two example refinements for the above aspect bean: class TestRefinement refining TestAspect.TestHook for java.io.Serializable { public refinable Object getData() { thisHook.iAmRefining(thisJoinPoint.getName()); return thisJoinPointObject; } } class TestRefinement2 refining TestAspect.TestHook for status.DataStore { public refinable Object getData() { //refinable modifier here as well DataStore store = thisJoinPointObject; thisHook.iAmRefining(thisJoinPoint.getName()); return store.getData(); } } Notice that the thisJoinPointObject keyword has the type of the refining target. Apart from that keyword, the thisJoinPoint keyword and thisHook keywords are available as well. The thisHook keyword refers to the hook instance that has invoked the refinable method. This keyword has the type of the declared hook to refine. Refinements are bound lately. Just compile them into the classpath (as class or in jar) and the JAsCo runtime infrastructure will load them. Just make sure to use the compileRefinement tool for compiling them. The result of the above declaration is that the aspect will be that depending on the target type of the currently enountered joinpoint, the aspect will fetch the data to save in a different way! Inheritance for refining classes is allowed as well. 2. Connector Inline RefinementsInline refinements in the connector have some added features to make them consistent with refining classes:
Example: static connector InlineRefiningConnector { ToRefineAspect.ToRefine temp = new ToRefineAspect.ToRefine(* *.*(*)) { public refinable int doRefine(String s) { thisHook.iAmRefining(thisJoinPoint.getName()); return 29; } }; } 3. Virtual MixinsVirtual mixins allow to insert the implementation of an interface in target classes so that other aspects can depend on that. This is mainly useful for communicating information between aspects. In order to cast an object to the mixin interface, use the following code (only available inside hooks): ICustomerInfo info = (ICustomerInfo) mixinOf(customer,ICustomerInfo.class); The ICustomerInfo interface consists of: interface ICustomerInfo { public boolean isFrequent(); public boolean setIsFrequent(boolean b); } The interface is inserted into a target class by simply declaring a hook that implements the interface and correspondig connector. Notice the perobject modifier in the connector for having one hook instance per customer instance. Otherwise the isFrequent property would be global for all customer instances. The hook is also able to define regular advices. Those are executed as usual, i.e. for all method executions on customer objects in this case. class BRFrequent { hook Introduce implements ICustomerInfo { private boolean isFrequent=false; Introduce(void method(..args)) { execution(method(args)); } public boolean isFrequent() { return isFrequent ; } public boolean setIsFrequent(boolean b) { isFrequent=b; } } } static connector IntroduceMixin { perobject BRFrequent.Introduce hook1 = new BRFrequent.Introduce(* Customer.*(*)); //the wildcards are important! } Now other hooks are able to access this mixin through the following code: around returning(double price) { ICustomerInfo mixin = (ICustomerInfo) mixinOf(customer,ICustomerInfo.class); if(mixin.isFrequent()) return applyDiscount(price); else return price; } 4. Small improvements
hook TestHook(int compute(int k)) { execution(compute); } around() { int j = proceed(k*2); return new Integer(j/2); }
Changes of previous milestonesFor changes introduced in 0.8.5M1, see the release notes of that milestone. |
SiteMapRecent | Content by SSEL ©2002-2005 |
|