Package org.apache.avalon.framework.configuration

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


        Configuration builtin;
        try {
            Source source = this.resolver.resolveURI(xconfURL);
            try {
                Settings settings = SettingsHelper.getSettings(this.context);
                SAXConfigurationHandler handler = new PropertyAwareSAXConfigurationHandler(settings, getLogger());
                SourceUtil.toSAX( this.manager, source, null, handler);
                builtin = handler.getConfiguration();
            } finally {
                this.resolver.release(source);
            }
        } catch(Exception e) {
            String msg = "Error while reading " + xconfURL + ": " + e.getMessage();
View Full Code Here


        Settings settings = SettingsHelper.getSettings(this.context);

        Configuration roles = null;
        try {
            p = (SAXParser) startupManager.lookup(SAXParser.ROLE);
            SAXConfigurationHandler b = new PropertyAwareSAXConfigurationHandler(settings, getLogger());
            URL url = ClassUtils.getResource("org/apache/cocoon/cocoon.roles");
            InputSource is = new InputSource(url.openStream());
            is.setSystemId(url.toString());
            p.parse(is, b);
            roles = 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, this.rootLogger.getChildLogger("roles"));
        ContainerUtil.configure(drm, roles);
        roles = null;

        try {
            this.configurationFile.refresh();
            p = (SAXParser)startupManager.lookup(SAXParser.ROLE);
            SAXConfigurationHandler b = new PropertyAwareSAXConfigurationHandler(settings, getLogger());
            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 PropertyAwareSAXConfigurationHandler(settings, getLogger());
                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(url.toString());
                p.parse(is, b);
                roles = 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

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

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

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

                    XSPFormValidatorHelper.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

        org.apache.excalibur.source.SourceResolver resolver = null;
        try {
            resolver = (org.apache.excalibur.source.SourceResolver)this.manager.lookup(org.apache.excalibur.source.SourceResolver.ROLE);
            org.apache.excalibur.source.Source source = resolver.resolveURI( xconfURL );
            try {
                SAXConfigurationHandler handler = new SAXConfigurationHandler();
                SourceUtil.toSAX( this.manager, source, null, handler);
                builtin = handler.getConfiguration();
            } finally {
                resolver.release( source );
            }
        } catch(Exception e) {
            String msg = "Error while reading " + xconfURL + ": " + e.getMessage();
View Full Code Here

        try {
            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);

            parser = (SAXParser) this.manager.lookup(SAXParser.ROLE);
            SAXConfigurationHandler confighandler = new SAXConfigurationHandler();

            source = resolver.resolveURI(this.file);

            parser.parse(new InputSource(source.getInputStream()),
                         confighandler);

            configuration = confighandler.getConfiguration();

        } catch (Exception e) {
            this.logger.error("Could not load slide configuration file", e);
            return;
        } finally {
View Full Code Here

                    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

     */
    public static Configuration build( final InputSource input, boolean validate )
        throws SAXException, ParserConfigurationException, IOException
    {
        final XMLReader reader = createXMLReader();
        final SAXConfigurationHandler handler = new SAXConfigurationHandler();
        setupXMLReader( reader, handler, validate );
        reader.parse( input );
        return handler.getConfiguration();
    }
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.parse(is, b);
            rolesConfig = b.getConfiguration();
        } catch (Exception e) {
            getLogger().error("Could not configure Cocoon environment", e);
            throw new ConfigurationException("Error trying to load configurations", e);
        } finally {
            this.manager.release(p);
View Full Code Here

        return callback.getFragment( params );
    }

    public XMLEventDescriptor resolve( XMLFragment fragment )
    {
        SAXConfigurationHandler handler = new SAXConfigurationHandler();
        Configuration config = handler.getConfiguration();
        DefaultXMLEventDescriptor descriptor = new DefaultXMLEventDescriptor();

        descriptor.m_name = config.getAttribute( "type", "null" );

        try
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.