You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@clerezza.apache.org by Reto Bachmann-Gmuer <re...@trialox.org> on 2010/12/01 13:52:53 UTC

New shell

I've just switched to the new Scala based shell in our launchers. What does
this involve?

You'll notice that you're using the new shell by the zz> prompt

This is how you are greated:

> Welcome to the Apache Clerezza Console
> Console is based on Scala version 2.8.0.final (OpenJDK 64-Bit Server VM,
> Java 1.6.0_20).
> Type in expressions to have them evaluated.
> Hint: To execute a Felix-Shell command prepend ":f "
> Type :help for more information.
> zz>
>

You're now using a scala shell and interpret scala code

zz>val m = "hello world"
> m: java.lang.String = hello world
> zz>println(m)
> hello world
>

You can also access the bundleContext

zz>val b = bundleContext.getBundle(0)
> b: org.osgi.framework.Bundle = org.apache.felix.framework [0]
> zz>b.getHeaders
> res4: java.util.Dictionary[_, _] = {Bundle-Description=This bundle is
> system specific; it implements various system services.,
> Bundle-ManifestVersion=2, Bundle-Name=System Bundle,
> Bundle-SymbolicName=org.apache.felix.framework, Bundle-Version=3.0.3,
> Export-Package=org.osgi.framework; version="1.5.0",
> org.osgi.framework.launch; version="1.0.0",
> org.osgi.framework.hooks.service; version="1.0.0",
> org.osgi.service.packageadmin; version="1.2.0", org.osgi.service.startlevel;
> version="1.1.0", org.osgi.service.url; version="1.0.0",
> org.osgi.util.tracker; version="1.4.0", javax.accessibility;
> version="0.0.0.1_006_JavaSE", javax.activation;
> version="0.0.0.1_006_JavaSE", javax.activity; version="0.0.0.1_006_JavaSE",
> javax.annotation; version="0.0.0.1_006_JavaSE", javax.annotation.processing;
> versi...zz>
> zz>
>

The console supports autocompletion with the TAB-key:

zz>b.[TAB]
>
> asInstanceOf                    findEntries
> getBundleContext                getBundleId
> getEntry                        getEntryPaths
> getHeaders                      getLastModified
> getLocation                     getPersistentState
> getRegisteredServices           getResource
> getResources                    getServicesInUse
> getSignerCertificates           getState
> getSymbolicName                 getVersion
> hasPermission                   init
> isInstanceOf                    loadClass
> setPersistentStateActive        setPersistentStateInactive
> setPersistentStateUninstalled   start
> stop                            toString
> uninstall                       update
> waitForStop
>

You can access services using the syntax $[serviceInterface]

> zz>val tcManager = $[rdf.core.access.TcManager]
> tcManager: org.apache.clerezza.rdf.core.access.TcManager =
> org.apache.clerezza.rdf.core.access.TcManager@6241ad5d
> zz>import scala.collection.JavaConversions._
> import scala.collection.JavaConversions._
> zz>for (g <- tcManager.listMGraphs) {println(g)}
> <http://zz.localhost/enrichment.graph>
> <http://zz.localhost/graph-access.graph>
> <http://tpf.localhost/content.graph>
> <http://tpf.localhost/config.graph>
> <http://tpf.localhost/system.graph>
> <http://zz.localhost/web-resources.graph>
>

While one could do all OSGi stuff using the bundleContext an DSL makes
things easier, it currently is very incomplete, but is hould be easy to add
everything that is frequently needed:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.shell/src/main/scala/org/apache/clerezza/shell/OsgiDsl.scala?view=markup

> zz>install("mvn:example/example")
> zz>shutdown
>

but as long as some command are missing in the DSL, there's still the
possibility to execute felix shell commands

> zz>:f scr list
>    Id   State          Name
> [   0] [active       ]
> org.apache.clerezza.platform.security.BundlePermissionManager
> ...
>

Cheers,
reto

Re: New shell

Posted by Tommaso Teofili <to...@gmail.com>.
Hello Reto,
I found it cool from the first time we talked about it :-)
Also I'd maintain the possibility to switch to Felix console in the future
to provide a familiar shell environment to people new to Clerezza.
Cheers,
Tommaso

2010/12/1 Reto Bachmann-Gmuer <re...@trialox.org>

> I've just switched to the new Scala based shell in our launchers. What does
> this involve?
>
> You'll notice that you're using the new shell by the zz> prompt
>
> This is how you are greated:
>
> > Welcome to the Apache Clerezza Console
> > Console is based on Scala version 2.8.0.final (OpenJDK 64-Bit Server VM,
> > Java 1.6.0_20).
> > Type in expressions to have them evaluated.
> > Hint: To execute a Felix-Shell command prepend ":f "
> > Type :help for more information.
> > zz>
> >
>
> You're now using a scala shell and interpret scala code
>
> zz>val m = "hello world"
> > m: java.lang.String = hello world
> > zz>println(m)
> > hello world
> >
>
> You can also access the bundleContext
>
> zz>val b = bundleContext.getBundle(0)
> > b: org.osgi.framework.Bundle = org.apache.felix.framework [0]
> > zz>b.getHeaders
> > res4: java.util.Dictionary[_, _] = {Bundle-Description=This bundle is
> > system specific; it implements various system services.,
> > Bundle-ManifestVersion=2, Bundle-Name=System Bundle,
> > Bundle-SymbolicName=org.apache.felix.framework, Bundle-Version=3.0.3,
> > Export-Package=org.osgi.framework; version="1.5.0",
> > org.osgi.framework.launch; version="1.0.0",
> > org.osgi.framework.hooks.service; version="1.0.0",
> > org.osgi.service.packageadmin; version="1.2.0",
> org.osgi.service.startlevel;
> > version="1.1.0", org.osgi.service.url; version="1.0.0",
> > org.osgi.util.tracker; version="1.4.0", javax.accessibility;
> > version="0.0.0.1_006_JavaSE", javax.activation;
> > version="0.0.0.1_006_JavaSE", javax.activity;
> version="0.0.0.1_006_JavaSE",
> > javax.annotation; version="0.0.0.1_006_JavaSE",
> javax.annotation.processing;
> > versi...zz>
> > zz>
> >
>
> The console supports autocompletion with the TAB-key:
>
> zz>b.[TAB]
> >
> > asInstanceOf                    findEntries
> > getBundleContext                getBundleId
> > getEntry                        getEntryPaths
> > getHeaders                      getLastModified
> > getLocation                     getPersistentState
> > getRegisteredServices           getResource
> > getResources                    getServicesInUse
> > getSignerCertificates           getState
> > getSymbolicName                 getVersion
> > hasPermission                   init
> > isInstanceOf                    loadClass
> > setPersistentStateActive        setPersistentStateInactive
> > setPersistentStateUninstalled   start
> > stop                            toString
> > uninstall                       update
> > waitForStop
> >
>
> You can access services using the syntax $[serviceInterface]
>
> > zz>val tcManager = $[rdf.core.access.TcManager]
> > tcManager: org.apache.clerezza.rdf.core.access.TcManager =
> > org.apache.clerezza.rdf.core.access.TcManager@6241ad5d
> > zz>import scala.collection.JavaConversions._
> > import scala.collection.JavaConversions._
> > zz>for (g <- tcManager.listMGraphs) {println(g)}
> > <http://zz.localhost/enrichment.graph>
> > <http://zz.localhost/graph-access.graph>
> > <http://tpf.localhost/content.graph>
> > <http://tpf.localhost/config.graph>
> > <http://tpf.localhost/system.graph>
> > <http://zz.localhost/web-resources.graph>
> >
>
> While one could do all OSGi stuff using the bundleContext an DSL makes
> things easier, it currently is very incomplete, but is hould be easy to add
> everything that is frequently needed:
>
> http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.shell/src/main/scala/org/apache/clerezza/shell/OsgiDsl.scala?view=markup
>
> > zz>install("mvn:example/example")
> > zz>shutdown
> >
>
> but as long as some command are missing in the DSL, there's still the
> possibility to execute felix shell commands
>
> > zz>:f scr list
> >    Id   State          Name
> > [   0] [active       ]
> > org.apache.clerezza.platform.security.BundlePermissionManager
> > ...
> >
>
> Cheers,
> reto
>