use of org.osgi.service.component.ComponentException in project opencast by opencast.
the class StaticFileServiceImpl method activate.
/**
* OSGI callback for activating this component
*
* @param cc
* the osgi component context
*/
public void activate(ComponentContext cc) {
logger.info("Upload Static Resource Service started.");
registerMXBean = JmxUtil.registerMXBean(staticFileStatistics, "UploadStatistics");
rootDirPath = OsgiUtil.getContextProperty(cc, STATICFILES_ROOT_DIRECTORY_KEY);
final File rootFile = new File(rootDirPath);
if (!rootFile.exists()) {
try {
FileUtils.forceMkdir(rootFile);
} catch (IOException e) {
throw new ComponentException(String.format("%s does not exists and could not be created", rootFile.getAbsolutePath()));
}
}
if (!rootFile.canRead())
throw new ComponentException(String.format("Cannot read from %s", rootFile.getAbsolutePath()));
purgeService = new PurgeTemporaryStorageService();
purgeService.addListener(new Listener() {
@Override
public void failed(State from, Throwable failure) {
logger.warn("Temporary storage purging service failed: {}", getStackTrace(failure));
}
}, MoreExecutors.sameThreadExecutor());
purgeService.startAsync();
logger.info("Purging of temporary storage section scheduled");
}
Aggregations