Technical Overview
OpenCms is written in Java. It makes use of industry-standard XML (eXtensible Markup Language), and uses Java DataBase Connectivity (JDBC) to store data in a relational database. Built in Java, OpenCms can run on different platforms, including numerous versions of UNIX and Linux, and Windows.
Hardware-wise, OpenCms is designed for scalability. It will run on hardware ranging from small laptops (I've run it on a Pentium III 733 Toshiba Tecra laptop with 256 MB RAM and Red Hat 8) to a distributed collection of servers.
Being a web-based application, OpenCms runs as a Java servlet inside a servlet container such as Apache Tomcat or BEA WebLogic. For data storage, it can use a number of SQL databases, including MySQL, Microsoft SQL Server, and Oracle.
At one time, OpenCms required developers to learn a proprietary XML schema for developing templates, but in version 5.0, OpenCms has changed direction and now uses Java Server Pages; we'll get into the details of the system later. Here is a brief summary of how each of these components works (and how they all work together).
The Web Server and Java Servlets
The web server handles incoming connections. As it sees connections intended for OpenCms, it hands them off to the servlet container for processing. The servlet container manages one or more Java servlets. Unlike a CGI script, which runs only for the amount of time it takes to process a single request, a servlet stays running until the server explicitly stops it (which usually only happens when the server shuts down). The job of the servlet container is to provide the runtime environment for the servlets.
While it is possible to run OpenCms on the command line, it is almost always run as a servlet.
The Database
OpenCms uses a database for persistent data storage. Information about file types, templates, and publishing is stored in the database, as is all the content. OpenCms supports a couple of major SQL-based databases, including MySQL, Microsoft SQL Server, and Oracle. Developers are working on ports to PostgreSQL and other databases.
OpenCms uses JDBC to connect the Servlet to the database during startup. Content is managed inside the database, though it can be exported from the database into static files during a publishing cycle.
Pages, Templates, and Java Server Pages
Content is stored in the database in the form of XML files. Layout information and processing code is also stored in the database, but not in the same XML document as the content. When a page is requested, the content is pulled out of the database and put into a template. Any special processing needed is run, and the results are sent back to the requester (usually a web browser) in the form of a complete HTML file.
Templates and custom code are written in two languages: XML Template, a simple XML-based language developed by the OpenCms team, and Java Server Pages, a standardized language for embedding Java processing instructions inside of an HTML or XML document. While XML Template is still used in OpenCms 5, it will be phased out and replaced by the more flexible and mature JSP technology in future releases.
Bringing it Together
Each of these pieces functions together for each request. A typical response to a document (we'll call it test.html
) might look like this:
- The web browser requests
test.html
. - The web server recognizes that the request must be handled by OpenCms; it passes it off to the OpenCms Servlet request handler.
- OpenCms retrieves information about
test.html
(including the content) from the database. - OpenCms puts the content for
test.html
into its template, adding all of the necessary layout elements and interpreting any JSP or XML template code that it needs for fulfilling the request. - Once OpenCms has created the complete HTML document, the document is returned to the browser.
- The web browser interprets the HTML, runs any JavaScript that it finds, and displays the
test.html
page.