Package org.osgi.service.cm

Examples of org.osgi.service.cm.ConfigurationException


    }

    private static Boolean getMandatoryValue(Dictionary dict, String key) throws ConfigurationException {
        Object value = dict.get(key);
        if (value == null || !(value instanceof String || value instanceof Boolean)) {
            throw new ConfigurationException(key, "missing or invalid value!");
        }
        return parseBoolean(value);
    }
View Full Code Here


        this.properties = properties;
        this.bundleContext = bundleContext;
        // Transaction timeout
        int transactionTimeout = getInt(TRANSACTION_TIMEOUT, DEFAULT_TRANSACTION_TIMEOUT);
        if (transactionTimeout <= 0) {
            throw new ConfigurationException(TRANSACTION_TIMEOUT, "Property " + TRANSACTION_TIMEOUT + " must be > 0");
        }
        // XID factory
        XidFactory xidFactory = new XidFactoryImpl(pid.getBytes());
        // Transaction log
        if (getBool(RECOVERABLE, DEFAULT_RECOVERABLE)) {
            String bufferClassName = getString(HOWL_BUFFER_CLASS_NAME, "org.objectweb.howl.log.BlockLogBuffer");
            int bufferSizeKBytes = getInt(HOWL_BUFFER_SIZE, 32);
            if (bufferSizeKBytes < 1 || bufferSizeKBytes > 32) {
                throw new ConfigurationException(HOWL_BUFFER_SIZE, "bufferSize must be between 1 and 32");
            }
            boolean checksumEnabled = getBool(HOWL_CHECKSUM_ENABLED, true);
            boolean adler32Checksum = getBool(HOWL_ADLER32_CHECKSUM, true);
            int flushSleepTimeMilliseconds = getInt(HOWL_FLUSH_SLEEP_TIME, 50);
            String logFileExt = getString(HOWL_LOG_FILE_EXT, "log");
            String logFileName = getString(HOWL_LOG_FILE_NAME, "transaction");
            int maxBlocksPerFile = getInt(HOWL_MAX_BLOCKS_PER_FILE, -1);
            int maxLogFiles = getInt(HOWL_MAX_LOG_FILES, 2);
            int minBuffers = getInt(HOWL_MIN_BUFFERS, 4);
            if (minBuffers < 0) {
                throw new ConfigurationException(HOWL_MIN_BUFFERS, "minBuffers must be > 0");
            }
            int maxBuffers = getInt(HOWL_MAX_BUFFERS, 0);
            if (maxBuffers > 0 && minBuffers < maxBuffers) {
                throw new ConfigurationException(HOWL_MAX_BUFFERS, "minBuffers must be <= maxBuffers");
            }
            int threadsWaitingForceThreshold = getInt(HOWL_THREADS_WAITING_FORCE_THRESHOLD, -1);
            String logFileDir = getString(HOWL_LOG_FILE_DIR, null);
            if (logFileDir == null || logFileDir.length() == 0 || !new File(logFileDir).isAbsolute()) {
                throw new ConfigurationException(HOWL_LOG_FILE_DIR, "Property should be set to an absolute directory");
            }
            try {
                transactionLog = new HOWLLog(bufferClassName,
                                             bufferSizeKBytes,
                                             checksumEnabled,
                                             adler32Checksum,
                                             flushSleepTimeMilliseconds,
                                             logFileDir,
                                             logFileExt,
                                             logFileName,
                                             maxBlocksPerFile,
                                             maxBuffers,
                                             maxLogFiles,
                                             minBuffers,
                                             threadsWaitingForceThreshold,
                                             xidFactory != null ? xidFactory : new XidFactoryImpl(),
                                             null);
            } catch (LogConfigurationException e) {
                // This should not really happen as we've checked properties earlier
                throw new ConfigurationException(null, null, e);
            } catch (IOException e) {
                // This should not really happen as we've checked properties earlier
                throw new ConfigurationException(null, null, e);
            }
        } else {
            transactionLog =  new UnrecoverableLog();
        }
        // Create transaction manager
View Full Code Here

        String value = (String) properties.get(property);
        if (value != null) {
            try {
                return Integer.parseInt(value);
            } catch (Exception e) {
                throw new ConfigurationException(property, "Error parsing " + property + "(" + value + ") property as an integer", e);
            }
        }
        return dflt;
    }
