private void updatePermissionsFromFile() throws IOException {
final ServiceReference cpaRef = bundleContext.getServiceReference(ConditionalPermissionAdmin.class.getName());
final ConditionalPermissionAdmin conditionalPermissionAdmin = (ConditionalPermissionAdmin) bundleContext.getService(cpaRef);
final ConditionalPermissionUpdate permissionUpdate = conditionalPermissionAdmin.newConditionalPermissionUpdate();
final List conditionalPermissionInfos = permissionUpdate.getConditionalPermissionInfos();
try {
final BufferedReader reader = new BufferedReader(new FileReader(felixPolicy));
String line;
final Set<String> cpiNames = new HashSet<String>();
while ((line = reader.readLine()) != null) {
if (!line.startsWith("//")) {
final ConditionalPermissionInfo cpi = conditionalPermissionAdmin.newConditionalPermissionInfo(line);
final String cpiName = cpi.getName();
if (cpiNames.contains(cpiName)) {
throw new RuntimeException("Redundant policy name!");
}
cpiNames.add(cpiName);
conditionalPermissionInfos.add(cpi);
}
}
reader.close();
permissionUpdate.commit();
} finally {
bundleContext.ungetService(cpaRef);
}
}