Package org.apache.avalon.framework.configuration

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


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

                    SAXConfigurationHandler builder = new SAXConfigurationHandler();
                    SourceUtil.toSAX(source, builder);

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

                    FormValidatorHelper.cacheConfiguration(source.getURI(), conf);
                } else {
                    logger.debug("Using cached configuration for " + descriptor);
                }
View Full Code Here


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

                    SAXConfigurationHandler builder = new SAXConfigurationHandler();
                    SourceUtil.parse(this.manager, resource, builder);

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

                    AbstractComplementaryConfigurableAction.configurations.put(resource.getURI(), conf);
                } else {
                    getLogger().debug("Using cached configuration for " + descriptor);
                }
View Full Code Here

            String url = getBuilderConfigURL();
            Configuration config;
            try {
                Source src = resolver.resolveURI(url);
                try {
                    SAXConfigurationHandler handler = new SAXConfigurationHandler();
                    SourceUtil.toSAX(this.manager, src, null, handler);
                    config = handler.getConfiguration();
                } finally {
                    resolver.release(src);
                }
            } catch (Exception e) {
                throw new ConfigurationException("Could not load TreeBuilder configuration from " +
View Full Code Here

    /**
     *
     */
    private Configuration readRefreshJobConfiguration() {
        Source source = null;
        SAXConfigurationHandler b = new SAXConfigurationHandler();
        try {
            if (this.configFile.exists()) {
                source = this.resolver.resolveURI(this.configFile.toURL().toString());
                SourceUtil.toSAX(this.manager, source, source.getMimeType(), b);
            }
        } catch (Exception ignore) {
            getLogger().warn("Unable to read configuration from " + this.configFile);
        } finally {
            if (source != null) {
                this.resolver.release(source);
            }
        }
        return b.getConfiguration();
    }
View Full Code Here

                    if (conf == null || conf.lastModified < resource.getLastModified()) {
                        getLogger().debug("(Re)Loading " + descriptor);
                        if (conf == null)
                            conf = new ConfigurationHelper();

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

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

                        this.cacheConfiguration(descriptor, conf);
                    } else {
                        getLogger().debug("Using cached configuration for " + descriptor);
                    }
View Full Code Here

        // Read sitemap roles
        Parser p = null;
        Configuration rolesConfig;
        try {
            p = (Parser)this.manager.lookup(Parser.ROLE);
            SAXConfigurationHandler b = new SAXConfigurationHandler();
            InputStream inputStream = ClassUtils.getResource("org/apache/cocoon/sitemap/sitemap.roles").openStream();
            InputSource is = new InputSource(inputStream);
            is.setSystemId("org/apache/cocoon/sitemap/sitemap.roles");
            p.setContentHandler(b);
            p.parse(is);
            rolesConfig = b.getConfiguration();
        } catch (Exception e) {
            getLogger().error("Could not configure Cocoon environment", e);
            throw new ConfigurationException("Error trying to load configurations", e);
        } finally {
            if (p != null) this.manager.release(p);
View Full Code Here

       
        try {
            URLFactory factory = (URLFactory)this.manager.lookup(URLFactory.ROLE);
            URLSource source = new URLSource(factory.getURL(XCONF_URL), this.manager);
            try {
                SAXConfigurationHandler handler = new SAXConfigurationHandler();
                source.toSAX(handler);
                builtin = handler.getConfiguration();
            } finally {
                this.manager.release((Component)factory);
                if (source != null) {
                    source.recycle();
                }
View Full Code Here

       
        // Read the tree definition file as a Configuration
        getLogger().debug("Building " + this.language + " from " + source.getSystemId());
       
        // Build a namespace-aware configuration object
        SAXConfigurationHandler handler = new NamespacedSAXConfigurationHandler();
        source.toSAX(handler);
        Configuration treeConfig = handler.getConfiguration();
       
        TreeBuilder treeBuilder = (TreeBuilder)this.treeBuilderClass.newInstance();
        LifecycleHelper.setupComponent(treeBuilder,
            getLogger(),
            this.context,
View Full Code Here

            super(enableNamespaces);
            this.broker = broker;
        }

        public Configuration buildFromNode(NodeValue configFile) throws SAXException {
            SAXConfigurationHandler handler = getHandler();
            handler.clear();
            configFile.toSAX(broker, handler, new Properties());
            return handler.getConfiguration();
        }
View Full Code Here

        Configuration roleConfig = null;

        try {
            this.configurationFile.refresh();
            p = (SAXParser)startupManager.lookup(SAXParser.ROLE);
            SAXConfigurationHandler b = new SAXConfigurationHandler();
            InputStream inputStream = ClassUtils.getResource("org/apache/cocoon/cocoon.roles").openStream();
            InputSource is = new InputSource(inputStream);
            is.setSystemId(this.configurationFile.getURI());
            p.parse(is, b);
            roleConfig = b.getConfiguration();
        } catch (Exception e) {
            throw new ConfigurationException("Error trying to load configurations", e);
        } finally {
            if (p != null) startupManager.release((Component)p);
        }

        DefaultRoleManager drm = new DefaultRoleManager();
        ContainerUtil.enableLogging(drm, getLogger().getChildLogger("roles"));
        ContainerUtil.configure(drm, roleConfig);
        roleConfig = null;

        try {
            p = (SAXParser)startupManager.lookup(SAXParser.ROLE);
            SAXConfigurationHandler b = new SAXConfigurationHandler();
            InputSource is = SourceUtil.getInputSource(this.configurationFile);
            p.parse(is, b);
            this.configuration = b.getConfiguration();
        } catch (Exception e) {
            throw new ConfigurationException("Error trying to load configurations",e);
        } finally {
            if (p != null) startupManager.release((Component)p);
        }

        Configuration conf = this.configuration;
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Root configuration: " + conf.getName());
        }
        if (! "cocoon".equals(conf.getName())) {
            throw new ConfigurationException("Invalid configuration file\n" + conf.toString());
        }
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Configuration version: " + conf.getAttribute("version"));
        }
        if (!Constants.CONF_VERSION.equals(conf.getAttribute("version"))) {
            throw new ConfigurationException("Invalid configuration schema version. Must be '" + Constants.CONF_VERSION + "'.");
        }

        String userRoles = conf.getAttribute("user-roles", "");
        if (!"".equals(userRoles)) {
            try {
                p = (SAXParser)startupManager.lookup(SAXParser.ROLE);
                SAXConfigurationHandler b = new SAXConfigurationHandler();
                org.apache.cocoon.environment.Context context =
                    (org.apache.cocoon.environment.Context) this.context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
                URL url = context.getResource(userRoles);
                if (url == null) {
                    throw new ConfigurationException("User-roles configuration '"+userRoles+"' cannot be found.");
                }
                InputSource is = new InputSource(new BufferedInputStream(url.openStream()));
                is.setSystemId(this.configurationFile.getURI());
                p.parse(is, b);
                roleConfig = b.getConfiguration();
            } catch (Exception e) {
                throw new ConfigurationException("Error trying to load user-roles configuration", e);
            } finally {
                startupManager.release((Component)p);
            }
View Full Code Here

TOP

Related Classes of org.apache.avalon.framework.configuration.SAXConfigurationHandler

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.