[[kernel:0.8.5m3]] | |||||||||
Table of Contents
0.8.5M3 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. Aspect FactoriesJAsCo now supports a range of facilities for automatically creating multiple aspect instances depending on the current joinpoint. The following keywords are currently supported:
They are placed in front of a hook instantiation in the connector. For example, the following connector instantiates the ProtocolChecker hook once for every thread running in the application: static connector PerThreadConnector { perthread Protocol.ProtocolChecker aspect3 = new Protocol.ProtocolChecker(....); //predefined factory instantiation } It is also possible to implement custom aspect factories by implementing the jasco.runtime.aspect.factory.IAspectFactory interface. This interface contains one method, getAspectInstance, that is responsible for fetching the aspect instance for the currently executing joinpoint jp. The second argument allows to create a new hook instance and initialize it properly as defined in the associated connector. public interface IAspectFactory { public IHook getAspectInstance(MethodJoinpoint jp, IAspectInstanceCreator creator); } The following code fragment illustrates a custom aspect factory that returns a new hook instance for every class loader that loaded the executing class of the current joinpoint. As such, both the hook and the joinpoint are loaded by the same class loader and thus avoiding possible class loader hell problems. package test.aspects; public class PerClassLoaderAspectFactory implements IAspectFactory { public PerClassLoaderAspectFactory(){} private Hashtable map = new Hashtable(); IHook getAspectInstance(MethodJoinpoint jp, IAspectInstanceCreator creator) { IHook instance = (IHook) map.get(jp.getClassLoader()); if(instance==null) { instance = creator.createNewInstance(jp.getClassLoader()); map.put(jp.getClassLoader(),instance); } return instance; } } Good to know:
Applying the Factory: The custom factory can now be used in a connector as follows: static connector PerConnector { per(test.aspects.PerClassLoaderAspectFactory) MyAspect.MyHook aspect2 = new MyAspect.MyHook(....); //custom factory instantiation } The custom factory will be used for all joinpoints where this instantiation of the MyAspect.MyHook hook is applicable. 2. Limited subtype matching patternThe + operator defined in a method signature in an instantiatian expression in the connector allows to match all subtypes of a given class. However, it is often useful to match all overriden methods of a given type or all implemented methods of a certain interface. This is now supported using the ++ operator. Take for instance the following connector: static connector LimitedSubtypeConnector { MyAspect.MyHook test= MyAspect.MyHook(* MouseListener.*++(*); } The MyHook hook will be triggered on all methods of the type MousListener implemented by implementing classes. Other methods of the implementing classes are not affected by the hook (this in contrary to the regular + operator). 3. Virtual Mixins can be cast normallyVirtual 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. Previously, in order to cast an object to the mixin interface, the mixinOf operator was required. Now it is possibly to use plain Java casting in order to cast an object to the mixin interface. Suppose a ICustomerInfo interface was inserted into the Customer class, then the mixin interface can be accessed as follows: ICustomerInfo info = (ICustomerInfo) customer; //customer is an instance of the Customer class The implementation of the ICustomerInfo interface is inserted in the Customer class by a JAsCo hook as described in the quick language reference. Good to know:
4. Easier fetching of hook instances from Java codeIn order to fetch aspect instances directly, do the following in case of normal instantiation: Connector.MyConnectorName.getConnector().myAspectVariableName(); //myAspectVariableName is the variable name of the hook instance in the connector
Connector.MyConnectorName.getConnector().myAspectVariableName(keyForPerInstantiation); //myAspectVariableName is the var name of the aspect instance in the connector //keyForPerInstantiation is the key to fetch the hook instance, e.g. target object in case of perobject, targetclass in case of perclass etc... 5. Small improvements
Changes of previous milestones
|
SiteMapRecent | Content by SSEL ©2002-2005 |
|