[
https://issues.apache.org/jira/browse/KARAF-5202?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16046735#comment-16046735
]
Denis Jouvin commented on KARAF-5202:
-------------------------------------
Here is the help from the Groovy side, including help on the 3 OSGi and Karaf
related Groovy commands introduced in my prototype implementation
({{:osgi-service}}, {{:blueprint}} and {{:karaf}}).
The 2 first commands (prefixed with {{get}} and in camel-case), are also
available as Groovy closures (accessible from the current Groovysh session
binding).
{noformat}
groovy:000> :help
Available commands:
:help (:h ) Display this help message
? (:? ) Alias to: :help
:exit (:x ) Exit the shell
:quit (:q ) Alias to: :exit
import (:i ) Import a class into the namespace
:display (:d ) Display the current buffer
:clear (:c ) Clear the buffer and reset the prompt counter
:show (:S ) Show variables, classes or imports
:inspect (:n ) Inspect a variable or the last result with the GUI
object browser
:purge (:p ) Purge variables, classes, imports or preferences
:edit (:e ) Edit the current buffer
:load (:l ) Load a file or URL into the buffer
. (:. ) Alias to: :load
:save (:s ) Save the current buffer to a file
:record (:r ) Record the current session to a file
:history (:H ) Display, manage and recall edit-line history
:alias (:a ) Create an alias
:set (:= ) Set (or list) preferences
:register (:rc) Register a new command with the shell
:doc (:D ) Open a browser window displaying the doc for the argument
:osgi-service (:os) Resolve an OSGi service and assign it to a variable
:blueprint (:bp) Resolve a blueprint container and assign it to a variable
:karaf (:k ) Executes a Karaf command (from current Karaf session)
For help on a specific command type:
:help command
groovy:000> :help :karaf
usage: :karaf [<arg1> [<arg2> [...]]]
Executes a Karaf command from the current Karaf session.Arguments are passed
through without specific
(un)escaping or (un)quoting that may happen atGroovy or Karaf side. A trick is
to escape double-quoted
arguments in single-quotes and vice versa.
groovy:000> :help :osgi-service
usage: :osgi-service <variableName> <serviceInterface> [<ldapFilter>]
Resolve the best matching OSGi service with the given interface, (i.e. with the
highest ranking and,
if equal, lowest ID), possibly using the given LDAP filter if any, and bind it
a local variable
groovy:000> :help :blueprint
usage: :blueprint <variableName> <bundleSymbolicName> [<bundleVersion>]
Resolves the blueprint container OSGi service for the given bundle symbolic
name (and version
if specified), and binds it to a shell variable.
{noformat}
> Groovy and groovysh integration into Karaf console
> --------------------------------------------------
>
> Key: KARAF-5202
> URL: https://issues.apache.org/jira/browse/KARAF-5202
> Project: Karaf
> Issue Type: New Feature
> Components: karaf-shell
> Reporter: Denis Jouvin
> Assignee: Jean-Baptiste Onofré
> Priority: Minor
> Labels: Groovy, Groovysh, Karaf, ShellCommands
>
> The idea is to integrate Groovy into Karaf as an alternative scripting and/or
> interactive shell language. Since Groovysh also uses JLine, integration is
> quite easy (pass the current Jline console/session instance to Groovysh at
> construction time). There are some class loading issues though since Groovy
> uses sometimes the TCCL even when we instruct it to use a given class loader
> (I opened a Groovy JIRA issue about that).
> The Groovysh shell then would allow to get OSGi service reference or
> Blueprint/Spring context references, or execute Karaf commands. Groovysh has
> a very nice command completion feature that enable to discover any objet
> (including OSGi service instance) API at runtime, which makes it very easy to
> play with in a dynamic environment like Karaf. In addition, its native
> closures and set operations, and very concise syntaxe, facilitates its use as
> a shell replacement.
> This open nice possibilites like exploratory programming on a live running
> Karaf instance, scripting, tests or analysis, etc.
> Another common use case is to modify a not yet parameterized value in a
> Blueprint or Spring context at runtime (you can browse or access the
> Blueprint context components, and reinstaciate them or inject properties).
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)