use of org.osgi.service.cm.ConfigurationException in project acs-aem-commons by Adobe-Consulting-Services.
the class Activator method start.
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
@Override
public void start(BundleContext context) throws Exception {
LOG.info(context.getBundle().getSymbolicName() + " started");
ServiceReference ref = context.getServiceReference(SlingSettingsService.class.getName());
SlingSettingsService service = (SlingSettingsService) context.getService(ref);
try {
ModeUtil.configure(service);
} catch (ConfigurationException ex) {
LOG.error("Unable to configure ModeUtil with Sling Settings.", ex);
}
context.ungetService(ref);
}
use of org.osgi.service.cm.ConfigurationException in project aries by apache.
the class TransactionManagerService method createTransactionLog.
static TransactionLog createTransactionLog(Dictionary properties, XidFactory xidFactory) throws ConfigurationException {
TransactionLog result = null;
if (getBool(properties, RECOVERABLE, DEFAULT_RECOVERABLE)) {
String bufferClassName = getString(properties, HOWL_BUFFER_CLASS_NAME, "org.objectweb.howl.log.BlockLogBuffer");
int bufferSizeKBytes = getInt(properties, HOWL_BUFFER_SIZE, 4);
if (bufferSizeKBytes < 1 || bufferSizeKBytes > 32) {
throw new ConfigurationException(HOWL_BUFFER_SIZE, "The buffer size must be between one and thirty-two.");
}
boolean checksumEnabled = getBool(properties, HOWL_CHECKSUM_ENABLED, true);
boolean adler32Checksum = getBool(properties, HOWL_ADLER32_CHECKSUM, true);
int flushSleepTimeMilliseconds = getInt(properties, HOWL_FLUSH_SLEEP_TIME, 50);
String logFileExt = getString(properties, HOWL_LOG_FILE_EXT, "log");
String logFileName = getString(properties, HOWL_LOG_FILE_NAME, "transaction");
int maxBlocksPerFile = getInt(properties, HOWL_MAX_BLOCKS_PER_FILE, -1);
int maxLogFiles = getInt(properties, HOWL_MAX_LOG_FILES, 2);
int minBuffers = getInt(properties, HOWL_MIN_BUFFERS, 4);
if (minBuffers < 0) {
throw new ConfigurationException(HOWL_MIN_BUFFERS, "The minimum number of buffers must be greater than zero.");
}
int maxBuffers = getInt(properties, HOWL_MAX_BUFFERS, 0);
if (maxBuffers > 0 && minBuffers < maxBuffers) {
throw new ConfigurationException(HOWL_MAX_BUFFERS, "The maximum number of buffers must be greater than the minimum number of buffers.");
}
int threadsWaitingForceThreshold = getInt(properties, HOWL_THREADS_WAITING_FORCE_THRESHOLD, -1);
boolean flushPartialBuffers = getBool(properties, HOWL_FLUSH_PARTIAL_BUFFERS, true);
String logFileDir = getString(properties, HOWL_LOG_FILE_DIR, null);
if (logFileDir == null || logFileDir.length() == 0 || !new File(logFileDir).isAbsolute()) {
throw new ConfigurationException(HOWL_LOG_FILE_DIR, "The log file directory must be set to an absolute directory.");
}
try {
result = new HOWLLog(bufferClassName, bufferSizeKBytes, checksumEnabled, adler32Checksum, flushSleepTimeMilliseconds, logFileDir, logFileExt, logFileName, maxBlocksPerFile, maxBuffers, maxLogFiles, minBuffers, threadsWaitingForceThreshold, flushPartialBuffers, xidFactory, null);
((HOWLLog) result).doStart();
} catch (Exception e) {
// This should not really happen as we've checked properties earlier
throw new ConfigurationException(null, e.getMessage(), e);
}
} else {
result = new UnrecoverableLog();
}
return result;
}
use of org.osgi.service.cm.ConfigurationException in project stanbol by apache.
the class PrefixccProviderComponent method activate.
@Activate
protected void activate(ComponentContext ctx) throws ConfigurationException {
bc = ctx.getBundleContext();
Object value = ctx.getProperties().get(UPDATE_INTERVAL);
if (value instanceof Number) {
updateInterval = ((Number) value).intValue();
} else if (value != null && !value.toString().isEmpty()) {
try {
updateInterval = new BigDecimal(value.toString()).intValue();
} catch (NumberFormatException e) {
throw new ConfigurationException(UPDATE_INTERVAL, "Unable to parse integer value from the configured value '" + value + "' (type: " + value.getClass() + ")");
}
} else {
updateInterval = DEFAULT_UPDATE_INTERVAL;
}
if (updateInterval < 0) {
log.warn("Negative update interval '{}' configured. Will use default '{}'!", updateInterval, DEFAULT_UPDATE_INTERVAL);
updateInterval = DEFAULT_UPDATE_INTERVAL;
} else if (updateInterval == 0) {
updateInterval = DEFAULT_UPDATE_INTERVAL;
}
// we need to copy over the service ranking
providerProperties = new Hashtable<String, Object>();
Object ranking = ctx.getProperties().get(Constants.SERVICE_RANKING);
if (ranking != null) {
providerProperties.put(Constants.SERVICE_RANKING, ranking);
}
updateProviderState();
}
use of org.osgi.service.cm.ConfigurationException in project stanbol by apache.
the class CeliAnalyzedTextSentimentAnalysisEngine method activate.
@Override
@Activate
protected void activate(ComponentContext ctx) throws IOException, ConfigurationException {
super.activate(ctx);
Dictionary<String, Object> properties = ctx.getProperties();
this.licenseKey = Utils.getLicenseKey(properties, ctx.getBundleContext());
String url = (String) properties.get(SERVICE_URL);
if (url == null || url.isEmpty()) {
throw new ConfigurationException(SERVICE_URL, String.format("%s : please configure the URL of the CELI Web Service (e.g. by" + "using the 'Configuration' tab of the Apache Felix Web Console).", getClass().getSimpleName()));
}
this.serviceURL = new URL(url);
// parse the parsed language configuration
languageConfig.setConfiguration(properties);
int connectionTimeout = Utils.getConnectionTimeout(properties, ctx.getBundleContext());
this.client = new SentimentAnalysisServiceClientHttp(this.serviceURL, this.licenseKey, connectionTimeout);
}
use of org.osgi.service.cm.ConfigurationException in project stanbol by apache.
the class CeliAnalyzedTextLemmatizerEngine method activate.
@Override
@Activate
protected void activate(ComponentContext ctx) throws IOException, ConfigurationException {
super.activate(ctx);
Dictionary<String, Object> properties = ctx.getProperties();
this.licenseKey = Utils.getLicenseKey(properties, ctx.getBundleContext());
String url = (String) properties.get(SERVICE_URL);
if (url == null || url.isEmpty()) {
throw new ConfigurationException(SERVICE_URL, String.format("%s : please configure the URL of the CELI Web Service (e.g. by" + "using the 'Configuration' tab of the Apache Felix Web Console).", getClass().getSimpleName()));
}
this.serviceURL = new URL(url);
// parse the parsed language configuration
languageConfig.setConfiguration(properties);
int conTimeout = Utils.getConnectionTimeout(properties, ctx.getBundleContext());
this.client = new LemmatizerClientHTTP(this.serviceURL, this.licenseKey, conTimeout);
}
Aggregations