incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [CONF] Apache Sling > Multiple Workspace Support
Date Fri, 04 Jun 2010 19:54:00 GMT
    <base href="">
            <link rel="stylesheet" href="/confluence/s/1810/9/1/_/styles/combined.css?spaceKey=SLING&amp;forWysiwyg=true"
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="">Multiple
Workspace Support</a></h2>
    <h4>Page <b>edited</b> by             <a href="">Justin
                         <h4>Changes (1)</h4>
<div id="page-diffs">
            <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >If this attribute is set at the time
of resolution (i.e. is passed to {{ResourceResolver.resolve(HttpServletRequest)}} or {{ResourceResolver.resolve(HttpServletRequest,
String)}}), then future invocations of {{ResourceResolver.adaptTo(Session.class)}} will return
a {{javax.jcr.Session}} logged into the requested workspace. <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">This
request-bound workspace is also used for {{findResources()}} and {{queryResources()}}. <br>
            <tr><td class="diff-unchanged" >h3. Impact on Resource instances <br>
            <tr><td class="diff-snipped" >...<br></td></tr>
</div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="MultipleWorkspaceSupport-MultiWorkspaceSupport"></a>Multi-Workspace

<p>The Java Content Repository (JSR-170/JSR-283) standard requires that content repositories
be composed of one or more workspaces which contain the actual content nodes. Workspaces are
intended to be used to store different branches of the same node graph (see <a href=""
class="external-link" rel="nofollow"></a>).</p>

<h2><a name="MultipleWorkspaceSupport-ResourceResolution"></a>Resource Resolution</h2>

<p>By default, only the default workspace will be consulted during resource resolution.</p>

<h3><a name="MultipleWorkspaceSupport-Configuration"></a>Configuration</h3>

<p>To enable multi-workspace resource resolution, set the <tt>resource.resolver.multiworkspace</tt>
configuration property of PID <tt></tt>
to true. This can be done via the Web Console on the Configuration screen.</p>

<p><span class="image-wrap" style=""><img src="/confluence/download/attachments/21792201/00000039.png?version=1&amp;modificationDate=1275681089000"
style="border: 1px solid black" /></span></p>

<p>By default, Sling's JCR Resource Resolver will resolve resources from the default
workspace (typically named "default"). An alternate workspace can be specified by including
a workspace as a colon-delimited prefix to the path. For example:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
Resource res = resResolver.getResource(<span class="code-quote">"ws2:/path/to/node"</span>);

<h3><a name="MultipleWorkspaceSupport-RequestbasedResolving"></a>Request-based

<p>When resolving a resource based on an <tt>HttpServletRequest</tt>, the
workspace name can also be provided through a request attribute named <tt></tt>.
Note that Sling does not provide any mechanism to set this attribute. Since resource resolution
occurs very early in the Sling request pipeline (see <a href=""
class="external-link" rel="nofollow"></a>),
you must set this attribute either outside of Sling (i.e. in a Servlet Filter) or in the Authentication

<p>If this attribute is set at the time of resolution (i.e. is passed to <tt>ResourceResolver.resolve(HttpServletRequest)</tt>
or <tt>ResourceResolver.resolve(HttpServletRequest, String)</tt>), then future
invocations of <tt>ResourceResolver.adaptTo(Session.class)</tt> will return a
<tt>javax.jcr.Session</tt> logged into the requested workspace.</p>

<p>This request-bound workspace is also used for <tt>findResources()</tt>
and <tt>queryResources()</tt>.</p>

<h3><a name="MultipleWorkspaceSupport-ImpactonResourceinstances"></a>Impact
on Resource instances</h3>

<p>Regardless of how a Resource is resolved in a non-default workspace, the path of
the resolved resource will contain the workspace name as a path prefix. This means that <tt>Resource.getPath()</tt>
will not equal <tt>Resource.adaptTo(Node.class).getPath()</tt>.</p>

<h2><a name="MultipleWorkspaceSupport-JCRResourceEvents"></a>JCR Resource

<p>The jcr.resource bundle includes support for converting JCR Observation events into
OSGi EventAdmin events. Once multi-workspace support is enabled, resource events will be sent
for JCR events across all workspaces, with the resource path containing the workspace prefix.</p>

<h2><a name="MultipleWorkspaceSupport-ScriptResolution"></a>Script Resolution</h2>

<p>By default, scripts are always resolved from the default workspace, regardless of
how the Resource Resolver is configured. The default workspace for scripts can be configured
separately from the default workspace for resources by setting the <tt>servletresolver.defaultScriptWorkspace</tt>
configuration property of PID <tt></tt>
to true.</p>

<p><span class="image-wrap" style=""><img src="/confluence/download/attachments/21792201/2010-06-04_1550.png?version=1&amp;modificationDate=1275681089000"
style="border: 1px solid black" /></span></p>

<p>Script resolution can also be configured to look first (or only) in the same workspace
as the resource.</p>

<p>If <tt>servletresolver.useRequestWorkspace</tt> is true and <tt>servletresolver.useDefaultWorkspace</tt>
is false, <b>only</b> the workspace containing the resource will be used for resolution.<br/>
If <tt>servletresolver.useRequestWorkspace</tt> is true and <tt>servletresolver.useDefaultWorkspace</tt>
is also true, the resource's workspace will be consulted first and, if nothing is found, the
default workspace will be checked.</p>

        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href=""
class="grey">Change Notification Preferences</a>
        <a href="">View
        <a href="">View
        <a href=";showCommentArea=true#addcomment">Add

View raw message