Package org.apache.avalon.framework.configuration

Examples of org.apache.avalon.framework.configuration.ConfigurationException


            if (className == null) {
                String message = "Unable to determine class name for component named '" + hint +
                    "' at " + instance.getLocation();

                getLogger().error(message);
                throw new ConfigurationException(message);
            }

            try
            {
                Class clazz = this.classLoader.loadClass(className);
                addComponent(hint, clazz, instance);

            } catch(Exception e) {

                String message = "Could not load class " + className + " for component named '" +
                    hint + "' at " + instance.getLocation();

                getLogger().error(message, e);
                throw new ConfigurationException(message, e);
            }
        }
    }
View Full Code Here


                        getLogger().debug("registered method \"" + methodName + "\" as action \"" + actionName + "\"");
                    }
                }
            }
        } catch (Exception e) {
            throw new ConfigurationException("cannot get methods by reflection", e);
        }
    }
View Full Code Here

     * Implemenation of configurable interface.
     * Configure this transformer.
     */
    public void configure(Configuration conf) throws ConfigurationException {
        if (factory == null) {
            throw new ConfigurationException("BundleFactory component is not found.");
        }
        // read in the config options from the transformer definition

        // there are two possible configuration methods:
        //  (1) the one dating from before multiple catalogues were supported:
        //      in this case the elements catalogue-name and catalogue-location specify
        //      the catalogue to be used
        //  (2) the new one supporting mulitple catalogues

        // obtain the base name of the message catalogue
        Configuration child = conf.getChild(I18N_CATALOGUE_NAME);
        catalogueName = child.getValue(null);

        // obtain the directory location of message catalogues
        child = conf.getChild(I18N_CATALOGUE_LOCATION);
        catalogueLocation = child.getValue(null);

        Configuration cataloguesConf = conf.getChild("catalogues", false);

        if ((catalogueName != null || catalogueLocation != null) && cataloguesConf != null) {
            // if old and new style configuration are used at the same time...
            throw new ConfigurationException("I18nTransformer: old and new configuration style are used at the same time. Use either the 'catalogue-name' and 'catalogue-location' elements or use the 'catalogues' element, but don't use both at the same time.");
        } else if (catalogueName != null || catalogueLocation != null) {
            if (!(catalogueName != null && catalogueLocation != null))
                throw new ConfigurationException("I18nTransformer: catalogue-name and catalogue-location must both be specified");
            if (getLogger().isDebugEnabled())
                getLogger().debug("using old-style configuration: name = " + catalogueName
                        + ", location = " + catalogueLocation);
        } else if (cataloguesConf == null) {
            // if both old and new style configuration are missing ...
            throw new ConfigurationException("Missing configuration for the I18nTransformer: a 'catalogues' element specifying the catalogues is required.");
        } else {
            // new configuration style
            Configuration[] catalogueConfs = cataloguesConf.getChildren("catalogue");
            for (int i = 0; i < catalogueConfs.length; i++) {
                String id = catalogueConfs[i].getAttribute("id");
                String name = catalogueConfs[i].getAttribute("name");
                String location = catalogueConfs[i].getAttribute("location");
                CatalogueInfo newCatalogueInfo;
                try {
                    newCatalogueInfo = new CatalogueInfo(name, location);
                } catch (PatternException e) {
                    throw new ConfigurationException("I18nTransformer: error in name or location attribute on catalogue element with id " + id, e);
                }
                catalogues.put(id, newCatalogueInfo);
            }

            defaultCatalogueId = cataloguesConf.getAttribute("default");
            if (!catalogues.containsKey(defaultCatalogueId))
                throw new ConfigurationException("I18nTransformer: default catalogue id '" + defaultCatalogueId + "' denotes a nonexisting catalogue");
        }

        // obtain default text to use for untranslated messages
        child = conf.getChild(I18N_UNTRANSLATED);
        untranslated = child.getValue(null);
View Full Code Here

     */
    protected Configuration getConfiguration(String descriptor, SourceResolver resolver, boolean reloadable) throws ConfigurationException {
        ConfigurationHelper conf = null;

        if (descriptor == null) {
            throw new ConfigurationException("The form descriptor is not set!");
        }

        synchronized (AbstractComplementaryConfigurableAction.configurations) {
            Source resource = null;
            try {
                resource = resolver.resolveURI(descriptor);
                conf = (ConfigurationHelper) AbstractComplementaryConfigurableAction.configurations.get(resource.getURI());
                if (conf == null || (reloadable && conf.lastModified != resource.getLastModified())) {
                    getLogger().debug("(Re)Loading " + descriptor);

                    if (conf == null) {
                        conf = new ConfigurationHelper();
                    }

                    SAXConfigurationHandler builder = new SAXConfigurationHandler();
                    resolver.toSAX(resource, builder);

                    conf.lastModified = resource.getLastModified();
                    conf.configuration = builder.getConfiguration();

                    AbstractComplementaryConfigurableAction.configurations.put(resource.getURI(), conf);
                } else {
                    getLogger().debug("Using cached configuration for " + descriptor);
                }
            } catch (Exception e) {
                getLogger().error("Could not configure Database mapping environment", e);
                throw new ConfigurationException("Error trying to load configurations for resource: "
                    + (resource == null ? "null" : resource.getURI()));
            } finally {
                resolver.release(resource);
            }
        }
View Full Code Here

            this.generatorHandler.enableLogging(getLogger());
            this.generatorHandler.initialize();

        } catch(Exception e) {
            throw new ConfigurationException("Cannot set up component handler", e);
        }
    }
