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 > FAQ
Date Fri, 25 Jan 2013 16:40:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/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="https://cwiki.apache.org/confluence/display/SLING/FAQ">FAQ</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~bdelacretaz">Bertrand Delacretaz</a>
    </h4>
        <div id="versionComment">
        <b>Comment:</b>
        Add /content/config.author POST workaround<br />
    </div>
        <br/>
                         <h4>Changes (2)</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" >The _TypeHint_ tells the Sling POST servlet to create a multi-value property for _foo_. <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h3. I cannot add a node under /content/config.author using a POST, the new node goes under /content/config <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">That happens if both the /content/config.author and /content/config nodes exist, and you do something like: <br> <br>{code} <br>$ curl -F try=first -u admin:admin http://localhost:8080/content/config.author/underauthor <br>{code} <br> <br>The underauthor node goes under /content/config in that case, as Sling finds a resource at that path and considers .author as an extension or selector. <br> <br>This is inherent to the way Sling matches URL paths to resources - to work around that, use <br> <br>{code} <br>$ curl -F underauthor/try=second -F &quot;underauthor/jcr:primaryType=sling:Folder&quot; -u admin:admin http://localhost:8080/content/config.author <br>{code} <br> <br>Which correctly creates the underauthor node under /content/config.author. You can of course add more properties to the request, like -F {{underauthor/jcr:primaryType}} if needed. <br> <br>Here&#39;s the resulting content of our example (including specifying the jcr:primaryType): <br> <br>{code} <br>$ curl http://localhost:8080/content.tidy.5.json <br>{ <br>  &quot;jcr:primaryType&quot;: &quot;nt:unstructured&quot;, <br>  &quot;config.author&quot;: { <br>    &quot;foo&quot;: &quot;bar&quot;, <br>    &quot;jcr:primaryType&quot;: &quot;nt:unstructured&quot;, <br>    &quot;underauthor&quot;: { <br>      &quot;try&quot;: &quot;second&quot;, <br>      &quot;jcr:createdBy&quot;: &quot;admin&quot;, <br>      &quot;jcr:created&quot;: &quot;Fri Jan 25 2013 17:35:18 GMT+0100&quot;, <br>      &quot;jcr:primaryType&quot;: &quot;sling:Folder&quot; <br>    } <br>  }, <br>  &quot;config&quot;: { <br>    &quot;foo&quot;: &quot;bar&quot;, <br>    &quot;jcr:primaryType&quot;: &quot;nt:unstructured&quot;, <br>    &quot;underauthor&quot;: { <br>      &quot;try&quot;: &quot;first&quot;, <br>      &quot;jcr:primaryType&quot;: &quot;nt:unstructured&quot; <br>    } <br>  } <br>} <br>{code} <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h2. Scripts and Servlets <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="FAQ-FrequentlyAskedQuestions"></a>Frequently Asked Questions</h1>

<p>This page lists a series of common questions and answers. It is of course work in progress ...</p>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>This page is <b>not</b> meant for asking questions</b><br />Use the Sling users mailing lists for that, see <a href="http://sling.apache.org/site/project-information.html#ProjectInformation-lists" class="external-link" rel="nofollow">http://sling.apache.org/site/project-information.html#ProjectInformation-lists</a> - this page is about <em>answers</em>. Thanks!</td></tr></table></div>

<div>
<ul>
    <li><a href='#FAQ-Administration'>Administration</a></li>
<ul>
    <li><a href='#FAQ-HowdoIchangeJackrabbit%27sadminpassword%3F'>How do I change Jackrabbit's admin password?</a></li>
</ul>
    <li><a href='#FAQ-RESTfulAPI'>RESTful API</a></li>
<ul>
    <li><a href='#FAQ-HowdoIcreateanodebypostingajsondocumenttoaURL%3F'>How do I create a node by posting a json document to a URL?</a></li>
    <li><a href='#FAQ-Whatsospecialaboutthe%27content%27%2C%27apps%27and%27%27urls%3F'>What so special about the 'content','apps' and '*' urls?</a></li>
    <li><a href='#FAQ-Ipostedaresource%2Cwherediditgo%3F'>I posted a resource, where did it go?</a></li>
    <li><a href='#FAQ-HowtoIcreateamultivaluepropertywithasinglevalue%2CinHTTP%3F'>How to I create a multi-value property with a single value, in HTTP?</a></li>
    <li><a href='#FAQ-Icannotaddanodeunder%2Fcontent%2Fconfig.authorusingaPOST%2Cthenewnodegoesunder%2Fcontent%2Fconfig'>I cannot add a node under /content/config.author using a POST, the new node goes under /content/config</a></li>
</ul>
    <li><a href='#FAQ-ScriptsandServlets'>Scripts and Servlets</a></li>
<ul>
    <li><a href='#FAQ-HowdoIgeneratelinkstopreviousversionsofanode%3F'>How do I generate links to previous versions of a node?</a></li>
    <li><a href='#FAQ-HowdoIfindoutwhyagivenscriptorservletispreferredtoanotherwhenprocessingarequest%3F'>How do I find out why a given script or servlet is preferred to another when processing a request?</a></li>
    <li><a href='#FAQ-HowdoIrenderascriptforastar%22%22resource%3F'>How do I render a script for a star "*" resource?</a></li>
    <li><a href='#FAQ-Howtoreplacethedefaultjsonrenderer%28forexample%29withmyown%3F'>How to replace the default json renderer (for example) with my own?</a></li>
    <li><a href='#FAQ-Howtoexecutescriptsdirectly%3F'>How to execute scripts directly?</a></li>
    <li><a href='#FAQ-HowdoIcreateanewscriptengine%3F'>How do I create a new script engine?</a></li>
</ul>
    <li><a href='#FAQ-Workingwithbundles'>Working with bundles</a></li>
<ul>
    <li><a href='#FAQ-Isthereaneasywaytoupdatebundlesinarunninginstallationduringdevelopment%3F'>Is there an easy way to update bundles in a running installation during development?</a></li>
</ul>
    <li><a href='#FAQ-Classloadingissues'>Classloading issues</a></li>
