incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Sling > Multiple Workspace Support
Date Fri, 04 Jun 2010 19:52:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/9/1/_/styles/combined.css?spaceKey=SLING&amp;forWysiwyg=true"
type="text/css">
    </head>
<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="http://cwiki.apache.org/confluence/display/SLING/Multiple+Workspace+Support">Multiple
Workspace Support</a></h2>
    <h4>Page  <b>added</b> by             <a href="http://cwiki.apache.org/confluence/display/~justinedelson">Justin
Edelson</a>
    </h4>
         <br/>
    <div class="notificationGreySide">
         <h1><a name="MultipleWorkspaceSupport-MultiWorkspaceSupport"></a>Multi-Workspace
Support</h1>

<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="http://wiki.apache.org/jackrabbit/DavidsModel#Rule_.233:_Workspaces_are_for_clone.28.29.2C_merge.28.29_and_update.28.29."
class="external-link" rel="nofollow">http://wiki.apache.org/jackrabbit/DavidsModel#Rule_.233:_Workspaces_are_for_clone.28.29.2C_merge.28.29_and_update.28.29.</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>org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl</tt>
to true. This can be done via the Web Console on the Configuration screen.</p>

<p><span class="error">Unable to render embedded object: File (00000039.png) not
found.</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>);
</pre>
</div></div>

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

<p>When resolving a resource based on an <tt>HttpServletRequest</tt>, the
workspace name can also be provided through a request attribute named <tt>org.apache.sling.api.resource.ResourceResolver/use.workspace</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="http://sling.apache.org/site/filters.html"
class="external-link" rel="nofollow">http://sling.apache.org/site/filters.html</a>),
you must set this attribute either outside of Sling (i.e. in a Servlet Filter) or in the Authentication
phase.</p>

<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>

<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
Events</h2>

<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>org.apache.sling.servlets.resolver.SlingServletResolver</tt>
to true.</p>


<p><span class="error">Unable to render embedded object: File (2010-06-04_1550.png)
not found.</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>
    <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>
       <a href="http://cwiki.apache.org/confluence/display/SLING/Multiple+Workspace+Support">View
Online</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/SLING/Multiple+Workspace+Support?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
           </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message