DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
Using Scala with Sling
Sling supports the Scala programming language version 2.8.1 through optional modules located in /contrib/scripting/scala.
Installation
The following bundles are required for Scala support: scala-library, scala-compiler, Scala Script Engine, Apache Sling Scala Scripting Configuration. Note: In order to see the Scala scripting engine in action you can also use the Launchpad Contrib Testing module which comes with all necessary bundles (including the examples) pre-installed. See below.
Manual installation
- Start Sling
- Download the scala-library bundle and the scala-compiler bundle and install them using for example the Apache Felix Web Management Console.
- Install the Scala Script Engine bundle. Goto
/contrib/scripting/scala/scriptand typemvn org.apache.sling:maven-sling-plugin:install.
- Install the Apache Sling Scala Scripting Configuration bundle. Goto
/contrib/scripting/scala/configand typemvn org.apache.sling:maven-sling-plugin:install.
Using Launchpad Contrib Testing
- Goto
/contrib/launchpad/testingand typemvn jetty:run -Pjcrinstall-teststo start Sling.
- Sling is now running at http://localhost:8888/. All required bundles and examples are pre-installed. See next section on how to access the examples. Remember to substitute the port number with 8888!
- See
/contrib/launchpad/testing/README.txtfor details.
Examples Applications
There are two example applications available in /contrib/scripting/scala/samples: A simple Hello World programm and a more advanced Forum application. The examples require the Apache Sling Sample Path Based Resource Type Provider bundle. So lets install this bundle first:
- Goto
/samples/path-based-rtpand typemvn -P autoInstallBundle clean install -Dsling.url=http://localhost:8888/system/console.
Now the examples themselves:
- Install the Scala for Sling Demo Application - Hello World bundle. Goto
/contrib/scripting/scala/samples/hello-worldand typemvn -P autoInstallBundle clean install -Dsling.url=http://localhost:8888/system/console. The hello world application is then available at http://localhost:8888/content/helloworld.html
- Install the Scala for Sling Demo Application - Forum bundle. Goto
/contrib/scripting/scala/samples/forumand typemvn -P autoInstallBundle clean install -Dsling.url=http://localhost:8888/system/console. The form application is the available at http://localhost:8888/content/forum.html?sling:authRequestLogin=true. When prompted for credentials use admin/admin.
Configuration
The Scala scripting bundle is configurable through the Apache Felix Web Management Console (PID: org.apache.sling.scripting.scala.config.SlingSettingsProvider).
- Scala compiler options. Scala compiler settings as documented by
scalac -help. Default is blank.
- Compiler output directory. Output directory for files generated by the Scala compiler. Default is
/var/classes.
Further Information
See these session slides for further information: