You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@cocoon.apache.org by da...@cocoon.zones.apache.org on 2008/08/18 16:31:17 UTC
[DAISY] Updated: JCRSourceFactory
A document has been updated:
http://cocoon.zones.apache.org/daisy/documentation/1507.html
Document ID: 1507
Branch: main
Language: default
Name: JCRSourceFactory (unchanged)
Document Type: Cocoon Document (unchanged)
Updated on: 8/18/08 2:31:10 PM
Updated by: Lukas Lang
A new version has been created, state: draft
Parts
=====
Content
-------
This part has been updated.
Mime type: text/xml (unchanged)
File name: (unchanged)
Size: 5176 bytes (previous version: 37 bytes)
Content diff:
--- <html><body><p>TODO</p></body></html>
+++ <html>
+++ <body>
+++
+++ <h1>Summary</h1>
+++
+++ <p>The JCRSourceFactory implements the Excalibur SourceFactory interface on top
+++ of a JCR (aka <a href="http://www.jcp.org/en/jsr/detail?id=170">JSR-170</a>)
+++ repository. It can be used to obtain resources, specified by <em>jcr://
+++ </em>URIs.</p>
+++
+++ <h1>Documentation</h1>
+++
+++ <p>Since JCR allows a repository to define its own node types, it is necessary
+++ to configure this source factory with a description of what node types map to
+++ "files" and "folders" and the properties used to store source-related data.</p>
+++
+++ <h3>Example</h3>
+++
+++ <p>A SourceFactory can be used within a sitemap generator component:</p>
+++
+++ <pre> <map:match pattern="**">
+++ <map:generate src="jcr://{1}" />
+++ <map:serialize />
+++ </map:match></pre>
+++
+++ <p>Every request will be forwarded to the JCRSourceFactory. Please have a look
+++ at the configuration section for further details.</p>
+++
+++ <h3>Configuration</h3>
+++
+++ <p>JCRSourceFactory is configured via Spring and gets a repository injected. A
+++ typical Spring configuration for a naked Jackrabbit repository is as follows:
+++ </p>
+++
+++ <pre> <bean name="org.apache.excalibur.source.SourceFactory/jcr"
+++ class="org.apache.cocoon.jcr.source.JCRSourceFactory">
+++ <property name="repository" ref="javax.jcr.Repository" />
+++ <property name="credentials">
+++ <bean class="javax.jcr.SimpleCredentials">
+++ ...
+++ </bean>
+++ </property>
+++ <property name="typeInfos">
+++ <util:map map-class="java.util.HashMap">
+++ <entry key="rep:root">
+++ <bean class="org.apache.cocoon.jcr.source.JCRSourceFactory$FolderTypeInfo">
+++ <property name="newFileType" value="nt:file" />
+++ <property name="newFolderType" value="nt:folder" />
+++ </bean>
+++ </entry>
+++ <entry key="nt:folder">
+++ <bean class="org.apache.cocoon.jcr.source.JCRSourceFactory$FolderTypeInfo">
+++ <property name="newFileType" value="nt:file" />
+++ <property name="newFolderType" value="nt:folder" />
+++ </bean>
+++ </entry>
+++ <entry key="nt:file">
+++ <bean class="org.apache.cocoon.jcr.source.JCRSourceFactory$FileTypeInfo">
+++ <property name="contentPath" value="jcr:content" />
+++ <property name="contentType" value="nt:resource" />
+++ </bean>
+++ </entry>
+++ <entry key="nt:linkedFile">
+++ <bean class="org.apache.cocoon.jcr.source.JCRSourceFactory$FileTypeInfo">
+++ <property name="contentPath" value="jcr:content" />
+++ <property name="contentRef" value="jcr:content" />
+++ </bean>
+++ </entry>
+++ <entry key="nt:resource">
+++ <bean class="org.apache.cocoon.jcr.source.JCRSourceFactory$ContentTypeInfo">
+++ <property name="contentProp" value="jcr:data" />
+++ <property name="lastModifiedProp" value="jcr:lastModified" />
+++ <property name="mimeTypeProp" value="jcr:mimeType" />
+++ <property name="validityProp" value="jcr:lastModified" />
+++ </bean>
+++ </entry>
+++ </util:map>
+++ </property>
+++ </bean>
+++ </pre>
+++
+++ <p>A FolderTypeInfo defines a node type that is mapped to a non-terminal source
+++ (i.e. that can have children). The newFileType and newFolderType fields
+++ respectively define what node types should be used to create a new terminal and
+++ non-terminal source.</p>
+++
+++ <p>A FileTypeInfo defines a note type that is mapped to a terminal source (i.e.
+++ that can have some content). The contentPath field defines the path to the
+++ node's child that actually holds the content, and contentType defines the type
+++ of this content node.</p>
+++
+++ <p>The contentRef field is used to comply with JCR's nt:linkedFile definition
+++ where the content node is not a direct child of the file node, but is referenced
+++ by a property of this file node. Such node types are read-only as there's no way
+++ to indicate where the referenced content node should be created.</p>
+++
+++ <p>A ContentTypeInfo defines a node type that actually holds the content of a
+++ FileTypeInfo. The contentProp field must be present and gives the name of the
+++ node's binary property that will hold the actual content. Other attributes are
+++ optional:</p>
+++
+++ <ul>
+++ <li>mimeTypeProp defines a string property holding the content's MIME type,
+++ </li>
+++ <li>lastModifiedProp defines a date property holding the node's last
+++ modification date. It is automatically updated when content is written to the
+++ ContentTypeInfo.</li>
+++ <li>validityProp defines a property that gives the validity of the content, used
+++ by Cocoon's cache. If not specified, lastModifiedProp is used, if present.
+++ Otherwise the source has no validity and won't be cacheable.</li>
+++ </ul>
+++
+++ <p>The format of URIs for this source is a path in the repository, and it is
+++ therefore currently limited to repository traversal. Further work will add the
+++ ability to specify query strings.</p>
+++
+++ <h1>Further reading</h1>
+++
+++ <p>Please see the <a href="daisy:1505">sample</a> page for more information.</p>
+++
+++ </body>
+++ </html>