View Full Code Here

        String value = (String) properties.get(property);
        if (value != null) {
            try {
                return Boolean.parseBoolean(value);
            } catch (Exception e) {
                throw new ConfigurationException(property, "Error parsing " + property + "(" + value + ") property as a boolean", e);
            }
        }
        return dflt;
    }
View Full Code Here

    protected final void handleCallBackError( final Throwable error, final ServiceReference target, final TargetedPID pid )
    {
        if ( error instanceof ConfigurationException )
        {
            final ConfigurationException ce = ( ConfigurationException ) error;
            if ( ce.getProperty() != null )
            {
                this.cm.log( LogService.LOG_ERROR,
                    "{0}: Updating property {1} of configuration {2} caused a problem: {3}", new Object[]
                        { ConfigurationManager.toString( target ), ce.getProperty(), pid, ce.getReason(), ce } );
            }
            else
            {
                this.cm.log( LogService.LOG_ERROR, "{0}: Updating configuration {1} caused a problem: {2}",
                    new Object[]
                        { ConfigurationManager.toString( target ), pid, ce.getReason(), ce } );
            }
        }
        else
        {
            {
View Full Code Here

                {
                    Long number = ( Long ) properties.get( "number" );
                    long currentNumber = _factoryConfigUpdateLatch.getCount();
                    if ( number.longValue() != currentNumber )
                    {
                        throw new ConfigurationException( "number", "Expected number=" + currentNumber + ", actual="
                            + number );
                    }
                    _factoryConfigUpdateLatch.countDown();
                    log( LogService.LOG_DEBUG, "Config updated; update latch= " + _factoryConfigUpdateLatch.getCount()
                        + " (number=" + number + ")" );
                }
                catch ( ClassCastException e )
                {
                    throw new ConfigurationException( "number", e.getMessage(), e );
                }
            }
        }
View Full Code Here

                {
                    throw (ConfigurationException) x;
                }
                else
                {
                    throw new ConfigurationException("?", "Update failed", x);
                }
            }
        }
        else
        {
View Full Code Here

                    }
                    catch ( Exception e )
                    {
                        // IOException from getting/updated config
                        // IllegalStateException from hashing password
                        throw new ConfigurationException( OsgiManager.PROP_PASSWORD, "Cannot update password property",
                            e );
                    }
                    finally
                    {
                        bc.ungetService( ref );
View Full Code Here

        TimeUnit writeDelayUnit = DEFAULT_WRITE_DELAY_TIMEUNIT;

        if (properties != null) {
            Object wd = properties.get(KEY_WRITE_DISABLED);
            if (wd == null) {
                throw new ConfigurationException(KEY_WRITE_DISABLED, "Missing write disabled value!");
            }
            try {
                writeDisabled = Boolean.parseBoolean((String) wd);
            } catch (Exception e) {
                throw new ConfigurationException(KEY_WRITE_DISABLED, "Invalid write disabled value!");
            }

            if (!writeDisabled) {
                Object wdv = properties.get(KEY_WRITE_DELAY_VALUE);
                if (wdv == null) {
                    throw new ConfigurationException(KEY_WRITE_DELAY_VALUE, "Missing write delay value!");
                }
                try {
                    writeDelayValue = Integer.parseInt((String) wdv);
                } catch (Exception e) {
                    throw new ConfigurationException(KEY_WRITE_DELAY_VALUE, "Invalid write delay value!");
                }
                if (writeDelayValue <= 0) {
                    throw new ConfigurationException(KEY_WRITE_DELAY_VALUE, "Invalid write delay value!");
                }

                Object wdu = properties.get(KEY_WRITE_DELAY_TIMEUNIT);
                if (wdu != null) {
                    try {
                        writeDelayUnit = TimeUnit.valueOf(((String) wdu).toUpperCase());
                    } catch (Exception e) {
                        throw new ConfigurationException(KEY_WRITE_DELAY_TIMEUNIT, "Invalid write delay unit!");
                    }
                }
            }
        }
View Full Code Here

        {
            return null;
        }
        if (!(raw instanceof String))
        {
            throw new ConfigurationException(key, "invalid value");
        }
        return ((String) raw).trim();
    }
View Full Code Here

TOP

Related Classes of org.osgi.service.cm.ConfigurationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.