Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
<!-- this MUST be initialised before any mediators --><bean id="applicationFacade" class="com.my.application.ApplicationFacade" factory-method="getInst" init-method="start"> <property name="app" ref="demoApp"></property> <property name="mediators"> <list> <ref local="appMediator"/> <ref local="homeUIMediator"/> </list> </property> <property name="models"> <list> <ref local="propertyProxy"/> </list> </property> <property name="commands"> <list> <ref local="propertyChangeCommand"/> <ref local="botStateChangeCommand"/> <ref local="startupCommand"/> </list> </property> </bean> <!-- MVC Command Beans --><!--I chose to define my command mappings in codebut could have used a Map structure here instead, or I could have embedded the notification Name ineach of my command classes(not good if u have same command class associated with different notifications in different cores or projects, but otherwise fine).<property name="commandMappings"><map> <entry key="abc" value-ref="myCommand"></entry> </map> </property>--> <bean id="startupCommand" class="com.my.mvc.controller.StartupCommand"> <constructor-arg value="${multitonControllerKey}"/> <property name="propertyChangeCommand" ref="propertyChangeCommand"/> <property name="botStateChangeCommand" ref="botStateChangeCommand"/> <property name="loadDataCommand" ref="loadDataCommand"/> <property name="homeUIView" ref="homeUIView"/> </bean>... etc
ApplicationFacade facade=(ApplicationFacade) getFacade(); //just register everything for (IMediator mediator : facade.getMediators()) { facade.registerMediator(mediator); } for (IProxy proxy : facade.getModels()) { facade.registerProxy(proxy); } facade.registerCommand(Command.PROPERTY_CHANGED.name(), propertyChangeCommand); facade.registerCommand(Command.STATE_CHANGED.name(), botStateChangeCommand); facade.registerCommand(Command.LOAD_USER_DATA.name(), loadDataCommand);
Not really sure why the ordinary startup process of creating and registering mediators doesn't work.-=Cliff>
makes no attempt to call onRemove for components when it shuts down or a core is removed, so if it needs to be done at all, it needs to be done manually for each component.
It would be really nice if there were also a setProxies(List<IProxy> proxies), setCommands(Map<ICommand,String notification>) etc too so I dont have to create duplicate lists.