This is an automated email from the ASF dual-hosted git repository. djencks pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/felix-antora-site.git
commit ee60a5195d130c28253198dcbe59ec0e46d0db3a Author: David Jencks <[email protected]> AuthorDate: Sun Jul 11 15:51:10 2021 -0700 remove script-console-plugin doc (unmaintained) --- modules/ROOT/pages/documentation/subprojects.adoc | 2 +- .../apache-felix-script-console-plugin.adoc | 170 --------------------- 2 files changed, 1 insertion(+), 171 deletions(-) diff --git a/modules/ROOT/pages/documentation/subprojects.adoc b/modules/ROOT/pages/documentation/subprojects.adoc index 567554d..7f192ca 100644 --- a/modules/ROOT/pages/documentation/subprojects.adoc +++ b/modules/ROOT/pages/documentation/subprojects.adoc @@ -126,7 +126,7 @@ The last documentation may be found in the https://github.com/apache/felix-site- * https://github.com/apache/felix-site-pub/blob/last-cms/documentation/subprojects/apache-felix-maven-scr-plugin.html[Maven SCR Plugin] * https://github.com/apache/felix-site-pub/blob/last-cms/documentation/subprojects/mosgi-managed-osgi-framework.html[MOSGi Managed OSGi framework] * https://github.com/apache/felix-site-pub/blob/last-cms/documentation/subprojects/apache-felix-osgi-core.html[OSGi Core] -* xref:documentation/subprojects/apache-felix-script-console-plugin.adoc[Script Console Plugin] +* https://github.com/apache/felix-site-pub/blob/last-cms/documentation/subprojects/apache-felix-script-console-plugin.html[Script Console Plugin] * xref:documentation/subprojects/apache-felix-serialization-framework.adoc[Serialization Framework] * xref:documentation/subprojects/apache-felix-upnp.adoc[UPnP] * xref:documentation/subprojects/apache-felix-user-admin.adoc[User Admin] diff --git a/modules/ROOT/pages/documentation/subprojects/apache-felix-script-console-plugin.adoc b/modules/ROOT/pages/documentation/subprojects/apache-felix-script-console-plugin.adoc deleted file mode 100644 index 32d53f3..0000000 --- a/modules/ROOT/pages/documentation/subprojects/apache-felix-script-console-plugin.adoc +++ /dev/null @@ -1,170 +0,0 @@ -= Apache Felix Script Console Plugin - -Script Console is a Felix web console plugin which allows evaluation of scripts within the OSGi container. -It provides following features - -* Support evaluation of script in any e.g. -Groovy, JavaScript, Ruby etc. -You would need to ensure that relevant language bundle is deployed -* Code editor with syntax highlighting support based on http://codemirror.net/[CodeMirror] Javascript library -* Hot key support -* Execute remote testcase via evaluating test scripts - -== Installation - -To make use of this plugin you need to - -=== A - Install the Script Console Plugin bundle - -Refer to http://felix.apache.org/downloads.cgi[downloads] for getting the bundle. - -For Maven use following coordinates -[source,xml] - <dependency> - <groupId>org.apache.felix</groupId> - <artifactId>org.apache.felix.webconsole.plugins.scriptconsole</artifactId> - <version>1.0.0</version> - </dependency> - -For latest build follow steps below - - $svn co https://svn.apache.org/repos/asf/felix/trunk/webconsole-plugins/script-console/ - $cd script-console - $mvn clean install - $mvn org.apache.sling:maven-sling-plugin:2.1.0:install -Dsling.url=http://localhost:8080/system/console - -=== B- Install the language specific bundle - -Install bundles for the Script Language you want to use - -* http://repo1.maven.org/maven2/org/codehaus/groovy/groovy-all/2.1.6/groovy-all-2.1.6.jar[Groovy] -* http://repo1.maven.org/maven2/org/jruby/jruby/1.7.4/jruby-1.7.4.jar[JRuby] - -== Usage - -After installing it you would see a new tab "Script Console" in Felix Web Console. -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. - -The script exposes following variables - -* `request` - Current HttpServletRequest instance -* `response` - Current HttpServletResponse instance -* `reader` - Direct access to the Reader of the request - same as request.getReader(). -Use it for reading the data of an HTTP request body. -* `out` - Direct access to the PrintWriter of the response - same as response.getWriter(). -Use it for writing to the HTTP response body. -* `osgi` - 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). -* `bundleContext` - OSGi BundleContext instance for the script console plugin bundle. -Can be used to access the OSGi runtime - -So simplest script that can work is - -[source,groovy] - out.println ("Hello world!!"); - -To access a service use `osgi.getService` - -[source,groovy] - def httpService = osgi.getService(org.osgi.service.http.HttpService.class) - -To access a service satisfying OSGi filter - -[source,groovy] - def eventPlugin = osgi.getServices(javax.servlet.Servlet.class,'(felix.webconsole.label=events)')[0] - -Following hotkeys work - -* Ctrl+F9 - Execute the script -* Ctrl+q - Clear the output - -== HTTP API - -The plugin can also be invoked by making POST request. -It supports following parameters - -* `code`- Script content. -Can be norm form data or a multi part content -* `lang` - Language extension. - ** Groovy - groovy - ** JavaScript - esp - -If any exception occurs while evaluating the script then it would return the exception message with status set to 500. -Scripts can control what output they want to emit. - -== Sample Scripts - -Following are some sample scripts in Groovy. -Note the scripts might be depending on implementation details to access the relevant data structures - -. Script to find out servlets which are registered problematically with Felix HTTP Service -+ -[source,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 -> - Bundle bnd = FrameworkUtil.getBundle(servlet.class) - println "$alias : ${servlet.class.name} ($bnd.symbolicName)" - } ----- - -. 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. -+ -[source,groovy] ----- - import org.osgi.framework.Bundle - import org.osgi.framework.BundleContext - - //Script to load a class which is not exported and then invoke some static method on that class - - //Name of the class - def className = "org.apache.sling.engine.impl.SlingMainServlet" - - def resPath = className.replaceAll('.','/')+".class" - def bundles = bundleContext.getBundles().findAll{Bundle b -> - b.getEntry(resPath) != null - } - - if(!bundles){ - println "No bundle found for class $className" - return - } - - def b = bundles.asList().first() - def clazz = b.loadClass(className) - - //Invoke some static method - def result = clazz.metaClass.invokeStaticMethod(clazz, 'foo', arg1) - println result ----- - -. Script to find out which bundle embeds a given class -+ -[source,groovy] ----- - import org.osgi.framework.Bundle - import org.osgi.framework.BundleContext - - //Name of the class - def className = "org.apache.sling.engine.impl.SlingMainServlet" - - def resPath = className.replaceAll('.','/')+".class" - def bundles = bundleContext.getBundles().findAll{Bundle b -> - b.getEntry(resPath) != null - } - - println "Following bundles have the class" - bundles.each{ - println it - } ----- - -== Screenshots - -image::documentation/subprojects/script-console-1.png[]
