打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Hoople: Attribute-oriented programming for URLs
 

Hoople

Hoople: Attribute-oriented programming for URLs

Traditionally, configuration gets spread poorly throughout the site.

  1. Information/Configuration for a particular URL gets split into many different configuration files.
  2. Configuration files that deal with many URLs get so large that they get difficult to read and manage--especially with multiple developers.

Examples of the problem include

  1. Web MVC frameworks such as Struts, Spring, JSF etc. define which controllers to run for each URL in a central config file or set of files. For large sites, this quickly becomes unwieldy.
  2. “URL Logic” such as
    • Listing/Configuration of links for “site maps"
    • Security logic beyond the scope of what web.xml covers
    • Documentation of what URLs are supposed to do
    • Pre/post conditions for URLs running to aid in development
    • Logging

    is stored in separate and unrelated areas.

How does Hoople solve the problem?

Hoople is like attribute-oriented programming for URLs. Rather than having the configuration information and “URL Logic” for a particular URL spread throughout the site, you create a single XML configuration file that contains all the “logic” for each URL on the filesystem. 

These XML files are stored where the file for the URL would normally go.  So, for example, if your site has a URL of “/news/index.html” you would create an XML configuration file and store it at $DOCUMENT_ROOT/news/index.html.  Note that since web frameworks like Struts, Spring, JSF, etc. all use a servlet that catch all *.html requests, you would normally not have that file at all. 

These files can then be accessed in various ways depending on how the configuration is needed:

  • For applications that require a central configuration file for all URLs at run time, an Ant task can be used to generate the required config file
  • A servlet or scheduled job can parse through all the config files at run time
  • A Servlet Filter can parse the configuration file at run time to apply security, logging, transactions, etc to the URL
  • Developers can simply read the configuration files to find out what URLs are supposed to do and not do

But wait, there’s more!

  • During development, possible URLs are easy to find because there is a file actually in the file system for each URL on the system. Compare that to having URLs specified in various XML configuration files.
  • “welcome-file-list" actually works for welcome URLS managed by struts/spring/jsf because application servers see there actually is a file there, and will not automatically return a 404 error before seeing if there is a servlet-mapping that matches the URL.

     

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
What book taught you most about being a good programmer?
SSH框架搭建遇到的问题Unable to load configuration. bean jar:file:/D:/Tomcat%206.0/webapps/bar/WEBINF / 蓝讯
Struts2中实现自定义分页标签
用JTAG模式配置Serial Flash芯片
toolbox.xilinx SelectMAP Configuration Mode
How to install and configure Python on a hosted server
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服