Author: chetanm
Date: Thu Dec  3 08:39:30 2015
New Revision: 1717724

URL: http://svn.apache.org/viewvc?rev=1717724&view=rev
Log:
OAK-3687 - Oak standalone application example based on Spring Boot

Update readme to include example for script console

Modified:
    jackrabbit/oak/trunk/oak-examples/standalone/README.md

Modified: jackrabbit/oak/trunk/oak-examples/standalone/README.md
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-examples/standalone/README.md?rev=1717724&r1=1717723&r2=1717724&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-examples/standalone/README.md (original)
+++ jackrabbit/oak/trunk/oak-examples/standalone/README.md Thu Dec  3 08:39:30 
2015
@@ -42,6 +42,38 @@ This would create a node `hello` at root
 This should return a json rendition of the node. Application also has some 
 other web interfaces which are linked at http://localhost:8080/
 
+### Scripting Repository
+
+The application also has a [Script Console][1] at 
http://localhost:8080/osgi/system/console/sc
+which can be used to execute scripts like below
+
+```java
+import javax.jcr.Repository
+import javax.jcr.Session
+import javax.jcr.SimpleCredentials
+import javax.jcr.query.QueryResult
+import javax.jcr.query.Row
+
+def queryStr = '''select [jcr:path], [jcr:score], *
+    from [oak:QueryIndexDefinition]
+'''
+
+Repository repo = osgi.getService(Repository.class)
+Session s = null
+try {
+    s = repo.login(new SimpleCredentials("admin", "admin".toCharArray()))
+    def qm = s.getWorkspace().getQueryManager()
+    def query = qm.createQuery(queryStr,'sql')
+    QueryResult result = query.execute()
+
+    result.rows.each {Row r -> println r.path}
+} finally {
+    s?.logout()
+}
+```
+
+Above script would dump path for all index definition nodes.
+
 Using Mongo
 -----------
 
@@ -125,4 +157,6 @@ In above setup
 2. `REPOSITORY_CONFIG_FILE` - Comma separated json config file paths 
 
 Standalone Application is based on [Spring 
Boot](http://projects.spring.io/spring-boot/)
-and thus supports all features provided by it. 
\ No newline at end of file
+and thus supports all features provided by it. 
+
+[1]: 
http://felix.apache.org/documentation/subprojects/apache-felix-script-console-plugin.html
\ No newline at end of file


Reply via email to