use of org.opencastproject.util.ReadinessIndicator in project opencast by opencast.
the class FeedRegistrationScanner method install.
/**
* {@inheritDoc}
*
* @see org.apache.felix.fileinstall.ArtifactInstaller#install(java.io.File)
*/
@Override
public void install(File artifact) throws Exception {
logger.info("Installing a feed from '{}'", artifact.getName());
Properties props = new Properties();
FileInputStream in = null;
try {
in = new FileInputStream(artifact);
props.load(in);
} finally {
IOUtils.closeQuietly(in);
}
// Always include the server URL obtained from the bundle context
props.put("org.opencastproject.server.url", bundleContext.getProperty("org.opencastproject.server.url"));
Class<?> clazz = getClass().getClassLoader().loadClass(props.getProperty(FEED_CLASS));
FeedGenerator generator = (FeedGenerator) clazz.newInstance();
generator.setSearchService(searchService);
generator.setSeriesService(seriesService);
generator.initialize(props);
ServiceRegistration<?> reg = bundleContext.registerService(FeedGenerator.class.getName(), generator, null);
generators.put(artifact, reg);
sumInstalledFiles++;
// Determine the number of available profiles
String[] filesInDirectory = artifact.getParentFile().list(new FilenameFilter() {
@Override
public boolean accept(File arg0, String name) {
return name.endsWith(".properties");
}
});
// Once all profiles have been loaded, announce readiness
if (filesInDirectory.length == sumInstalledFiles) {
Dictionary<String, String> properties = new Hashtable<>();
properties.put(ARTIFACT, "feed");
logger.debug("Indicating readiness of feed");
bundleContext.registerService(ReadinessIndicator.class.getName(), new ReadinessIndicator(), properties);
logger.info("All {} feeds installed", filesInDirectory.length);
} else {
logger.debug("{} of {} feeds installed", sumInstalledFiles, filesInDirectory.length);
}
}
Aggregations