in src/main/groovy/osgi/hello-groovy-bundle/org/codehaus/groovy/osgi/Activator.groovy [38:53]
public void start(BundleContext context) {
println "Groovy BundleActivator started"
// Normally, the classloader code would not need to be run when
// adding a service to the context. However, this is required when
// adding a Groovy service because of the way Groovy uses class
// loaders and reflection.
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader()
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader())
GroovyGreeter myService = new GroovyGreeterImpl()
registration = context.registerService(GroovyGreeter.class.getName(), myService, null)
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader)
}
}