From: Marc P. <ma...@an...> - 2005-08-03 13:23:24
|
> Whatever, WebMacro configuration needs to be "bean scriptable". I am > not > suggesting any replacement of the existing properties config scheme for > WM > - but it -must- be possible for users to configurable WebMacro at > runtime, > and from any POJO configuration tool such as Spring, Pico etc. Let me qualify this a bit more - in my "dream" of WM 3 we'd have POJOs that let us configure a WebMacro instance - both initially at startup using somethign like Spring, but also at runtime for non-persistent changes to the config such as temporarily adding a new directive. A Spring bean config XML might look like this: <beans> <bean id="myBusinessLogic" class="com.somecorp.LogicClass"> <property name="datastore" ref="myJDBCstorage"/> </bean> <bean id="myJDBCstorage" class="com.somecorp.JDBCStorageClass"> <property name="datasource" value="java:comp/env/jdbc/TestDB"/> </bean> <bean id="someDirective" class="com.somecorp.SomeDirectiveClass"> <property name="datastore" ref="myJDBCstorage"/> </bean> <bean id="webmacro1" class="org.webmacro.WebMacroConfiguration"> <property name="baseConfiguration" value="file:wm.properties"/> <property name="contextTools"> <map> <entry key="logic" value-ref="myBusinessLogic"> </map> </property> <property name="directives"> <map> <entry key="specialdirective" value-ref="someDirective"> </map> </property> </bean> <bean id="webmacro2" class="org.webmacro.WebMacroConfiguration"> <property name="baseConfiguration" value="file:wm2.properties"/> <property name="contextTools"> <map> <entry key="logic" value-ref="myBusinessLogic"> </map> </property> </bean> <bean id="uiController1" class="com.somecorp.MyUIController"> <property name="webmacro" ref="webmacro1"/> </bean> <bean id="uiController2" class="com.somecorp.MyOtherUIController"> <property name="webmacro" ref="webmacro2"/> </bean> </beans> Now for anyone not familiar with Spring, the above will create a bunch of Java objects (using the "class=" attribute value) calling their default constructors and then will automatically set the properties on those objects including resolving references to other beans within the context, independent of order in the XML file. Anyway, the above shows how simple it would then be to configure WebMacro for a single application that has: * Multiple WM instances, initialized from different config * WM instances initialized with context tools that are configured with references to other configuration-domain objects -without- the use of ugly singletons in your application, or arguably worse JNDI (yes I used a JNDI datasource just to save space...). Remember, those beans referenced by the WM config could be anything, and exist anywhere. Your WM setup / application no longer needs to know. * Wiring of WM instances to other components such as your controllers/actions. This is -great-! It would also be possible to allow configuration of Context "templates" so that whenever WM needs a new context it takes it from a bean factory configured in the Spring XML - thus externalizing this config from WM and most importantly integrating it with Spring applications. Like the XML or not Lane, -lots- of people out there are using Spring and havnig WM non-configurable from it is very ugly indeed, forcing you or end-users to understand and use multiple configuration schemes/tools. It makes WM much less attractive. I haven't checked but I'm pretty sure that Velocity config is Spring friendly. $0.02 :) |