The facade class for the MIoC framework. All the communication
with the framework is channeled via an instance of MiocFacade.
Usage scenario:
- Instantiate by calling the constructor
- Register classes either by a series of registerClass calls
or with the ConfigReader
- Get wired up instances of your classes
View the examples.
public function MiocFacade()
public function getInstanceByClassName(aName:String):Object
Retrieves a wired-up and (optionally) initiated instance of the
requested class. Unless it is readily available, the instance is
created on the spot. Instances of other registered classes, required
by the newly created instance, are automatically created (recursively).
Parameters
| aName:String — Fully qualified class name.
|
Returns
| Object — An instance of the requested class.
|
public function getInstancesImplementing(aIfaceName:String):Object
Retrieves instances of all registered classes implementing the given
interface. All new objects are instantiated, wired-up and initialized,
recursively creating instances of any registered classes, required in
the process.
Parameters
| aIfaceName:String — Fully qualified name of an interface. The interface
itself can be a mere marker.
|
Returns
| Object — A hash (Object) with requested objects indexed by their fully
qualified class names.
|
public function hasDefinition(aName:String):Boolean
Checks if the class is registered with the MIoC framework.
Parameters
| aName:String — Fully qualified class name.
|
Returns
| Boolean — True if registered, false otherwise.
|
public function registerClass(aClass:Class):void
Registers a class with the MIoC framework.
Parameters
import flash.utils.IDataInput;
import ishwest.mioc.MiocFacade;
import some.package.*;
public function parseSwf(aSwfBytes : IDataInput) : Swf {
var miocFacade : MiocFacade = new MiocFacade();
miocFacade.registerClass(DefineMorphShape2Parser);
miocFacade.registerClass(DefineShape4Parser);
miocFacade.registerClass(DefineShape4Parser);
miocFacade.registerClass(DefineScalingGridParser);
miocFacade.registerClass(SwfParser);
var parser : SwfParser = miocFacade.getInstanceByClassName("some.package.SwfParser");
return parser.parse(aSwfBytes);
}
import flash.utils.IDataInput;
import ishwest.mioc.MiocFacade;
import ishwest.mioc.ConfigReader;
import some.package.SwfParser;
import some.package.Swf;
public function parseSwf(aSwfBytes : IDataInput) : Swf {
var miocFacade : MiocFacade = new MiocFacade();
[Embed(source="mioc-config.xml",mimeType="application/octet-stream")]
var configXmlAsset : Class;
ConfigReader.instance.readEmbeddedConfig(configXmlAsset, miocFacade);
var parser : SwfParser = miocFacade.getInstanceByClassName("some.package.SwfParser");
return parser.parse(aSwfBytes);
}
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:XML id="f_MiocConfig" source="mioc-config.xml" />
<mx:Script>
<![CDATA[
import flash.utils.IDataInput;
import ishwest.mioc.MiocFacade;
import ishwest.mioc.ConfigReader;
import some.package.SwfParser;
import some.package.Swf;
public function parseSwf(aSwfBytes : IDataInput) : Swf {
var miocFacade : MiocFacade = new MiocFacade();
ConfigReader.instance.readConfigXml(f_MiocConfig, miocFacade);
var parser : SwfParser =
miocFacade.getInstanceByClassName("some.package.SwfParser");
return parser.parse(aSwfBytes);
}
]]>
</mx:Script>
</mx:Application>
project hosting

MIoC © 2008 ish-west