org.opencms.loader
Interface I_CmsResourceLoader

All Superinterfaces:
I_CmsConfigurationParameterHandler
All Known Implementing Classes:
CmsDumpLoader, CmsImageLoader, CmsJspLoader, CmsPointerLoader, CmsXmlContentLoader, CmsXmlPageLoader

public interface I_CmsResourceLoader
extends I_CmsConfigurationParameterHandler

This interface describes a resource loader for OpenCms, a class that can load a resource from the VFS, process it's contents and deliver the result to the user.

The I_CmsResourceLoader operates with Request and Response in much the same way as a standard Java web application.

This interface uses a standard servlet HttpServletRequestWrapper / HttpServletResponseWrapper that provide access to a special implementation of the RequestDispatcher. The handling of the output written to the response is done by this dispatcher. The results are then passed back to OpenCms which will deliver them to the requesting user.

Since:
6.0.0
Version:
$Revision: 1.43 $
Author:
Alexander Kandzior
See Also:
CmsFlexRequest, CmsFlexResponse, CmsFlexRequestDispatcher

Field Summary
static java.lang.String PARAMETER_ELEMENT
          Request parameter to force element selection.
 
Fields inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler
ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHOD
 
Method Summary
 void destroy()
          Destroys this ResourceLoder.
 byte[] dump(CmsObject cms, CmsResource resource, java.lang.String element, java.util.Locale locale, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Dumps the processed content of the the requested file (and it's sub-elements) to a byte array.
 byte[] export(CmsObject cms, CmsResource resource, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Static exports the contents of the requested file and it's sub-elements.
 int getLoaderId()
          Returns the id of the ResourceLoader.
 java.lang.String getResourceLoaderInfo()
          Returns a String describing the ResourceLoader.
 boolean isStaticExportEnabled()
          Signals if the loader implementation supports static export of resources.
 boolean isStaticExportProcessable()
          Signals if the loader implementation requires processing during static export of resources.
 boolean isUsableForTemplates()
          Signals if the loader implementation is usable for creating templates.
 boolean isUsingUriWhenLoadingTemplate()
          Signals if a loader that supports templates must be invoked on the template URI or the resource URI.
 void load(CmsObject cms, CmsResource resource, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Basic top-page processing method for a I_CmsResourceLoader, this method is called if the page is called as a sub-element on a page not already loaded with a I_CmsResourceLoader.
 void service(CmsObject cms, CmsResource resource, javax.servlet.ServletRequest req, javax.servlet.ServletResponse res)
          Does the job of including the requested resource, this method is called directly if the element is called as a sub-element from another I_CmsResourceLoader.
 
Methods inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler
addConfigurationParameter, getConfiguration, initConfiguration
 

Field Detail

PARAMETER_ELEMENT

static final java.lang.String PARAMETER_ELEMENT
Request parameter to force element selection.

See Also:
Constant Field Values
Method Detail

destroy

void destroy()
Destroys this ResourceLoder.


dump

byte[] dump(CmsObject cms,
            CmsResource resource,
            java.lang.String element,
            java.util.Locale locale,
            javax.servlet.http.HttpServletRequest req,
            javax.servlet.http.HttpServletResponse res)
            throws javax.servlet.ServletException,
                   java.io.IOException,
                   CmsException
Dumps the processed content of the the requested file (and it's sub-elements) to a byte array.

Dumping the content is like calling "load" where the result is not written to the response stream, but to the returned byte array. Dumping is different from an export because the export might actually require that the content is handled or modified in a special way, or set special http headers.

Moreover, if the page type is template based, calling "dump" will not trigger the template but directly deliver the contents from the selected element.

Parameters:
cms - used to access the OpenCms VFS
resource - the requested resource in the VFS
element - the element in the file to display
locale - the locale to display
req - the servlet request
res - the servlet response
Returns:
the content of the processed file
Throws:
javax.servlet.ServletException - might be thrown by the servlet environment
java.io.IOException - might be thrown by the servlet environment
CmsException - in case of errors accessing OpenCms functions

export

byte[] export(CmsObject cms,
              CmsResource resource,
              javax.servlet.http.HttpServletRequest req,
              javax.servlet.http.HttpServletResponse res)
              throws javax.servlet.ServletException,
                     java.io.IOException,
                     CmsException
Static exports the contents of the requested file and it's sub-elements.

During static export, the resource content may be written to 2 streams: The export stream, and the http response output stream. Which stream is actually used depends whether the export is in "on demand" or "after publish" mode. In "on demand" mode, the resource needs to be written both to the response stream and to the file stream. In "after publish" mode, it's usually only written to the file stream, but sometimes it's required to write to the response stream as well.

Parameters:
cms - the initialized CmsObject which provides user permissions
resource - the requested OpenCms VFS resource
req - the servlet request
res - the servlet response
Returns:
the contents to export, or null if no export is required
Throws:
javax.servlet.ServletException - might be thrown in the process of including the sub element
java.io.IOException - might be thrown in the process of including the sub element
CmsException - in case something goes wrong

getLoaderId

int getLoaderId()
Returns the id of the ResourceLoader.

Returns:
the id of the ResourceLoader

getResourceLoaderInfo

java.lang.String getResourceLoaderInfo()
Returns a String describing the ResourceLoader.

Returns:
a String describing the ResourceLoader

isStaticExportEnabled

boolean isStaticExportEnabled()
Signals if the loader implementation supports static export of resources.

Returns:
true if static export is supported, false otherwise

isStaticExportProcessable

boolean isStaticExportProcessable()
Signals if the loader implementation requires processing during static export of resources.

Returns:
true if static export processing is required, false otherwise

isUsableForTemplates

boolean isUsableForTemplates()
Signals if the loader implementation is usable for creating templates.

Returns:
true if the loader implementation is usable for creating templates, false otherwise

isUsingUriWhenLoadingTemplate

boolean isUsingUriWhenLoadingTemplate()
Signals if a loader that supports templates must be invoked on the template URI or the resource URI.

Returns:
true if the resource URI is to be used, false if the template URI is to be used

load

void load(CmsObject cms,
          CmsResource resource,
          javax.servlet.http.HttpServletRequest req,
          javax.servlet.http.HttpServletResponse res)
          throws javax.servlet.ServletException,
                 java.io.IOException,
                 CmsException
Basic top-page processing method for a I_CmsResourceLoader, this method is called if the page is called as a sub-element on a page not already loaded with a I_CmsResourceLoader.

Parameters:
cms - the initialized CmsObject which provides user permissions
resource - the requested OpenCms VFS resource
req - the servlet request
res - the servlet response
Throws:
javax.servlet.ServletException - might be thrown by the servlet environment
java.io.IOException - might be thrown by the servlet environment
CmsException - in case of errors accessing OpenCms functions
See Also:
service(CmsObject, CmsResource, ServletRequest, ServletResponse)

service

void service(CmsObject cms,
             CmsResource resource,
             javax.servlet.ServletRequest req,
             javax.servlet.ServletResponse res)
             throws javax.servlet.ServletException,
                    java.io.IOException,
                    CmsException
Does the job of including the requested resource, this method is called directly if the element is called as a sub-element from another I_CmsResourceLoader.

Parameters:
cms - used to access the OpenCms VFS
resource - the requested resource in the VFS
req - the servlet request
res - the servlet response
Throws:
javax.servlet.ServletException - might be thrown by the servlet environment
java.io.IOException - might be thrown by the servlet environment
CmsException - in case of errors accessing OpenCms functions
See Also:
CmsFlexRequestDispatcher