incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Sling > Using Scala with Sling
Date Wed, 02 Mar 2011 13:59:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2036/9/1/_/styles/combined.css?spaceKey=SLING&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/SLING/Using+Scala+with+Sling">Using
Scala with Sling</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~alex.parvulescu">Alex
Parvulescu</a>
    </h4>
        <br/>
                         <h4>Changes (4)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >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: <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">*
Goto {{/samples/path-based-rtp}} and type {{mvn org.apache.sling:maven-sling-plugin:install}}.
<br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">*
Goto {{/samples/path-based-rtp}} and type {{mvn -P autoInstallBundle clean install -Dsling.url=http://localhost:8888/system/console}}.
<br></td></tr>
            <tr><td class="diff-unchanged" > <br>Now the examples themselves:
<br> <br></td></tr>
            <tr><td class="diff-changed-lines" >* Install the Scala for Sling
Demo Application - Hello World bundle. Goto {{/contrib/scripting/scala/samples/hello-world}}
and type {{mvn <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">org.apache.sling:maven-sling-plugin:install}}.</span>
<span class="diff-added-words"style="background-color: #dfd;">-P autoInstallBundle clean
install -Dsling.url=http://localhost:8888/system/console}}.</span> The hello world application
is then available at <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">[http://localhost:8080/content/helloworld.html]</span>
<span class="diff-added-words"style="background-color: #dfd;">[http://localhost:8888/content/helloworld.html]</span>
<br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-changed-lines" >* Install the Scala for Sling
Demo Application - Forum bundle. Goto {{/contrib/scripting/scala/samples/forum}} and type
{{mvn <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">org.apache.sling:maven-sling-plugin:install}}.</span>
<span class="diff-added-words"style="background-color: #dfd;">-P autoInstallBundle clean
install -Dsling.url=http://localhost:8888/system/console}}.</span> The form application
is the available at <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">[http://localhost:8080/content/forum.html?sling:authRequestLogin=true].</span>
<span class="diff-added-words"style="background-color: #dfd;">[http://localhost:8888/content/forum.html?sling:authRequestLogin=true].</span>
When prompted for credentials use admin/admin. <br></td></tr>
            <tr><td class="diff-unchanged" > <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="UsingScalawithSling-UsingScalawithSling"></a>Using
Scala with Sling</h1>

<p>Sling supports the <a href="http://www.scala-lang.org/" class="external-link"
rel="nofollow">Scala</a> programming language version 2.8.1 through optional modules
located in <tt>/contrib/scripting/scala</tt>.</p>


<h2><a name="UsingScalawithSling-Installation"></a>Installation</h2>

<p>The following bundles are required for Scala support: scala-library, scala-compiler,
Scala Script Engine, Apache Sling Scala Scripting Configuration. <em>Note</em>:
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.</p>

<h3><a name="UsingScalawithSling-Manualinstallation"></a>Manual installation</h3>
<ul>
	<li>Start Sling</li>
</ul>


<ul>
	<li>Download the <a href="http://scala-tools.org/repo-releases/com/weiglewilczek/scala-lang-osgi/scala-library/2.8.1/scala-library-2.8.1.jar"
class="external-link" rel="nofollow">scala-library bundle</a> and the <a href="http://scala-tools.org/repo-releases/com/weiglewilczek/scala-lang-osgi/scala-compiler/2.8.1/scala-compiler-2.8.1.jar"
class="external-link" rel="nofollow">scala-compiler bundle</a> and install them using
for example the <a href="http://localhost:8080/system/console/bundles" class="external-link"
rel="nofollow">Apache Felix Web Management Console</a>.</li>
</ul>


<ul>
	<li>Install the Scala Script Engine bundle. Goto <tt>/contrib/scripting/scala/script</tt>
and type <tt>mvn org.apache.sling:maven-sling-plugin:install</tt>.</li>
</ul>


<ul>
	<li>Install the Apache Sling Scala Scripting Configuration bundle. Goto <tt>/contrib/scripting/scala/config</tt>
and type <tt>mvn org.apache.sling:maven-sling-plugin:install</tt>.</li>
</ul>


<h3><a name="UsingScalawithSling-UsingLaunchpadContribTesting"></a>Using
Launchpad Contrib Testing</h3>
<ul>
	<li>Goto <tt>/contrib/launchpad/testing</tt> and type <tt>mvn jetty:run
-Pjcrinstall-tests</tt> to start Sling.</li>
</ul>


<ul>
	<li>Sling is now running at <a href="http://localhost:8888/" class="external-link"
rel="nofollow">http://localhost:8888/</a>. 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!</li>
</ul>


<ul>
	<li>See <tt>/contrib/launchpad/testing/README.txt</tt> for details.</li>
</ul>


<h2><a name="UsingScalawithSling-ExamplesApplications"></a>Examples Applications</h2>

<p>There are two example applications available in <tt>/contrib/scripting/scala/samples</tt>:
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:</p>

<ul>
	<li>Goto <tt>/samples/path-based-rtp</tt> and type <tt>mvn -P autoInstallBundle
clean install -Dsling.url=<a href="http://localhost:8888/system/console" class="external-link"
rel="nofollow">http://localhost:8888/system/console</a></tt>.</li>
</ul>


<p>Now the examples themselves:</p>

<ul>
	<li>Install the Scala for Sling Demo Application - Hello World bundle. Goto <tt>/contrib/scripting/scala/samples/hello-world</tt>
and type <tt>mvn -P autoInstallBundle clean install -Dsling.url=<a href="http://localhost:8888/system/console"
class="external-link" rel="nofollow">http://localhost:8888/system/console</a></tt>.
The hello world application is then available at <a href="http://localhost:8888/content/helloworld.html"
class="external-link" rel="nofollow">http://localhost:8888/content/helloworld.html</a></li>
</ul>


<ul>
	<li>Install the Scala for Sling Demo Application - Forum bundle. Goto <tt>/contrib/scripting/scala/samples/forum</tt>
and type <tt>mvn -P autoInstallBundle clean install -Dsling.url=<a href="http://localhost:8888/system/console"
class="external-link" rel="nofollow">http://localhost:8888/system/console</a></tt>.
The form application is the available at <a href="http://localhost:8888/content/forum.html?sling:authRequestLogin=true"
class="external-link" rel="nofollow">http://localhost:8888/content/forum.html?sling:authRequestLogin=true</a>.
When prompted for credentials use admin/admin.</li>
</ul>



<h2><a name="UsingScalawithSling-Configuration"></a>Configuration</h2>

<p>The Scala scripting bundle is configurable through the <a href="http://localhost:8080/system/console/configMgr"
class="external-link" rel="nofollow">Apache Felix Web Management Console</a> (PID:
org.apache.sling.scripting.scala.config.SlingSettingsProvider).</p>

<ul>
	<li>Scala compiler options. Scala compiler settings as documented by <a href="http://www.scala-lang.org/docu/files/tools/scalac.html"
class="external-link" rel="nofollow"><tt>scalac &#45;help</tt></a>.
Default is blank.</li>
</ul>


<ul>
	<li>Compiler output directory. Output directory for files generated by the Scala compiler.
Default is <tt>/var/classes</tt>.</li>
</ul>



<h2><a name="UsingScalawithSling-FurtherInformation"></a>Further Information</h2>

<p>See these session slides for further information:</p>

<ul>
	<li><a href="http://jazoon.com/portals/0/Content/ArchivWebsite/jazoon.com/jazoon09/en.html"
class="external-link" rel="nofollow">Jazoon 2009 </a>: <a href="http://www.slideshare.net/michid/scala-sling"
class="external-link" rel="nofollow">Scala for Sling </a></li>
	<li><a href="http://days2010.scala-lang.org/" class="external-link" rel="nofollow">Scala
Days 2010 </a>: <a href="http://www.slideshare.net/michid/scala-for-scriptinh" class="external-link"
rel="nofollow">Scala for Scripting </a></li>
</ul>



    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/SLING/Using+Scala+with+Sling">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=12845530&revisedVersion=4&originalVersion=3">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/SLING/Using+Scala+with+Sling?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message