You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by bu...@apache.org on 2013/07/22 10:10:48 UTC

svn commit: r870547 - in /websites/staging/felix/trunk/content: ./ documentation/subprojects/apache-felix-script-console-plugin.html

Author: buildbot
Date: Mon Jul 22 08:10:47 2013
New Revision: 870547

Log:
Staging update by buildbot for felix

Modified:
    websites/staging/felix/trunk/content/   (props changed)
    websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-script-console-plugin.html

Propchange: websites/staging/felix/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Mon Jul 22 08:10:47 2013
@@ -1 +1 @@
-1505617
+1505620

Modified: websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-script-console-plugin.html
==============================================================================
--- websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-script-console-plugin.html (original)
+++ websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-script-console-plugin.html Mon Jul 22 08:10:47 2013
@@ -87,14 +87,16 @@ features</p>
 <p>After installing it you would see a new tab "Script Console" in <a href="http://localhost:4502/system/console">Felix Web Console</a>.
 The plugin screen provides a textarea to author script code. One can select the language via the given dropdown. The generated
 output is shown in pane below.</p>
-<p>The script exposes following variables
-<em> <code>request</code> - Current HttpServletRequest instance
-</em> <code>response</code> - Current HttpServletResponse instance
-<em> <code>reader</code> - Direct access to the Reader of the request - same as request.getReader(). Use it for reading the data of an HTTP request body.
-</em> <code>out</code> - Direct access to the PrintWriter of the response - same as response.getWriter(). Use it for writing to the HTTP response body.
-<em> <code>osgi</code> -  Provides convenience methods for scripts, mainly osgi.getService(foo.bar.Service.class) to retrieve OSGi services available in
-   OSGi Container (Class notation depending on scripting language).
-</em> <code>bundleContext</code> - OSGi BundleContext instance for the script console plugin bundle. Can be used to access the OSGi runtime</p>
+<p>The script exposes following variables</p>
+<ul>
+<li><code>request</code> - Current HttpServletRequest instance</li>
+<li><code>response</code> - Current HttpServletResponse instance</li>
+<li><code>reader</code> - Direct access to the Reader of the request - same as request.getReader(). Use it for reading the data of an HTTP request body.</li>
+<li><code>out</code> - Direct access to the PrintWriter of the response - same as response.getWriter(). Use it for writing to the HTTP response body.</li>
+<li><code>osgi</code> -  Provides convenience methods for scripts, mainly osgi.getService(foo.bar.Service.class) to retrieve OSGi services available in
+   OSGi Container (Class notation depending on scripting language).</li>
+<li><code>bundleContext</code> - OSGi BundleContext instance for the script console plugin bundle. Can be used to access the OSGi runtime</li>
+</ul>
 <p>So simplest script that can work is</p>
 <div class="codehilite"><pre><span class="n">out</span><span class="o">.</span><span class="na">println</span> <span class="o">(</span><span class="s2">&quot;Hello world!!&quot;</span><span class="o">);</span>
 </pre></div>
@@ -130,24 +132,24 @@ output is shown in pane below.</p>
 <h3 id="sample-scripts">Sample Scripts</h3>
 <p>Following are some sample scripts in Groovy. Note the scripts might be depending on implementation details to access the
 relevant data structures</p>
+<p>1 Script to find out servlets which are registered problematically with Felix HTTP Service</p>
+<div class="codehilite"><pre>    :::groovy
+    import org.osgi.service.http.HttpService
+    import org.osgi.framework.FrameworkUtil
+    import org.osgi.framework.Bundle
+
+    def httpService = osgi.getService(HttpService.class)
+    httpService.handlerRegistry.aliasMap.each{alias,servlet -&gt;
+        Bundle bnd = FrameworkUtil.getBundle(servlet.class)
+        println &quot;<span class="nv">$alias</span> : <span class="cp">${</span><span class="n">servlet</span><span class="o">.</span><span class="n">class</span><span class="o">.</span><span class="n">name</span><span class="cp">}</span> (<span class="nv">$bnd.symbolicName</span>)&quot;
+    }
+</pre></div>
+
+
 <ol>
 <li>
