Skip to content

Commit

Permalink
included bundle activator example
Browse files Browse the repository at this point in the history
  • Loading branch information
bradbeck committed Feb 20, 2012
1 parent 0064e91 commit c3aa119
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ karaf@root> install -s mvn:com.example/scala.osgi.greeter.impl/1.0.0-SNAPSHOT
karaf@root> install -s mvn:com.example/scala.osgi.greeter.cmd/1.0.0-SNAPSHOT
karaf@root> greeter:greet Fred
Hello Fred
karaf@root> install -s mvn:com.example/scala.osgi.hello/1.0.0-SNAPSHOT
29 changes: 29 additions & 0 deletions scala.osgi.hello/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
group = 'com.example'
version = '1.0.0-SNAPSHOT'

apply plugin: 'maven'
apply plugin: 'scala'
apply plugin: 'osgi'
apply plugin: 'eclipse'

repositories {
mavenCentral()
}

dependencies {
scalaTools 'org.scala-lang:scala-compiler:2.9.1'
scalaTools 'org.scala-lang:scala-library:2.9.1'

compile 'org.scala-lang:scala-library:2.9.1'
compile 'org.osgi:org.osgi.core:4.2.0'
}

jar {
manifest {
name = 'scala osgi bundle built with gradle'
instruction 'Bundle-Vendor', 'example.com'
instruction 'Bundle-Activator', 'com.example.scala.osgi.hello.Activator'
instruction 'Import-Package', '!com.example.scala.osgi.hello,*'
instruction 'Export-Package', 'com.example.scala.osgi.hello'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.example.scala.osgi.hello

import org.osgi.framework._

class Activator extends BundleActivator {
def start( context: BundleContext ) {
var bundleNames = context.getBundles()
.map (b => b.getSymbolicName())
.filter (b => b != context.getBundle())
bundleNames.foreach(name => println("Bundle: " + name))
}

def stop( context: BundleContext ) {
println("Stopping...")
}
}
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include 'scala.osgi.greeter', 'scala.osgi.greeter.cmd', 'scala.osgi.greeter.impl'
include 'scala.osgi.greeter', 'scala.osgi.greeter.cmd', 'scala.osgi.greeter.impl', 'scala.osgi.hello'

0 comments on commit c3aa119

Please sign in to comment.