Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><em>Thanks to everyone for the answers, you led me to the solution! I will describe it here in a little simpler terms for a wider audience.</em></p> <p><strong>Goal</strong>: Code in scala, deploy to OSGi.</p> <p><strong>Tools used:</strong></p> <ol> <li>Equinox OSGi implementation</li> <li>Eclipse Helios 3.6, </li> <li>Scala 2.9</li> </ol> <p><strong>Procedure</strong></p> <ol> <li>Install <a href="http://www.scala-ide.org/">Scala IDE</a> for Eclipse. Find version that will work with Scala 2.9 and Eclipse 3.6</li> <li>Create new <strong><code>Scala Project</code></strong> in Eclipse.</li> <li><p>Convert the project to OSGi bundle by right clicking on it and selecting: <code>Configure -&gt; Convert to Plug-in Projects...</code></p> <p><em>Now, the next part was where I got stuck. You see, now we need to deploy this bundle (our project) to OSGi environment. However we are missing the Scala classes (or bundle that contains those classes) that have to be in OSGi container to provide all the Scala packages API we use in our bundle. Unfortunately finding the "Scala bundle" is not that easy. After <a href="https://github.com/weiglewilczek/scala-lang-osgi">looking around</a> it turns out, that for some reason, Scala bundle is actually located in the <a href="https://oss.sonatype.org/content/groups/scala-tools/com/weiglewilczek/scala-lang-osgi/">Sonatype Maven Repository</a>.</em></p></li> <li><p>Download the <code>scala-library-2.9.1.jar</code> from the appropriate location in the <a href="https://oss.sonatype.org/content/groups/scala-tools/com/weiglewilczek/scala-lang-osgi/scala-library/2.9.1/">Sonatype Maven Repository</a>, and deploy it (by means most comfortable for you) to your OSGi container.</p></li> <li><p>Adjust your manifest file to require the Scala bundle (<em>I am pretty sure that this is one place where bundle dependency (i.e. Require-Bundle) is actually pretty safe - after all, you will never run your Scala code without Scala!</em>):</p> <pre><code>Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Scala Hello Bundle-SymbolicName: com.test.scala.hello Bundle-Version: 1.0.0.qualifier Bundle-Vendor: drozzy Import-Package: org.osgi.framework;version="1.5.0" Bundle-Activator: com.test.scala.hello.Activator Require-Bundle: scala-library;bundle-version="2.9.1" </code></pre></li> <li><p>Now, you can write your bundle activator in Scala (wooho!):</p> <pre><code>//Activator.scala package com.test.scala.hello import java.lang.System import org.osgi.framework.BundleActivator import org.osgi.framework.BundleContext class Activator extends BundleActivator { def start(context: BundleContext) { System.out.println("Hello world from scala!"); } def stop(context: BundleContext){} } </code></pre></li> <li><p>Deploy your project as a bundle to OSGi container and look out for the "Hello world from scala!" message.</p></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload