Search in sources :

Example 71 with ConfigurationException

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);
}
Also used : ConfigurationException(org.osgi.service.cm.ConfigurationException) SlingSettingsService(org.apache.sling.settings.SlingSettingsService) ServiceReference(org.osgi.framework.ServiceReference)

Example 72 with ConfigurationException

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;
}
Also used : TransactionLog(org.apache.geronimo.transaction.manager.TransactionLog) ConfigurationException(org.osgi.service.cm.ConfigurationException) HOWLLog(org.apache.geronimo.transaction.log.HOWLLog) File(java.io.File) ConfigurationException(org.osgi.service.cm.ConfigurationException) XAException(javax.transaction.xa.XAException) UnrecoverableLog(org.apache.geronimo.transaction.log.UnrecoverableLog)

Example 73 with ConfigurationException

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();
}
Also used : ConfigurationException(org.osgi.service.cm.ConfigurationException) BigDecimal(java.math.BigDecimal) Activate(org.apache.felix.scr.annotations.Activate)

Example 74 with ConfigurationException

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);
}
Also used : ConfigurationException(org.osgi.service.cm.ConfigurationException) URL(java.net.URL) Activate(org.apache.felix.scr.annotations.Activate)

Example 75 with ConfigurationException

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);
}
Also used : ConfigurationException(org.osgi.service.cm.ConfigurationException) URL(java.net.URL) Activate(org.apache.felix.scr.annotations.Activate)

Aggregations

ConfigurationException (org.osgi.service.cm.ConfigurationException)190 Activate (org.apache.felix.scr.annotations.Activate)31 ServiceReference (org.osgi.framework.ServiceReference)30 Matcher (java.util.regex.Matcher)28 Hashtable (java.util.Hashtable)26 Properties (java.util.Properties)22 IOException (java.io.IOException)21 Test (org.junit.Test)21 ManagedService (org.osgi.service.cm.ManagedService)20 FooService (org.apache.felix.ipojo.runtime.core.services.FooService)19 HashMap (java.util.HashMap)17 File (java.io.File)11 URISyntaxException (java.net.URISyntaxException)11 Collection (java.util.Collection)11 HashSet (java.util.HashSet)11 ServiceTracker (org.osgi.util.tracker.ServiceTracker)10 URI (java.net.URI)9 Dictionary (java.util.Dictionary)9 Map (java.util.Map)9 NotFoundException (org.opencastproject.util.NotFoundException)9