/**
* Constructor for service resource
*
* @param serviceReference the service reference
*/
public ServiceResource(ServiceReference serviceReference) {
super(SERVICES_PATH.addElements(Long.toString((Long) serviceReference.getProperty(Constants.SERVICE_ID))));
m_serviceReference = serviceReference;
List<Relation> relations = new ArrayList<Relation>();
// Bundle from which this service is registered
Bundle bundle = m_serviceReference.getBundle();
Path bundlePath = BundleResourceManager.getInstance().getPath().addElements(Long.toString(bundle.getBundleId()));
relations.add(new DefaultRelation(bundlePath, Action.READ, FROM_BUNDLE_NAME));
//Package of the bundle that is exposed for this service
String[] packageNames = packageNamesFromService(m_serviceReference);
BundleRevision rev = bundle.adapt(BundleRevision.class);
List<BundleCapability> capabilities = rev.getDeclaredCapabilities(PACKAGE_NAMESPACE);
BundleCapability capability = null;
//TODO go find the package
for (BundleCapability cap : capabilities) {
for (String packageName : packageNames) {
if (cap.getAttributes().get(PACKAGE_NAMESPACE).equals(packageName)) {
//System.out.println(serviceReference.getProperty(Constants.OBJECTCLASS)+" - "+packageName);
capability = cap;
}
}
}
if (capability != null) {
Path packagePath = PackageResourceManager.getInstance().getPath().add(Path.from(Path.SEPARATOR + uniqueCapabilityId(capability)));
relations.add(new DefaultRelation(packagePath, Action.READ, FROM_PACKAGE_NAME));
}
// Create relations
setRelations(relations);
}
ServiceResource.java 文件源码
java
阅读 29
收藏 0
点赞 0
评论 0
项目:everest
作者:
评论列表
文章目录