WebMacro Framework Design Overview
Here's an overview of WebMacro's overall design. You can also:
- download WebMacro here.
- Go back to Programming or up to Intro top
- Read the Fundamentals of Servlet Design article
WebMacro Servlet Design
WebMacro's fundamental idea is to separate work into three distinct categories:
- Page design: Create HTML templates using WebMacro Script. This can be done using many regular old HTML editing tools, since the script language does not interfere with HTML syntax.
- Domain logic: Write your business logic in back end classes that know nothing about servlets. Make them available using WebMacro's ResourceProvider.
- Controller code: Write session management code in standard Java. Just subclass from WMServlet. Your code will examine the request, select a template, and put all the information it will require into a hashtable. WebMacro does the rest.
A framework like this is called a Model/View/Controller (MVC) approach to servlet design.
Your business logic objects represent a model which your servlet interacts with. The front end templates are views into the system. You create a controller by subclassing from WMServlet--here you process the request and perform session management tasks, including selecting which template to return.
In Fundamentals of Servlet Design I present the reasons why this is usually the right way to design a servlet--it's also a good introduction to the overall design principles behind WebMacro.
WebMacro provides extensive support for all three levels of the MVC architecture:
This way of doing things has numerous advantages:
- Model:
Register your own information providers with WebMacro's ResourceProvider. This gives you a convenient way to link in your business logic--WebMacro can even cache model objects in a pool for more effecient access.
- View:
WebMacro's templates make creation and modification of views trivial. You don't have to recompile your servlet every time you change the way something looks; and the page designer can work in parallel with the servlet writer.
- Controller:
The WMServlet superclass provides a controller framework that looks after many housekeeping tasks, providing access to WebMacro's servlet library. You can actually plug your own components into this library, and even replace core WebMacro functionality (such as template loading).
- Clarity. Simple, obvious script language with minimal syntax.
- Power. Templates can access any object in your Java servlet.
- Elegance. Keep HTML clutter out of your servlet code.
- Independence. Change the look and feel without touching the servlet.
- Extensibity. Component model lets you extend or replace core WebMacro functionality with your own classes.
- Friendly. WebMacro won't confuse your XML/HTML editor or parser.
- Free. WebMacro is available under the GNU Public License.
Now that you know all about WebMacro, why not try it out?
On to: Download WebMacro
api | design | faq | goals | links | license | othertech | quickstart | script | status