
Bundle
interface documentation. If we can get a Bundle
object, we can call its getBundleContext()
method to get a BundleContext
object. The BundleContext
interface has a getBundles()
method, which returns all installed bundles.Bundle
object. To that end, we can use the static method getBundle
of the FrameworkUtil
class, which takes a Class
object, and returns a Bundle
object representing the bundle containing that class (assuming it belongs to a bundle, of course).com.sap.gateway.ip.core.customdev.util.Message
.def knownBundleClass = 'com.sap.gateway.ip.core.customdev.util.Message'
def entryBundle = FrameworkUtil.getBundle(Class.forName(knownBundleClass))
def bundleContext = entryBundle.getBundleContext()
bundleContext.getBundles().each { b ->
// Process each Bundle object here
}
import com.sap.gateway.ip.core.customdev.util.Message
import groovy.xml.MarkupBuilder
import org.osgi.framework.FrameworkUtil
def Message matchingVersionBundles(Message message) {
def sw = new StringWriter()
def builder = new MarkupBuilder(sw)
def matchingVersionBundles = getMatchingVersionBundles('2.35.7')
builder.bundles {
matchingVersionBundles.each { b ->
bundle {
id(b.getSymbolicName())
name(b.getHeaders().get('Bundle-Name'))
version(b.getVersion().toString())
}
}
}
message.setBody(sw.toString())
return message
}
def getBundleContext() {
def knownBundleClass = 'com.sap.gateway.ip.core.customdev.util.Message'
def entryBundle = FrameworkUtil.getBundle(Class.forName(knownBundleClass))
if (entryBundle == null) {
throw new AssertionError("No OSGi bundle for class ${knownBundleClass}")
}
entryBundle.getBundleContext()
}
def getMatchingVersionBundles(String version) {
getBundleContext().getBundles().findAll() { b ->
b.getVersion().toString() == version
}
}
<bundles>
<bundle>
<id>com.sap.it.node.stack.profile</id>
<name>Node Stack Profile Bundle for Stack iflmap</name>
<version>2.35.7</version>
</bundle>
<bundle>
<id>com.sap.it.node.stack.repository</id>
<name>Node Stack Repsository Bundle for Stack iflmap</name>
<version>2.35.7</version>
</bundle>
</bundles>
com.sap.it.node.stack.profile
bundle, and watched it over a period of time, to confirm that its version number does in fact match the CPI build number. The CPITracker code uses this bundle, and the technique described above, to determine the CPI build number.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
9 | |
7 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
5 |