use of org.opencastproject.util.ReadinessIndicator in project opencast by opencast.
the class EncodingProfileScanner method install.
/**
* {@inheritDoc}
*
* @see org.apache.felix.fileinstall.ArtifactInstaller#install(java.io.File)
*/
@Override
public void install(File artifact) throws Exception {
logger.info("Registering encoding profiles from {}", artifact);
try {
Map<String, EncodingProfile> profileMap = loadFromProperties(artifact);
for (Map.Entry<String, EncodingProfile> entry : profileMap.entrySet()) {
logger.info("Installed profile {}", entry.getValue().getIdentifier());
profiles.put(entry.getKey(), entry.getValue());
}
sumInstalledFiles++;
} catch (Exception e) {
logger.error("Encoding profiles could not be read from {}: {}", artifact, e.getMessage());
}
// Determine the number of available profiles
String[] filesInDirectory = artifact.getParentFile().list(new FilenameFilter() {
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<String, String>();
properties.put(ARTIFACT, "encodingprofile");
logger.debug("Indicating readiness of encoding profiles");
bundleCtx.registerService(ReadinessIndicator.class.getName(), new ReadinessIndicator(), properties);
logger.info("All {} encoding profiles installed", filesInDirectory.length);
} else {
logger.debug("{} of {} encoding profiles installed", sumInstalledFiles, filesInDirectory.length);
}
}
use of org.opencastproject.util.ReadinessIndicator in project opencast by opencast.
the class DictionaryServiceImpl method activate.
/**
* OSGi callback on component activation.
*
* @param ctx the bundle context
*/
void activate(BundleContext ctx) {
logger.info("Activating regexp based DictionaryService");
Dictionary<String, String> properties = new Hashtable<String, String>();
properties.put(ARTIFACT, "dictionary");
ctx.registerService(ReadinessIndicator.class.getName(), new ReadinessIndicator(), properties);
}
use of org.opencastproject.util.ReadinessIndicator in project opencast by opencast.
the class DictionaryServiceImpl method activate.
/**
* OSGi callback on component activation.
*
* @param ctx the bundle context
*/
void activate(BundleContext ctx) throws UnsupportedEncodingException {
Dictionary<String, String> properties = new Hashtable<String, String>();
properties.put(ARTIFACT, "dictionary");
ctx.registerService(ReadinessIndicator.class.getName(), new ReadinessIndicator(), properties);
/* Get hunspell binary from config file */
String binary = (String) ctx.getProperty(HUNSPELL_BINARY_CONFIG_KEY);
if (binary != null) {
/* Fix special characters */
binary = new String(binary.getBytes("ISO-8859-1"), "UTF-8");
logger.info("Setting hunspell binary to '{}'", binary);
this.binary = binary;
}
/* Get hunspell command line options from config file */
String command = (String) ctx.getProperty(HUNSPELL_COMMAND_CONFIG_KEY);
if (command != null) {
/* Fix special characters */
command = new String(command.getBytes("ISO-8859-1"), "UTF-8");
logger.info("Setting hunspell command line options to '{}'", command);
this.command = command;
}
}
use of org.opencastproject.util.ReadinessIndicator in project opencast by opencast.
the class DictionaryServiceImpl method activate.
/**
* OSGi callback on component activation.
*
* @param ctx
* the bundle context
*/
void activate(BundleContext ctx) {
Dictionary<String, String> properties = new Hashtable<String, String>();
properties.put(ARTIFACT, "dictionary");
ctx.registerService(ReadinessIndicator.class.getName(), new ReadinessIndicator(), properties);
}
use of org.opencastproject.util.ReadinessIndicator in project opencast by opencast.
the class WorkflowDefinitionScanner method install.
/**
* {@inheritDoc}
*
* @see org.apache.felix.fileinstall.ArtifactInstaller#install(java.io.File)
*/
public void install(File artifact) throws Exception {
WorkflowDefinition def = currentWFD;
// If the current workflow definition is null, it means this is a first install and not an update...
if (def == null) {
// ... so we have to load the definition first
def = parseWorkflowDefinitionFile(artifact);
if (def == null) {
logger.warn("Unable to install workflow from '{}'", artifact.getName());
artifactsWithError.add(artifact);
return;
}
}
logger.debug("Installing workflow from file '{}'", artifact.getName());
artifactsWithError.remove(artifact);
artifactIds.put(artifact, def.getId());
putWorkflowDefinition(def.getId(), def);
// Determine the number of available profiles
String[] filesInDirectory = artifact.getParentFile().list(new FilenameFilter() {
public boolean accept(File arg0, String name) {
return name.endsWith(".xml");
}
});
logger.info("Worfkflow definition '{}' from file '{}' installed", def.getId(), artifact.getName());
// Once all profiles have been loaded, announce readiness
if ((filesInDirectory.length - artifactsWithError.size()) == artifactIds.size() && !isWFSinitiliazed) {
logger.info("{} Workflow definitions loaded, activating Workflow service", filesInDirectory.length - artifactsWithError.size());
Dictionary<String, String> properties = new Hashtable<String, String>();
properties.put(ARTIFACT, "workflowdefinition");
logger.debug("Indicating readiness of workflow definitions");
bundleCtx.registerService(ReadinessIndicator.class.getName(), new ReadinessIndicator(), properties);
isWFSinitiliazed = true;
}
}
Aggregations