From: Sebastian K. <seb...@mu...> - 2004-10-01 17:27:50
|
Hi Lane, thanks for your comments. I want to start with some comments as well to provide you with some background information. First of all one has to decide what goals one wants to achieve by "integrating" WebMacro and Spring. Integration alone does not describe this exactly enough. I see two scenarios here: 1) Use the WebMacro "framework" (e.g. WMServlet) and access Spring resources from there 2) Use the Spring framework (not quoted because this is a real framework :) ) and use WebMacro for the View layer For 1) you don't need any additional code, I think. You just fetch a Spring (Web-)ApplicationContext during the initialisation of WMServlet (or whatever approach you are using) and use it to get your configured beans. I was interested in doing 2) that is use Spring's MVC framework and WebMacro only as a template engine for the view. That means I want everything else to be handled the Spring way: Logging, Resource-Loading, request dispatching/handling etc... Lane Sharman wrote: > Couple of observations from experience. > > If you have read the new book, "Effective (or is it) Better Java", you > will note that the author stresses the importance of decoupling > dependencies. Therefore, I do not like either of the solutions below > because you are subclassing WMServlet and WMBroker. What if they have > side effects? Change? Are inadequate? WMBroker has a lot of > implementation internals which could break a subclass. > I agree that the Spring integration should not be coupled with WMServlet in any way. However I don't aggree with your points about Broker. A Broker is WebMacro's way of adapting to an environment. As Hai-Chen pointed out in another mail, it is mainly used for "external" concerns like configuration, logging and resource loading. This is why I wrote my own SpringBroker: To make WebMacro use the spring infrastructure. For example it uses Spring's preferred logging system (common logs) that is usually configured through Spring. It loads resources via Spring's resource loader, so that Spring users don't have to learn WebMacro's template providers. Note that the users does not see SpringBroker at all, it is only an implementation detail. All they see is a WM instance provided by WMFactory bean, so they are not really coupled to anything, but the standard WebMacro interface. > see: http://www.webmacro.org/api/org/webmacro/util/WMEval.html > (the docs are a bit out of date). Can you elaborate on how such a class could fit into the Spring framework? I don't see any use for it right now. Sebastian |