You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Using Scala with Sling

Sling supports the Scala programming language version 2.7.7 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.

  • Start Sling
  • Install the Scala Script Engine bundle. Goto /contrib/scripting/scala/script and type mvn org.apache.sling:maven-sling-plugin:install.
  • Install the Apache Sling Scala Scripting Configuration bundle. Goto /contrib/scripting/scala/config and type mvn org.apache.sling:maven-sling-plugin:install.

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-rtp and type mvn org.apache.sling:maven-sling-plugin:install.

Now the examples themselves:

  • Install the Scala for Sling Demo Application - Hello World bundle. Goto /contrib/scripting/scala/samples/hello-world and type mvn org.apache.sling:maven-sling-plugin:install. The hello world application is then available at http://localhost:8080/content/helloworld.html

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 some further information.

  • No labels