Pax Script

Skip to end of metadata
Go to start of metadata
Unknown macro: {ops4j-style}

Pax Script is an extender that automatically registers JSR223 engines (javax.script.ScriptEngineFactory) as OSGi services when a JSR223 JAR is loaded.

SCM: http://scm.ops4j.org/browse/OPS4J/laboratory/users/ceefour/pax-script

Also "jointly developed" with JSR223: https://scripting.dev.java.net/issues/show_bug.cgi?id=34

An effort is undergoing to make all JSR223 engines OSGi-compliant. Right now Groovy engine is directly usable by Pax-Script.

Requirements

  1. OSGi R4.1 runtime
  2. Java 5 or Java 4 with javax.scripting package
  3. A scripting implementation (e.g. groovy)
  4. A JSR223 scripting engine for that scripting implementation (from https://scripting.dev.java.net/ )
  5. Pax-Script dependencies (Extender, OPS4J Base-Lang)

Example Usage

Run OSGi runtime and install the bundles mentioned in Requirements

$ pax-provision -f equinox -u runner-groovy.lst
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building org.ops4j.pax.script
[INFO]    task-segment: [org.ops4j:maven-pax-plugin:1.3:provision] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [pax:provision]
[INFO] Installing /home/ceefour/project/ops4j/pax-script/runner/deploy-pom.xml to /home/ceefour/.m2/repository/org/ops4j/pax/script/build/deployment/1.0.1-SNAPSHOT/deployment-1.0.1-SNAPSHOT.pom
    ______  ________  __  __
   / __  / /  __   / / / / /
  /  ___/ /  __   / _\ \ _/
 /  /    /  / /  / / _\ \
/__/    /__/ /__/ /_/ /_/

Pax Runner from OPS4J - http://www.ops4j.org
--------------------------------------------

 -> Using config [classpath:META-INF/runner.properties]
 -> Provision from [/home/ceefour/project/ops4j/pax-script/runner/deploy-pom.xml]
 -> Provision from [scan-pom:file:/home/ceefour/project/ops4j/pax-script/runner/deploy-pom.xml]
 -> Using property [bundle.symbolicName=org.ops4j.pax.script]
 -> Using property [bundle.namespace=org.ops4j.pax.script]
 -> Installing bundle [{location=mvn:org.ops4j.pax.script/pax-script/1.0.1-SNAPSHOT,startlevel=null,shouldStart=true,shouldUpdate=false}]
 -> Installing bundle [{location=mvn:org.ops4j.pax.swissbox/pax-swissbox-lifecycle/0.2.0,startlevel=null,shouldStart=true,shouldUpdate=false}]
 -> Installing bundle [{location=mvn:org.ops4j.base/ops4j-base-lang/0.5.0,startlevel=null,shouldStart=true,shouldUpdate=false}]
 -> Installing bundle [{location=mvn:org.ops4j.pax.swissbox/pax-swissbox-extender/0.2.0,startlevel=null,shouldStart=true,shouldUpdate=false}]
 -> Installing bundle [{location=mvn:org.ops4j.pax.logging/pax-logging-api/1.1.1,startlevel=null,shouldStart=true,shouldUpdate=false}]
 -> Installing bundle [{location=mvn:org.ops4j.pax.logging/pax-logging-service/1.1.1,startlevel=null,shouldStart=true,shouldUpdate=false}]
 -> Provision from [runner-groovy.lst]
 -> Provision from [scan-file:file:/home/ceefour/project/ops4j/pax-script/runner-groovy.lst]
 -> Installing bundle [{location=mvn:com.sun.script/groovy-engine/1.1,startlevel=null,shouldStart=true,shouldUpdate=false}]
 -> Installing bundle [{location=mvn:org.ops4j.pax.swissbox/pax-swissbox-extender/0.2.0,startlevel=null,shouldStart=true,shouldUpdate=false}]
 -> Installing bundle [{location=mvn:org.ops4j.base/ops4j-base-lang/0.5.0,startlevel=null,shouldStart=true,shouldUpdate=false}]
 -> Installing bundle [{location=mvn:org.ops4j.pax.swissbox/pax-swissbox-lifecycle/0.2.0,startlevel=null,shouldStart=true,shouldUpdate=false}]
 -> Installing bundle [{location=mvn:org.codehaus.groovy/groovy/1.5.7-SNAPSHOT,startlevel=null,shouldStart=true,shouldUpdate=false}]
 -> Installing bundle [{location=mvn:org.antlr/com.springsource.antlr/2.7.7,startlevel=null,shouldStart=true,shouldUpdate=false}]
 -> Installing bundle [{location=mvn:org.objectweb.asm/com.springsource.org.objectweb.asm.util/2.2.0,startlevel=null,shouldStart=true,shouldUpdate=false}]
 -> Installing bundle [{location=mvn:org.objectweb.asm/com.springsource.org.objectweb.asm.attrs/2.2.0,startlevel=null,shouldStart=true,shouldUpdate=false}]
 -> Installing bundle [{location=mvn:org.objectweb.asm/com.springsource.org.objectweb.asm.tree.analysis/2.2.0,startlevel=null,shouldStart=true,shouldUpdate=false}]
 -> Installing bundle [{location=mvn:org.objectweb.asm/com.springsource.org.objectweb.asm.tree/2.2.0,startlevel=null,shouldStart=true,shouldUpdate=false}]
 -> Installing bundle [{location=mvn:org.objectweb.asm/com.springsource.org.objectweb.asm/2.2.0,startlevel=null,shouldStart=true,shouldUpdate=false}]
 -> Downloading bundles...
 -> mvn:org.ops4j.pax.script/pax-script/1.0.1-SNAPSHOT : 7910 bytes @ [ 659kBps ]]
 -> mvn:org.ops4j.pax.swissbox/pax-swissbox-lifecycle/0.2.0 : 6493 bytes @ [ 927kBps ]]
 -> mvn:org.ops4j.base/ops4j-base-lang/0.5.0 : 5965 bytes @ [ 2982kBps ]
 -> mvn:org.ops4j.pax.swissbox/pax-swissbox-extender/0.2.0 : 14782 bytes @ [ 1343kBps ]
 -> mvn:org.ops4j.pax.logging/pax-logging-api/1.1.1 : 72696 bytes @ [ 2506kBps ]
 -> mvn:org.ops4j.pax.logging/pax-logging-service/1.1.1 : 183340 bytes @ [ 2957kBps ]
 -> mvn:com.sun.script/groovy-engine/1.1 : 12050 bytes @ [ 12050kBps ]
 -> mvn:org.ops4j.pax.swissbox/pax-swissbox-extender/0.2.0 : 14782 bytes @ [ 14782kBps ]
 -> mvn:org.ops4j.base/ops4j-base-lang/0.5.0 : 5965 bytes @ [ 5965kBps ]
 -> mvn:org.ops4j.pax.swissbox/pax-swissbox-lifecycle/0.2.0 : 6493 bytes @ [ 6493kBps ]
 -> mvn:org.codehaus.groovy/groovy/1.5.7-SNAPSHOT : 2339050 bytes @ [ 3360kBps ]
 -> mvn:org.antlr/com.springsource.antlr/2.7.7 : 445573 bytes @ [ 4500kBps ]]
 -> mvn:org.objectweb.asm/com.springsource.org.objectweb.asm.util/2.2.0 : 33393 bytes @ [ 1236kBps ]
 -> mvn:org.objectweb.asm/com.springsource.org.objectweb.asm.attrs/2.2.0 : 7351 bytes @ [ 7351kBps ]
 -> mvn:org.objectweb.asm/com.springsource.org.objectweb.asm.tree.analysis/2.2.0 : 18211 bytes @ [ 958kBps ]
 -> mvn:org.objectweb.asm/com.springsource.org.objectweb.asm.tree/2.2.0 : 16805 bytes @ [ 16805kBps ]
 -> mvn:org.objectweb.asm/com.springsource.org.objectweb.asm/2.2.0 : 35272 bytes @ [ 11757kBps ]
 -> Execution environment [J2SE-1.6]
 -> Starting platform [Equinox 3.3.2]. Runner has successfully finished his job!

osgi> [org.ops4j.pax.script.internal.ExtenderActivator] : STARTING org.ops4j.pax.script Extender
[org.ops4j.pax.swissbox.extender.BundleWatcher] : Creating bundle watcher with scanner [BundleURLScanner{path=META-INF/services/,filePattern=javax.script.ScriptEngineFactory,recurse=false}]...
[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.eclipse.osgi]
[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.eclipse.osgi.util]
[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.eclipse.osgi.services]
[org.ops4j.pax.script.internal.ExtenderActivator] : Pax-Script JSR223 watcher started.
[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.ops4j.pax.script]
[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.ops4j.pax.swissbox.lifecycle]
[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.ops4j.base.lang]
[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.ops4j.pax.swissbox.extender]
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator] : Enabling SLF4J API support.
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator] : Enabling Jakarta Commons Logging API support.
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator] : Enabling Log4J API support.
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator] : Enabling Avalon Logger API support.
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator] : Enabling JULI Logger API support.
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.ops4j.pax.logging.pax-logging-api]
[Start Level Event Dispatcher] DEBUG org.ops4j.pax.swissbox.extender.BundleWatcher - Scanning bundle [org.ops4j.pax.logging.pax-logging-service]
[Framework Event Dispatcher] INFO org.ops4j.pax.logging.pax-logging-service - BundleEvent STARTED
[Start Level Event Dispatcher] DEBUG org.ops4j.pax.swissbox.extender.BundleWatcher - Scanning bundle [com.sun.script.groovy]
[Start Level Event Dispatcher] DEBUG org.ops4j.pax.swissbox.extender.BundleWatcher - Found resources [bundleentry://9/META-INF/services/javax.script.ScriptEngineFactory]
[Start Level Event Dispatcher] INFO org.ops4j.pax.script.internal.ExtenderActivator - Bundle com.sun.script.groovy added with 1 factories.
[Start Level Event Dispatcher] DEBUG org.ops4j.pax.swissbox.extender.BundleWatcher - Scanning bundle [groovy]
[Framework Event Dispatcher] INFO groovy - BundleEvent STARTED
[Start Level Event Dispatcher] INFO com.sun.script.groovy - ServiceEvent REGISTERED
[Start Level Event Dispatcher] INFO org.ops4j.pax.script.internal.ExtenderActivator - Registered JSR223 class=com.sun.script.groovy.GroovyScriptEngineFactory engine.name=groovy engine.version=1.5.7-SNAPSHOT language.name=groovy language.version=1.5.6
[Framework Event Dispatcher] INFO com.sun.script.groovy - BundleEvent STARTED
[Start Level Event Dispatcher] DEBUG org.ops4j.pax.swissbox.extender.BundleWatcher - Scanning bundle [com.springsource.antlr]
[Framework Event Dispatcher] INFO com.springsource.antlr - BundleEvent STARTED
[Start Level Event Dispatcher] DEBUG org.ops4j.pax.swissbox.extender.BundleWatcher - Scanning bundle [com.springsource.org.objectweb.asm.util]
[Framework Event Dispatcher] INFO com.springsource.org.objectweb.asm.util - BundleEvent STARTED
[Start Level Event Dispatcher] DEBUG org.ops4j.pax.swissbox.extender.BundleWatcher - Scanning bundle [com.springsource.org.objectweb.asm.tree.attrs]
[Framework Event Dispatcher] INFO com.springsource.org.objectweb.asm.tree.attrs - BundleEvent STARTED
[Start Level Event Dispatcher] DEBUG org.ops4j.pax.swissbox.extender.BundleWatcher - Scanning bundle [com.springsource.org.objectweb.asm.tree.analysis]
[Framework Event Dispatcher] INFO com.springsource.org.objectweb.asm.tree.analysis - BundleEvent STARTED
[Start Level Event Dispatcher] DEBUG org.ops4j.pax.swissbox.extender.BundleWatcher - Scanning bundle [com.springsource.org.objectweb.asm.tree]
[Framework Event Dispatcher] INFO com.springsource.org.objectweb.asm.tree - BundleEvent STARTED
[Start Level Event Dispatcher] DEBUG org.ops4j.pax.swissbox.extender.BundleWatcher - Scanning bundle [com.springsource.org.objectweb.asm]
[Framework Event Dispatcher] INFO com.springsource.org.objectweb.asm - BundleEvent STARTED
[Framework Event Dispatcher] INFO org.eclipse.osgi - FrameworkEvent STARTLEVEL CHANGED

Inspect the bundles, particularly the JSR223 engine bundle.

osgi> ss

Framework is launched.

id    State       Bundle
0    ACTIVE      org.eclipse.osgi_3.3.2.R33x_v20080105
1    ACTIVE      org.eclipse.osgi.util_3.1.200.v20070605
2    ACTIVE      org.eclipse.osgi.services_3.1.200.v20070605
3    ACTIVE      org.ops4j.pax.script_1.0.1.SNAPSHOT
4    ACTIVE      org.ops4j.pax.swissbox.lifecycle_0.2.0
5    ACTIVE      org.ops4j.base.lang_0.5.0
6    ACTIVE      org.ops4j.pax.swissbox.extender_0.2.0
7    ACTIVE      org.ops4j.pax.logging.pax-logging-api_1.1.1
8    ACTIVE      org.ops4j.pax.logging.pax-logging-service_1.1.1
9    ACTIVE      com.sun.script.groovy_0.0.0
10    ACTIVE      groovy_1.5.7.SNAPSHOT
11    ACTIVE      com.springsource.antlr_2.7.7
12    ACTIVE      com.springsource.org.objectweb.asm.util_2.2.0
13    ACTIVE      com.springsource.org.objectweb.asm.tree.attrs_2.2.0
14    ACTIVE      com.springsource.org.objectweb.asm.tree.analysis_2.2.0
15    ACTIVE      com.springsource.org.objectweb.asm.tree_2.2.0
16    ACTIVE      com.springsource.org.objectweb.asm_2.2.0

osgi> b 9
initial@reference:file:com.sun.script.groovy_0.jar/ [9]
  Id=9, Status=ACTIVE      Data Root=/home/ceefour/project/ops4j/pax-script/runner/equinox/org.eclipse.osgi/bundles/9/data
  Registered Services
    {javax.script.ScriptEngineFactory}={language.version=1.5.6, engine.name=groovy, language,name=groovy, engine.version=1.5.7-SNAPSHOT, language=groovy, service.id=22}
  No services in use.
  Exported packages
    com.sun.script.groovy; version="0.0.0"[exported]
  Imported packages
    com.sun.script.groovy; version="0.0.0"<initial@reference:file:com.sun.script.groovy_0.jar/ [9]>
    groovy.lang; version="1.5.7.SNAPSHOT"<initial@reference:file:groovy_1.5.7.SNAPSHOT.jar/ [10]>
    javax.script; version="0.0.0"<System Bundle [0]>
    org.codehaus.groovy.control; version="1.5.7.SNAPSHOT"<initial@reference:file:groovy_1.5.7.SNAPSHOT.jar/ [10]>
    org.codehaus.groovy.runtime; version="1.5.7.SNAPSHOT"<initial@reference:file:groovy_1.5.7.SNAPSHOT.jar/ [10]>
    org.codehaus.groovy.syntax; version="1.5.7.SNAPSHOT"<initial@reference:file:groovy_1.5.7.SNAPSHOT.jar/ [10]>
  No fragment bundles
  Named class space
    com.sun.script.groovy; bundle-version="0.0.0"[provided]
  No required bundles

Pax-Script Extender has registered OSGi services for that bundle.

JSR223 Scripting is now very easy to use under OSGi!

Labels:
pax-script pax-script Delete
rhino rhino Delete
scripting scripting Delete
jsr223 jsr223 Delete
beanshell beanshell Delete
pax pax Delete
jruby jruby Delete
laboratory laboratory Delete
groovy groovy Delete
osgi osgi Delete
project project Delete
script script Delete
javascript javascript Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Clicky Web Analytics