| Package | org.springextensions.actionscript.mvc.processor |
| Class | public class MVCControllerObjectFactoryPostProcessor |
| Inheritance | MVCControllerObjectFactoryPostProcessor Object |
| Implements | IObjectFactoryPostProcessor |
IObjectFactoryPostProcessor that checks the specified IConfigurableListableObjectFactory
if it contains an MVCRouteEventsMetaDataPostProcessor. If not, it creates one and adds it to
the IConfigurableListableObjectFactory using its addObjectPostProcessor() method.
After that it loops through all the object definitions and examines each class for the presence of [Command] metadata annotations.
Any class can be annotated with [Command] metadata, as long as some metadata keys are provided as well.
What follows are some examples of typical usage:
If an object acts as a command that needs to be executed after a specific event type was dispatched add this metadata to the class:
[Command(eventType="someEventType")]
public class SomeCommandClass {
//implementation ommitted...
}
If the command needs to be excecuted after a specific event Class was dispatched then add this
metadata:
[Command(eventClass="com.events.MyEvent")]
public class SomeCommandClass {
//implementation ommitted...
}
By default the method that will be invoked on the command object will be 'execute', but it is also possible to specify the method like this:
[Command(eventType="someEventType",executeMethod="process")]
public class SomeCommandClass {
//implementation ommitted...
}
If more than one command is to be executed after a specific event and it is needed to control the order in which these command will be executed, use the priority key:
[Command(eventType="someEventType",priority=10)]
public class SomeCommandClass {
//implementation ommitted...
}
Properties on the Event instance can be mapped to the arguments of the specified execution
method or to properties on the command instance.
First there will be a check if the first argument for the specified execute method is of the same type as the associated event, in this case the event is simply passed into the execute method.
If this is not the case the properties of the event or the properties defined by the properties
metadata key will be mapped by type to the arguments of the execute method.
Finally, if this is not possible, the properties on the event will be mapped by type to the properties on the command instance.
[Command] annotations can be stacked, so one command class can be triggered by multiple Events.
| Method | Defined By | ||
|---|---|---|---|
Creates a new MVCControllerObjectFactoryPostProcessor instance. | MVCControllerObjectFactoryPostProcessor | ||
Checks if the specified IConfigurableListableObjectFactory instance contains an object that
implements the IController interface. | MVCControllerObjectFactoryPostProcessor | ||
addRouteEventsMetaDataPostProcessor(objectFactory:IObjectFactory):void | MVCControllerObjectFactoryPostProcessor | ||
getPropertiesFromMetaData(metaData:Metadata):Vector.<String>
Checks if the properties key was set on the specified MetaData instance, if so
it creates an Array of strings from the key. | MVCControllerObjectFactoryPostProcessor | ||
postProcessObjectFactory(objectFactory:IObjectFactory):IOperation | MVCControllerObjectFactoryPostProcessor | ||
processCommandMetaData(type:Type, controller:IController, commandName:String, applicationDomain:ApplicationDomain):void | MVCControllerObjectFactoryPostProcessor | ||
processMetaData(metaData:Metadata, controller:IController, commandName:String, applicationDomain:ApplicationDomain):void
Extracts all the necessary information from the specified MetaData and registers
the command with the specified IController. | MVCControllerObjectFactoryPostProcessor | ||
Loops through all the IObjectDefinitions in the specified IConfigurableListableObjectFactory instance,
creates a Type instance for the classes and invokes the processCommandMetaData() method. | MVCControllerObjectFactoryPostProcessor | ||
| Constant | Defined By | ||
|---|---|---|---|
| COMMAND_METADATA : String = Command [static] | MVCControllerObjectFactoryPostProcessor | ||
| CONTROLLER_OBJECT_NAME : String = SpringActionScriptMVCController [static]
The object name that will be given to the controller instance in the object factory
| MVCControllerObjectFactoryPostProcessor | ||
| DEFAULT_EXECUTE_METHOD_NAME : String = execute [static] | MVCControllerObjectFactoryPostProcessor | ||
| EVENT_CLASS_METADATA_KEY : String = eventClass [static] | MVCControllerObjectFactoryPostProcessor | ||
| EVENT_TYPE_METADATA_KEY : String = eventType [static] | MVCControllerObjectFactoryPostProcessor | ||
| EXECUTE_METHOD_METADATA_KEY : String = executeMethod [static] | MVCControllerObjectFactoryPostProcessor | ||
| METADATAPROCESSOR_OBJECT_NAME : String = SpringActionScriptMVCRouteEventsMetaDataProcessor [static] | MVCControllerObjectFactoryPostProcessor | ||
| PRIORITY_METADATA_KEY : String = priority [static] | MVCControllerObjectFactoryPostProcessor | ||
| PROPERTIES_METADATA_KEY : String = properties [static] | MVCControllerObjectFactoryPostProcessor | ||
| MVCControllerObjectFactoryPostProcessor | () | Constructor |
public function MVCControllerObjectFactoryPostProcessor()
Creates a new MVCControllerObjectFactoryPostProcessor instance.
| addMVControllerInstance | () | method |
public function addMVControllerInstance(objectFactory:IObjectFactory):IController
Checks if the specified IConfigurableListableObjectFactory instance contains an object that
implements the IController interface. When none is found a Controller instance
is created and registered as a singleton in the IConfigurableListableObjectFactory instance.
Parameters
objectFactory:IObjectFactory — The specified IConfigurableListableObjectFactory instance.
|
IController — The created or retrieved IController instance.
|
| addRouteEventsMetaDataPostProcessor | () | method |
public function addRouteEventsMetaDataPostProcessor(objectFactory:IObjectFactory):void
Parameters
objectFactory:IObjectFactory — The specified IConfigurableListableObjectFactory instance.
|
| getPropertiesFromMetaData | () | method |
public function getPropertiesFromMetaData(metaData:Metadata):Vector.<String>
Checks if the properties key was set on the specified MetaData instance, if so
it creates an Array of strings from the key.
Parameters
metaData:Metadata — The specified MetaData instance
|
Vector.<String> — An Array of property names or null when the properties key was not set.
|
| postProcessObjectFactory | () | method |
public function postProcessObjectFactory(objectFactory:IObjectFactory):IOperation
Parameters
objectFactory:IObjectFactory — The specified IConfigurableListableObjectFactory instance.
|
IOperation |
| processCommandMetaData | () | method |
public function processCommandMetaData(type:Type, controller:IController, commandName:String, applicationDomain:ApplicationDomain):void
Parameters
type:Type — The specified Type instance.
| |
controller:IController — The specified IController instance used to register commands in.
| |
commandName:String — The name of the command as its registered in the application context.
| |
applicationDomain:ApplicationDomain — The specified ApplicationDomain used for reflection.
|
| processMetaData | () | method |
public function processMetaData(metaData:Metadata, controller:IController, commandName:String, applicationDomain:ApplicationDomain):void
Extracts all the necessary information from the specified MetaData and registers
the command with the specified IController.
Parameters
metaData:Metadata — The specified MetaData that needs to be processed.
| |
controller:IController — The specified IController instance used to register commands in.
| |
commandName:String — The name of the command as its registered in the application context.
| |
applicationDomain:ApplicationDomain — The specified ApplicationDomain used for reflection.
|
| registerCommands | () | method |
public function registerCommands(objectFactory:IObjectFactory, controller:IController):void
Loops through all the IObjectDefinitions in the specified IConfigurableListableObjectFactory instance,
creates a Type instance for the classes and invokes the processCommandMetaData() method.
Parameters
objectFactory:IObjectFactory — The specified IConfigurableListableObjectFactory.
| |
controller:IController — The specified IController instance used to register commands in.
|
| COMMAND_METADATA | Constant |
public static const COMMAND_METADATA:String = Command| CONTROLLER_OBJECT_NAME | Constant |
public static const CONTROLLER_OBJECT_NAME:String = SpringActionScriptMVCControllerThe object name that will be given to the controller instance in the object factory
| DEFAULT_EXECUTE_METHOD_NAME | Constant |
public static const DEFAULT_EXECUTE_METHOD_NAME:String = execute| EVENT_CLASS_METADATA_KEY | Constant |
public static const EVENT_CLASS_METADATA_KEY:String = eventClass| EVENT_TYPE_METADATA_KEY | Constant |
public static const EVENT_TYPE_METADATA_KEY:String = eventType| EXECUTE_METHOD_METADATA_KEY | Constant |
public static const EXECUTE_METHOD_METADATA_KEY:String = executeMethod| METADATAPROCESSOR_OBJECT_NAME | Constant |
public static const METADATAPROCESSOR_OBJECT_NAME:String = SpringActionScriptMVCRouteEventsMetaDataProcessor| PRIORITY_METADATA_KEY | Constant |
public static const PRIORITY_METADATA_KEY:String = priority| PROPERTIES_METADATA_KEY | Constant |
public static const PROPERTIES_METADATA_KEY:String = properties