cmsjspvfsaccessbean.java
来自「找了很久才找到到源代码」· Java 代码 · 共 633 行 · 第 1/2 页
JAVA
633 行
* @see #getRequestContext()
*/
public CmsRequestContext getContext() {
return getRequestContext();
}
/**
* Short form for {@link #getExistsResource()}.<p>
*
* Usage example on a JSP with the EL / JSTL:<pre>
* <c:if test="${cms:vfs(pageContext).exists['/checkme.html']}" >
* The resource "/checkme.html" exists.
* </c:if>
* </pre>
*
* @return a map that lazily reads resources from the OpenCms VFS
*
* @see #getExistsResource()
*/
public Map getExists() {
return getExistsResource();
}
/**
* Returns a map that lazily checks if a resources exists in the OpenCms VFS.<p>
*
* Usage example on a JSP with the EL / JSTL:<pre>
* <c:if test="${cms:vfs(pageContext).existsResource['/checkme.html']}" >
* The resource "/checkme.html" exists.
* </c:if>
* </pre>
*
* Usage example on a JSP with the <code><cms:contentaccess></code> tag:<pre>
* <cms:contentload ... >
* <cms:contentaccess var="content" />
* <c:if test="${content.vfs.existsResource['/checkme.html']}" >
* The resource "/checkme.html" exists.
* </c:if>
* </cms:contentload></pre>
*
* @return a map that lazily checks if a resources exists in the OpenCms VFS
*
* @see #getExists() for a short form of this method
*/
public Map getExistsResource() {
if (m_existsResource == null) {
// create lazy map only on demand
m_existsResource = LazyMap.decorate(new HashMap(), new CmsExistsResourceTransformer());
}
return m_existsResource;
}
/**
* Returns a map that lazily checks if a resources exists in the VFS and is of type XML content or XML page.<p>
*
* Usage example on a JSP with the EL / JSTL:<pre>
* <c:if test="${cms:vfs(pageContext).existsXml['/text.xml']}" >
* The resource "/text.xml" exists and is an XML document.
* </c:if>
* </pre>
*
* @return a map that lazily checks if a resources exists in the VFS and is of type XML content or XML page
*/
public Map getExistsXml() {
if (m_existsXml == null) {
// create lazy map only on demand
m_existsXml = LazyMap.decorate(new HashMap(), new CmsExistsXmlTransformer());
}
return m_existsXml;
}
/**
* Flushes the internal caches of this VFS access bean.<p>
*
* The VFS access bean uses lazy initialized Maps for all access, but once a value has been
* read it is cached in the Map and not read again from the VFS. This means the lazy Maps
* act as another layer of cache to the VFS.<p>
*
* The VFS access bean instance itself is cached in the OpenCms request context attributes of the {@link CmsObject},
* see {@link #create(CmsObject)}. Normally there is a new {@link CmsObject} created for
* all incoming requests, so the live-time of the VFS access bean is short.
* In that case the caching of the lazy Maps should improve performance and not be an issue.
* However, in rare cases an instance of a {@link CmsObject} may be kept for a long time in
* some custom code. In theses cases flushing the caches of the lazy Maps manually may be required, otherwise
* the Map caches may be out of sync with the VFS.
*
* @return always returns <code>true</code>
*/
public boolean getFlushCaches() {
m_resources = null;
m_properties = null;
m_propertiesSearch = null;
return true;
}
/**
* Returns a map that lazily calculates links to files in the OpenCms VFS,
* which has been adjusted according to the web application path and the
* OpenCms static export rules.<p>
*
* Please note that the target is always assumed to be in the OpenCms VFS, so you can't use
* this method for links external to OpenCms.<p>
*
* Relative links are converted to absolute links, using the current element URI as base.<p>
*
* Relative links are converted to absolute links, using the current OpenCms request context URI as base.<p>
*
* Usage example on a JSP with the EL:<pre>
* Link to the "/index.html" file: ${cms:vfs(pageContext).link['/index.html']}
* </pre>
*
* Usage example on a JSP with the <code><cms:contentaccess></code> tag:<pre>
* <cms:contentload ... >
* <cms:contentaccess var="content" />
* Link to the "/index.html" file: ${content.vfs.link['/index.html']}
* </cms:contentload></pre>
*
* @return a map that lazily calculates links to resources in the OpenCms VFS
*
* @see org.opencms.jsp.CmsJspActionElement#link(String)
* @see org.opencms.jsp.CmsJspTagLink#linkTagAction(String, javax.servlet.ServletRequest)
*/
public Map getLink() {
if (m_links == null) {
// create lazy map only on demand
m_links = LazyMap.decorate(new HashMap(), new CmsVfsLinkTransformer());
}
return m_links;
}
/**
* Short form for {@link #getReadProperties()}.<p>
*
* Usage example on a JSP with the EL:<pre>
* Title property of the "/index.html" resource: ${cms:vfs(pageContext).property['/index.html']['Title']}
* </pre>
*
* @return a map that lazily reads all resource properties from the OpenCms VFS, without search
*
* @see #getReadProperties()
*/
public Map getProperty() {
return getReadProperties();
}
/**
* Short form for {@link #getReadPropertiesSearch()}.<p>
*
* Usage example on a JSP with the EL:<pre>
* Title property of the "/index.html" resource (searched): ${cms:vfs(pageContext).propertySearch['/index.html']['Title']}
* </pre>
*
* @return a map that lazily reads all resource properties from the OpenCms VFS, with search
*
* @see #getReadPropertiesSearch()
*/
public Map getPropertySearch() {
return getReadPropertiesSearch();
}
/**
* Returns a map that lazily reads all resource properties from the OpenCms VFS, without search.<p>
*
* Usage example on a JSP with the EL:<pre>
* Title property of the "/index.html" resource: ${cms:vfs(pageContext).readProperties['/index.html']['Title']}
* </pre>
*
* Usage example on a JSP with the <code><cms:contentaccess></code> tag:<pre>
* <cms:contentload ... >
* <cms:contentaccess var="content" />
* Title property of the "/index.html" resource: ${content.vfs.readProperties['/index.html']['Title']}
* </cms:contentload></pre>
*
* @return a map that lazily reads all resource properties from the OpenCms VFS, without search
*
* @see #getProperty() for a short form of this method
*/
public Map getReadProperties() {
if (m_properties == null) {
// create lazy map only on demand
m_properties = LazyMap.decorate(new HashMap(), new CmsPropertyLoaderTransformer(false));
}
return m_properties;
}
/**
* Returns a map that lazily reads all resource properties from the OpenCms VFS, with search.<p>
*
* Usage example on a JSP with the EL:<pre>
* Title property of the "/index.html" resource (searched): ${cms:vfs(pageContext).readPropertiesSearch['/index.html']['Title']}
* </pre>
*
* Usage example on a JSP with the <code><cms:contentaccess></code> tag:<pre>
* <cms:contentload ... >
* <cms:contentaccess var="content" />
* Title property of the "/index.html" resource (searched): ${content.vfs.readPropertiesSearch['/index.html']['Title']}
* </cms:contentload></pre>
*
* @return a map that lazily reads all resource properties from the OpenCms VFS, with search
*
* @see #getPropertySearch() for a short form of this method
*/
public Map getReadPropertiesSearch() {
if (m_propertiesSearch == null) {
// create lazy map only on demand
m_propertiesSearch = LazyMap.decorate(new HashMap(), new CmsPropertyLoaderTransformer(true));
}
return m_propertiesSearch;
}
/**
* Returns a map that lazily reads resources from the OpenCms VFS.<p>
*
* Usage example on a JSP with the EL:<pre>
* Root path of the "/index.html" resource: ${cms:vfs(pageContext).readResource['/index.html'].rootPath}
* </pre>
*
* Usage example on a JSP with the <code><cms:contentaccess></code> tag:<pre>
* <cms:contentload ... >
* <cms:contentaccess var="content" />
* Root path of the "/index.html" resource: ${content.vfs.readResource['/index.html'].rootPath}
* </cms:contentload></pre>
*
* @return a map that lazily reads resources from the OpenCms VFS
*
* @see #getResource() for a short form of this method
*/
public Map getReadResource() {
if (m_resources == null) {
// create lazy map only on demand
m_resources = LazyMap.decorate(new HashMap(), new CmsResourceLoaderTransformer());
}
return m_resources;
}
/**
* Returns a map that lazily reads XML documents from the OpenCms VFS that are wrapped using a
* {@link CmsJspContentAccessBean}.<p>
*
* Usage example on a JSP with the EL:<pre>
* Title of "/text.xml": ${cms:vfs(pageContext).readXml['/text.xml'].value['Title']}
* </pre>
*
* @return a map that lazily reads wrapped XML documents from the OpenCms VFS
*
* @see #getXml() for a short form of this method
*/
public Map getReadXml() {
if (m_xmlContent == null) {
// create lazy map only on demand
m_xmlContent = LazyMap.decorate(new HashMap(), new CmsXmlContentAccessTransformer());
}
return m_xmlContent;
}
/**
* Returns the OpenCms request context the current user this bean was initialized with.<p>
*
* Usage example on a JSP with the EL:<pre>
* The current URI is: ${cms:vfs(pageContext).requestContext.uri}
* </pre>
*
* @return the OpenCms request context the current user this bean was initialized with
*
* @see #getContext() for a short form of this method
*/
public CmsRequestContext getRequestContext() {
return m_cms.getRequestContext();
}
/**
* Short form for {@link #getReadResource()}.<p>
*
* Usage example on a JSP with the EL:<pre>
* Root path of the "/index.html" resource: ${cms:vfs(pageContext).resource['/index.html'].rootPath}
* </pre>
*
* @return a map that lazily reads resources from the OpenCms VFS
*
* @see #getReadResource()
*/
public Map getResource() {
return getReadResource();
}
/**
* Short form for {@link #getReadXml()}.<p>
*
* Usage example on a JSP with the EL:<pre>
* Title of "/text.xml": ${cms:vfs(pageContext).xml['/text.xml'].value['Title']}
* </pre>
*
* @return a map that lazily reads wrapped XML documents from the OpenCms VFS
*
* @see #getReadXml()
*/
public Map getXml() {
return getReadXml();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?