<ul>
    <li><a href='#FAQ-AccessingClassesfromtheEnvironment'>Accessing Classes from the Environment</a></li>
    <li><a href='#FAQ-Howarethe%7B%7Bsling.bootdelegation%7D%7Dpropertiesused%3F'>How are the <tt>sling.bootdelegation</tt> properties used ?</a></li>
    <li><a href='#FAQ-HowdoesSlingsupportthe%7B%7Borg.osgi.framework.system.packages%7D%7DProperty%3F'>How does Sling support the <tt>org.osgi.framework.system.packages</tt> Property ?</a></li>
    <li><a href='#FAQ-Shouldthe%7B%7Borg.osgi.framework.bootdelegation%7D%7Dorthe%7B%7Borg.osgi.framework.system.packages%7D%7DPropertybeused%3F'>Should the <tt>org.osgi.framework.bootdelegation</tt> or the <tt>org.osgi.framework.system.packages</tt> Property be used ?</a></li>
    <li><a href='#FAQ-HowtosharesessionbetweenSlingandotherwebapplications%3F'>How to share session between Sling and other web applications?</a></li>
</ul>
    <li><a href='#FAQ-Miscellaneous'>Miscellaneous</a></li>
<ul>
    <li><a href='#FAQ-Whycan%27tIconnecttoSling%27sWebDAVusingWindowsNetworkDriveMapping%3F'>Why can't I connect to Sling's WebDAV using Windows NetworkDriveMapping ?</a></li>
    <li><a href='#FAQ-WhyismyWebDAVconnectionsoslowonWindows%3F'>Why is my WebDAV connection so slow on Windows ?</a></li>
    <li><a href='#FAQ-WhyshouldIusethesling%3AFoldernodetypeinsteadofnt%3Afolder%3F'>Why should I use the sling:Folder node type instead of nt:folder ?</a></li>
    <li><a href='#FAQ-Howtochangetheservice.rankingofaservicethroughconfiguration%3F'>How to change the service.ranking of a service through configuration?</a></li>
</ul>
</ul></div>

<h2><a name="FAQ-Administration"></a>Administration</h2>

<h3><a name="FAQ-HowdoIchangeJackrabbit%27sadminpassword%3F"></a>How do I change Jackrabbit's admin password?</h3>

<p>Using the userManager:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
   curl \
    -F<span class="code-quote">"oldPwd=admin"</span> \
    -F<span class="code-quote">"newPwd=Fritz"</span> \
    -F<span class="code-quote">"newPwdConfirm=Fritz"</span> \
    http:<span class="code-comment">//admin:admin@localhost:8080/system/userManager/user/admin.changePassword.html</span>
</pre>
</div></div>

<p>You will also have to set that password in the Felix Web Management Console (/system/console/configMgr) under "Apache Sling Embedded JCR Repository." This is used by Sling to create an admin JCR session (using SlingRepository.loginAdministrative()) for components that need to have full access to the repository.</p>

<p>Note: Only after restarting the framework the old password will become invalid (as of 09-11-10).</p>

<p>Note: depending on the login module used in Jackrabbit, the password might not be checked at all (SimpleLoginModule, standard in Jackrabbit &lt;= 1.4). Since Jackrabbit 1.5, the DefaultLoginModule provides full user support.</p>


<h2><a name="FAQ-RESTfulAPI"></a>RESTful API</h2>

<h3><a name="FAQ-HowdoIcreateanodebypostingajsondocumenttoaURL%3F"></a>How do I create a node by posting a json document to a URL?</h3>

<p>At the moment, you cannot do this. (Soon to change as per <a href="https://issues.apache.org/jira/browse/SLING-1172" class="external-link" rel="nofollow">SLING-1172</a>&#33;)  Instead, each value must be a field in the request POST.  For example, suppose you have the json document:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
  {
    <span class="code-quote">"greetings"</span>:<span class="code-quote">"Hello, World!"</span>,
    <span class="code-quote">"multi"</span> : [<span class="code-quote">"first"</span>,<span class="code-quote">"second"</span>],
    <span class="code-quote">"translations"</span> : { <span class="code-quote">"en"</span>: <span class="code-quote">"Hello"</span>, <span class="code-quote">"zh"</span>, <span class="code-quote">"你好"</span> }
  }
</pre>
</div></div>

<p>You would do a post such as:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
curl -F<span class="code-quote">"greetings=Hello, World!"</span> -F<span class="code-quote">"mult=first"</span> -F<span class="code-quote">"multi=second"</span> -F<span class="code-quote">"translations/en=Hello"</span> -F<span class="code-quote">"translations/zh=你好"</span> http:<span class="code-comment">//admin:admin@localhost:8080/content/../../..</span>
</pre>
</div></div>

<h3><a name="FAQ-Whatsospecialaboutthe%27content%27%2C%27apps%27and%27%27urls%3F"></a>What so special about the 'content','apps' and '*' urls?</h3>

<p>'apps' is reserved for matching scripts evaluated by sling.</p>

<p>The "*" url is used for POSTing to a child node.</p>

<p>By default, if a resource cannot be found from the root url, sling will try appending "content".  For example, if you request the following non-existent resource:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
http:<span class="code-comment">//localhost:8080/blog/first_post</span>
</pre>
</div></div>

<p>Sling will look in:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
http:<span class="code-comment">//localhost:8080/content/blog/first_post</span>
</pre>
</div></div>

<p>Before returning a 404.</p>

<h3><a name="FAQ-Ipostedaresource%2Cwherediditgo%3F"></a>I posted a resource, where did it go?</h3>

<p>Let's start by creating a resource:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
curl -F<span class="code-quote">"greetings=Hello, World"</span> -F<span class="code-quote">"translations/en=Hello"</span> -F<span class="code-quote">"translations/es=hola"</span> http:<span class="code-comment">//admin:admin@localhost:8080/content/greet</span>
</pre>
</div></div>

<p>We can now view the resource with:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
curl http:<span class="code-comment">//admin:admin@localhost:8080/content/greet.json
</span>{<span class="code-quote">"greetings"</span>:<span class="code-quote">"Hello, World"</span>,<span class="code-quote">"jcr:created"</span>:<span class="code-quote">"Fri Nov 06 2009 16:26:23 GMT-0800"</span>,<span class="code-quote">"jcr:primaryType"</span>:<span class="code-quote">"sling:Folder"</span>}
</pre>
</div></div>

<p>Notice that the "greet" resource is a sling:Folder.  Also notice that it's a little hard to read the result.  Let's tidy it up:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
curl http:<span class="code-comment">//admin:admin@localhost:8080/content/greet.tidy.json
</span>{
  <span class="code-quote">"greetings"</span>: <span class="code-quote">"Hello, World"</span>,
  <span class="code-quote">"jcr:created"</span>: <span class="code-quote">"Fri Nov 06 2009 16:26:23 GMT-0800"</span>,
  <span class="code-quote">"jcr:primaryType"</span>: <span class="code-quote">"sling:Folder"</span>
}
</pre>
</div></div>

<p>But where did our translations go?  To get them, we have to request 2 nodes down into the tree:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
curl http:<span class="code-comment">//admin:admin@localhost:8080/content/greet.tidy.2.json
</span>{
  <span class="code-quote">"greetings"</span>: <span class="code-quote">"Hello, World"</span>,
  <span class="code-quote">"jcr:created"</span>: <span class="code-quote">"Fri Nov 06 2009 16:26:23 GMT-0800"</span>,
  <span class="code-quote">"jcr:primaryType"</span>: <span class="code-quote">"sling:Folder"</span>,
  <span class="code-quote">"translations"</span>: {
    <span class="code-quote">"en"</span>: <span class="code-quote">"Hello"</span>,
    <span class="code-quote">"jcr:created"</span>: <span class="code-quote">"Fri Nov 06 2009 16:26:23 GMT-0800"</span>,
    <span class="code-quote">"es"</span>: <span class="code-quote">"hola"</span>,
    <span class="code-quote">"jcr:primaryType"</span>: <span class="code-quote">"sling:Folder"</span>
  }
}
</pre>
</div></div>

<p>However, if we try and get the resource without an extension, we get nothing found.  This is because we're requesting a folder, so sling tries to find either an index.html or return a directory list, just like a normal directory on a webserver.</p>

<p>To fix this, we can use a script and a sling resource type.  Let's update our greeting document:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
curl F<span class="code-quote">"sling:resourceType=greeting"</span> -F<span class="code-quote">"greetings=Hello, World"</span> -F<span class="code-quote">"translations/en=Hello"</span> -F<span class="code-quote">"translations/es=hola"</span> http:<span class="code-comment">//admin:admin@localhost:8080/content/greet</span>
</pre>
</div></div>

<p>Then we'll post a simple esp script to apps:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>GET.esp</b></div><div class="codeContent panelContent">
<pre class="code-java">
&lt;html&gt;
  &lt;head&gt;&lt;title&gt;&lt;/title&gt;&lt;/head&gt;
  &lt;body&gt;
    &lt;h1&gt;&lt;%= currentNode.greetings %&gt;&lt;/h1&gt;
  &lt;/body&gt;
&lt;/html&gt;
</pre>
</div></div>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
curl -X MKCOL http:<span class="code-comment">//admin:admin@gandalf.local:8080/apps/greeting
</span>curl -T GET.esp http:<span class="code-comment">//admin:admin@localhost:8080/apps/greeting/GET.esp</span>
</pre>
</div></div>

<p>Now you should be able to see an HTML version of the resource at <a href="http://localhost.local:8080/content/greet" class="external-link" rel="nofollow">http://localhost.local:8080/content/greet</a>.  This script matches the sling:resourceType we set and the HTTP method we used.  Note that resourceType matches must be exact.</p>

<h3><a name="FAQ-HowtoIcreateamultivaluepropertywithasinglevalue%2CinHTTP%3F"></a>How to I create a multi-value property with a single value, in HTTP?</h3>

<p>Use this:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
curl -u admin:admin -F'foo=bar' -F'foo@TypeHint=<span class="code-object">String</span>[]' http:<span class="code-comment">//localhost:8080/some/path</span>
</pre>
</div></div>
<p>The <em>TypeHint</em> tells the Sling POST servlet to create a multi-value property for <em>foo</em>.</p>

<h3><a name="FAQ-Icannotaddanodeunder%2Fcontent%2Fconfig.authorusingaPOST%2Cthenewnodegoesunder%2Fcontent%2Fconfig"></a>I cannot add a node under /content/config.author using a POST, the new node goes under /content/config</h3>

<p>That happens if both the /content/config.author and /content/config nodes exist, and you do something like:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
$ curl -F <span class="code-keyword">try</span>=first -u admin:admin http:<span class="code-comment">//localhost:8080/content/config.author/underauthor</span>
</pre>
</div></div>

<p>The underauthor node goes under /content/config in that case, as Sling finds a resource at that path and considers .author as an extension or selector.</p>

<p>This is inherent to the way Sling matches URL paths to resources - to work around that, use</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
$ curl -F underauthor/<span class="code-keyword">try</span>=second -F <span class="code-quote">"underauthor/jcr:primaryType=sling:Folder"</span> -u admin:admin http:<span class="code-comment">//localhost:8080/content/config.author</span>
</pre>
</div></div>

<p>Which correctly creates the underauthor node under /content/config.author. You can of course add more properties to the request, like -F <tt>underauthor/jcr:primaryType</tt> if needed.</p>

<p>Here's the resulting content of our example (including specifying the jcr:primaryType):</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
$ curl http:<span class="code-comment">//localhost:8080/content.tidy.5.json
</span>{
  <span class="code-quote">"jcr:primaryType"</span>: <span class="code-quote">"nt:unstructured"</span>,
  <span class="code-quote">"config.author"</span>: {
    <span class="code-quote">"foo"</span>: <span class="code-quote">"bar"</span>,
    <span class="code-quote">"jcr:primaryType"</span>: <span class="code-quote">"nt:unstructured"</span>,
    <span class="code-quote">"underauthor"</span>: {
      <span class="code-quote">"<span class="code-keyword">try</span>"</span>: <span class="code-quote">"second"</span>,
      <span class="code-quote">"jcr:createdBy"</span>: <span class="code-quote">"admin"</span>,
      <span class="code-quote">"jcr:created"</span>: <span class="code-quote">"Fri Jan 25 2013 17:35:18 GMT+0100"</span>,
      <span class="code-quote">"jcr:primaryType"</span>: <span class="code-quote">"sling:Folder"</span>
    }
  },
  <span class="code-quote">"config"</span>: {
    <span class="code-quote">"foo"</span>: <span class="code-quote">"bar"</span>,
    <span class="code-quote">"jcr:primaryType"</span>: <span class="code-quote">"nt:unstructured"</span>,
    <span class="code-quote">"underauthor"</span>: {
      <span class="code-quote">"<span class="code-keyword">try</span>"</span>: <span class="code-quote">"first"</span>,
      <span class="code-quote">"jcr:primaryType"</span>: <span class="code-quote">"nt:unstructured"</span>
    }
  }
}
</pre>
</div></div>

<h2><a name="FAQ-ScriptsandServlets"></a>Scripts and Servlets</h2>

<h3><a name="FAQ-HowdoIgeneratelinkstopreviousversionsofanode%3F"></a>How do I generate links to previous versions of a node?</h3>

<p>Assuming a versionable node at /content/versioned, with sling:resourceType=foo, here's the /apps/foo/html.esp script that handles the /content/versioned.html request:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&lt;html&gt;

&lt;%
<span class="code-comment">// assume we have a versionable node
</span><span class="code-keyword">var</span> iter = currentNode.getVersionHistory().getAllVersions();
%&gt;

  &lt;body&gt;
    &lt;h1&gt;Versions of node &lt;%= currentNode.getPath() %&gt;&lt;/h1&gt;
    &lt;%
    	<span class="code-keyword">while</span>(iter.hasNext()) {
    	  <span class="code-keyword">var</span> v = iter.nextVersion();

    	  <span class="code-comment">// use UUID of version node to build a link, and add a .version
</span>    	  <span class="code-comment">// selector to have another esp script process that request
</span>    	  <span class="code-keyword">var</span> uuid = v[<span class="code-quote">"jcr:uuid"</span>];
    	  <span class="code-keyword">var</span> vPath = currentNode.getPath() + <span class="code-quote">".version."</span> + uuid + <span class="code-quote">".html"</span>;

    	  <span class="code-comment">// Use Version creation date as the link text
</span>    	  <span class="code-keyword">var</span> vDate = v.getCreated().getTime();

    	  %&gt;
    	  &lt;a href=<span class="code-quote">"&lt;%= vPath %&gt;"</span>&gt;&lt;%= vDate %&gt;&lt;/a&gt;&lt;br/&gt;
    	  &lt;%
    	}
    %&gt;
  &lt;/body&gt;
&lt;/html&gt;
</pre>
</div></div>

<p>The links to the individual versions look like: /content/versioned.version.313016e1.html where the first .version. selector causes a different esp script to be called to display the version data, and the 313016e1 selector is the UUID of the versioned node (real UUIDs are longer).</p>

<p>That request is handled by this second script, /apps/foo/version/html.esp (name will change soon, SLING-387):</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&lt;html&gt;

&lt;%
	<span class="code-comment">// Get version node UUID, which is the second selector
</span>	<span class="code-keyword">var</span> uuid = <span class="code-keyword">null</span>;
	<span class="code-keyword">var</span> sel = request.getRequestPathInfo().getSelectors();
	<span class="code-keyword">if</span>(sel.length &gt;= 2) {
		uuid = sel[1];
	} <span class="code-keyword">else</span> {
		response.sendError(400, <span class="code-quote">"Version node UUID must be given as second selector"</span>);
	}

	<span class="code-comment">// Get version node
</span>	<span class="code-keyword">var</span> v = currentNode.getSession().getNodeByUUID(uuid);
	<span class="code-keyword">var</span> frozen = v.getNode(<span class="code-quote">"jcr:frozenNode"</span>);
	<span class="code-keyword">var</span> title = frozen.title;
%&gt;

  &lt;body&gt;
    &lt;h1&gt;Version of node &lt;%= currentNode.getPath() %&gt;&lt;/h1&gt;
    Name: &lt;b&gt;&lt;%= v.getName() %&gt;&lt;/b&gt;&lt;br/&gt;
    UUID: &lt;b&gt;&lt;%= uuid %&gt;&lt;/b&gt;&lt;br/&gt;
    Path: &lt;b&gt;&lt;%= v.getPath() %&gt;&lt;/b&gt;&lt;br/&gt;
    Frozen node path: &lt;b&gt;&lt;%= frozen.getPath() %&gt;&lt;/b&gt;&lt;br/&gt;

    &lt;% <span class="code-keyword">if</span>(title) { %&gt;
	    Frozen node title: &lt;b&gt;&lt;%= frozen.getProperty(<span class="code-quote">"title"</span>) %&gt;&lt;/b&gt;&lt;br/&gt;
    &lt;% } <span class="code-keyword">else</span> { %&gt;
    	Frozen node does not have a title property
    &lt;% } %&gt;
  &lt;/body&gt;
&lt;/html&gt;
</pre>
</div></div>

<p>Which uses the UUID selector to retrieve the versioned node.</p>

<p>The second trick here is that the versioned data is saved as a "jcr:frozenNode" node under the Version node. This is explained for example at <a href="http://www.onjava.com/lpt/a/6784" class="external-link" rel="nofollow">http://www.onjava.com/lpt/a/6784</a> .</p>

<h3><a name="FAQ-HowdoIfindoutwhyagivenscriptorservletispreferredtoanotherwhenprocessingarequest%3F"></a>How do I find out why a given script or servlet is preferred to another when processing a request?</h3>

<p>See <a href="https://issues.apache.org/jira/browse/SLING-580" class="external-link" rel="nofollow">SLING-580</a>, the SlingServletResolver class logs detailed information (at the DEBUG level) to indicate in which order the candidate scripts and servlets are considered for processing a request.</p>

<h3><a name="FAQ-HowdoIrenderascriptforastar%22%22resource%3F"></a>How do I render a script for a star "*" resource?</h3>

<p>"*" resources do not have a sling:resourceType which can cause confusion when you're trying to render a specific script.  Consider:</p>

<p>Suppose we have content such as:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>content
--gradapp
----application
--------app1
--------app2
------------tabs
----------------tab1
----------------tab2

apps
--gradapp
----application
--------edit.esp
--------html.esp
--------list.esp
----tab
--------edit.esp
</pre>
</div></div>

<p>In this case, <a href="http://localhost:8888/gradapp/application/app1.edit.html" class="external-link" rel="nofollow">http://localhost:8888/gradapp/application/app1.edit.html</a> will provide an edit page for the app1 resource using the script from apps/gradapp/application/edit.esp.  However, <a href="http://localhost:8888/gradapp/application/*.edit.html" class="external-link" rel="nofollow">http://localhost:8888/gradapp/application/*.edit.html</a> will not use that edit.esp script.</p>

<p>By default the "star resource" does not have a resource type, so you get the default rendering. To give it a specific resource type based on its path, you can install and start the samples/path-based-rtp bundle.</p>

<p>Another suggestion is to register a generic node creation form script, e.g. at /apps/sling/servlet/default/create.esp. You should be able to invoke that script by browsing to /gradapp/application/*.create. If you want the create.esp script to be able to render different forms<br/>
(e.g. one for applications, one for tabs) you can use different selectors, like &#42;.createTab, &#42;.createApp, etc.</p>

<p>An older version of this answer suggests using a query parameter, this also works but we recommend using selectors in Sling, leading to cleaner and cachable URLs.</p>

<p>So this would work:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
   /gradapp/application/*.create?typeToCreate=application
</pre>
</div></div>
<p>for creating application nodes and</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
   /gradapp/application/*.create?typeToCreate=tab
</pre>
</div></div>
<p>for showing the tab form, but this is the preferred way:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
   /gradapp/application/*.createApp
</pre>
</div></div>
<p>for creating application nodes and</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
   /gradapp/application/*.createTab
</pre>
</div></div>
<p>for showing the tab form.</p>

<p>See: <a href="http://markmail.org/message/htl6r3uctuzb6l5q" class="external-link" rel="nofollow">http://markmail.org/message/htl6r3uctuzb6l5q</a> and <a href="http://mail-archives.apache.org/mod_mbox/sling-users/200911.mbox/%3c8A802DC6-7472-4040-807A-D55524F30D3E@gmail.com%3e" class="external-link" rel="nofollow">http://mail-archives.apache.org/mod_mbox/sling-users/200911.mbox/%3c8A802DC6-7472-4040-807A-D55524F30D3E@gmail.com%3e</a></p>


<h3><a name="FAQ-Howtoreplacethedefaultjsonrenderer%28forexample%29withmyown%3F"></a>How to replace the default json renderer (for example) with my own?</h3>

<p>The JSON rendering is done by the DefaultGetServlet, which is hardwired to use the JsonRendererServlet for .json extensions.</p>

<p>If a servlet or script is registered for the <tt>sling/servlet/default</tt> resource type, but with a specific <tt>sling.servlet.extensions</tt> property (set using the <tt>@scr.property</tt> annotation), it will take over and process GET requests which have a .json extension and no specific servlet or script.</p>

<p>As scripts and servlets are equivalent in Sling, the simplest way to do this to create a script at <tt>apps/sling/servlet/default/json.esp</tt>, for example.</p>

<p>The same logic applies to other extensions (html, txt, ...) handled by the DefaultGetServlet.</p>

<h3><a name="FAQ-Howtoexecutescriptsdirectly%3F"></a>How to execute scripts directly?</h3>

<p>The following servlet (inspired from the <a href="http://github.com/ieb/open-experiments/tree/334aacad2832ee2dde03eeff16f1d079314c8750/slingtests/osgikernel/bundles/scriptrunner" class="external-link" rel="nofollow">Sakai ScriptRunner</a>) executes scripts directly when called with the script URL and a <em>.runscript</em> selector (for example <em>/foo/myscript.esp.runscript.html</em>).</p>

<p>Note that this can be <b>insecure</b>: if users are allowed to upload scripts, they can execute any code supported by Sling, so use that only if you know what you're doing.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>ScriptRunnerServlet</b></div><div class="codeContent panelContent">
<pre class="code-java">
/* @scr.component
 *    immediate=<span class="code-quote">"<span class="code-keyword">true</span>"</span> label=<span class="code-quote">"ScriptRunner"</span>
 *    description=<span class="code-quote">"Runs scripts using the .runscript selector"</span>
 *
 * @scr.service
 *    <span class="code-keyword">interface</span>=<span class="code-quote">"javax.servlet.Servlet"</span>
 * @scr.property
 *    name=<span class="code-quote">"sling.servlet.resourceTypes"</span>
 *    value=<span class="code-quote">"sling/servlet/<span class="code-keyword">default</span>"</span>
 * @scr.property
 *    name=<span class="code-quote">"sling.servlet.selectors"</span>
 *    value=<span class="code-quote">"runscript"</span>
 * @scr.property
 *    name=<span class="code-quote">"sling.servlet.methods"</span>
 *    value=<span class="code-quote">"GET"</span>
 */
<span class="code-keyword">public</span> class ScriptRunnerServlet <span class="code-keyword">extends</span> SlingAllMethodsServlet {

<span class="code-keyword">protected</span> void doGet(
  SlingHttpServletRequest req,
  SlingHttpServletResponse resp)
  <span class="code-keyword">throws</span> ServletException, IOException {
    Servlet s = req.getResource().adaptTo(Servlet.class);
    <span class="code-keyword">if</span>(s == <span class="code-keyword">null</span>) {
      <span class="code-keyword">throw</span> <span class="code-keyword">new</span>
        ServletException(<span class="code-quote">"Resource "</span>
        + req.getResource()
        + <span class="code-quote">" does not adapt to a Servlet"</span>);
    }
    s.service(req, resp);
  }
}
</pre>
</div></div>

<h3><a name="FAQ-HowdoIcreateanewscriptengine%3F"></a>How do I create a new script engine?</h3>

<p>As I write this, we don't have documentation on how to create more script engines, but that's not too hard to do if you take one of the simple existing engines as an example.</p>

<p>The <a href="http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/ruby/" class="external-link" rel="nofollow">JRuby engine</a> for example, implemented in the <em>scripting/ruby</em> module, is built out of two simple classes, one that inherits from AbstractSlingScriptEngine, and one that inherits from AbstractScriptEngineFactory. The code is very simple, it's basically only a wrapper around the JRuby engine, that adapts it for Sling.</p>

<p>If creating a script engine, don't forget the <em>META-INF/services/javax.script.ScriptEngineFactory</em> file, which lets scripting subsystem know about the factory class, so that the engine is activated when the bundle that contains it is loaded.</p>

<p>Once the script engine is created, loading its bundle into Sling should be enough to activate scripts having the extension defined by the engine. If several scripts are found with the same name but different script extensions, the priority in selecting them is currently unspecified.</p>

<p>The javascript and freemarker engines source code also shows how to add automated tests to a script engine, including making a JCR repository available to the tests.</p>

<p>To go further, the javascript and jsp script engines are the most interesting ones to study.</p>

<p>The javascript engine provides <a href="http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/" class="external-link" rel="nofollow">wrappers</a> to make it easier to access JCR and Sling objects from server-side javascript, and also uses a clever <a href="http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/io/EspReader.java?view=markup" class="external-link" rel="nofollow">EspReader</a> (sorry it's not <em>that</em> <a href="http://en.wikipedia.org/wiki/Extra-sensory_perception" class="external-link" rel="nofollow">ESP</a>) to convert <em>.esp</em> scripts to plain javascript code.</p>

<p>The JSP engine is actually a compiler, so it can be an interesting example if your language needs or can benefit from compiling.</p>

<p><b>Note:</b> If the script engine you add involves compiling the scripts to Java Class files which are consumed by a classloader, it may be worth it to consider to properly seriliaze access to scripts which are under compilation to prevent paralell compilation and consequential class loading issues. Sling's JSP Engine is based on Jasper from Apache Tomcat and employs such serialization.</p>

<h2><a name="FAQ-Workingwithbundles"></a>Working with bundles</h2>

<h3><a name="FAQ-Isthereaneasywaytoupdatebundlesinarunninginstallationduringdevelopment%3F"></a>Is there an easy way to update bundles in a running installation during development?</h3>

<p>The Sling Maven Plugin provides an install goal which is able to install or update a bundle in a running Sling application (if the Sling web console is deployed). If the plugin properties are configured accordingly you can just <tt>mvn clean package org.apache.sling:maven-sling-plugin:install</tt> and the bundle is uploaded.</p>

<p>You can use the <tt>settings.xml</tt> to set the url to your Sling application. See the <a href="/confluence/pages/createpage.action?spaceKey=SLING&amp;title=Plugins&amp;linkCreation=true&amp;fromPageId=73883" class="createlink">Sling Maven Plugin</a> for more information.</p>

<h2><a name="FAQ-Classloadingissues"></a>Classloading issues</h2>

<h3><a name="FAQ-AccessingClassesfromtheEnvironment"></a>Accessing Classes from the Environment</h3>

<p>Mostly when using the Sling Web Application, that is running Sling inside a web application deployed into some servlet container, you might want to share classes between the servlet container and Sling. Some examples of such sharing are:</p>
<ol>
	<li>Accessing EJB from the Application Server</li>
	<li>Sharing classe with another web application such as a Jackrabbit instance</li>
	<li>Using other container features</li>
</ol>


<p>For such cases the OSGi Core Specification provides a functionality to declare such class sharing. The functionality is defined in terms of two Framework properties <tt>org.osgi.framework.system.packages</tt> and <tt>org.osgi.framework.bootdelegation</tt>:</p>
<ol>
	<li><tt><b>org.osgi.framework.bootdelegation</b></tt> &#45; All classes matching any entry in this list are always loaded from the parent class loader and not through the OSGi framework infrastructure. This property is a comma separated list of package names. A package name may be terminated by a wildcard character such that any package starting with the list entry matches the entry and thus will be used from the parent class loader.</li>
	<li><tt><b>org.osgi.framework.system.packages</b></tt> &#45; Additional package declarations for packages to be exported from the system bundle. This property is a simple package declaration list just like any <tt>Export-Package</tt> manifest header. In a sense the <tt>org.osgi.framework.system.packages</tt> property may be seen as the <tt>Export-Package</tt> manifest header of the system bundle. Namely these entries may not contain wildcards (as is allowed for the <tt>bootdelegation</tt> property) and may contain directives and attributes such as the <tt>uses</tt> directive and the <tt>version</tt> attribute. It is recommended to provide this additional information to help in resolving the bundles. The OSGi Core Specification even prescribes the use of the <tt>uses</tt> directive.</li>
</ol>


<p>The problem with the <tt>org.osgi.framework.bootdelegation</tt> property is, that it completely bypasses any bundle import wirings and just asks the parent classloader. Such situations are not easily recognizable. Therefore the Sling Console will be enhanced to mark any package import which matchs an entry in the <tt>org.osgi.framework.bootdelegation</tt> appropriately (<a href="ttps://issues.apache.org/jira/browse/SLING-148" class="external-link" rel="nofollow">SLING-148</a>).</p>

<p>Also note, that any package listed as an import in a bundle must be resolveable for the bundle resolve. The import resolution process does not take the <tt>org.osgi.framework.bootdelegation</tt> configuration into account. This means, that regardless of whether a package is listed in the <tt>org.osgi.framework.bootdelegation</tt> property or not, if the package is listed as a required import in the <tt>Import-Package</tt> header, it must be exported by some other bundle.</p>

<h3><a name="FAQ-Howarethe%7B%7Bsling.bootdelegation%7D%7Dpropertiesused%3F"></a>How are the <tt>sling.bootdelegation</tt> properties used ?</h3>

<p>Sling uses the <tt>sling.bootdelegation.class</tt> property name prefix to define lists of classes that must be added to the <tt>org.osgi.framework.bootdelegation</tt> property. In case you want to have a closer look, this is implemented in the <tt>org.apache.sling.launcher.app.Sling.resolve()</tt> method.</p>

<p>If a Sling property name starts with the <tt>sling.bootdelegation.class.</tt> prefix, the list of packages defined as the property value is appended to the <tt>org.osgi.framework.bootdelegation</tt> property, but only if the fully qualified class taken from the rest of the property name exists in the parent class loader.</p>

<p>Here's an example, from the jcr-client.properties file:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
sling.bootdelegation.class.javax.jcr.Repository = \
 javax.jcr, \
 javax.jcr.lock, \
 javax.jcr.nodetype, \
 javax.jcr.observation, \
 javax.jcr.query, \
 javax.jcr.util, \
 javax.jcr.version
</pre>
</div></div>

<p>This means that, if the <tt>javax.jcr.Repository</tt> class is available in the parent class loader, all packages listed will be added to the <tt>org.osgi.framework.bootdelegation</tt>, making the corresponding classes available to OSGi bundles.</p>

<p>If the property name does not start with this <tt>sling.bootdelegation.class.</tt> property, the list of packages is just appended to the <tt>org.osgi.framework.bootdelegation</tt> property.</p>

<h3><a name="FAQ-HowdoesSlingsupportthe%7B%7Borg.osgi.framework.system.packages%7D%7DProperty%3F"></a>How does Sling support the <tt>org.osgi.framework.system.packages</tt> Property ?</h3>

<p>Currently extending the <tt>org.osgi.framework.system.packages</tt> property in a Sling configuration file is only possibly by setting the <tt>org.apache.sling.launcher.system.packages</tt> property. The value of this property, which <em>must</em> start with a comma, is just appended to the <tt>org.osgi.framewrok.system.packages</tt> property.</p>

<p>A more elaborate support as is supported for the <tt>org.osgi.framework.bootdelegation</tt> Property has been prepared (<a href="http://issues.apache.org/jira/browse/SLING-147" class="external-link" rel="nofollow">SLING-147</a>).</p>

<h3><a name="FAQ-Shouldthe%7B%7Borg.osgi.framework.bootdelegation%7D%7Dorthe%7B%7Borg.osgi.framework.system.packages%7D%7DPropertybeused%3F"></a>Should the <tt>org.osgi.framework.bootdelegation</tt> or the <tt>org.osgi.framework.system.packages</tt> Property be used ?</h3>

<p>So, what mechanism should be used ? The answer is, that it depends.</p>

<p>Most of the time, you will want to use the <tt>org.osgi.framework.system.packages</tt> property. Because this property ensures that you will allways benefit from the normal class resolution mechanism through package imports and exports.</p>

<p>This allows creating the bundles normally by having the package import lists being built according to the packages used by the bundle classes. For example you may use the Apache Felix Maven Bundle Plugin to build your OSGi bundles and the imports are automatically calculated (by default).</p>

<p>The drawback of this method is, that there may be bundles in your system, which export packages also listed in the <tt>org.osgi.framework.system.packages</tt> property. Depending on the export version, the wrong package may be bound. So to prevent such collisions you should not install such bundles.</p>

<p>An example of such a declaration is the Servlet API packages (<tt>javax.servlet</tt>, <tt>javax.servlet.http</tt> and <tt>javax.servlet.resources</tt>). These packages are imported into the OSGi framework by the <tt>SlingServlet</tt> of the <tt>launcher/webapp</tt> project as part of the <tt>org.osgi.framework.system.packages</tt> property. To have this work correctly, no bundle should export the respective packages. In the case of Sling, this means, the <tt>org.apache.felix.commons.sling-api</tt> bundle must not be installed.</p>

<p>If on the other hand you cannot prevent the installation of such bundles and hence the export of the respective packages, you might want to set the <tt>org.osgi.framework.bootdelegation</tt> property conditionally as described above in the answer to how this property is supported in Sling. This ensures the property is only set, if the classes are actually available. This should be used as a fall back only, if the <tt>org.osgi.framework.system.packages</tt> method does not work.</p>


<h3><a name="FAQ-HowtosharesessionbetweenSlingandotherwebapplications%3F"></a>How to share session between Sling and other web applications?</h3>

<p>It is some times required to share HTTP session between Sling and other web applications. This is typically needed when existing Web MVC applicatios are getting migrated to Sling.<br/>
Most leading application servers (Oracle Weblogic, IBM Websphere) allow feature called 'shared session context'. It is allowed to share HTTP session between two web applications packaged in single EAR archive.<br/>
For sharing session with Sling, you need to package launchpad.war in to the EAR with other WARs. Sling is little tricky, because its not just a WAR. Its based on OSGI and on top of Web application classloading rules, it is also bounded by OSGI classloading rules.<br/>
I will explain configuration with weblogic here, because thats what I have tried out. Configuration in IBM Websphere should be similar.</p>


<p>The approach to share classes and session in Sling with other web<br/>
application in weblogic is as following.</p>

<p>1. Package CQ/Sling as web application in an existing EAR.<br/>
2. Deploy system.bundle extension fragment exporting all the packages<br/>
that you need to access in CQ.<br/>
3. In Weblogic, there are two ways to share classes<br/>
a) Put all the shared jars in APP-INF/lib directory in EAR. With<br/>
this approach you do not need Class-Path entries in MANIFEST.MF. And<br/>
classes are loaded by EAR classloader.<br/>
b) Put jars in some common lib in ear. Say EAR/lib. Then in all<br/>
the web applications have Class-path entry in MANIFEST.MF to list the<br/>
jars in EAR/lib. Make sure all the classes in shared jars are<br/>
serializable.<br/>
Update MANIFEST.MF in launchpad.war to have same Class-Path entries.<br/>
Now whenever you access a session object by<br/>
request.getSession().getAttribute(), the object will be serialized,<br/>
and then deserialized again. While deserialzing, it will resolve class<br/>
by Launchpad's classloader.</p>

<p>APP-INF/lib is the prefered approach to MANIFEST.MF, as the later<br/>
is adding unnecessary overhead of serialization and deserialization<br/>
for session sharing within same JVM.</p>

<p>In J2EE 5, there is addition of library element in<br/>
application.xml in EAR, which allows you to define EAR level library.<br/>
That is much cleaner than above two approaches.</p>

<p>There is one more approach that was tried out in our case. This is buggy and will not work, but I am explaining it here so that anyone else trying it out knows that it does not work.</p>

<p>1. In this approach, instead of deploying a system.bundle extension fragment, you package all the shared jars in an OSGI bundle and export all the shared packages from that bundle.<br/>
2. This seems to resolve classes only in JSPs in sling but fails in Sling servlets with ClassCastException.<br/>
The reason for this is as following.<br/>
Weblogic uses context classloader of the thread to resolve classes while deserializing session objects. When JSP is processed in Sling, the context classloader is set to org.apache.sling.commons.classloader.impl.ClassLoaderFacade<br/>
This classloader can find all the classes ex ported from OSGI bundles loaded in felix.<br/>
So, when session attributes are accessed from migrated JSPs in Sling, the objects used to get serialized, and then deserialized. While deserializing, the classes were resolved by org.apache.sling.commons.classloader.impl.ClassLoaderFacade.</p>

<p>Even if it appeared to work fine, this is not the right solution for the problem at all. The worst part here is that, once the object is deserialized, weblogic replaces original object reference to the deserialized object. So if any other WAR needs the object again, it needs to be serialized/deserialized again. But that works only if original object is loaded with weblogic classloader. So once object is serialized/deserialized with Sling classloader, it will never be serialized/deserialized for other WARs and you will always get ClassCastException. </p>

<p>It did not work with Sling Servlets because, when servlet is executed, the context classloader is weblogic.utils.classloaders.ChangeAwareClassLoader. This classloader finds classes in EAR or classpath, so we get ClassCastException. Even here, some weblogic classloader magic is going on. The context classloader here, is the classloader for launchpad.war. This is the WAR file for Sling. The classes referred by servlet can not be loaded by this classloader, because classes exported from OSGI bundles are not visible to this classloader. So welogic, seeing the ClassNotFoundException from context classloader, uses the WAR classloader of the WAR which set the object in the session. Obviously, we get ClassCastException in the sling servlet.</p>


<p>So class/session sharing should never be done with classes packaged<br/>
and exported in an OSGI bundle. Relying on weblogic to serialize and<br/>
deserialize is always likely to fail.</p>

<p>System fragment extensions is the only safer approach in this case.</p>