View Full Code Here

    public void configure(Configuration config) throws ConfigurationException {

        super.configure(config);
        this.reloadAll = config.getChild("reloadable").getValueAsBoolean(this.reloadAll);
        if (config.getChild("cachable", false) != null) {
            throw new ConfigurationException(
                    "Bzzt! Wrong spelling at "+config.getChild("cachable").getLocation()+": please use 'cacheable', not 'cachable'");
        }
        this.cacheAll = config.getChild("cacheable").getValueAsBoolean(this.cacheAll);

        Configuration[] files = config.getChildren("file");
        if (this.documents == null)
            this.documents = Collections.synchronizedMap(new HashMap());

        for (int i = 0; i < files.length; i++) {
            boolean reload = files[i].getAttributeAsBoolean("reloadable", this.reloadAll);
            boolean cache  = files[i].getAttributeAsBoolean("cacheable", this.cacheAll);
            this.src = files[i].getAttribute("src");
            // by assigning the source uri to this.src the last one will be the default
            // OTOH caching / reload parameters can be specified in one central place
            // if multiple file tags are used.
            this.documents.put(files[i], new DocumentHelper(reload, cache, this.src));
        }

        if (this.src == null)
            throw new ConfigurationException("No source given!");
    }
View Full Code Here

            if (modeConf != null) {
                final Configuration fileConf = modeConf.getChild("file");
                reload = fileConf.getAttributeAsBoolean("reloadable",reload);
                cache = fileConf.getAttributeAsBoolean("cacheable",cache);
                if (fileConf.getAttribute("cachable", null) != null) {
                    throw new ConfigurationException(
                            "Bzzt! Wrong spelling at "+fileConf.getLocation()+": please use 'cacheable', not 'cachable'");
                }

            }
            this.documents.put(src, new DocumentHelper(reload, cache, src));
        }

        Document dom = null;

        try{           
            dom = ((DocumentHelper) this.documents.get(src)).getDocument(this.manager, this.resolver, getLogger());
        } catch (Exception e) {
            if (getLogger().isDebugEnabled())
                getLogger().debug("Error using source "+src+"\n"+ e.getMessage(), e);
            throw new ConfigurationException("Error using source "+src, e);
        }
        return dom;

    }
View Full Code Here

    }

    public ProcessingNode buildNode(Configuration config) throws Exception {
       
        if (((SitemapLanguage)this.treeBuilder).isBuildingErrorHandler()) {
            throw new ConfigurationException("'map:redirect' is forbidden inside a 'map:handle-errors', at "
              + config.getLocation());
        }

        // Is it a redirect to resource ?
        this.resourceName = config.getAttribute("resource", null);
View Full Code Here

            CategoryNode resources = CategoryNodeBuilder.getCategoryNode(this.treeBuilder, "resources");

            if (resources == null) {
                String msg = "This sitemap contains no resources. Cannot redirect at " +
                    this.callNode.getLocation();
                throw new ConfigurationException(msg);
            }

            this.callNode.setResource(
                resources,
                this.resourceName
View Full Code Here

        if (this.isBuildingView) {
            // Labels are forbidden inside view definition
            if (statementLabels != null) {
                String msg = "Cannot put a 'label' attribute inside view definition at " + statement.getLocation();
                throw new ConfigurationException(msg);
            }

            // We are currently building a view. Don't recurse !
            return null;
        }
View Full Code Here

TOP

Related Classes of org.apache.avalon.framework.configuration.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.