in rsa/src/main/java/org/apache/aries/rsa/core/PackageUtil.java [46:85]
public String getVersion(Class<?> iClass) {
ServiceReference<PackageAdmin> paRef = bc.getServiceReference(PackageAdmin.class);
if (paRef != null) {
PackageAdmin pa = bc.getService(paRef);
try {
Bundle b = pa.getBundle(iClass);
if (b == null) {
LOG.info("Unable to find interface version for interface " + iClass.getName()
+ ". Falling back to 0.0.0");
return "0.0.0";
}
LOG.debug("Interface source bundle: {}", b.getSymbolicName());
ExportedPackage[] ep = pa.getExportedPackages(b);
LOG.debug("Exported Packages of the source bundle: {}", (Object)ep);
String pack = iClass.getPackage().getName();
LOG.debug("Looking for Package: {}", pack);
if (ep != null) {
for (ExportedPackage p : ep) {
if (p != null
&& pack.equals(p.getName())) {
LOG.debug("found package -> Version: {}", p.getVersion());
return p.getVersion().toString();
}
}
}
} finally {
if (pa != null) {
bc.ungetService(paRef);
}
}
} else {
LOG.error("Was unable to obtain the package admin service -> can't resolve interface versions");
}
LOG.info("Unable to find interface version for interface " + iClass.getName()
+ ". Falling back to 0.0.0");
return "0.0.0";
}