<h2><a name="FAQ-Miscellaneous"></a>Miscellaneous</h2>

<h3><a name="FAQ-Whycan%27tIconnecttoSling%27sWebDAVusingWindowsNetworkDriveMapping%3F"></a>Why can't I connect to Sling's WebDAV using Windows NetworkDriveMapping ?</h3>

<p>Since Windows XP SP 2 (thus also affects Windows Vista, Windows 7, etc.) support for HTTP Basic authentication is by default switched off unless using HTTPS. Support can be switched on again by setting a Windows registry value. See Microsoft Knowledge Base entry <a href="http://support.microsoft.com/kb/841215" class="external-link" rel="nofollow">841215</a> for full details and warnings regarding modifying registry entries.</p>

<h3><a name="FAQ-WhyismyWebDAVconnectionsoslowonWindows%3F"></a>Why is my WebDAV connection so slow on Windows ?</h3>

<p>One reason might be automatic proxy detection being enabled in the Internet Options. See the <a href="http://oddballupdate.com/2009/12/18/fix-slow-webdav-performance-in-windows-7/" class="external-link" rel="nofollow">Fix Slow WebDAV Performance in Windows 7</a> for the solution.</p>

<h3><a name="FAQ-WhyshouldIusethesling%3AFoldernodetypeinsteadofnt%3Afolder%3F"></a>Why should I use the sling:Folder node type instead of nt:folder ?</h3>

