|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opencms.loader.CmsJspLoader
public class CmsJspLoader
The JSP loader which enables the execution of JSP in OpenCms.
Parameters supported by this loader:
${TOMCAT_HOME}/webapps/opencms/
.
The jsp.folder
(see below) is added to this path.
Usually the jsp.repository
is not changed.
jsp.repository
path where the
JSPs generated by OpenCms are stored. The default is to store the generated JSP in
/WEB-INF/jsp/
.
This works well in Tomcat 4, and the JSPs are
not accessible directly from the outside this way, only through the OpenCms servlet.
Please note: Some servlet environments (e.g. BEA Weblogic) do not permit
JSPs to be stored under /WEB-INF
. For environments like these,
set the path to some place where JSPs can be accessed, e.g. /jsp/
only.
<% page errorPage="..." %>
. If you find that these don't work
in your servlet environment, you should try to change the value here.
The default true
has been tested with Tomcat 4.1 and 5.0.
Older versions of Tomcat like 4.0 require a setting of false
.
I_CmsResourceLoader
Field Summary | |
---|---|
static java.lang.String |
CACHE_PROPERTY_BYPASS
Property value for "cache" that indicates that the FlexCache should be bypassed. |
static java.lang.String |
CACHE_PROPERTY_STREAM
Property value for "cache" that indicates that the output should be streamed. |
static java.lang.String |
DEFAULT_JSP_FOLDER
Default jsp folder constant. |
static java.lang.String |
DIRECTIVE_END
Special JSP directive tag start ( %> ). |
static java.lang.String |
DIRECTIVE_START
Special JSP directive tag start ( <%( ). |
static java.lang.String |
JSP_EXTENSION
Extension for JSP managed by OpenCms ( .jsp ). |
static java.lang.String |
PARAM_CLIENT_CACHE_MAXAGE
Cache max age parameter name. |
static java.lang.String |
PARAM_JSP_CACHE_SIZE
Jsp cache size parameter name. |
static java.lang.String |
PARAM_JSP_ERRORPAGE_COMMITTED
Error page committed parameter name. |
static java.lang.String |
PARAM_JSP_FOLDER
Jsp folder parameter name. |
static java.lang.String |
PARAM_JSP_REPOSITORY
Jsp repository parameter name. |
static int |
RESOURCE_LOADER_ID
The id of this loader. |
Fields inherited from interface org.opencms.loader.I_CmsResourceLoader |
---|
PARAMETER_ELEMENT |
Fields inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler |
---|
ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHOD |
Constructor Summary | |
---|---|
CmsJspLoader()
The constructor of the class is empty, the initial instance will be created by the resource manager upon startup of OpenCms. |
Method Summary | |
---|---|
void |
addConfigurationParameter(java.lang.String paramName,
java.lang.String paramValue)
Adds a configuration parameter to this parameter configurable class instance. |
void |
cmsEvent(CmsEvent event)
Acknowledge the occurrence of the specified event, implement this method to check for CmsEvents in your class. |
void |
destroy()
Destroy this ResourceLoder, this is a NOOP so far. |
protected byte[] |
dispatchJsp(CmsFlexController controller)
Dispatches the current request to the OpenCms internal JSP. |
byte[] |
dump(CmsObject cms,
CmsResource file,
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. |
java.util.Map |
getConfiguration()
Returns the configuration of this parameter configurable class instance, or null if the class does not need to be configured. |
protected CmsFlexController |
getController(CmsObject cms,
CmsResource resource,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
boolean streaming,
boolean top)
Delivers a Flex controller, either by creating a new one, or by re-using an existing one. |
static java.lang.String |
getJspRepository()
Returns the absolute path in the "real" file system for the JSP repository toplevel directory. |
int |
getLoaderId()
Returns the id of the ResourceLoader. |
void |
getReferencingStrongLinks(CmsObject cms,
CmsResource resource,
java.util.Set referencingPaths)
Returns a set of root paths of files that are including the given resource using the 'link.strong' macro. |
java.lang.String |
getResourceLoaderInfo()
Return a String describing the ResourceLoader, which is (localized to the system default locale) "The OpenCms default resource loader for JSP" . |
void |
initConfiguration()
Initializes a configuration after all parameters have been added. |
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 file,
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. |
protected byte[] |
parseJsp(byte[] byteContent,
java.lang.String encoding,
CmsFlexController controller,
java.util.Set updatedFiles,
boolean isHardInclude)
Parses the JSP and modifies OpenCms critical directive information. |
protected java.lang.String |
parseJspCmsTag(java.lang.String content,
CmsFlexController controller,
java.util.Set updatedFiles)
Parses the JSP content for the special <%cms file="..." |
protected java.lang.String |
parseJspEncoding(java.lang.String content,
java.lang.String encoding,
boolean isHardInclude)
Parses the JSP content for the <%page pageEncoding="..." |
protected java.lang.String |
parseJspIncludes(java.lang.String content,
CmsFlexController controller,
java.util.Set updatedFiles)
Parses the JSP content for includes and replaces all OpenCms VFS path information with information for the real FS. |
protected java.lang.String |
parseJspLinkMacros(java.lang.String content,
CmsFlexController controller)
Parses all jsp link macros, and replace them by the right target path. |
protected CmsResource |
readJspResource(CmsFlexController controller,
java.lang.String jspName)
Returns the jsp resource identified by the given name, using the controllers cms context. |
void |
removeFromCache(java.util.Set rootPaths,
boolean online)
Removes the given resources from the cache. |
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. |
void |
setFlexCache(CmsFlexCache cache)
Will be called after the resource manager was initialized. |
protected void |
showSource(CmsObject cms,
CmsResource file,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Delivers the plain uninterpreted resource with escaped XML. |
java.lang.String |
updateJsp(CmsResource resource,
CmsFlexController controller,
java.util.Set updatedFiles)
Updates a JSP page in the "real" file system in case the VFS resource has changed. |
protected java.lang.String |
updateJsp(java.lang.String vfsName,
CmsFlexController controller,
java.util.Set updatedFiles)
Updates a JSP page in the "real" file system in case the VFS resource has changed based on the resource name. |
void |
updateJspFromRequest(java.lang.String servletPath,
CmsFlexRequest request)
Updates the internal jsp repository when the servlet container tries to compile a jsp file that may not exist. |
protected boolean |
updateStrongLinks(CmsResource resource,
CmsFlexController controller,
java.util.Set updatedFiles)
Updates all jsp files that include the given jsp file using the 'link.strong' macro. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String CACHE_PROPERTY_BYPASS
public static final java.lang.String CACHE_PROPERTY_STREAM
public static final java.lang.String DEFAULT_JSP_FOLDER
public static final java.lang.String DIRECTIVE_END
%>
).
public static final java.lang.String DIRECTIVE_START
<%(
).
public static final java.lang.String JSP_EXTENSION
.jsp
).
public static final java.lang.String PARAM_CLIENT_CACHE_MAXAGE
public static final java.lang.String PARAM_JSP_CACHE_SIZE
public static final java.lang.String PARAM_JSP_ERRORPAGE_COMMITTED
public static final java.lang.String PARAM_JSP_FOLDER
public static final java.lang.String PARAM_JSP_REPOSITORY
public static final int RESOURCE_LOADER_ID
Constructor Detail |
---|
public CmsJspLoader()
CmsResourceManager
Method Detail |
---|
public static java.lang.String getJspRepository()
public void addConfigurationParameter(java.lang.String paramName, java.lang.String paramValue)
I_CmsConfigurationParameterHandler
addConfigurationParameter
in interface I_CmsConfigurationParameterHandler
paramName
- the name of the parameterparamValue
- the value for the parameterI_CmsConfigurationParameterHandler.addConfigurationParameter(java.lang.String, java.lang.String)
public void cmsEvent(CmsEvent event)
I_CmsEventListener
cmsEvent
in interface I_CmsEventListener
event
- CmsEvent that has occurredI_CmsEventListener.cmsEvent(org.opencms.main.CmsEvent)
public void destroy()
destroy
in interface I_CmsResourceLoader
public byte[] dump(CmsObject cms, CmsResource file, 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
I_CmsResourceLoader
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.
dump
in interface I_CmsResourceLoader
cms
- used to access the OpenCms VFSfile
- the requested resource in the VFSelement
- the element in the file to displaylocale
- the locale to displayreq
- the servlet requestres
- the servlet response
javax.servlet.ServletException
- might be thrown by the servlet environment
java.io.IOException
- might be thrown by the servlet environmentI_CmsResourceLoader.dump(org.opencms.file.CmsObject, org.opencms.file.CmsResource, java.lang.String, java.util.Locale, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
public byte[] export(CmsObject cms, CmsResource resource, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws javax.servlet.ServletException, java.io.IOException
I_CmsResourceLoader
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.
export
in interface I_CmsResourceLoader
cms
- the initialized CmsObject which provides user permissionsresource
- the requested OpenCms VFS resourcereq
- the servlet requestres
- the servlet response
null
if no export is required
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 elementI_CmsResourceLoader.export(org.opencms.file.CmsObject, org.opencms.file.CmsResource, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
public java.util.Map getConfiguration()
I_CmsConfigurationParameterHandler
null
if the class does not need to be configured.
All elements in the configuration are key, value String pairs,
set using the I_CmsConfigurationParameterHandler.addConfigurationParameter(String, String)
method
during initialization of the loader.
Implementations will (should) not to return a direct reference to the internal configuration but just a copy of it, to avoid unwanted external manipulation.
getConfiguration
in interface I_CmsConfigurationParameterHandler
null
I_CmsConfigurationParameterHandler.getConfiguration()
public int getLoaderId()
I_CmsResourceLoader
getLoaderId
in interface I_CmsResourceLoader
I_CmsResourceLoader.getLoaderId()
public void getReferencingStrongLinks(CmsObject cms, CmsResource resource, java.util.Set referencingPaths) throws CmsException
cms
- the current cms contextresource
- the resource to checkreferencingPaths
- the set of already referencing paths, also return parameter
CmsException
- if something goes wrongpublic java.lang.String getResourceLoaderInfo()
"The OpenCms default resource loader for JSP"
.
getResourceLoaderInfo
in interface I_CmsResourceLoader
public void initConfiguration()
I_CmsConfigurationParameterHandler
initConfiguration
in interface I_CmsConfigurationParameterHandler
I_CmsConfigurationParameterHandler.initConfiguration()
public boolean isStaticExportEnabled()
I_CmsResourceLoader
isStaticExportEnabled
in interface I_CmsResourceLoader
I_CmsResourceLoader.isStaticExportEnabled()
public boolean isStaticExportProcessable()
I_CmsResourceLoader
isStaticExportProcessable
in interface I_CmsResourceLoader
I_CmsResourceLoader.isStaticExportProcessable()
public boolean isUsableForTemplates()
I_CmsResourceLoader
isUsableForTemplates
in interface I_CmsResourceLoader
I_CmsResourceLoader.isUsableForTemplates()
public boolean isUsingUriWhenLoadingTemplate()
I_CmsResourceLoader
isUsingUriWhenLoadingTemplate
in interface I_CmsResourceLoader
I_CmsResourceLoader.isUsingUriWhenLoadingTemplate()
public void load(CmsObject cms, CmsResource file, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws javax.servlet.ServletException, java.io.IOException, CmsException
I_CmsResourceLoader
load
in interface I_CmsResourceLoader
cms
- the initialized CmsObject which provides user permissionsfile
- the requested OpenCms VFS resourcereq
- the servlet requestres
- the servlet response
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 functionsI_CmsResourceLoader.load(org.opencms.file.CmsObject, org.opencms.file.CmsResource, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
public void removeFromCache(java.util.Set rootPaths, boolean online)
rootPaths
- the set of root paths to removeonline
- if online or offlinepublic void service(CmsObject cms, CmsResource resource, javax.servlet.ServletRequest req, javax.servlet.ServletResponse res) throws javax.servlet.ServletException, java.io.IOException, CmsLoaderException
I_CmsResourceLoader
service
in interface I_CmsResourceLoader
cms
- used to access the OpenCms VFSresource
- the requested resource in the VFSreq
- the servlet requestres
- the servlet response
javax.servlet.ServletException
- might be thrown by the servlet environment
java.io.IOException
- might be thrown by the servlet environment
CmsLoaderException
I_CmsResourceLoader.service(org.opencms.file.CmsObject, org.opencms.file.CmsResource, javax.servlet.ServletRequest, javax.servlet.ServletResponse)
public void setFlexCache(CmsFlexCache cache)
I_CmsFlexCacheEnabledLoader
setFlexCache
in interface I_CmsFlexCacheEnabledLoader
cache
- the (optional) flex cache instance to useI_CmsFlexCacheEnabledLoader.setFlexCache(org.opencms.flex.CmsFlexCache)
public java.lang.String updateJsp(CmsResource resource, CmsFlexController controller, java.util.Set updatedFiles) throws java.io.IOException, javax.servlet.ServletException, CmsLoaderException
Also processes the <%@ cms %>
tags before the JSP is written to the real FS.
Also recursively updates all files that are referenced by a <%@ cms %>
tag
on this page to make sure the file actually exists in the real FS.
All <%@ include %>
tags are parsed and the name in the tag is translated
from the OpenCms VFS path to the path in the real FS.
The same is done for filenames in <%@ page errorPage=... %>
tags.
resource
- the requested JSP file resource in the VFScontroller
- the controller for the JSP integrationupdatedFiles
- a Set containing all JSP pages that have been already updated
javax.servlet.ServletException
- might be thrown in the process of including the JSP
java.io.IOException
- might be thrown in the process of including the JSP
CmsLoaderException
- if the resource type can not be readpublic void updateJspFromRequest(java.lang.String servletPath, CmsFlexRequest request)
servletPath
- the servlet path, just to avoid unneeded recursive callsrequest
- the current requestprotected byte[] dispatchJsp(CmsFlexController controller) throws javax.servlet.ServletException, java.io.IOException
controller
- the current controller
javax.servlet.ServletException
- if inclusion does not work
java.io.IOException
- if inclusion does not workprotected CmsFlexController getController(CmsObject cms, CmsResource resource, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, boolean streaming, boolean top)
cms
- the initial CmsObject to wrap in the controllerresource
- the resource requestedreq
- the current requestres
- the current responsestreaming
- indicates if the response is streamingtop
- indicates if the response is the top response
protected byte[] parseJsp(byte[] byteContent, java.lang.String encoding, CmsFlexController controller, java.util.Set updatedFiles, boolean isHardInclude)
byteContent
- the original JSP contentencoding
- the encoding to use for the JSPcontroller
- the controller for the JSP integrationupdatedFiles
- a Set containing all JSP pages that have been already updatedisHardInclude
- indicated if this page is actually a "hard" include with <%@ include file="..." >
protected java.lang.String parseJspCmsTag(java.lang.String content, CmsFlexController controller, java.util.Set updatedFiles)
<%cms file="..." %>
tag.
content
- the JSP content to parsecontroller
- the current JSP controllerupdatedFiles
- a set of already updated jsp files
protected java.lang.String parseJspEncoding(java.lang.String content, java.lang.String encoding, boolean isHardInclude)
<%page pageEncoding="..." %>
tag
and ensures that the JSP page encoding is set according to the OpenCms
"content-encoding" property value of the JSP.
content
- the JSP content to parseencoding
- the encoding to use for the JSPisHardInclude
- indicated if this page is actually a "hard" include with <%@ include file="..." >
protected java.lang.String parseJspIncludes(java.lang.String content, CmsFlexController controller, java.util.Set updatedFiles)
content
- the JSP content to parsecontroller
- the current JSP controllerupdatedFiles
- a set of already updated files
protected java.lang.String parseJspLinkMacros(java.lang.String content, CmsFlexController controller)
content
- the content to parsecontroller
- the request controller
protected CmsResource readJspResource(CmsFlexController controller, java.lang.String jspName) throws CmsException
controller
- the flex controllerjspName
- the name of the jsp
CmsException
- if something goes wrongprotected void showSource(CmsObject cms, CmsResource file, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws CmsException, java.io.IOException
This is intended for viewing historical versions.
cms
- the initialized CmsObject which provides user permissionsfile
- the requested OpenCms VFS resourcereq
- the servlet requestres
- the servlet response
java.io.IOException
- might be thrown by the servlet environment
CmsException
- in case of errors accessing OpenCms functionsprotected java.lang.String updateJsp(java.lang.String vfsName, CmsFlexController controller, java.util.Set updatedFiles)
Generates a resource based on the provided name and calls updateJsp(CmsResource, CmsFlexController, Set)
.
vfsName
- the name of the JSP file resource in the VFScontroller
- the controller for the JSP integrationupdatedFiles
- a Set containing all JSP pages that have been already updated
protected boolean updateStrongLinks(CmsResource resource, CmsFlexController controller, java.util.Set updatedFiles) throws CmsLoaderException, java.io.IOException, javax.servlet.ServletException
resource
- the current updated jsp filecontroller
- the controller for the jsp integrationupdatedFiles
- the already updated files
true
if the given JSP file should be updated due to dirty included files
javax.servlet.ServletException
- might be thrown in the process of including the JSP
java.io.IOException
- might be thrown in the process of including the JSP
CmsLoaderException
- if the resource type can not be read
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |