org.opencms.main.overview.html Maven / Gradle / Ivy
Show all versions of opencms-core Show documentation
This is the API description for the OpenCms core, please read the introdution below to learn
about the packages and functions of the API that are intended to be used in OpenCms application development.
Introduction to the OpenCms API
The OpenCms API contains several building blocks:
- The document repository, called Virtual File System (or just VFS).
- The JSP based templating system.
- The module API.
- The main runtime system.
- Several utility classes, for example for mail transport or scheduling.
- A number of low level database connetion methods.
- The OpenCms Workplace implementation.
Not all packages defined in this API are considered "end user" API functions.
For example, to access the OpenCms repository you should use an initialized instance of the
{@link org.opencms.file.CmsObject}
class, and never access the database directly with SQL.
So the database functionalities in the org.opencms.db
package are
"low level" functions, used by the classes in the org.opencms.file
package
but usually not directly by an application.
How to start developing OpenCms applications
Here are some basic pointers that should help you identify importants
parts in this API documentation that are usually required in OpenCms application development:
You should start with the template functions provided in the org.opencms.jsp
package.
This contains the OpenCms <cms:>
taglib, as well as the {@link org.opencms.jsp.CmsJspActionElement}
(for use with scriptlets).
These allow you to easliy access the current users {@link org.opencms.file.CmsObject}
from a JSP,
and with this you can dynamically build OpenCms front end applications based on the users permissions.
For easy template navigation building, check out the methods {@link org.opencms.jsp.CmsJspNavBuilder}
.
You can build full-blown OpenCms applications with the functions from the org.opencms.jsp
package
and never bother about the rest of the API.
After you have mastered the basics of template development, you should take a closer look at the objects in the
org.opencms.file
package. These object are the "building blocks" for OpenCms applications,
and it certainly helps to understand these in greater detail before moving on to more complex OpenCms applications.
As already mentioned, the {@link org.opencms.file.CmsObject}
is probably the most important class there.
In case you want to use certain OpenCms "operating system" features, use the {@link org.opencms.main.OpenCms}
singleton to
gain access to the low level manager classes that handle the system runtime.
The org.opencms.module
package contains the OpenCms module API.
You do not usually need to "program" a module because a module is most often created using the OpenCms Workplace.
However, in case you want to trigger certain module lifecyle events, have a look at the {@link org.opencms.module.I_CmsModuleAction}
interface.
There are a couple of utility functions worth to mention here:
In case you want to send emails from your application, check out the org.opencms.mail
package.
You can schedule recurring operations in OpenCms by implementing the {@link org.opencms.scheduler.I_CmsScheduledJob}
interface.
The basic OpenCms application design
OpenCms runs as a multi tier application.
The database layer that contains the VFS is accessed only through the business logic provided by the
{@link org.opencms.file.CmsObject}
class.
This runs totally independent
of any servlet container, there is no database logic whatsoever in the "front end", for example the JSP templates.
Check the {@link org.opencms.main.CmsShell}
description to see how to access the VFS without a servlet container.
In normal operation, OpenCms runs as a servlet in a servlet container.
On the startup of the container, OpenCms initializes itself from the configuration provided in the XML files.
After the XML configuration has been read, a singleton instance of the {@link org.opencms.main.OpenCms}
object provides access to all OpenCms functionality.
This {@link org.opencms.main.OpenCms}
singleton instance can be considered the "operating system" of OpenCms.
After the "operating system" is initialized and the {@link org.opencms.main.OpenCms}
object is available,
all requestes made to the {@link org.opencms.main.OpenCmsServlet}
are directly passed to this for authorization.
When a request is recieved, it's first authenticated to see which {@link org.opencms.file.CmsUser}
has made the request. If the user has not been authenticated so far, the {@link org.opencms.file.CmsUser}
object
is initialized with "Guest" user permissions.
With this user context, an instance of a {@link org.opencms.file.CmsRequestContext}
is generated, and with that
a {@link org.opencms.file.CmsObject}
is initialized.
This initialized {@link org.opencms.file.CmsObject}
then provides the "users context" for all access operations to the OpenCms VFS.
It can also be considered the "shell" of the user to the OpenCms VFS.
All access operations to the VFS are done through the {@link org.opencms.file.CmsObject}
, and
this means that all access operations automatically are done with the authenticated users permissions.