<p>As you can see in the <a href="http://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/resource/src/main/resources/SLING-INF/nodetypes/folder.cnd" class="external-link" rel="nofollow">folder.cnd</a> file (in <a href="http://jackrabbit.apache.org/node-type-notation.html" class="external-link" rel="nofollow">CND notation</a>), <tt>sling:Folder</tt> inherits from <tt>nt:folder</tt> and in addition allows any single or multi-valued property, and any child node with <tt>sling:Folder</tt> as the default child node type. The <tt>nt:folder</tt> node type is much more restrictive.</p>

<p>In general, using <tt>sling:Folder</tt> is recommended, as it's more flexible.</p>

<h3><a name="FAQ-Howtochangetheservice.rankingofaservicethroughconfiguration%3F"></a>How to change the service.ranking of a service through configuration?</h3>

<p>This is possible even if that property is not exposed in the configuration admin (either if the service is not a meta type or if the property is private). You can use jcrinstall to configure services by placing the configuration inside a <tt>config</tt> folder, for example <tt>/apps/myapp/config/&lt;myservice-pid&gt;.&lt;extension&gt;</tt> (extension depends on the config format). Note that "service.ranking" must be an Integer property, which you need to explicitly specify. This is currently only possible if you use the properties file format (see <a href="https://issues.apache.org/jira/browse/SLING-2477" class="external-link" rel="nofollow">SLING-2477</a> for more).</p>

<p>For example, to make a service named "com.foo.app.impl.MyServiceImpl" have a ranking of 1234:</p>

<ul>
	<li>create a file <tt>/apps/myapp/config/com.foo.app.impl.MyServiceImpl.config</tt></li>
	<li>contents must be one line: <tt>service.ranking=I"1234"</tt> (I stands for Integer)</li>
</ul>

    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action" class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/SLING/FAQ">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=73883&revisedVersion=34&originalVersion=33">View Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/SLING/FAQ?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message