-<p>Script to find out servlets which are registered problematically with Felix HTTP Service</p>
-<p>:::groovy
-import org.osgi.service.http.HttpService
-import org.osgi.framework.FrameworkUtil
-import org.osgi.framework.Bundle</p>
-<p>def httpService = osgi.getService(HttpService.class)
-httpService.handlerRegistry.aliasMap.each{alias,servlet -&gt;
-    Bundle bnd = FrameworkUtil.getBundle(servlet.class)
-    println "$alias : ${servlet.class.name} ($bnd.symbolicName)"
-}</p>
-</li>
-<li>
-<p>Script to load a class which is not exported and then invoke some static method on that class</p>
-</li>
-</ol>
-<p>At times you need to access some private class to see the runtime state.</p>
+<p>Script to load a class which is not exported and then invoke some static method on that class. At times you need to
+access some private class to see the runtime state.</p>
 <div class="codehilite"><pre><span class="kn">import</span> <span class="nn">org.osgi.framework.Bundle</span>
 <span class="kn">import</span> <span class="nn">org.osgi.framework.BundleContext</span>
 
@@ -175,26 +177,31 @@ httpService.handlerRegistry.aliasMap.eac
 </pre></div>
 
 
-<ol>
+</li>
 <li>
 <p>Script to find out which bundle embeds a given class</p>
-<p>:::groovy
-import org.osgi.framework.Bundle
-import org.osgi.framework.BundleContext</p>
-<p>//Name of the class
-def className = "org.apache.sling.engine.impl.SlingMainServlet"</p>
-<p>def resPath = className.replaceAll('.','/')+".class"
-def bundles = bundleContext.getBundles().findAll{Bundle b -&gt;
-    b.getEntry(resPath) != null
-}</p>
-<p>println "Following bundles have the class"
-bundles.each{
-    println it
-}</p>
+<div class="codehilite"><pre><span class="kn">import</span> <span class="nn">org.osgi.framework.Bundle</span>
+<span class="kn">import</span> <span class="nn">org.osgi.framework.BundleContext</span>
+
+<span class="c1">//Name of the class</span>
+<span class="kt">def</span> <span class="n">className</span> <span class="o">=</span> <span class="s2">&quot;org.apache.sling.engine.impl.SlingMainServlet&quot;</span>
+
+<span class="kt">def</span> <span class="n">resPath</span> <span class="o">=</span> <span class="n">className</span><span class="o">.</span><span class="na">replaceAll</span><span class="o">(</span><span class="s1">&#39;.&#39;</span><span class="o">,</span><span class="s1">&#39;/&#39;</span><span class="o">)+</span><span class="s2">&quot;.class&quot;</span>
+<span class="kt">def</span> <span class="n">bundles</span> <span class="o">=</span> <span class="n">bundleContext</span><span class="o">.</span><span class="na">getBundles</span><span class="o">().</span><span class="na">findAll</span><span class="o">{</span><span class="n">Bundle</span> <span class="n">b</span> <span class="o">-&gt;</span>
+    <span class="n">b</span><span class="o">.</span><span class="na">getEntry</span><span class="o">(</span><span class="n">resPath</span><span class="o">)</span> <span class="o">!=</span> <span class="kc">null</span>
+<span class="o">}</span>
+
+<span class="n">println</span> <span class="s2">&quot;Following bundles have the class&quot;</span>
+<span class="n">bundles</span><span class="o">.</span><span class="na">each</span><span class="o">{</span>
+    <span class="n">println</span> <span class="n">it</span>
+<span class="o">}</span>
+</pre></div>
+
+
 </li>
 </ol>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1505617 by chetanm on Mon, 22 Jul 2013 08:03:10 +0000
+        Rev. 1505620 by chetanm on Mon, 22 Jul 2013 08:10:39 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Felix, Felix, Apache, the Apache feather logo, and the Apache Felix project