最近研究opentaps (基于apache的ofbiz),里面用到了Jpublish
看了不少Jpublish相关内容,现摘录如下:
JPublish is a Java web publishing framework which merges the Velocity, FreeMarker, StringTemplate or WebMacro templates with a content repository and application control framework. JPublish is designed to ensure a clean separation of developer roles.
JPublish is loosely based on the FreeEnergy methodology. FreeEnergy was originally created by Leon Atkinson and others as described in his self-authored article Harnessing PHP's FreeEnergy. Essentially the FreeEnergy methodology was designed to handle page development in an object oriented fashion so that common objects could be reused. Much of JPublish's initial development ideas were obtained while documenting J.J. Berhens implementation of FreeEnergy in Python, called Aquarium.
This project is a continuation of the design and work started by Anthony Eden few years ago.
Like all good web frameworks, JPublish provides a clean separation of code, content, and layout. JPublish has the following features:
Flexible actions - actions which are programmatic elements which can be attached globally to a site, to a path (with wildcards) or to a page. Actions can be written in Java or any Bean Scripting Framework supported language (such as JavaScript(Rhino), Python(Jython), BeanShell,Groovy or JRuby.)
Templates for layout - the Velocity template engine from the Apache group has been chosen as JPublish's default template engine because of its straightforward syntax as well as its solid and simple design.
Repository abstraction layer - JPublish provides a method for binding concrete repository implementations to a site for easy and controlled access to content.
Content which can include nested content - content pulled from repositories can be parsed by the Template engine in order to include nested dynamic elements.
Automatically reloading configuration - a centralized configuration file which will automatically reload when modified makes it easy to make changes at runtime without restarting the web server.
Search-engine friendly URLs - JPublish URLs look just like static URLs, even though they are not.
Flexible character encoding - flexible character encoding control – character encoding can be specified for both input and output for specified paths.
Pluggable page manager - JPublish page definitions, which define page properties such as the title and page actions, can be loaded from any class which implements the PageManager interface. Current implementation include two: a file-based system which map one XML file to one page definition and one which pulls all page definitions from a single XML file.
Custom error handling - multiple custom error handlers can be assigned globally or by path.
Utilities - JPublish includes several utility classes which can be used to build URLs, format dates and numbers, and perform other common web tasks.
JPublish can be easily extended through Modules or Components. Examples are provided to demonstrate the smooth integration with Spring, Lucene, Hibernate, AJAX (through DWR), etc.
Welcome to the world of JPublish and ... Develop with Fun!
The JPublish Team
JPublish 是一个功能强大的web发布系统. 它的目的也是最大的特点是将web开发人员的角色严格并清晰的区分开来.
JPublish支持多种模版引擎, 包括Apache Velocity, FreeMarker 和WebMacro.
JPublish也支持各种脚本语言, 如: Python, BeanShell, and JavaScript. JPublish是绝对是一个经典的"合成器", 平滑的扩展性让人赞叹.
JPublish 定义了多种角色用户:
应用程序设计师(Application designer)-- 主要是通过模板来为一个网站和这个网站的不同部分进行统一的设计, 构架.
内容策划(content producer)-- 负责处理内容库(content repository)中的文档或其他信息.内容策划在板面设计中通常使用一套有限的设计元素(比如粗体或斜体).
特定业务领域的程序员(Domain-specific programmer)-- 负责build 特定领域的Java代码,这可能是JavaBeans,或者与Web应用程序相关的普通Java类.
集成程序员(Integration programmer ) -- 负责新建一个将特定代码和Web site连接起来的逻辑,该逻辑体现为JPublish的用于scripts自动化任务的action system.
有了这种用户角色的清晰分离,实际上做到了内容, 程序逻辑,和表示逻辑的分离.
大多数开发者往往会将所有的任务放在一起,而没有将它们更好地组织起来.笔者之前所在的项目组也遇到了此类的问题:项目开始时,似乎已经做了很好的设计.然后将功能化成很多块,每个人负责一块.但是到了项目后期发现,需求无奈变更,代码变得很糟糕.程序员往往为了解决一个问题,乱塞代码.导致原有的设计变形.结果项目难以维护,不停地refactor.导致这样的后果是因为在开发阶段没有将开发人员的职能清晰的分离开来.调试程序时,总是将表示逻辑和程序逻辑,整合过程一同考虑.这样代码的质量必然下降.导致最后为解决问题牺牲了代码的质量.
而使用这种基于角色的工具会使你不得不将这些任务分开并重新合成,我相信这一点一定会使你的程序变得更好更高效.