====== Links providers & configuration classes ====== The Reflex kernel hooks classes according to the currently defined set of //links//. A link defines: * A //hookset//, which indicates the places in the code where control should be transfered to the meta-level. * A MOP (Meta Object Protocol), which indicates which meta-object should be called and how to call it. * An activation condition, which permits to enable or disable a link at runtime. ===== Link providers ===== Link providers are entities that provide the Reflex kernel with links. One way to add links to the kernel is to specify a set of link providers as a command line option: reflex -lp provider1,...,providerN The ''-lp'' command line argument expects a coma-separated list of link providers, where each provider is described by an URL in the form ''protocol:name''. For instance the ''class:'' protocol expects the fully qualified name of a class that implements the ''ILinkProvider'' interface. When Reflex starts, it will attempt to instantiate this class, retrieve contributed links by calling the ''getLinks()'' method, and add those links to the kernel. ===== Configuration classes ===== ''ReflexConfig'' is a helper class that simplifies the implementation of link providers. It provides a few factory methods to create links. Here is an example: public class MyConfig extends ReflexConfig { public void initReflex() { // Create a hookset Hookset theHookset = new PrimitiveHookset( FieldAccess.class, // We want to hook field accesses... AllCS.getInstance(), // ...on all classes... FieldWriteOS.getInstance()); // ...but only for field writes, excluding field reads // Create and dd the link to the config BLink theLink = addBLink( theHookset, new MODefinition.MOClass(MO_CLASSNAME)); // The metaobject will be obtained by instantiating a given class // Further configure the link: // There should be one system-wide instance of the metaobject... theLink.setScope(Scope.GLOBAL); // ...which should be called after the operation occurs theLink.setControl(Control.AFTER); // There is no activation condition, meaning the link is always active. theLink.setActivation(Activation.DISABLED); // Define the MOP: the metaobject should have its fieldWrite method called with no arguments. theLink.setMOCall(Control.AFTER, new CallDescriptor( MO_CLASSNAME, "fieldWrite", new Parameter[0])); } } In order to use this configuration class, simple call Reflex like this: reflex -lp class:MyConfig