设为首页】 【加入收藏】 【网站地图】 【商品折扣
娱乐一生 娱乐明星
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
首页  |  java  |  .NET  |  C/C++  |  网页技术  |  php  |  asp  |  delphi  |  VC  |  VB开发  |  游戏开发  |  软件工程  |  Power Builder  |  Linux开发  |  Windows开发技巧
当前位置:首页 >> JAVA与XML >> Integrate Cocoon with PostgreSQL for XML-driven Apps

Integrate Cocoon with PostgreSQL for XML-driven Apps -

ocoon is a powerful tool for publishing content to multiple formats from XML. It can be used for static content, but its most powerful application is publishing dynamically generated XML streams. The XML streams can come from database information wrapped in XML tags, from XHTML Web site content from a remote site (as would be common in portal integration), from Web services, or from a multitude of other sources.

This article describes how to integrate Cocoon with PostgreSQL, a leading open source database. Once you learn how to access PostgreSQL data (or any other relational database) from Cocoon, you can develop robust XML-driven applications with a relational backend. Think about it: XML is highly structured data; relational databases store highly structured data—it's a natural fit.

Because it assumes that you already have some familiarity with Cocoon, it does not describe how to set up the tool. If you have not set up Cocoon previously, visit the Cocoon Web site and read the INSTALL.txt file included in the Cocoon distribution.

Why PostgreSQL for Your Relational Database?
When you develop with Cocoon and use XML for your source data, chances are you will need to integrate with a relational database. Most Web sites or applications that store or access large amounts of data interface with a relational database, because relational databases are reliable, have good performance, and are familiar to many developers.

In the open source world, PostgreSQL and MySQL are two of the best-known databases. MySQL is in wider use, but PostgreSQL bears closer resemblance to the commercial database servers—in fact, it was the basis for Informix, now part of IBM. I prefer PostgreSQL for the following reasons:

  • It more closely follows the ANSI SQL standard.
  • It has had transaction support for longer (and thus is presumably more robust)
  • It feels better designed, possibly because, as the successor to the INGRES database project at UC Berkeley, it has really been in development since the 1970's.

Find additional information on MySQL and PostgreSQL at sql-info.de's MySQL gotchas and PostgreSQL gotchas pages.

Set Up Tomcat and Cocoon
Begin by downloading Tomcat. You will want the Tomcat 5.5.4 release (or later). It should be called "5.5.4 tar.gz". Unpack the archive once you have downloaded it.

Next, download Cocoon. You should get the latest release (2.1.6 as of the writing of this article). You should also download the patch I created (cocoon-2.1.6_patch_for_java_1.5.diff). To obtain the cocoon-2.1.6_patch_for_java_1.5.diff file, look in the downloadable code accompanying this article. You need the patch because Cocoon 2.1.6 does not compile under Java 1.5. Luckily, the changes are fairly minor: just changing "enum" to "enumeration" (because enum is a reserved keyword in Java 1.5) and fixing some of the build files in Cocoon to recognize Java 1.5.

I run Cocoon in a Tomcat servlet engine on Linux. Your interaction with Cocoon may differ if your setup is different. Since the rest of this article uses Unix commands, you will also have to adjust them if you run Windows rather than Linux.

The versions of software I use are Java 1.5.0_01, Cocoon 2.1.6, Tomcat 5.5.4, and PostgreSQL 8.0.0. Again, if you use different versions, you may have different results. If you use a version of Cocoon released after this article was published (in other words, greater than 2.1.6), you may not need to perform the patch described in the next paragraph because a newer version of Cocoon may already include the necessary changes.

If you use Java 1.5 and Cocoon 2.1.6, type the following commands:

  1. cd /path/to/cocoon-2.1.6 (Replace /path/to/cocoon-2.1.6 with the real path to the Cocoon directory.)
  2. patch -p1 < /path/to/cocoon-2.1.6_patch_for_java_1.5.diff
  3. ./build.sh webapp
  4. cp -a build/webapp /path/to/tomcat-5.5.4/webapp/cocoon (Replace /path/to/tomcat-5.5.4 with real path.)

Going forward, I use $TOMCAT_HOME to represent /path/to/tomcat-5.5.4 and $COCOON_HOME to represent /path/to/tomcat-5.5.4/webapp/cocoon. When you see these references, replace them with the full path to Tomcat and to Cocoon, respectively, in your filesystem.

Test that your Tomcat and Cocoon installation works. First, start up Tomcat with the following two commands:

  1. cd $TOMCAT_HOME/bin
  2. ./startup.sh

  Figure 1. Welcome Screen for Successful Cocoon Installation

View $TOMCAT_HOME/logs/catalina.out and look for something like "INFO: Server startup in 18312 ms" at the very end of the log file (the "18312 ms" will appear different because your computer will probably take a different amount of time to start Tomcat). Once that appears, you know the server has started up.

Open a Web browser and go to http://$SERVER_HOSTNAME:8080/cocoon, where $SERVER_HOSTNAME is the name of the host on which you run Tomcat and Cocoon. I have a Linux machine called galleon on which I run Cocoon. To test whether Cocoon works after following the Cocoon installation instructions, I visit http://galleon:8080/cocoon. Replace "galleon" with the name of the machine on which you run Cocoon (localhost is valid if you run Cocoon on your local computer). You should see something like Figure 1 in your browser. If you see it, you have successfully installed Cocoon and are ready to set up and test the PostgreSQL integration.

First, you should shut down Tomcat because you need to install more software and make further changes to your server configuration files. Shut down Tomcat with the following two commands:

  1. cd $TOMCAT_HOME/bin
  2. ./shutdown.sh



 

娱乐图摘

更多 >>

靓丽清纯美女meimei

美女私房全裸照
导演劝女演员脱衣服(视频)

大胆火辣人体艺术写真(图)

黑丝妹妹热辣诱惑-丝袜美女妹妹

PLMM 漂亮妹妹图集-妹妹图库

全球美女图库-美女集中营

52MM 我爱漂亮妹妹-制服妹妹诱惑

图王图库-世界美女明星图片资料库
美女写真集锦

激情两性-解密性生活
浴室MM湿身内衣诱惑
邻家小妹洗澡被偷拍(视频)

热点文章

更多

· Eclipse Plugins Exposed, Part
· Enterprise Web Services Securi
· Portlets and Portals Design Ov
· 实现电子商务的可伸缩性和高可用性--BEA WebLogic
· Getting the Most from the MX C
· XML DTD for EJB Deployment Des
· A Dozen Ways to Get the Testi
· XQuery Not Necessarily the Dea
· AXIS学习笔记(一)
· Java程序文件格式设计

热点文章

更多