SOSOC : a Script-oriented and Service-Oriented Component Model
Description
SOSOC can managed script-based components as well as Java components (R4 SCR).
This code of this implementation is mainly based on a pre-release of the Felix SCR developed by Humberto Cervantes.
This implementation is a vehicle to experiment extensions of the R4-SCR.
This implementation provides currently an extension for Scripting-language based components.
Other possible extensions are listed here.
Extension for script-oriented components
The script-oriented component are written in a scripting language such as JavaScript, Groovy, Jython, Jacl, BeanShell, NetRexx, JRuby, JudoScript, ObjectScript, JSR223-script languages, JSTL ...
However only the manager for JavaScript is currently implemented.
The script source can be directly into the XML component descriptors or they can s:
The command sosoccmd
(provided by the sosoc.cmd bundle) can be use to start/stop scripts from a url
For more details on how to use this bundle, refer to the /doc/readme.html file embedded in the bundle jarfile.
Author
Felix Project Team
License
ASL 2.0
Build
- mvn clean install
Settings
None
Run the demo
To run the demo of this bundle, enter in the Felix shell the following command lines contained in the script.txt from the sosoc command.
Typical Usages
quick services assembling
Tested gateways
- Oscar (done for the very early version)
- Felix (done)
- Eclipse OSGi (to do)
TODO (contributions are welcome)
TODO: use the SCR release 1.0 to refactor SOSOC
TODO: deploy JSR223 engines (https://scripting.dev.java.net) and implementations as bundles (may be with Pax handlers wrap:mvn: )
- TODO: apply the base url to the relative entries
- TODO: unify the entry and the url parameter in the source element
- TODO: add a extender-based manager to instanciate components in others bundles (as SCR, iPOJO, ...)
- TODO: use javax.tools.JavaCompiler and may be JavaSourceFromString extends SimpleJavaFileObject to compile on-the-fly Java sources (see the exemple component.runnable.java.xml)
- TODO: add field attribute in reference for direct IoD
- TODO: use dynamic import to load scripting engine classes
- TODO: org.mozilla.javascript.Context.setErrorReporter(org.mozilla.javascript.ErrorReporter) with XML start line
- TODO: use org.mozilla.javascript.ContextFactory instead of org.mozilla.javascript.Context
- TODO: add manager for other scripting language : Groovy, PHP, Jython, Jacl, BeanShell, NetRexx, JRuby, JudoScript, ObjectScript ...
- TODO: synchronization on bind/unbind and invoke in the JavaScriptInstanceManager.ScriptComponent
- TODO: use Apache BSF as in the ANT script task
- TODO: object sharing between script components ?? useful or not
- TODO: more component.xml samples with various scripting languages
- TODO: live script-debugging with the Swing-based rhino debugger ??
- TODO: local vs global context in Rhino. the component-name attribute could be useful !
- DONE (06/12/2007): add replace elements to the implementation element
- DONE (06/12/2007): add source and attribute elements to the implementation element : multiple sources are concated and attributes can be passed to the script engine (ie compile=true, source=6.0, ...
- DONE (06/12/2007): use JSR223 ("Scripting for the JavaTM Platform 6") for other scripting language : Groovy, PHP, Jython, Jacl, BeanShell, NetRexx, JRuby, JudoScript, ObjectScript ...
- DONE (05/12/2007): append CDATA to the script located in the entry or url attributes of the implementation element : useful to complete import (legacy) scripts
- DONE (05/12/2007): add a "base" mechanism for URL completion: so, scripts file could have a relative URL according to the component XML descriptor file
- DONE (04/12/2007): rename SCRX in SOSOC
- DONE (04/12/2007): mavenize the project
- DONE (26/07/2005): defines a service and a command to start and stop scripts (embedded in the component description) from a URL (see http://people.apache.org/~donsez/dev/osgi/sosoc
- DONE (27/07/2005): provisioning the script outside the descriptor to ease script writing (specialized editor plugin) and off-bundle debugging (thanks to Rick Hall for his remark)
- DONE (27/07/2005): <script language="javascript" entry="echocmd.js"/> when the script is provisioned in the bundle jar as a ressource
- DONE (27/07/2005): <script language="javascript" url="http://www.foo.org/osgi/sb/scripts/echocmd.js"/> when the script is provisioned on a external web site
- DONE (27/07/2005): give a hook on SOSOC metadata in the script scope
- BUG FIXED (27/07/2005): fix this warning --- ScriptComponent:call method execute
RHINO USAGE WARNING: Missed Context.javaToJS() conversion:
Rhino runtime detected object org.apache.felix.sandbox.bundle.hello.impl.HelloServiceImpl@1
0e790c of class org.apache.felix.sandbox.bundle.hello.impl.HelloServiceImpl where it expect
ed String, Number, Boolean or Scriptable instance. Please check your code for mi
ssig Context.javaToJS() call.
- BUG FIXED (27/07/2005): context-associated thread (### JavaScriptInstanceManager : exception during call to deactivate():java.lang.RuntimeException: No Context associated with current Thread)
Links