Create a simple OSGi environment using groovyx.osgi.runtime module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// these are necessary for current version (3.6.1) of Equinox | |
@GrabResolver(name='ebrRelease', root='http://repository.springsource.com/maven/bundles/release') | |
@GrabResolver(name='ebrExternal', root='http://repository.springsource.com/maven/bundles/external') | |
@GrabResolver(name='githubJetztgradNet', root='https://github.com/jetztgradnet/repository/raw/master') | |
@Grapes([ | |
@GrabConfig(systemClassLoader=true), | |
@Grab(group='groovyx.osgi', module='groovyx.osgi.runtime', version='0.1'), | |
@Grab(group='org.eclipse.osgi', module='org.eclipse.osgi', version='3.6.1.R36x_v20100806'), | |
@Grab(group='org.apache.commons', module='com.springsource.org.apache.commons.logging', version='1.1.1') | |
]) | |
import groovyx.osgi.runtime.OsgiRuntimeBuilder | |
OsgiRuntimeBuilder.run { | |
framework 'equinox' | |
bundle 'mvn:org.apache.felix:org.apache.felix.configadmin:1.2.4' | |
bundle 'mvn:org.apache.felix:org.apache.felix.fileinstall:3.0.2' | |
beforeStart = { | |
println "starting OSGi runtime" | |
} | |
afterInstallBundles = { runtime -> | |
def bundleContext = runtime.bundleContext | |
if (bundleContext) { | |
println "installed bundles:" | |
bundleContext?.bundles?.each { bundle -> | |
println "[${bundle.bundleId}] ${bundle.symbolicName} ${bundle.version}" | |
} | |
} | |
else { | |
println "failed to list bundles" | |
} | |
} | |
doRun = { | |
// wait one minute | |
println "stopping OSGi runtime after one minute" | |
Thread.sleep 60000 | |
} | |
afterStop = { | |
println "stopped OSGi runtime" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment