Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: MindScriptAct/mvcExpress-examples
base: 351f4ad3e4
...
head fork: MindScriptAct/mvcExpress-examples
compare: 9dd5cdb646
  • 3 commits
  • 171 files changed
  • 0 commit comments
  • 1 contributor
Showing with 4,501 additions and 902 deletions.
  1. +19 −19 .idea/compiler.xml
  2. +1 −1  .idea/encodings.xml
  3. +3 −3 .idea/flexCompiler.xml
  4. +3 −4 .idea/misc.xml
  5. +5 −5 .idea/modules.xml
  6. +3 −3 .idea/scopes/scope_settings.xml
  7. +3 −3 .idea/vcs.xml
  8. +7 −5 libSrc/mvcexpress/MvcExpress.as
  9. +84 −31 libSrc/mvcexpress/core/CommandMap.as
  10. +101 −0 libSrc/mvcexpress/core/ExtensionManager.as
  11. +119 −59 libSrc/mvcexpress/core/MediatorMap.as
  12. +84 −57 libSrc/mvcexpress/core/ModuleManager.as
  13. +435 −135 libSrc/mvcexpress/core/ProxyMap.as
  14. +48 −0 libSrc/mvcexpress/core/ProxyMapForMediator.as
  15. +6 −4 libSrc/mvcexpress/core/inject/InjectRuleVO.as
  16. +9 −7 libSrc/mvcexpress/core/inject/InjectTester.as
  17. +8 −7 libSrc/mvcexpress/core/inject/PendingInject.as
  18. +18 −15 libSrc/mvcexpress/core/interfaces/IMediatorMap.as
  19. +8 −6 libSrc/mvcexpress/core/interfaces/IProxyMap.as
  20. +9 −1 libSrc/mvcexpress/core/lazy/LazyProxyVO.as
  21. +3 −2 libSrc/mvcexpress/core/messenger/HandlerVO.as
  22. +78 −28 libSrc/mvcexpress/core/messenger/Messenger.as
  23. +1 −1  libSrc/mvcexpress/core/namespace/pureLegsCore.as
  24. +5 −1 libSrc/mvcexpress/core/traceObjects/MvcTraceActions.as
  25. +3 −1 libSrc/mvcexpress/core/traceObjects/TraceObj.as
  26. +3 −1 libSrc/mvcexpress/core/traceObjects/TraceObj_SendMessage.as
  27. +3 −1 libSrc/mvcexpress/core/traceObjects/command/TraceCommand_sendMessage.as
  28. +3 −1 libSrc/mvcexpress/core/traceObjects/commandMap/TraceCommandMap_execute.as
  29. +3 −1 libSrc/mvcexpress/core/traceObjects/commandMap/TraceCommandMap_handleCommandExecute.as
  30. +3 −1 libSrc/mvcexpress/core/traceObjects/commandMap/TraceCommandMap_map.as
  31. +3 −1 libSrc/mvcexpress/core/traceObjects/commandMap/TraceCommandMap_unmap.as
  32. +27 −0 libSrc/mvcexpress/core/traceObjects/errors/TraceError.as
  33. +3 −1 libSrc/mvcexpress/core/traceObjects/mediator/TraceMediator_addHandler.as
  34. +3 −1 libSrc/mvcexpress/core/traceObjects/mediator/TraceMediator_sendMessage.as
  35. +3 −1 libSrc/mvcexpress/core/traceObjects/mediatorMap/TraceMediatorMap_map.as
  36. +3 −1 libSrc/mvcexpress/core/traceObjects/mediatorMap/TraceMediatorMap_mediate.as
  37. +4 −2 libSrc/mvcexpress/core/traceObjects/mediatorMap/TraceMediatorMap_unmap.as
  38. +3 −1 libSrc/mvcexpress/core/traceObjects/mediatorMap/TraceMediatorMap_unmediate.as
  39. +3 −1 libSrc/mvcexpress/core/traceObjects/messenger/TraceMessenger_addHandler.as
  40. +3 −1 libSrc/mvcexpress/core/traceObjects/messenger/TraceMessenger_removeHandler.as
  41. +3 −1 libSrc/mvcexpress/core/traceObjects/messenger/TraceMessenger_send.as
  42. +3 −1 libSrc/mvcexpress/core/traceObjects/messenger/TraceMessenger_send_handler.as
  43. +3 −1 libSrc/mvcexpress/core/traceObjects/moduleBase/TraceModuleBase_sendMessage.as
  44. +3 −1 libSrc/mvcexpress/core/traceObjects/moduleManager/TraceModuleManager_createModule.as
  45. +3 −1 libSrc/mvcexpress/core/traceObjects/moduleManager/TraceModuleManager_disposeModule.as
  46. +3 −1 libSrc/mvcexpress/core/traceObjects/proxy/TraceProxy_sendMessage.as
  47. +4 −2 libSrc/mvcexpress/core/traceObjects/proxyMap/TraceProxyMap_injectPending.as
  48. +3 −1 libSrc/mvcexpress/core/traceObjects/proxyMap/TraceProxyMap_injectStuff.as
  49. +3 −1 libSrc/mvcexpress/core/traceObjects/proxyMap/TraceProxyMap_lazyMap.as
  50. +3 −1 libSrc/mvcexpress/core/traceObjects/proxyMap/TraceProxyMap_map.as
  51. +3 −1 libSrc/mvcexpress/core/traceObjects/proxyMap/TraceProxyMap_unmap.as
  52. +74 −0 libSrc/mvcexpress/extensions/combo/scopedLive/core/CommandMapScopedLive.as
  53. +83 −0 libSrc/mvcexpress/extensions/combo/scopedLive/core/ProxyMapScopedLive.as
  54. +93 −0 libSrc/mvcexpress/extensions/combo/scopedLive/modules/ModuleScopedLive.as
  55. +43 −0 libSrc/mvcexpress/extensions/combo/scopedLive/mvc/CommandScopedLive.as
  56. +104 −0 libSrc/mvcexpress/extensions/combo/scopedLive/mvc/MediatorScopedLive.as
  57. +35 −0 libSrc/mvcexpress/extensions/combo/scopedLive/mvc/PooledCommandScopedLive.as
  58. +104 −0 libSrc/mvcexpress/extensions/combo/scopedLive/mvc/ProxyScopedLive.as
  59. +3 −1 libSrc/mvcexpress/extensions/flex/core/MediatorMapFlex.as
  60. +23 −5 libSrc/mvcexpress/extensions/live/core/CommandMapLive.as
  61. +22 −6 libSrc/mvcexpress/extensions/live/core/MediatorMapLive.as
  62. +28 −18 libSrc/mvcexpress/extensions/live/core/ProcessMapLive.as
  63. +24 −6 libSrc/mvcexpress/extensions/live/core/ProxyMapLive.as
  64. +5 −2 libSrc/mvcexpress/extensions/live/core/inject/InjectRuleTaskVO.as
  65. +74 −17 libSrc/mvcexpress/extensions/live/engine/Process.as
  66. +19 −0 libSrc/mvcexpress/extensions/live/engine/ProcessTimerVO.as
  67. +33 −13 libSrc/mvcexpress/extensions/live/engine/Task.as
  68. +26 −9 libSrc/mvcexpress/extensions/live/modules/ModuleLive.as
  69. +24 −9 libSrc/mvcexpress/extensions/live/mvc/CommandLive.as
  70. +25 −10 libSrc/mvcexpress/extensions/live/mvc/MediatorLive.as
  71. +19 −1 libSrc/mvcexpress/extensions/live/mvc/PooledCommandLive.as
  72. +19 −7 libSrc/mvcexpress/extensions/live/mvc/ProxyLive.as
  73. +4 −1 libSrc/mvcexpress/extensions/live/taskTests/TaskTestVO.as
  74. +4 −1 libSrc/mvcexpress/extensions/live/taskTests/TestRuleVO.as
  75. +3 −1 libSrc/mvcexpress/extensions/live/traceObjects/MvcTraceActionsLive.as
  76. +4 −1 libSrc/mvcexpress/extensions/live/traceObjects/TraceProcess_sendMessage.as
  77. +4 −1 libSrc/mvcexpress/extensions/live/traceObjects/process/TraceProcess_addFirstTask.as
  78. +4 −1 libSrc/mvcexpress/extensions/live/traceObjects/process/TraceProcess_addHandler.as
  79. +4 −1 libSrc/mvcexpress/extensions/live/traceObjects/process/TraceProcess_addTask.as
  80. +4 −1 libSrc/mvcexpress/extensions/live/traceObjects/process/TraceProcess_addTaskAfter.as
  81. +4 −1 libSrc/mvcexpress/extensions/live/traceObjects/process/TraceProcess_disableTask.as
  82. +4 −1 libSrc/mvcexpress/extensions/live/traceObjects/process/TraceProcess_enableTask.as
  83. +4 −1 libSrc/mvcexpress/extensions/live/traceObjects/process/TraceProcess_removeAllTasks.as
  84. +4 −1 libSrc/mvcexpress/extensions/live/traceObjects/process/TraceProcess_removeTask.as
  85. +4 −1 libSrc/mvcexpress/extensions/live/traceObjects/processMap/TraceProcessMap_provide.as
  86. +4 −1 libSrc/mvcexpress/extensions/live/traceObjects/processMap/TraceProcessMap_unprovide.as
  87. +23 −4 libSrc/mvcexpress/extensions/scoped/core/CommandMapScoped.as
  88. +27 −10 libSrc/mvcexpress/extensions/scoped/core/ProxyMapScoped.as
  89. +43 −6 libSrc/mvcexpress/extensions/scoped/core/ScopeManager.as
  90. +4 −2 libSrc/mvcexpress/extensions/scoped/core/inject/InjectRuleScopedVO.as
  91. +4 −2 ...ess/{core/traceObjects/command → extensions/scoped/core/traceObjects}/TraceCommand_sendScopeMessage.as
  92. +4 −2 ...s/{core/traceObjects/mediator → extensions/scoped/core/traceObjects}/TraceMediator_sendScopeMessage.as
  93. +4 −2 ...ore/traceObjects/moduleBase → extensions/scoped/core/traceObjects}/TraceModuleBase_sendScopeMessage.as
  94. +4 −2 .../traceObjects/moduleManager → extensions/scoped/core/traceObjects}/TraceModuleManager_registerScope.as
  95. +4 −2 ...raceObjects/moduleManager → extensions/scoped/core/traceObjects}/TraceModuleManager_unregisterScope.as
  96. +4 −2 ...vcexpress/{core/traceObjects/proxyMap → extensions/scoped/core/traceObjects}/TraceProxyMap_scopeMap.as
  97. +4 −2 ...express/{core/traceObjects/proxyMap → extensions/scoped/core/traceObjects}/TraceProxyMap_scopeUnmap.as
  98. +5 −3 ...core/traceObjects/proxyMap → extensions/scoped/core/traceObjects}/TraceProxyMap_scopedInjectPending.as
  99. +4 −2 ...express/{core/traceObjects/proxy → extensions/scoped/core/traceObjects}/TraceProxy_sendScopeMessage.as
  100. +41 −4 libSrc/mvcexpress/extensions/scoped/modules/ModuleScoped.as
  101. +17 −2 libSrc/mvcexpress/extensions/scoped/mvc/CommandScoped.as
  102. +19 −5 libSrc/mvcexpress/extensions/scoped/mvc/MediatorScoped.as
  103. +16 −2 libSrc/mvcexpress/extensions/scoped/mvc/PooledCommandScoped.as
  104. +19 −5 libSrc/mvcexpress/extensions/scoped/mvc/ProxyScoped.as
  105. +5 −1 libSrc/mvcexpress/extensions/unpuremvc/core/UnpureCommandMap.as
  106. +4 −0 libSrc/mvcexpress/extensions/unpuremvc/core/messenger/UnpureMessenger.as
  107. +2 −0  libSrc/mvcexpress/extensions/unpuremvc/patterns/command/UnpureICommand.as
  108. +2 −0  libSrc/mvcexpress/extensions/unpuremvc/patterns/command/UnpureMacroCommand.as
  109. +2 −0  libSrc/mvcexpress/extensions/unpuremvc/patterns/command/UnpureSimpleCommand.as
  110. +5 −0 libSrc/mvcexpress/extensions/unpuremvc/patterns/facade/UnpureFacade.as
  111. +10 −2 libSrc/mvcexpress/extensions/unpuremvc/patterns/mediator/UnpureMediator.as
  112. +1 −0  libSrc/mvcexpress/extensions/unpuremvc/patterns/observer/UnpureNotification.as
  113. +2 −0  libSrc/mvcexpress/extensions/unpuremvc/patterns/observer/UnpureObserver.as
  114. +1 −2  libSrc/mvcexpress/extensions/unpuremvc/patterns/observer/observerCommand/UnpureObserverCommand.as
  115. +2 −0  libSrc/mvcexpress/extensions/unpuremvc/patterns/proxy/UnpureProxy.as
  116. +2 −0  libSrc/mvcexpress/extensions/unpuremvc/unpureCore/UnpureController.as
  117. +2 −0  libSrc/mvcexpress/extensions/unpuremvc/unpureCore/UnpureModel.as
  118. +2 −0  libSrc/mvcexpress/extensions/unpuremvc/unpureCore/UnpureView.as
  119. +126 −0 libSrc/mvcexpress/extensions/workers/core/CommandMapWorker.as
  120. +673 −0 libSrc/mvcexpress/extensions/workers/core/WorkerManager.as
  121. +107 −0 libSrc/mvcexpress/extensions/workers/core/messenger/WorkerMessenger.as
  122. +32 −0 libSrc/mvcexpress/extensions/workers/core/traceObjects/command/TraceCommand_sendWorkerMessage.as
  123. +32 −0 libSrc/mvcexpress/extensions/workers/core/traceObjects/mediator/TraceMediator_sendWorkerMessage.as
  124. +32 −0 libSrc/mvcexpress/extensions/workers/core/traceObjects/moduleBase/TraceModuleBase_sendWorkerMessage.as
  125. +32 −0 libSrc/mvcexpress/extensions/workers/core/traceObjects/proxy/TraceProxy_sendWorkerMessage.as
  126. +83 −0 libSrc/mvcexpress/extensions/workers/data/ClassAliasRegistry.as
  127. +66 −0 libSrc/mvcexpress/extensions/workers/display/WorkerSprite.as
  128. +157 −0 libSrc/mvcexpress/extensions/workers/modules/ModuleWorker.as
  129. +130 −0 libSrc/mvcexpress/extensions/workers/mvc/CommandWorker.as
  130. +91 −0 libSrc/mvcexpress/extensions/workers/mvc/MediatorWorker.as
  131. +59 −0 libSrc/mvcexpress/extensions/workers/mvc/PooledCommandWorker.as
  132. +61 −0 libSrc/mvcexpress/extensions/workers/mvc/ProxyWorker.as
  133. +150 −63 libSrc/mvcexpress/modules/ModuleCore.as
  134. +28 −9 libSrc/mvcexpress/mvc/Command.as
  135. +84 −53 libSrc/mvcexpress/mvc/Mediator.as
  136. +8 −8 libSrc/mvcexpress/mvc/PooledCommand.as
  137. +29 −13 libSrc/mvcexpress/mvc/Proxy.as
  138. +27 −25 libSrc/mvcexpress/utils/AssertExpress.as
  139. +10 −3 libSrc/mvcexpress/utils/checkClassStringConstants.as
  140. +3 −2 libSrc/mvcexpress/utils/checkClassSuperclass.as
  141. BIN  libs/mvcExpress_v2_0_rc3-logger_v1_3.swc
  142. +8 −4 mvcExpress-examples.as3proj
  143. +4 −4 mvcExpress-examples.iml
  144. +1 −1  mvcExpress-helloMobile/src/mindscriptact/mobileTestApp/controler/test/TestCommand.as
  145. +4 −4 mvcExpress-helloWorld/src/helloWorld/Main.as
  146. +5 −5 mvcExpress-helloWorld/src/helloWorld/MainModule.as
  147. +2 −2 mvcExpress-helloWorld/src/helloWorld/controller/setup/SetupControllerCommand.as
  148. +2 −1  mvcExpress-helloWorld/src/helloWorld/controller/setup/SetupModelCommand.as
  149. +1 −1  mvcExpress-helloWorld/src/helloWorld/messages/{DataMsg.as → DataMessage.as}
  150. +1 −1  mvcExpress-helloWorld/src/helloWorld/messages/{Msg.as → Message.as}
  151. +1 −1  mvcExpress-helloWorld/src/helloWorld/messages/{ViewMsg.as → ViewMessage.as}
  152. +2 −2 mvcExpress-helloWorld/src/helloWorld/model/TestProxy.as
  153. +4 −4 mvcExpress-helloWorld/src/helloWorld/view/main/MainMediator.as
  154. +7 −8 mvcExpress-modular/src/modularProject/modularSample/ModularSample.as
  155. +5 −5 mvcExpress-modular/src/modularProject/modules/console/Console.as
  156. +14 −4 mvcExpress-ticTacToe/src/ticTacToe/Main.as
  157. +3 −10 mvcExpress-ticTacToe/src/ticTacToe/MainModule.as
  158. +0 −10 mvcExpress-ticTacToe/src/ticTacToe/constants/MainConfig.as
  159. +1 −1  mvcExpress-ticTacToe/src/ticTacToe/constants/TokenId.as
  160. +1 −2  mvcExpress-ticTacToe/src/ticTacToe/controller/game/CellClickCommand.as
  161. +1 −1  mvcExpress-ticTacToe/src/ticTacToe/controller/game/NewGameCommand.as
  162. +3 −3 mvcExpress-ticTacToe/src/ticTacToe/controller/setup/SetupControllerCommand.as
  163. +1 −1  mvcExpress-ticTacToe/src/ticTacToe/controller/setup/SetupModelCommand.as
  164. +1 −1  mvcExpress-ticTacToe/src/ticTacToe/messages/{DataMsg.as → DataMessages.as}
  165. +1 −1  mvcExpress-ticTacToe/src/ticTacToe/messages/{Msg.as → Messages.as}
  166. +1 −1  mvcExpress-ticTacToe/src/ticTacToe/messages/{ViewMsg.as → ViewMessages.as}
  167. +7 −7 mvcExpress-ticTacToe/src/ticTacToe/model/GameBoardProxy.as
  168. +2 −2 mvcExpress-ticTacToe/src/ticTacToe/model/GameProxy.as
  169. +0 −24 mvcExpress-ticTacToe/src/ticTacToe/services/BlankService.as
  170. +1 −1  mvcExpress-ticTacToe/src/ticTacToe/view/gameScreen/GameScreen.as
  171. +7 −7 mvcExpress-ticTacToe/src/ticTacToe/view/gameScreen/GameScreenMediator.as
View
38 .idea/compiler.xml
@@ -1,23 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
- <component name="CompilerConfiguration">
- <option name="DEFAULT_COMPILER" value="Javac"/>
- <resourceExtensions/>
- <wildcardResourcePatterns>
- <entry name="!?*.java"/>
- <entry name="!?*.form"/>
- <entry name="!?*.class"/>
- <entry name="!?*.groovy"/>
- <entry name="!?*.scala"/>
- <entry name="!?*.flex"/>
- <entry name="!?*.kt"/>
- <entry name="!?*.clj"/>
- </wildcardResourcePatterns>
- <annotationProcessing>
- <profile default="true" name="Default" enabled="false">
- <processorPath useClasspath="true"/>
- </profile>
- </annotationProcessing>
- </component>
+ <component name="CompilerConfiguration">
+ <option name="DEFAULT_COMPILER" value="Javac" />
+ <resourceExtensions />
+ <wildcardResourcePatterns>
+ <entry name="!?*.java" />
+ <entry name="!?*.form" />
+ <entry name="!?*.class" />
+ <entry name="!?*.groovy" />
+ <entry name="!?*.scala" />
+ <entry name="!?*.flex" />
+ <entry name="!?*.kt" />
+ <entry name="!?*.clj" />
+ </wildcardResourcePatterns>
+ <annotationProcessing>
+ <profile default="true" name="Default" enabled="false">
+ <processorPath useClasspath="true" />
+ </profile>
+ </annotationProcessing>
+ </component>
</project>
View
2  .idea/encodings.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
- <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false"/>
+ <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>
View
6 .idea/flexCompiler.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
- <component name="FlexIdeProjectLevelCompilerOptionsHolder">
- <compiler-options/>
- </component>
+ <component name="FlexIdeProjectLevelCompilerOptionsHolder">
+ <compiler-options />
+ </component>
</project>
View
7 .idea/misc.xml
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
- <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="flex_sdk_4.9.1"
- project-jdk-type="Flex SDK Type (new)">
- <output url="file://$PROJECT_DIR$/bin"/>
- </component>
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="flex_sdk_4.9.1" project-jdk-type="Flex SDK Type (new)">
+ <output url="file://$PROJECT_DIR$/bin" />
+ </component>
</project>
View
10 .idea/modules.xml
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
- <component name="ProjectModuleManager">
- <modules>
- <module fileurl="file://$PROJECT_DIR$/mvcExpress-examples.iml" filepath="$PROJECT_DIR$/mvcExpress-examples.iml"/>
- </modules>
- </component>
+ <component name="ProjectModuleManager">
+ <modules>
+ <module fileurl="file://$PROJECT_DIR$/mvcExpress-examples.iml" filepath="$PROJECT_DIR$/mvcExpress-examples.iml" />
+ </modules>
+ </component>
</project>
View
6 .idea/scopes/scope_settings.xml
@@ -1,5 +1,5 @@
<component name="DependencyValidationManager">
- <state>
- <option name="SKIP_IMPORT_STATEMENTS" value="false"/>
- </state>
+ <state>
+ <option name="SKIP_IMPORT_STATEMENTS" value="false" />
+ </state>
</component>
View
6 .idea/vcs.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
- <component name="VcsDirectoryMappings">
- <mapping directory="" vcs="Git"/>
- </component>
+ <component name="VcsDirectoryMappings">
+ <mapping directory="" vcs="Git" />
+ </component>
</project>
View
12 libSrc/mvcexpress/MvcExpress.as
@@ -5,22 +5,24 @@ import mvcexpress.core.traceObjects.TraceObj;
/**
* Class to store framework global settings and some important variables.
- * @author Raimundas Banevicius (http://www.mindscriptact.com/)
+ * @author Raimundas Banevicius (http://mvcexpress.org/)
+ *
+ * @version 2.0.rc1
*/
public class MvcExpress {
/** Home website of mvcExpress. */
- public static const WEBSITE_URL:String = "http://mvcexpress.org";
+ public static const WEBSITE_URL:String = "http://mvcExpress.org";
/** Framework name */
- public static const NAME:String = "mvcExpress 2 beta 2";
+ public static const NAME:String = "mvcExpress 2 RC3";
/** Current framework major version */
public static const MAJOR_VERSION:uint = 2;
/** Current framework minor version */
public static const MINOR_VERSION:uint = 0;
/** Current framework revision version */
- public static const REVISION:uint = 0;
+ public static const REVISION:uint = 3;
/** Current framework version */
public static const VERSION:String = "v" + MAJOR_VERSION + "." + MINOR_VERSION + "." + REVISION;
@@ -44,7 +46,7 @@ public class MvcExpress {
* If dependency is mapped during this waiting time - framework will find missing dependencies and resolve them.
* If in this time dependencies will not be resolved - error will be thrown.
*/
- public static var pendingInjectsTimeOut:int = 0;
+ public static var pendingInjectsTimeOut:uint = 0;
/**
* Sets a debug function that will get framework activity constants as String's.
View
115 libSrc/mvcexpress/core/CommandMap.as
@@ -20,21 +20,23 @@ use namespace pureLegsCore;
/**
* Handles command mappings, and executes them then mapped message string is sent.
- * @author Raimundas Banevicius (http://www.mindscriptact.com/)
+ * @author Raimundas Banevicius (http://mvcexpress.org/)
+ *
+ * @version 2.0.rc1
*/
public class CommandMap {
// name of the module CommandMap is working for.
protected var moduleName:String;
- // for internal use.
+ // used internally for communications
protected var messenger:Messenger;
- // for internal use.
+ // used internally to work with proxies.
protected var proxyMap:ProxyMap;
- // for internal use.
+ // used internally to handles application mediators.
protected var mediatorMap:MediatorMap;
- // collection of class arrays, stored by message type. Then message with this type is sent, all mapped classes are executed.
+ // commands class stored by message type. Then message with this type is sent, mapped class is executed.
protected var classRegistry:Dictionary = new Dictionary(); //* of Class by String */
// holds pooled command objects, stared by command class.
@@ -62,8 +64,8 @@ public class CommandMap {
//----------------------------------
/**
- * Map a class to be executed then message with provided type is sent. <br>
- * Only one command can be mapped to single messageType. Unless canMapOver set to true - error will be thrown if you attempt to map second command class to same message type.
+ * Map a class to be executed then message with provided type is sent. <p>
+ * Only one command can be mapped to single messageType. Error will be thrown if you attempt to map second command class to same message type, unless canMapOver set to true. </p>
* @param type Message type for command class to react to.
* @param commandClass Command class that will be executed.
* @param canMapOver Allows mapping command class over already existing command.
@@ -79,9 +81,15 @@ public class CommandMap {
if (!Boolean(type) || type == "null" || type == "undefined") {
throw Error("Message type:[" + type + "] can not be empty or 'null' or 'undefined'. (You are trying to map command:" + commandClass + ")");
}
+
+ // var check if extension is supported by this module.
+ var extensionId:int = ExtensionManager.getExtensionId(commandClass);
+ if (SUPPORTED_EXTENSIONS[extensionId] == null) {
+ throw Error("This extension is not supported by current module. You need " + ExtensionManager.getExtensionName(commandClass) + " extension enabled to use " + commandClass + " command.");
+ }
}
- if (classRegistry[type]) {
+ if (type in classRegistry) {
if (!canMapOver) {
throw Error("Only one command class can be mapped to one message type. You are trying to map " + commandClass + " to " + type + ", but it is already mapped to " + classRegistry[type]);
}
@@ -95,7 +103,7 @@ public class CommandMap {
/**
* Unmaps a class to be executed then message with provided type is sent.
- * @param type Message type for command class to react to.
+ * @param type Message type for command class to react to.
*/
public function unmap(type:String):void {
// debug this action
@@ -142,6 +150,12 @@ public class CommandMap {
// check if command has execute function, parameter, and store type of parameter object for future checks on execute.
CONFIG::debug {
validateCommandParams(commandClass, params);
+
+ // var check if extension is supported by this module.
+ var extensionId:int = ExtensionManager.getExtensionId(commandClass);
+ if (SUPPORTED_EXTENSIONS[extensionId] == null) {
+ throw Error("This extension is not supported by current module. You need " + ExtensionManager.getExtensionName(commandClass) + " extension enabled to use " + commandClass + " command.");
+ }
}
// construct command
@@ -194,20 +208,24 @@ public class CommandMap {
/**
* Checks if specific PooledCommand is already pooled.
- * @param commandClass PooledCommand sublcass to check Command pool for.
+ * @param commandClass PooledCommand subclass to check Command pool for.
* @return true if command pool is created.
*/
public function isCommandPooled(commandClass:Class):Boolean {
- return (commandPools[commandClass] != null);
+ return (commandClass in commandPools && commandPools[commandClass].length);
}
/**
- * Clears pool created for specified command.
+ * Clears all command pools, or specific one.
* (if commands are not pooled - function fails silently.)
- * @param commandClass Command class to clear
+ * @param commandClass Optional Command class to clear specific command pool
*/
- public function clearCommandPool(commandClass:Class):void {
- delete commandPools[commandClass];
+ public function clearCommandPool(commandClass:Class = null):void {
+ if (commandClass) {
+ delete commandPools[commandClass];
+ } else {
+ commandPools = new Dictionary();
+ }
}
@@ -223,7 +241,7 @@ public class CommandMap {
*/
public function isMapped(type:String, commandClass:Class = null):Boolean {
var retVal:Boolean; // = false;
- if (classRegistry[type]) {
+ if (type in classRegistry) {
if (commandClass) {
retVal = (classRegistry[type] == commandClass);
} else {
@@ -235,15 +253,27 @@ public class CommandMap {
/**
* Returns text of all command classes that are mapped to constants. (for debugging)
+ * @param verbose if set to true, will return readable string, false will return pairs of message type and command class definition separated by '>', all pairs are separated by ';'.
* @return Text with all mapped commands.
*/
- public function listMappings():String {
+ public function listMappings(verbose:Boolean = true):String {
var retVal:String = "";
- retVal = "===================== CommandMap Mappings: =====================\n";
+ if (verbose) {
+ retVal = "===================== CommandMap Mappings: =====================\n";
+ }
for (var key:String in classRegistry) {
- retVal += "SENDING MESSAGE:'" + key + "'\t> EXECUTES > " + classRegistry[key] + "\n";
+ if (verbose) {
+ retVal += "SENDING MESSAGE:'" + key + "'\t> EXECUTES > " + classRegistry[key] + "\n";
+ } else {
+ if (retVal) {
+ retVal += ";"
+ }
+ retVal += key + ">" + getQualifiedClassName(classRegistry[key]);
+ }
+ }
+ if (verbose) {
+ retVal += "================================================================\n";
}
- retVal += "================================================================\n";
return retVal;
}
@@ -303,7 +333,10 @@ public class CommandMap {
commandPools = null;
}
- /** function to be called by messenger on needed message type sent */
+ /**
+ * function to be called by messenger on needed message type sent
+ * @private
+ */
pureLegsCore function handleCommandExecute(messageType:String, params:Object):void {
use namespace pureLegsCore;
@@ -313,11 +346,6 @@ public class CommandMap {
commandClass = classRegistry[messageType];
if (commandClass) {
- // debug this action
- CONFIG::debug {
- MvcExpress.debug(new TraceCommandMap_handleCommandExecute(moduleName, command, commandClass, messageType, params));
- }
-
//////////////////////////////////////////////
////// INLINE FUNCTION runCommand() START
@@ -345,6 +373,11 @@ public class CommandMap {
command.messageType = messageType;
+ // debug this action
+ CONFIG::debug {
+ MvcExpress.debug(new TraceCommandMap_handleCommandExecute(moduleName, command, commandClass, messageType, params));
+ }
+
if (command is PooledCommand) {
// init pool if needed.
if (!pooledCommands) {
@@ -380,14 +413,14 @@ public class CommandMap {
CONFIG::debug
pureLegsCore function validateCommandClass(commandClass:Class):void {
- // skip alread validated classes.
- if (validatedCommands[commandClass] != true) {
+ // skip already validated classes.
+ if (!(commandClass in validatedCommands)) {
if (!checkClassSuperclass(commandClass, "mvcexpress.mvc::Command")) {
throw Error("commandClass:" + commandClass + " you are trying to map MUST extend: 'mvcexpress.mvc::Command' class.");
}
- if (!commandClassParamTypes[commandClass]) {
+ if (!(commandClass in commandClassParamTypes)) {
var classDescription:XML = describeType(commandClass);
var hasExecute:Boolean; // = false;
@@ -421,6 +454,7 @@ public class CommandMap {
}
}
+ /** @private */
CONFIG::debug
protected function validateCommandParams(commandClass:Class, params:Object):void {
use namespace pureLegsCore;
@@ -435,10 +469,29 @@ public class CommandMap {
}
}
- // used for debugging
- pureLegsCore function listMessageCommands(messageType:String):Class {
+ /**
+ * used for debugging
+ * @private
+ */
+ pureLegsCore function getMessageCommand(messageType:String):Class {
return classRegistry[messageType];
}
+
+ //----------------------------------
+ // Extension checking: INTERNAL, DEBUG ONLY.
+ //----------------------------------
+
+ /** @private */
+ CONFIG::debug
+ pureLegsCore var SUPPORTED_EXTENSIONS:Dictionary;
+
+ /** @private */
+ CONFIG::debug
+ pureLegsCore function setSupportedExtensions(supportedExtensions:Dictionary):void {
+ SUPPORTED_EXTENSIONS = supportedExtensions;
+ }
+
+
}
}
View
101 libSrc/mvcexpress/core/ExtensionManager.as
@@ -0,0 +1,101 @@
+// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
+package mvcexpress.core {
+import flash.utils.Dictionary;
+import flash.utils.getDefinitionByName;
+import flash.utils.getQualifiedSuperclassName;
+
+import mvcexpress.core.namespace.pureLegsCore;
+
+/**
+ * INTERNAL FRAMEWORK CLASS.
+ * Manages mvcExpress extensions.
+ * @author Raimundas Banevicius (http://mvcexpress.org/)
+ * @private
+ *
+ * @version 2.0.rc1
+ */
+public class ExtensionManager {
+
+ CONFIG::debug
+ private static var extensionIdRegistry:Dictionary = new Dictionary(); //* of int by Class */
+
+ CONFIG::debug
+ private static var extensionNameRegistry:Dictionary = new Dictionary(); //* of String by Class */
+
+ CONFIG::debug
+ private static const EXTENSION_NAMES:Dictionary = new Dictionary();
+
+ CONFIG::debug
+ private static var extensionCount:int;
+
+ /**
+ * get extension id by extension name.
+ * @param extensionName
+ * @return
+ */
+ CONFIG::debug
+ public static function getExtensionIdByName(extensionName:String):int {
+ if (!(extensionName in ExtensionManager.EXTENSION_NAMES)) {
+ ExtensionManager.EXTENSION_NAMES[extensionName] = ++ExtensionManager.extensionCount;
+ }
+ return ExtensionManager.EXTENSION_NAMES[extensionName];
+ }
+
+ /**
+ * get extension name by extension id.
+ * @param extensionId
+ * @return
+ */
+ CONFIG::debug
+ public static function getExtensionNameById(extensionId:int):String {
+ var retVal:String = "undefined";
+ for (var extensionName:Object in EXTENSION_NAMES) {
+ if (EXTENSION_NAMES[extensionName] == extensionId) {
+ retVal = extensionName as String;
+ break;
+ }
+ }
+ return retVal;
+ }
+
+ /**
+ * get extension id for framework class.
+ * @param frameworkClass
+ * @return
+ */
+ CONFIG::debug
+ public static function getExtensionId(frameworkClass:Class):int {
+ use namespace pureLegsCore;
+
+ var retVal:int = 0;
+ if (!(frameworkClass in extensionIdRegistry)) {
+ var currentClass:Class = frameworkClass;
+ while (retVal == 0 && currentClass != Object) {
+ retVal = currentClass["extension_id"];
+ if (retVal == 0) {
+ var className:String = getQualifiedSuperclassName(currentClass);
+ currentClass = getDefinitionByName(className) as Class;
+ } else {
+ extensionNameRegistry[frameworkClass] = String(currentClass["extension_name"]);
+ }
+ }
+ extensionIdRegistry[frameworkClass] = retVal;
+ } else {
+ retVal = extensionIdRegistry[frameworkClass];
+ }
+ return retVal;
+ }
+
+ /**
+ * get extension name for framework class.
+ * @param frameworkClass
+ * @return
+ */
+ CONFIG::debug
+ public static function getExtensionName(frameworkClass:Class):String {
+ return extensionNameRegistry[frameworkClass];
+ }
+
+
+}
+}
View
178 libSrc/mvcexpress/core/MediatorMap.as
@@ -1,6 +1,5 @@
// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
package mvcexpress.core {
-import flash.display.Sprite;
import flash.utils.Dictionary;
import flash.utils.getDefinitionByName;
import flash.utils.getQualifiedClassName;
@@ -20,26 +19,31 @@ use namespace pureLegsCore;
/**
* Handles application mediators.
- * @author Raimundas Banevicius (http://www.mindscriptact.com/)
+ * @author Raimundas Banevicius (http://mvcexpress.org/)
+ *
+ * @version 2.0.rc1
*/
public class MediatorMap implements IMediatorMap {
// name of the module MediatorMap is working for.
protected var moduleName:String;
- // for internal use.
+ // used internally to work with proxies.
protected var proxyMap:ProxyMap;
- // for internal use.
+ // used internally to work with proxies.
+ protected var viewProxyMap:ProxyMapForMediator;
+
+ // used internally for communications
protected var messenger:Messenger;
// stores all mediator classes using view class(mediator must mediate) as a key.
- protected var mediatorMappingRegistry:Dictionary = new Dictionary(); //* of Dictionary of Class) by Class */
+ protected var mediatorMappingRegistry:Dictionary = new Dictionary(); //* of (Dictionary of Class) by Class */
- // stores all mediator is sequence they were mapped.
+ // stores all mediators in sequence they were mapped.
protected var mediatorMapOrderRegistry:Dictionary = new Dictionary(); //* of Vector.<Class> by Class */
- // stores all mediators using use view object(mediator is mediating) as a key.
+ // stores all mediators using view object(mediators are mediating) as a key.
protected var mediatorRegistry:Dictionary = new Dictionary(); //* of Vector.<Mediator> by Object */
/** CONSTRUCTOR */
@@ -47,17 +51,18 @@ public class MediatorMap implements IMediatorMap {
moduleName = $moduleName;
messenger = $messenger;
proxyMap = $proxyMap;
+ viewProxyMap = new ProxyMapForMediator(proxyMap);
}
//----------------------------------
- // set up of mediators
+ // set up
//----------------------------------
/**
- * Maps mediator classes to view class.
+ * Maps one or more mediator classes to view class.
* @param viewClass view class that has to be mediated by mediator class then mediate() is called on the view object.
* @param mediatorClass mediator class that will be instantiated then viewClass object is passed to mediate() function.
- * @param injectClass inject mediator as this class.
+ * @param injectClass inject view into mediator as this class.
* @param restClassPairs rest or mediatorClass and injectClass pairs if you want your view mediated by more then one mediator.
*/
public function map(viewClass:Class, mediatorClass:Class, injectClass:Class = null, ...restClassPairs:Array):void {
@@ -69,36 +74,40 @@ public class MediatorMap implements IMediatorMap {
MvcExpress.debug(new TraceMediatorMap_map(moduleName, viewClass, mediatorClass, injectClass));
// check if mediatorClass is subclass of Mediator class
- if (!checkClassSuperclass(mediatorClass, "mvcexpress.mvc::Mediator")) {
+ if (!checkClassSuperclass(mediatorClass, "mvcexpress.mvc::Mediator", true)) {
throw Error("mediatorClass:" + mediatorClass + " you are trying to map is not extended from 'mvcexpress.mvc::Mediator' class.");
}
+
+ // var check if extension is supported by this module.
+ var extensionId:int = ExtensionManager.getExtensionId(mediatorClass);
+ if (SUPPORTED_EXTENSIONS[extensionId] == null) {
+ throw Error("This extension is not supported by current module. You need " + ExtensionManager.getExtensionName(mediatorClass) + " extension enabled to use " + mediatorClass + " command.");
+ }
}
// check if mapping is not created already
- if (mediatorMappingRegistry[viewClass] != null) {
- if (mediatorMappingRegistry[viewClass][mediatorClass] != null) {
+ if ((viewClass in mediatorMappingRegistry)) {
+ if (mediatorClass in mediatorMappingRegistry[viewClass]) {
throw Error("Mediator class:" + mediatorClass + " is already mapped with this view class:" + viewClass + "");
}
}
// map mediatorClass to viewClass
- if (mediatorMappingRegistry[viewClass] == null) {
+ if (!(viewClass in mediatorMappingRegistry)) {
mediatorMappingRegistry[viewClass] = new Dictionary();
}
-
- if (mediatorMapOrderRegistry[viewClass] == null) {
+ if (!(viewClass in mediatorMapOrderRegistry)) {
mediatorMapOrderRegistry[viewClass] = new Vector.<Class>();
}
-
- // map injectClass to viewClass and mediatarClass.
+ // map injectClass to viewClass and mediatorClass.
if (!injectClass) {
injectClass = viewClass;
}
mediatorMappingRegistry[viewClass][mediatorClass] = injectClass;
mediatorMapOrderRegistry[viewClass].push(mediatorClass);
- // set multi Mediators.
+ // set rest of mediatorClass and injectClass pair classes if more then one mediator is being mapped.
if (restClassPairs) {
if (restClassPairs.length) {
mediatorClass = restClassPairs.shift();
@@ -115,10 +124,10 @@ public class MediatorMap implements IMediatorMap {
}
/**
- * Unmaps all or specific mediator class from given view class.
+ * Unmaps all or specific mediator class from mediating given view class.
* If view is not mapped - it will fail silently.
* @param viewClass view class to remove mapped mediator class from.
- * @param mediatorClass optional parameter if you want to unmap specific mediator. If this is not set - all mediators will be unmapped.
+ * @param mediatorClass optional parameter if you want to unmap specific mediator. If this is not set - all mediators mediating view class will be unmapped.
*/
public function unmap(viewClass:Class, mediatorClass:Class = null):void {
// debug this action
@@ -128,10 +137,9 @@ public class MediatorMap implements IMediatorMap {
MvcExpress.debug(new TraceMediatorMap_unmap(moduleName, viewClass, mediatorClass));
}
// clear mapping
- if (mediatorMappingRegistry[viewClass] != null) {
+ if (viewClass in mediatorMappingRegistry) {
if (mediatorClass) {
- delete mediatorMappingRegistry[viewClass][mediatorClass];
- //
+
var mediators:Vector.<Class> = mediatorMapOrderRegistry[viewClass];
for (var i:int = 0; i < mediators.length; i++) {
if (mediators[i] == mediatorClass) {
@@ -139,11 +147,17 @@ public class MediatorMap implements IMediatorMap {
break;
}
}
+ //
+ if (mediators.length > 0) {
+ delete mediatorMappingRegistry[viewClass][mediatorClass];
+ } else {
+ delete mediatorMappingRegistry[viewClass];
+ delete mediatorMapOrderRegistry[viewClass];
+ }
} else {
delete mediatorMappingRegistry[viewClass];
delete mediatorMapOrderRegistry[viewClass];
}
-
}
}
@@ -152,15 +166,16 @@ public class MediatorMap implements IMediatorMap {
//----------------------------------
/**
- * Mediates provided viewObject with all mapped mediator.
- * Automatically instantiates mediator class(es)(if mapped), handles all injections(including view object injection), and calls onRegister function.
- * Throws error if no mediator classes are mapped to viewObject class.
+ * @inheritDoc
+ * Mediates provided viewObject by all mapped mediator classes.
+ * Automatically instantiates mediator class(es), handles all injections(including view object injection), and calls onRegister function. <p>
+ * Throws error if no mediator classes are mapped to viewObject class. </p>
* @param viewObject view object to mediate.
*/
public function mediate(viewObject:Object):void {
use namespace pureLegsCore;
- if (mediatorRegistry[viewObject]) {
+ if (viewObject in mediatorRegistry) {
throw Error("This view object is already mediated by " + mediatorRegistry[viewObject]);
}
@@ -176,12 +191,11 @@ public class MediatorMap implements IMediatorMap {
var mappedMediators:Dictionary = mediatorMappingRegistry[viewClass];
for (var i:int = 0; i < mediators.length; i++) {
+ // get mapped mediator class.
var mediatorClass:Class = mediators[i];
var injectClass:Class = mappedMediators[mediatorClass];
- // get mapped mediator class.
-
CONFIG::debug {
// Allows Mediator to be constructed. (removed from release build to save some performance.)
Mediator.canConstruct = true;
@@ -190,15 +204,13 @@ public class MediatorMap implements IMediatorMap {
// create mediator.
var mediator:Mediator = new mediatorClass();
- // debug this action
CONFIG::debug {
+ // debug this action
MvcExpress.debug(new TraceMediatorMap_mediate(moduleName, viewObject, mediator, viewClass, mediatorClass, getQualifiedClassName(mediatorClass)));
- }
-
- CONFIG::debug {
// Block Mediator construction.
Mediator.canConstruct = false;
}
+
if (prepareMediator(mediator, mediatorClass, viewObject, injectClass)) {
mediator.register();
}
@@ -224,12 +236,12 @@ public class MediatorMap implements IMediatorMap {
mediator.moduleName = moduleName;
mediator.messenger = messenger;
- mediator.proxyMap = proxyMap;
+ mediator.proxyMap = viewProxyMap;
mediator.mediatorMap = this;
retVal = proxyMap.injectStuff(mediator, mediatorClass, viewObject, injectClass);
- if (mediatorRegistry[viewObject] == null) {
+ if (!(viewObject in mediatorRegistry)) {
mediatorRegistry[viewObject] = new Vector.<Mediator>;
}
mediatorRegistry[viewObject].push(mediator);
@@ -238,9 +250,10 @@ public class MediatorMap implements IMediatorMap {
}
/**
- * Mediates viewObject with specified mediator class. <br>
- * This function will mediate your view without mapping view class to mediator class. <br>
- * It is usually better practice to use 2 step mediation(map() then mediate()) instead of this function. But sometimes it is not possible/useful.
+ * @inheritDoc
+ * Mediates viewObject with specified mediator class. <p>
+ * This function will mediate your view without mapping view class to mediator class.
+ * It is usually better practice to use 2 step mediation(map() then mediate()) instead of this function. But sometimes it is not possible/useful. </p>
* @param viewObject view object to mediate.
* @param mediatorClass mediator class that will be instantiated and used to mediate view object
* @param injectClass inject mediator as this class.
@@ -248,7 +261,7 @@ public class MediatorMap implements IMediatorMap {
public function mediateWith(viewObject:Object, mediatorClass:Class, injectClass:Class = null):void {
use namespace pureLegsCore;
- if (mediatorRegistry[viewObject]) {
+ if (viewObject in mediatorRegistry) {
var mediators:Vector.<Mediator> = mediatorRegistry[viewObject];
for (var i:int = 0; i < mediators.length; i++) {
if ((mediators[i] as Object).constructor == mediatorClass) {
@@ -259,12 +272,16 @@ public class MediatorMap implements IMediatorMap {
CONFIG::debug {
// check if mediatorClass is subclass of Mediator class
- if (!checkClassSuperclass(mediatorClass, "mvcexpress.mvc::Mediator")) {
+ if (!checkClassSuperclass(mediatorClass, "mvcexpress.mvc::Mediator", true)) {
throw Error("mediatorClass:" + mediatorClass + " you are trying to use is not extended from 'mvcexpress.mvc::Mediator' class.");
}
- }
- CONFIG::debug {
+ // var check if mediator is supported by this module.
+ var extensionId:int = ExtensionManager.getExtensionId(mediatorClass);
+ if (SUPPORTED_EXTENSIONS[extensionId] == null) {
+ throw Error("This extension is not supported by current module. You need " + ExtensionManager.getExtensionName(mediatorClass) + " extension enabled to use " + mediatorClass + " command.");
+ }
+
// Allows Mediator to be constructed. (removed from release build to save some performance.)
Mediator.canConstruct = true;
}
@@ -283,25 +300,24 @@ public class MediatorMap implements IMediatorMap {
injectClass = viewClass;
}
- // debug this action
CONFIG::debug {
+ // debug this action
MvcExpress.debug(new TraceMediatorMap_mediate(moduleName, viewObject, mediator, viewClass, mediatorClass, getQualifiedClassName(mediatorClass)));
- }
- CONFIG::debug {
// Block Mediator construction.
Mediator.canConstruct = false;
}
+ // register mediator if everything is injected.
if (prepareMediator(mediator, mediatorClass, viewObject, injectClass)) {
mediator.register();
}
-
}
/**
- * Remove mediation of view object by all or specific mediators. <br>
- * If any mediator is mediating this viewObject - it calls onRemove mediator function, automatically removes all message handlers, all event listeners and dispose it.
+ * @inheritDoc
+ * Stops view object mediation by all or specific mediator. <p>
+ * If any mediator is mediating this viewObject - onRemove mediator function is called, all message handlers and all event listeners(adedd with addListener) are removed automatically, and mediator is disposed. </p>
* @param viewObject view object witch mediator will be destroyed.
* @param mediatorClass optional parameter to unmediate specific mediator class. If this not set - all mediators will be removed.
*/
@@ -341,14 +357,15 @@ public class MediatorMap implements IMediatorMap {
//----------------------------------
/**
- * Checks if mediator class is mapped to view class.
+ * @inheritDoc
+ * Checks if any or specific mediator class is mapped to view class.
* @param viewClass view class that has to be mediated by mediator class then mediate(viewObject) is called.
- * @param mediatorClass Optional Mediator class, if provided will check if viewClass is mapped to this particular mediator class.
+ * @param mediatorClass Optional Mediator class, if provided will check if viewClass is mapped to this specific mediator class.
* @return true if view class is already mapped to mediator class.
*/
public function isMapped(viewClass:Class, mediatorClass:Class = null):Boolean {
var retVal:Boolean; // = false;
- if (mediatorMappingRegistry[viewClass] != null) {
+ if (viewClass in mediatorMappingRegistry) {
if (mediatorClass) {
if (mediatorMappingRegistry[viewClass][mediatorClass] != null) {
retVal = true;
@@ -361,10 +378,18 @@ public class MediatorMap implements IMediatorMap {
}
/**
- * Checks if view object is mediated.
- * @param viewObject View object to check if it is mediated.
+ *
+ * @param viewObject
* @return true if view object is mediated.
*/
+
+ /**
+ * @inheritDoc
+ * Checks if view object is mediated by any or specific mediator.
+ * @param viewObject View object to check if it is mediated.
+ * @param mediatorClass optional parameter to check if view is mediated by specific mediator.
+ * @return
+ */
public function isMediated(viewObject:Object, mediatorClass:Class = null):Boolean {
var retVal:Boolean;// = false;
var mediators:Vector.<Mediator> = mediatorRegistry[viewObject]
@@ -386,15 +411,35 @@ public class MediatorMap implements IMediatorMap {
/**
* Returns String of all view classes that are mapped to mediator classes. (for debugging)
+ * @param verbose if set to true, will return readable string, false will return pairs of view class definition and mediator class list(separated by ',') definition separated by '>', all pairs are separated by ';'.
* @return Text with all mapped mediators.
*/
- public function listMappings():String {
+ public function listMappings(verbose:Boolean = true):String {
var retVal:String = "";
- retVal = "==================== MediatorMap Mappings: =====================\n";
+ if (verbose) {
+ retVal = "==================== MediatorMap Mappings: =====================\n";
+ }
for (var viewClass:Object in mediatorMappingRegistry) {
- retVal += "VIEW:'" + viewClass + "'\t> MEDIATED BY > " + mediatorMapOrderRegistry[viewClass] + "\n";
+ if (verbose) {
+ retVal += "VIEW:'" + viewClass + "'\t> MEDIATED BY > " + mediatorMapOrderRegistry[viewClass] + "\n";
+ } else {
+ if (retVal) {
+ retVal += ";";
+ }
+ retVal += getQualifiedClassName(viewClass) + ">";
+ var mediators:Vector.<Class> = mediatorMapOrderRegistry[viewClass];
+ var mediatorCount:int = mediators.length;
+ for (var i:int = 0; i < mediatorCount; i++) {
+ if (i > 0) {
+ retVal += ",";
+ }
+ retVal += getQualifiedClassName(mediators[i]);
+ }
+ }
+ }
+ if (verbose) {
+ retVal += "================================================================\n";
}
- retVal += "================================================================\n";
return retVal;
}
@@ -420,5 +465,20 @@ public class MediatorMap implements IMediatorMap {
mediatorMapOrderRegistry = null;
}
+
+ //----------------------------------
+ // Extension checking: INTERNAL, DEBUG ONLY.
+ //----------------------------------
+
+ /** @private */
+ CONFIG::debug
+ pureLegsCore var SUPPORTED_EXTENSIONS:Dictionary;
+
+ /** @private */
+ CONFIG::debug
+ pureLegsCore function setSupportedExtensions(supportedExtensions:Dictionary):void {
+ SUPPORTED_EXTENSIONS = supportedExtensions;
+ }
+
}
}
View
141 libSrc/mvcexpress/core/ModuleManager.as
@@ -6,6 +6,7 @@ import mvcexpress.MvcExpress;
import mvcexpress.core.inject.InjectTester;
import mvcexpress.core.messenger.Messenger;
import mvcexpress.core.namespace.pureLegsCore;
+import mvcexpress.core.traceObjects.errors.TraceError;
import mvcexpress.core.traceObjects.moduleManager.TraceModuleManager_createModule;
import mvcexpress.core.traceObjects.moduleManager.TraceModuleManager_disposeModule;
import mvcexpress.modules.ModuleCore;
@@ -15,7 +16,9 @@ use namespace pureLegsCore;
/**
* INTERNAL FRAMEWORK CLASS.
* Manages mvcExpress modules.
- * @author Raimundas Banevicius (http://www.mindscriptact.com/)
+ * @author Raimundas Banevicius (http://mvcexpress.org/)
+ *
+ * @version 2.0.rc1
*/
public class ModuleManager {
@@ -37,6 +40,8 @@ public class ModuleManager {
* @param moduleName name for module
* @param moduleCore module object for given name
* @return returns name (same as provided or generated new one) of the module.
+ *
+ * @private
*/
static pureLegsCore function registerModule(moduleName:String, moduleCore:ModuleCore):String {
@@ -45,6 +50,14 @@ public class ModuleManager {
needMetadataTest = false;
var injectTest:InjectTester = new InjectTester();
if (!injectTest.testInjectMetaTag()) {
+ use namespace pureLegsCore;
+
+ if (MvcExpress.loggerFunction != null) {
+ MvcExpress.loggerFunction(new TraceError(moduleName, "mvcExpress framework failed to use 'Inject' metadata. Please add '-keep-as3-metadata+=Inject' to compile arguments."));
+ }
+ if (MvcExpress.debugFunction != null) {
+ MvcExpress.debugFunction("mvcExpress framework failed to use 'Inject' metadata. Please add '-keep-as3-metadata+=Inject' to compile arguments.");
+ }
throw Error("mvcExpress framework failed to use 'Inject' metadata. Please add '-keep-as3-metadata+=Inject' to compile arguments.");
}
}
@@ -55,7 +68,7 @@ public class ModuleManager {
MvcExpress.debug(new TraceModuleManager_createModule(moduleName));
}
- if (moduleRegistry[moduleName] == null) {
+ if (!(moduleName in moduleRegistry)) {
_moduleId++;
//
if (!moduleName) {
@@ -72,16 +85,49 @@ public class ModuleManager {
/**
* get messenger for module name.
- * @param moduleName name of the module this messenger will belong to.
- * @return returns Messenger object.
* @private
*/
- static pureLegsCore function getMessenger(moduleName:String):Messenger {
+ static pureLegsCore function getModuleMessenger(moduleName:String):Messenger {
use namespace pureLegsCore;
return moduleRegistry[moduleName].messenger;
}
+ /**
+ * get proxyMap for module name.
+ * @private
+ */
+ static pureLegsCore function getModuleProxyMap(moduleName:String):Messenger {
+ use namespace pureLegsCore;
+
+ return moduleRegistry[moduleName].getProxyMap();
+ }
+
+ /**
+ * get mediatorMap for module name.
+ * @private
+ */
+ static pureLegsCore function getModuleMediatorMap(moduleName:String):MediatorMap {
+ use namespace pureLegsCore;
+
+ return moduleRegistry[moduleName].getMediatorMap();
+ }
+
+ /**
+ * get commandMap for module name.
+ * @private
+ */
+ static pureLegsCore function getModuleCommandMap(moduleName:String):CommandMap {
+ use namespace pureLegsCore;
+
+ return moduleRegistry[moduleName].getCommandMap();
+ }
+
+
+ /**
+ * get module object for module name.
+ * @private
+ */
static pureLegsCore function getModule(moduleName:String):ModuleCore {
return moduleRegistry[moduleName];
}
@@ -98,53 +144,20 @@ public class ModuleManager {
CONFIG::debug {
MvcExpress.debug(new TraceModuleManager_disposeModule(moduleName));
}
- if (moduleRegistry[moduleName]) {
- // remove scoped proxies from this module
- /*
- var scopiedProxies:Dictionary = scopedProxiesByScope[moduleName];
- if (scopiedProxies) {
- // remove scoped proxies.
- for each (var scopedProxyData:ScopedProxyData in scopiedProxies) {
- var scopedProxyMap:ProxyMap = scopedProxyMaps[scopedProxyData.scopeName];
- scopedProxyMap.unmap(scopedProxyData.injectClass, scopedProxyData.name);
- delete scopiedProxies[scopedProxyData.injectId];
- }
- }
- */
- //
+ if (moduleName in moduleRegistry) {
delete moduleRegistry[moduleName];
- //
- /*
- delete scopePermissionsRegistry[moduleName];
- */
} else {
throw Error("Module with moduleName:" + moduleName + " doesn't exist.");
}
}
- // REFACTOR : temp fuction to reset state - needs refactor after scope stuff is removed from here.
+ // REFACTOR : temp function to reset state - needs refactor after scope stuff is removed from here.
static public function disposeAll():void {
for each(var module:ModuleCore in moduleRegistry) {
module.disposeModule();
}
moduleRegistry = new Dictionary();
-
- // FIX ME - decide how to implement this..
-
-// for each(var messenger:Messenger in scopedMessengers) {
-// messenger.dispose();
-// }
-// scopedMessengers = new Dictionary();
-//
-// for each(var proxyMap:ProxyMap in scopedProxyMaps) {
-// proxyMap.dispose();
-// }
-// scopedProxyMaps = new Dictionary();
-//
-// scopedProxiesByScope = new Dictionary();
-// scopePermissionsRegistry = new Dictionary();
-
}
@@ -154,7 +167,7 @@ public class ModuleManager {
/**
* Returns string with all module names.
- * @return
+ * @return string of all module names
*/
static public function listModules():String {
var retVal:String = "";
@@ -167,57 +180,71 @@ public class ModuleManager {
return "Module list:" + retVal;
}
+ /**
+ * Lists messages for module name.
+ * @param moduleName module name to debug
+ * @return
+ */
static public function listMappedMessages(moduleName:String):String {
- if (moduleRegistry[moduleName]) {
+ if (moduleName in moduleRegistry) {
return (moduleRegistry[moduleName] as ModuleCore).listMappedMessages();
} else {
return "Module with name :" + moduleName + " is not found.";
}
}
+ /**
+ * lists mapped mediator for module name
+ * @param moduleName module name to debug
+ * @return
+ */
static public function listMappedMediators(moduleName:String):String {
- if (moduleRegistry[moduleName]) {
+ if (moduleName in moduleRegistry) {
return (moduleRegistry[moduleName] as ModuleCore).listMappedMediators();
} else {
return "Module with name :" + moduleName + " is not found.";
}
}
+ /**
+ * lists mapped proxies
+ * @param moduleName module name to debug
+ * @return
+ */
static public function listMappedProxies(moduleName:String):String {
- if (moduleRegistry[moduleName]) {
+ if (moduleName in moduleRegistry) {
return (moduleRegistry[moduleName] as ModuleCore).listMappedProxies();
} else {
return "Module with name :" + moduleName + " is not found.";
}
}
+ /**
+ * lists mapped commands
+ * @param moduleName module name to debug
+ * @return
+ */
static public function listMappedCommands(moduleName:String):String {
- if (moduleRegistry[moduleName]) {
+ if (moduleName in moduleRegistry) {
return (moduleRegistry[moduleName] as ModuleCore).listMappedCommands();
} else {
return "Module with name :" + moduleName + " is not found.";
}
}
- static pureLegsCore function listModuleMessageCommands(moduleName:String, key:String):String {
- use namespace pureLegsCore;
-
- if (moduleRegistry[moduleName]) {
- return ((moduleRegistry[moduleName] as ModuleCore).listMessageCommands(key) as String);
- } else {
- return "Module with name :" + moduleName + " is not found.";
- }
- }
-
/**
+ * EXPERIMENTAL
* Invokes custom module function.
+ * Experimental function for mvcLogger and extension development.
+ *
* @param moduleName Name of module.
* @param functionName name of the function
* @param params optional function params
* @return returns object.
+ * @private
*/
- static public function invokeModuleFunction(moduleName:String, functionName:String, params:Array = null):Object {
- if (moduleRegistry[moduleName]) {
+ static pureLegsCore function invokeModuleFunction(moduleName:String, functionName:String, params:Array = null):Object {
+ if (moduleName in moduleRegistry) {
try {
var callFunct:Function = moduleRegistry[moduleName][functionName]
if (params) {
View
570 libSrc/mvcexpress/core/ProxyMap.as
@@ -27,19 +27,23 @@ use namespace pureLegsCore;
/**
* ProxyMap is responsible for storing proxy objects and handling injection.
- * @author Raimundas Banevicius (http://www.mindscriptact.com/)
+ * @author Raimundas Banevicius (http://mvcexpress.org/)
+ *
+ * @version 2.0.rc1
*/
public class ProxyMap implements IProxyMap {
// name of the module CommandMap is working for.
protected var moduleName:String;
+ // used internally for communications
protected var messenger:Messenger;
+ // used internally for command pool handling.
protected var commandMap:CommandMap;
- /** stares class QualifiedClassName by class */
- static protected var qualifiedClassNameRegistry:Dictionary = new Dictionary(); //* of String by Class*/
+ /** stores class QualifiedClassName by class */
+ static protected var qualifiedClassNameRegistry:Dictionary = new Dictionary(); //* of String by Class */
/** dictionary of (Vector of InjectRuleVO), stored by class names. */
static protected var classInjectRules:Dictionary = new Dictionary(); //* of Vector.<InjectRuleVO> by Class */
@@ -53,9 +57,15 @@ public class ProxyMap implements IProxyMap {
/** dictionary of lazy Proxies, those proxies will be instantiated and mapped on first use. */
protected var lazyProxyRegistry:Dictionary = new Dictionary(); //* of Vector.<PendingInject> by String */
- /** Dictionary with constonts of inject names, used with constName, and constScope. */
+ /** Dictionary with constants of inject names, used with constName, and constScope. */
protected var classConstRegistry:Dictionary = new Dictionary();
+
+ // TODO : move, document.
+ protected var mediatorInjectObjectRegistry:Dictionary = new Dictionary(); //* of Proxy by String */
+ protected var mediatorInjectIdRegistry:Dictionary = new Dictionary(); //* of String by String */
+
+
/** CONSTRUCTOR */
public function ProxyMap($moduleName:String, $messenger:Messenger) {
moduleName = $moduleName;
@@ -70,11 +80,12 @@ public class ProxyMap implements IProxyMap {
/**
* Maps proxy object to injectClass and name.
* @param proxyObject Proxy instance to use for injection.
- * @param injectClass Optional class to use for injection, if null proxyObject class is used. It is helpful if you want to map proxy interface or subclass.
* @param name Optional name if you need more then one proxy instance of same class.
- * @return returns inject id. (for debuging reasons only.)
+ * @param injectClass Optional class to use for injection, if null proxyObject class is used. It is helpful if you want to map proxy interface or subclass.
+ * @param mediatorInjectClass Optional class to use for injection in mediators, if null - injectClass class is used. If injectClass is null - proxyObject class is used.
+ * @return returns inject id. (for debugging reasons only.)
*/
- public function map(proxyObject:Proxy, injectClass:Class = null, name:String = ""):String {
+ public function map(proxyObject:Proxy, name:String = null, injectClass:Class = null, mediatorInjectClass:Class = null):String {
use namespace pureLegsCore;
// get proxy class
@@ -85,6 +96,10 @@ public class ProxyMap implements IProxyMap {
injectClass = proxyClass;
}
+ if (name == null) {
+ name = "";
+ }
+
// get inject id
var className:String = qualifiedClassNameRegistry[injectClass];
if (!className) {
@@ -104,23 +119,54 @@ public class ProxyMap implements IProxyMap {
// debug this action
CONFIG::debug {
MvcExpress.debug(new TraceProxyMap_map(moduleName, proxyObject, injectClass, name));
- }
- if (proxyObject.messenger == null) {
- initProxy(proxyObject, proxyClass, injectId);
+ // var check if extension is supported by this module.
+ var extensionId:int = ExtensionManager.getExtensionId(proxyClass);
+ if (SUPPORTED_EXTENSIONS[extensionId] == null) {
+ throw Error("This extension is not supported by current module. You need " + ExtensionManager.getExtensionName(proxyClass) + " extension enabled to use " + proxyClass + " proxy.");
+ }
}
- // check if there is no pending injection with this key.
- if (pendingInjectionsRegistry[injectId]) {
- injectPendingStuff(injectId, proxyObject);
+ if (proxyObject.messenger == null) {
+ var isAllInjected:Boolean = initProxy(proxyObject, proxyClass, injectId);
}
- if (!injectObjectRegistry[injectId]) {
+ if (!(injectId in injectObjectRegistry)) {
// store proxy injection for other classes.
injectObjectRegistry[injectId] = proxyObject;
} else {
throw Error("Proxy object class is already mapped.[injectClass:" + className + " name:" + name + "]");
}
+ if (mediatorInjectClass != null) {
+ className = qualifiedClassNameRegistry[mediatorInjectClass];
+ if (!className) {
+ className = getQualifiedClassName(mediatorInjectClass);
+ qualifiedClassNameRegistry[mediatorInjectClass] = className;
+ }
+
+ var mediatorInjectId:String = className + name;
+ if (!(mediatorInjectId in mediatorInjectObjectRegistry)) {
+ mediatorInjectObjectRegistry[mediatorInjectId] = proxyObject;
+ mediatorInjectIdRegistry[injectId] = mediatorInjectId;
+
+ // handle case of pending injection.
+ if (mediatorInjectId in pendingInjectionsRegistry) {
+ injectPendingStuff(mediatorInjectId, proxyObject);
+ }
+ } else {
+ throw Error("Proxy object class is already mapped for inject to mediators.[injectClass:" + className + " name:" + name + "]");
+ }
+ }
+
+ // check if there is no pending injection with this key.
+ if (injectId in pendingInjectionsRegistry) {
+ injectPendingStuff(injectId, proxyObject);
+ }
+
+ // register proxy is all injections are done.
+ if (isAllInjected) {
+ proxyObject.register();
+ }
return injectId;
}
@@ -130,15 +176,19 @@ public class ProxyMap implements IProxyMap {
* If mapping does not exists - it will fail silently.
* @param injectClass class previously mapped for injection
* @param name name added to class, that was previously mapped for injection
- * @return returns inject id. (for debuging reasons only.)
+ * @return returns inject id. (for debugging reasons only.)
*/
- public function unmap(injectClass:Class, name:String = ""):String {
+ public function unmap(injectClass:Class, name:String = null):String {
use namespace pureLegsCore;
// debug this action
CONFIG::debug {
MvcExpress.debug(new TraceProxyMap_unmap(moduleName, injectClass, name));
}
+
+ if (name == null) {
+ name = "";
+ }
// get inject id
var className:String = qualifiedClassNameRegistry[injectClass];
if (!className) {
@@ -148,7 +198,7 @@ public class ProxyMap implements IProxyMap {
var injectId:String = className + name;
// remove proxy if it exists.
- if (injectObjectRegistry[injectId]) {
+ if (injectId in injectObjectRegistry) {
var proxy:Proxy = injectObjectRegistry[injectId] as Proxy;
// handle dependencies..
@@ -161,6 +211,18 @@ public class ProxyMap implements IProxyMap {
delete injectObjectRegistry[injectId];
}
+ // clear any injection mapping into mediators.
+ if (injectId in mediatorInjectIdRegistry) {
+ delete mediatorInjectObjectRegistry[mediatorInjectIdRegistry[injectId]];
+ delete mediatorInjectIdRegistry[injectId];
+ }
+
+ // clear lazy mappings
+ if (injectId in lazyProxyRegistry) {
+ lazyProxyRegistry[injectId].dispose();
+ delete lazyProxyRegistry[injectId];
+ }
+
return injectId;
}
@@ -171,18 +233,22 @@ public class ProxyMap implements IProxyMap {
/**
* Stores lazy proxy data to be instantiated on first use. Proxy will be instantiated and mapped then requested for the first time.
- * @param proxyClass
+ * @param proxyClass Class to construct proxy.
+ * @param name Optional name if you need more then one proxy instance of same class.
* @param injectClass Optional class to use for injection, if null proxyObject class is used. It is helpful if you want to map proxy interface or subclass.
- * @param name Optional name if you need more then one proxy instance of same class.
- * @param proxyParams
- * @return returns inject id. (for debuging reasons only.)
+ * @param proxyConstructorParams parameters to pass to proxy constructor. (up to 10 parameters)
+ * @return returns inject id. (for debugging reasons only.)
*/
- public function lazyMap(proxyClass:Class, injectClass:Class = null, name:String = "", proxyParams:Array = null):String {
+ public function lazyMap(proxyClass:Class, name:String = null, injectClass:Class = null, mediatorInjectClass:Class = null, proxyConstructorParams:Array = null):String {
if (!injectClass) {
injectClass = proxyClass;
}
+ if (name == null) {
+ name = "";
+ }
+
// get inject id
var className:String = qualifiedClassNameRegistry[injectClass];
if (!className) {
@@ -200,26 +266,53 @@ public class ProxyMap implements IProxyMap {
//debug this action
CONFIG::debug {
+ use namespace pureLegsCore;
+
if (!checkClassSuperclass(proxyClass, "mvcexpress.mvc::Proxy")) {
throw Error("proxyClass:" + proxyClass + " you are trying to lazy map is not extended from 'mvcexpress.mvc::Proxy' class.");
}
- if (proxyParams && proxyParams.length > 10) {
- throw Error("Only up to 10 Proxy parameters are supported. Please refactor some into parameter container objects. [injectClass:" + className + " name:" + name + " proxyParams:" + proxyParams + "]");
+ if (proxyConstructorParams && proxyConstructorParams.length > 10) {
+ throw Error("Only up to 10 Proxy parameters are supported. Please refactor some into parameter container objects. [injectClass:" + className + " name:" + name + " proxyParams:" + proxyConstructorParams + "]");
}
- use namespace pureLegsCore;
+ // var check if extension is supported by this module.
+ var extensionId:int = ExtensionManager.getExtensionId(proxyClass);
+ if (SUPPORTED_EXTENSIONS[extensionId] == null) {
+ throw Error("This extension is not supported by current module. You need " + ExtensionManager.getExtensionName(proxyClass) + " extension enabled to use " + proxyClass + " proxy.");
+ }
- MvcExpress.debug(new TraceProxyMap_lazyMap(moduleName, proxyClass, injectClass, name, proxyParams));
+ MvcExpress.debug(new TraceProxyMap_lazyMap(moduleName, proxyClass, injectClass, name, proxyConstructorParams));
}
var lazyInject:LazyProxyVO = new LazyProxyVO();
lazyInject.proxyClass = proxyClass;
lazyInject.injectClass = injectClass;
+ lazyInject.injectId = injectId;
lazyInject.name = name;
- lazyInject.proxyParams = proxyParams;
+ lazyInject.proxyParams = proxyConstructorParams;
lazyProxyRegistry[injectId] = lazyInject;
+ if (mediatorInjectClass) {
+ // get inject id
+ var mediatorInjectClassName:String = qualifiedClassNameRegistry[mediatorInjectClass];
+ if (!className) {
+ mediatorInjectClassName = getQualifiedClassName(mediatorInjectClass);
+ qualifiedClassNameRegistry[mediatorInjectClass] = mediatorInjectClassName;
+ }
+ var mediatorInjectId:String = mediatorInjectClassName + name;
+
+ lazyInject.mediatorInjectClass = mediatorInjectClass;
+ lazyInject.mediatorInjectId = mediatorInjectId;
+
+ lazyProxyRegistry[mediatorInjectId] = lazyInject;
+ }
+
+ // check if this class is not pending.
+ if (injectId in pendingInjectionsRegistry) {
+ initLazyProxy(injectId);
+ }
+
return injectId;
}
@@ -229,25 +322,36 @@ public class ProxyMap implements IProxyMap {
//----------------------------------
/**
- * Get mapped proxy. This is needed to get proxy manually instead of inject it automatically. <br>
- * You might wont to get proxy manually then your proxy has dynamic name. <br>
+ * @inheritDoc
+ * Get proxy by class. Alternative to injecting proxy automatically. <p>
+ * You might want to get proxy manually then your proxy has dynamic name.
* Also you might want to get proxy manually if your proxy is needed only in rare cases or only for short time.
- * (for instance - you need it only in onRegister() function.)
- * @param injectClass Optional class to use for injection, if null proxyObject class is used. It is helpful if you want to map proxy interface or subclass.
+ * (for instance - you need it only in onRegister() function.) </p>
+ * @param proxyClass class of proxy, proxy object is mapped to.
* @param name Optional name if you need more then one proxy instance of same class.
*/
- public function getProxy(injectClass:Class, name:String = ""):Proxy {
- var className:String = qualifiedClassNameRegistry[injectClass];
+ public function getProxy(proxyClass:Class, name:String = null):Proxy {
+ if (name == null) {
+ name = "";
+ }
+ var className:String = qualifiedClassNameRegistry[proxyClass];
if (!className) {
- className = getQualifiedClassName(injectClass);
- qualifiedClassNameRegistry[injectClass] = className;
+ className = getQualifiedClassName(proxyClass);
+ qualifiedClassNameRegistry[proxyClass] = className;
}
- var classAndName:String = className + name;
- if (classAndName in injectObjectRegistry) {
- return injectObjectRegistry[classAndName];
- } else {
- throw Error("Proxy object is not mapped. [injectClass:" + className + " name:" + name + "]");
+ var injectId:String = className + name;
+
+ // try to get proxy from standard registry.
+ var proxyObject:Proxy = injectObjectRegistry[injectId] as Proxy;
+ if (!proxyObject) {
+ // check lazy proxies.
+ if (injectId in lazyProxyRegistry) {
+ proxyObject = initLazyProxy(injectId);
+ } else {
+ throw Error("Proxy object is not mapped. [injectClass:" + className + " name:" + name + "]");
+ }
}
+ return proxyObject;
}
@@ -256,41 +360,70 @@ public class ProxyMap implements IProxyMap {
//----------------------------------
/**
- * Checks if proxy object is mapped using specified class(and optionaly name.). <br>
- * Optionally you can check if specific proxyObject is already mapped.
- * @param proxyObject Proxy instance to use for injection.
- * @param injectClass Optional class to use for injection, if null proxyObject class is used. It is helpful if you want to map proxy interface or subclass.
- * @param name Optional name if you need more then one proxy instance of same class.
- * @return true if object is already mapped.
+ * Checks if proxy object is mapped using specified class(and optionally name.). <p>
+ * Optionally you can check if specific proxyObject is already mapped. </p>
+ *
+ * @param injectClass Optional class to use for injection, if null proxyObject class is used. It is helpful if you want to map proxy interface or subclass.
+ * @param name Optional name if you need more then one proxy instance of same class.
+ * @param proxyObject Proxy instance, to check if it's mapped.
+ * @return true if proxy is mapped
*/
- public function isMapped(injectClass:Class, name:String = "", proxyObject:Proxy = null):Boolean {
+ public function isMapped(injectClass:Class, name:String = null, proxyObject:Proxy = null):Boolean {
var retVal:Boolean; // = false;
+ if (name == null) {
+ name = "";
+ }
var className:String = qualifiedClassNameRegistry[injectClass];
if (!className) {
className = getQualifiedClassName(injectClass);
qualifiedClassNameRegistry[injectClass] = className;
}
- if (injectObjectRegistry[className + name]) {
+
+ var injectId:String = className + name;
+
+ if (injectId in injectObjectRegistry) {
if (proxyObject) {
- retVal = (injectObjectRegistry[className + name] == proxyObject);
+ retVal = (injectObjectRegistry[injectId] == proxyObject);
} else {
retVal = true;
}
+ } else {
+ // if proxy object is not found, try lazy mapping.
+ if (proxyObject == null) {
+ if (injectId in lazyProxyRegistry) {
+ var lazyProxyData:LazyProxyVO = lazyProxyRegistry[injectId];
+ if (lazyProxyData.injectId == injectId) {
+ retVal = true;
+ }
+ }
+ }
}
return retVal;
}
/**
* Returns text of all mapped proxy objects, and keys they are mapped to. (for debugging)
+ * @param verbose if set to true, will return readable string, false will return pairs of object class name and key it is mapped to separated by '>', all pairs are separated by ';'.
* @return Text string with all mapped proxies.
*/
- public function listMappings():String {
+ public function listMappings(verbose:Boolean = true):String {
var retVal:String = "";
- retVal = "====================== ProxyMap Mappings: ======================\n";
+ if (verbose) {
+ retVal = "====================== ProxyMap Mappings: ======================\n";
+ }
for (var key:Object in injectObjectRegistry) {
- retVal += "PROXY OBJECT:'" + injectObjectRegistry[key] + "'\t\t\t(MAPPED TO:" + key + ")\n";
+ if (verbose) {
+ retVal += "PROXY OBJECT:'" + injectObjectRegistry[key] + "'\t\t\t(MAPPED TO:" + key + ")\n";
+ } else {
+ if (retVal) {
+ retVal += ";";
+ }
+ retVal += getQualifiedClassName(injectObjectRegistry[key]).split("::")[1] + ">" + key;
+ }
+ }
+ if (verbose) {
+ retVal += "================================================================\n";
}
- retVal += "================================================================\n";
return retVal;
}
@@ -299,6 +432,7 @@ public class ProxyMap implements IProxyMap {
// internal stuff
//----------------------------------
+ /** @private */
pureLegsCore function setCommandMap(value:CommandMap):void {
commandMap = value;
}
@@ -308,18 +442,138 @@ public class ProxyMap implements IProxyMap {
* @param proxyObject
* @private
*/
- pureLegsCore function initProxy(proxyObject:Proxy, proxyClass:Class, injectId:String):void {
+ pureLegsCore function initProxy(proxyObject:Proxy, proxyClass:Class, injectId:String):Boolean {
use namespace pureLegsCore;
proxyObject.messenger = messenger;
proxyObject.setProxyMap(this);
// inject dependencies
- var isAllInjected:Boolean = injectStuff(proxyObject, proxyClass);
+ return injectStuff(proxyObject, proxyClass);
+ }
- // register proxy is all injections are done.
- if (isAllInjected) {
- proxyObject.register();
+ // init lazy proxy
+ private function initLazyProxy(injectId:String):Proxy {
+
+ var lazyProxyData:LazyProxyVO = lazyProxyRegistry[injectId];
+
+ // check if this lazy proxy mapnig has second lazy mapnig for mediator injcet.
+ if (lazyProxyData.mediatorInjectId == injectId) {
+ // this is lazy proxy mediator inject, clear lazy proxy mapping.
+ delete lazyProxyRegistry[lazyProxyData.injectId];
+ } else if (lazyProxyData.mediatorInjectId != null) { // check if this lazy proxy has mediator ID mapped.
+ // this is lazy proxy inject, with mediator inject also mapped, clear lazy proxy mediator inject mapping.
+ delete lazyProxyRegistry[lazyProxyData.mediatorInjectId];
+ }
+
+ delete lazyProxyRegistry[injectId];
+
+ var lazyProxy:Proxy;
+ if (lazyProxyData.proxyParams) {
+ var paramCount:int = lazyProxyData.proxyParams.length;
+ if (paramCount == 0) {
+ lazyProxy = new lazyProxyData.proxyClass();
+ } else if (paramCount == 1) {
+ lazyProxy = new lazyProxyData.proxyClass(lazyProxyData.proxyParams[0]);
+ } else if (paramCount == 2) {
+ lazyProxy = new lazyProxyData.proxyClass(lazyProxyData.proxyParams[0], lazyProxyData.proxyParams[1]);
+ } else if (paramCount == 3) {
+ lazyProxy = new lazyProxyData.proxyClass(lazyProxyData.proxyParams[0], lazyProxyData.proxyParams[1], lazyProxyData.proxyParams[2]);
+ } else if (paramCount == 4) {
+ lazyProxy = new lazyProxyData.proxyClass(lazyProxyData.proxyParams[0], lazyProxyData.proxyParams[1], lazyProxyData.proxyParams[2], lazyProxyData.proxyParams[3]);
+ } else if (paramCount == 5) {
+ lazyProxy = new lazyProxyData.proxyClass(lazyProxyData.proxyParams[0], lazyProxyData.proxyParams[1], lazyProxyData.proxyParams[2], lazyProxyData.proxyParams[3], lazyProxyData.proxyParams[4]);
+ } else if (paramCount == 6) {
+ lazyProxy = new lazyProxyData.proxyClass(lazyProxyData.proxyParams[0], lazyProxyData.proxyParams[1], lazyProxyData.proxyParams[2], lazyProxyData.proxyParams[3], lazyProxyData.proxyParams[4], lazyProxyData.proxyParams[5]);
+ } else if (paramCount == 7) {
+ lazyProxy = new lazyProxyData.proxyClass(lazyProxyData.proxyParams[0], lazyProxyData.proxyParams[1], lazyProxyData.proxyParams[2], lazyProxyData.proxyParams[3], lazyProxyData.proxyParams[4], lazyProxyData.proxyParams[5], lazyProxyData.proxyParams[6]);
+ } else if (paramCount == 8) {
+ lazyProxy = new lazyProxyData.proxyClass(lazyProxyData.proxyParams[0], lazyProxyData.proxyParams[1], lazyProxyData.proxyParams[2], lazyProxyData.proxyParams[3], lazyProxyData.proxyParams[4], lazyProxyData.proxyParams[5], lazyProxyData.proxyParams[6], lazyProxyData.proxyParams[7]);
+ } else if (paramCount == 9) {
+ lazyProxy = new lazyProxyData.proxyClass(lazyProxyData.proxyParams[0], lazyProxyData.proxyParams[1], lazyProxyData.proxyParams[2], lazyProxyData.proxyParams[3], lazyProxyData.proxyParams[4], lazyProxyData.proxyParams[5], lazyProxyData.proxyParams[6], lazyProxyData.proxyParams[7], lazyProxyData.proxyParams[8]);
+ } else if (paramCount == 10) {
+ lazyProxy = new lazyProxyData.proxyClass(lazyProxyData.proxyParams[0], lazyProxyData.proxyParams[1], lazyProxyData.proxyParams[2], lazyProxyData.proxyParams[3], lazyProxyData.proxyParams[4], lazyProxyData.proxyParams[5], lazyProxyData.proxyParams[6], lazyProxyData.proxyParams[7], lazyProxyData.proxyParams[8], lazyProxyData.proxyParams[9]);
+ } else {
+ throw Error("Lazy proxing is not supported with that many parameters. Cut it douwn please. Thanks! [injectClass:" + lazyProxyData.injectClass + " ,name: " + lazyProxyData.name + "]");
+ }
+ } else {
+ lazyProxy = new lazyProxyData.proxyClass();
+ }
+ map(lazyProxy, lazyProxyData.name, lazyProxyData.injectClass, lazyProxyData.mediatorInjectClass);
+
+ return lazyProxy;
+ }
+
+ /**
+ * Function to get proxy from mediator.
+ * @param proxyClass
+ * @param name
+ * @private
+ * @return
+ */
+ pureLegsCore function mediatorGetProxy(proxyClass:Class, name:String = null):Proxy {
+ if (name == null) {
+ name = "";
+ }
+ var className:String = qualifiedClassNameRegistry[proxyClass];
+ if (!className) {
+ className = getQualifiedClassName(proxyClass);
+ qualifiedClassNameRegistry[proxyClass] = className;
+ }
+ var injectId:String = className + name;
+
+ // try to get proxy from mediator registry.
+ var proxyObject:Proxy = mediatorInjectObjectRegistry[injectId] as Proxy;
+ if (!proxyObject) {
+ // check lazy proxies.
+ if (injectId in lazyProxyRegistry) {
+ initLazyProxy(injectId);
+ // try to get mediator inject again.
+ proxyObject = mediatorInjectObjectRegistry[injectId];
+ }
+ }
+ // proxy is not found - throw error.
+ if (!proxyObject) {
+ proxyObject = injectObjectRegistry[injectId];
+ if (proxyObject) {
+ throw Error("You are trying to get proxy class:" + injectId + " from mediator, but mediators are not allowed to inject this proxy. To enable this: set mediatorInjectClass parameter then you map this proxy.");
+ } else {
+ throw Error("Proxy object is not mapped. [injectClass:" + className + " name:" + name + "]");
+ }
+ }
+ return proxyObject;
+ }
+
+ /**
+ * Function to check if proxy can be received from Mediator.
+ * @param proxyClass
+ * @param name
+ * @return
+ */
+ pureLegsCore function mediatorIsProxyMapped(proxyClass:Class, name:String = null):Boolean {
+ if (name == null) {
+ name = "";
+ }
+ var className:String = qualifiedClassNameRegistry[proxyClass];
+ if (!className) {
+ className = getQualifiedClassName(proxyClass);
+ qualifiedClassNameRegistry[proxyClass] = className;
}
+ var injectId:String = className + name;
+
+ var retVal:Boolean = (injectId in mediatorInjectObjectRegistry);
+
+ // if injection not found, try lazy mapping.
+ if (!retVal) {
+ if (injectId in lazyProxyRegistry) {
+ var lazyProxyData:LazyProxyVO = lazyProxyRegistry[injectId];
+ // check if this lazy proxy mapping maps mediator class.
+ if (lazyProxyData.mediatorInjectId == injectId) {
+ retVal = true;
+ }
+ }
+ }
+