Package org.osgi.service.cm

Examples of org.osgi.service.cm.ConfigurationException


    }

    public synchronized void updated(String pid, @SuppressWarnings("rawtypes") Dictionary dict) throws ConfigurationException {
        String name = (String) dict.get(LOG_NAME);
        if ((name == null) || "".equals(name)) {
            throw new ConfigurationException(LOG_NAME, "Log name has to be specified.");
        }

        Component service = m_instances.get(pid);
        if (service == null) {
            Properties props = new Properties();
View Full Code Here


    @SuppressWarnings("unchecked")
    public void updated(Dictionary dict) throws ConfigurationException {
        if (dict != null) {
            String path = (String) dict.get(OBRFileStoreConstants.FILE_LOCATION_KEY);
            if (path == null) {
                throw new ConfigurationException(OBRFileStoreConstants.FILE_LOCATION_KEY, "Missing property");
            }

            File newDir = new File(path);
            File curDir = getWorkingDir();

            if (!newDir.equals(curDir)) {
                if (!newDir.exists()) {
                    newDir.mkdirs();
                }
                else if (!newDir.isDirectory()) {
                    throw new ConfigurationException(OBRFileStoreConstants.FILE_LOCATION_KEY, "Is not a directory: " + newDir);
                }

                m_dir = newDir;
                m_dirChecksum = "";
            }
View Full Code Here

    private String get(Dictionary dict, String key) throws ConfigurationException {
        Object val = dict.get(key);

        if (val == null) {
            throw new ConfigurationException(key, "no such key defined");
        }

        if (val instanceof String) {
            return (String)val;
        }
        throw new ConfigurationException(key, "invalid format (not a String)");
    }
View Full Code Here

            url = url.replaceFirst("<port>", "" + m_port);
            location = new URL(url);

        }
        catch (Exception e) {
            throw new ConfigurationException(null, e.getMessage());
        }

        //all's well: apply
        m_serverType = serverType;
        m_location = location;
View Full Code Here

        throws ConfigurationException {
        if (null == context) {
            try {
                this.context = new InitialContext();
            } catch (NamingException e) {
                throw new ConfigurationException(
                    JNDI_NAME_PROPERTY, EXCEPTION_LOCALIZER.format(
                    "jndi-naming-exception"), e);
            }
        } else {
            this.context = context;
View Full Code Here

        synchronized (LOCK) {
            String jndiDataSourceName =
                (String) configuration.get(JNDI_NAME_PROPERTY);
            if (null == jndiDataSourceName || "".equals(jndiDataSourceName)) {
                throw new ConfigurationException(
                    JNDI_NAME_PROPERTY, EXCEPTION_LOCALIZER.format(
                    "property-is-not-set", JNDI_NAME_PROPERTY));
            }

            String tableName = (String) configuration.get(TABLE_NAME_PROPERTY);
            if (null == tableName || "".equals(tableName)) {
                throw new ConfigurationException(
                    TABLE_NAME_PROPERTY, EXCEPTION_LOCALIZER.format(
                    "property-is-not-set", TABLE_NAME_PROPERTY));
            }

            try {
                // now try to set up the datasource.
                final Context envContext =
                    (Context) context.lookup("java:comp/env");
                Object obj = envContext.lookup(jndiDataSourceName);
                // check it is the kind of object we expect
                if (!(obj instanceof DataSource)) {
                    throw new ConfigurationException(
                        JNDI_NAME_PROPERTY, EXCEPTION_LOCALIZER.format(
                        "unexpected-class",
                        new Object[]{DataSource.class, obj.getClass()}));
                }

                this.datasource = (DataSource) obj;
            } catch (NamingException e) {
                throw new ConfigurationException(
                    JNDI_NAME_PROPERTY, EXCEPTION_LOCALIZER.format(
                    "jndi-naming-exception"), e);
            }

            // now generate the prepared statement string
View Full Code Here

        synchronized (LOCK) {
            // message format string may be empty but not null
            String messageFormat = (String)
                configuration.get(MESSAGE_FORMAT_PROPERTY);
            if (null == messageFormat) {
                throw new ConfigurationException(
                    MESSAGE_FORMAT_PROPERTY, EXCEPTION_LOCALIZER.format(
                    "property-is-not-set", MESSAGE_FORMAT_PROPERTY));
            }
            // logger must be not null and not empty
            String loggerName = (String)
                configuration.get(LOGGER_NAME_PROPERTY);
            if (null == loggerName || "".equals(loggerName)) {
                throw new ConfigurationException(
                    LOGGER_NAME_PROPERTY, EXCEPTION_LOCALIZER.format(
                    "property-is-not-set", LOGGER_NAME_PROPERTY));
            }

            logger = Logger.getLogger(loggerName);
View Full Code Here

    public void updated(String pid, Dictionary dict) throws ConfigurationException {
        String ma = (String) dict.get(MA_NAME);
        String name = (String) dict.get(LOG_NAME);
        if ((name == null) || "".equals(name)) {
            throw new ConfigurationException(LOG_NAME, "Log name has to be specified.");
        }

        boolean needToAddComponent = false;
        Component component;
        synchronized (m_instances) {
View Full Code Here

        this.context = context;
        // create the SiteConfiguration based on the parsed properties
        // NOTE that the constructor also validation of the parsed configuration
        siteConfiguration = new ReferencedSiteConfigurationImpl(context.getProperties());
        if (PROHIBITED_SITE_IDS.contains(siteConfiguration.getId().toLowerCase())) {
            throw new ConfigurationException(SiteConfiguration.ID, String.format(
                "The ID '%s' of this Referenced Site is one of the following "
                        + "prohibited IDs: {} (case insensitive)", siteConfiguration.getId(),
                PROHIBITED_SITE_IDS));
        }
        log.info(" > initialise Referenced Site {}", siteConfiguration.getName());
View Full Code Here

        //check if all the Enumerated values are valid strings and convert them
        //to enumeration instances
        try {
            setCacheStrategy(getCacheStrategy());
        } catch (IllegalArgumentException e) {
            throw new ConfigurationException(CACHE_STRATEGY,
                String.format("Unknown CachStrategy (%s=%s) for Site %s! Valid values are %s ",
                    CACHE_STRATEGY,config.get(CACHE_STRATEGY),getId(),
                        Arrays.toString(CacheStrategy.values()),e));
        }
        //check that a cacheId is set if the CacheStrategy != none
        if(CacheStrategy.none != getCacheStrategy() && getCacheId() == null){
            throw new ConfigurationException(CACHE_ID,
                String.format("The CacheID (%s) MUST NOT be NULL nor empty if the the CacheStrategy != %s",
                    CACHE_ID,CacheStrategy.none));
        }
        //check that a accessUri and an entity dereferencer is set if the
        //cacheStrategy != CacheStrategy.all
        if(CacheStrategy.all != getCacheStrategy()){
            if(getAccessUri() == null){
                throw new ConfigurationException(ACCESS_URI,
                    String.format("An AccessUri (%s) MUST be configured if the CacheStrategy != %s",
                        ACCESS_URI,CacheStrategy.all));
            }
            if(getEntityDereferencerType() == null){
                throw new ConfigurationException(ENTITY_DEREFERENCER_TYPE,
                    String.format("An EntityDereferencer (%s) MUST be configured if the CacheStrategy != %s",
                        ENTITY_DEREFERENCER_TYPE,CacheStrategy.all));
            }
        }
    }
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.