Package org.apache.avalon.framework.configuration

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


                    new StringBuffer( 192 )
                    .append( inboxRootURL )
                    .append( userName )
                    .append( "/" );
            String destination = destinationBuffer.toString();
            DefaultConfiguration mboxConf
                    = new DefaultConfiguration( "repository", "generated:AvalonFileRepository.compose()" );
            mboxConf.setAttribute( "destinationURL", destination );
            mboxConf.setAttribute( "type", "MAIL" );
            try {
                userInbox = ( MailRepository ) mailstore.select( mboxConf );
                mailboxes.put( userName, userInbox );
            }
            catch ( Exception e ) {
View Full Code Here


                Configuration defConf = (Configuration)defaultConfigs.get(key);
                if ( defConf == null) {
                    config = repConf;
                }
                else {
                    config = new DefaultConfiguration(repConf.getName(),
                                                      repConf.getLocation());
                    copyConfig(defConf, (DefaultConfiguration)config);
                    copyConfig(repConf, (DefaultConfiguration)config);
                }
View Full Code Here

     */
    public void initialize()
            throws Exception {
        try {
            //prepare Configurations for object and stream repositories
            DefaultConfiguration objectConfiguration
                = new DefaultConfiguration( "repository",
                                            "generated:AvalonFileRepository.compose()" );

            objectConfiguration.setAttribute("destinationURL", destination);
            objectConfiguration.setAttribute("type", "OBJECT");
            objectConfiguration.setAttribute("model", "SYNCHRONOUS");

            DefaultConfiguration streamConfiguration
                = new DefaultConfiguration( "repository",
                                            "generated:AvalonFileRepository.compose()" );

            streamConfiguration.setAttribute( "destinationURL", destination );
            streamConfiguration.setAttribute( "type", "STREAM" );
            streamConfiguration.setAttribute( "model", "SYNCHRONOUS" );

            sr = (StreamRepository) store.select(streamConfiguration);
            or = (ObjectRepository) store.select(objectConfiguration);
            lock = new Lock();
            keys = Collections.synchronizedSet(new HashSet());
View Full Code Here

                new StringBuffer(192)
                        .append(inboxRootURL)
                        .append(userName)
                        .append("/");
            String destination = destinationBuffer.toString();
            DefaultConfiguration mboxConf
                = new DefaultConfiguration("repository", "generated:AvalonFileRepository.compose()");
            mboxConf.setAttribute("destinationURL", destination);
            mboxConf.setAttribute("type", "MAIL");
            try {
                userInbox = (MailRepository) mailstore.select(mboxConf);
                mailboxes.put(userName, userInbox);
            } catch (Exception e) {
                e.printStackTrace();
View Full Code Here

        this.roleName = getRoleName(config);

        // Pass a copy of the top-level object to superclass so that
        // our name is properly initialized
        // FIXME : could be avoided if parent m_role was protected or had protected accessors
        DefaultConfiguration temp = new DefaultConfiguration(config.getName(), config.getLocation());
        if (config.getAttribute("role", null) != null) {
            temp.setAttribute("role", this.roleName);
        }
        super.configure(temp);

        // Get default hint
        this.defaultHint = config.getAttribute(this.getDefaultHintAttributeName(), null);
View Full Code Here

     * REVISIT (MC): when we can get the resolver anywhere, we can pass the
     * configuration object directly to XMLResourceBundle.
     */
    private void configureFactory(String location) throws Exception {
        // configure the factory to log correctly and cache catalogues
        DefaultConfiguration configuration =
                new DefaultConfiguration("name", "location");
        DefaultConfiguration cacheConf =
                new DefaultConfiguration(
                        BundleFactory.ConfigurationKeys.CACHE_AT_STARTUP,
                        "location"
                );
        cacheConf.setValue(new Boolean(cacheAtStartup).toString());
        configuration.addChild(cacheConf);

        // set the root location for message catalogues
        DefaultConfiguration dirConf =
                new DefaultConfiguration(
                        BundleFactory.ConfigurationKeys.ROOT_DIRECTORY,
                        "location"
                );

        debug("catalog location:" + location);
        Source source = null;
        try {
            source = sourceResolver.resolveURI(location);
            String systemId = source.getURI();
            debug("catalog directory:" + systemId);
            dirConf.setValue(systemId);
            configuration.addChild(dirConf);
        } finally {
            if (source != null)
                sourceResolver.release(source);
        }
View Full Code Here

            configSource = (ModifiableSource) resolver.resolveURI(publicationsUri + "/"
                    + newPublicationId + "/" + CONFIGURATION_FILE);

            final boolean ENABLE_XML_NAMESPACES = true;
            DefaultConfiguration config = (DefaultConfiguration) new DefaultConfigurationBuilder(
                    ENABLE_XML_NAMESPACES).build(configSource.getInputStream());
            addTemplateConfiguration(template, config);

            removeChildren(config.getMutableChild(ELEMENT_MODULES), ELEMENT_MODULE);
            removeChildren(config.getMutableChild(ELEMENT_RESOURCE_TYPES), ELEMENT_RESOURCE_TYPE);

            OutputStream oStream = configSource.getOutputStream();
            new DefaultConfigurationSerializer().serialize(oStream, config);
            if (oStream != null) {
                oStream.flush();
View Full Code Here

            throws ConfigurationException {
        Configuration[] templateConfigs = config.getChildren(ELEMENT_TEMPLATE);
        for (int i = 0; i < templateConfigs.length; i++) {
            config.removeChild(templateConfigs[i]);
        }
        DefaultConfiguration templateConfig = new DefaultConfiguration(ELEMENT_TEMPLATE, null,
                CONFIGURATION_NAMESPACE, "");
        templateConfig.setAttribute(ATTRIBUTE_ID, template.getId());
        config.addChild(templateConfig);
    }
View Full Code Here

     * also be used for setting up the per-thread pools.
    */
    private ResourceLimitingJdbcDataSource initPool(String maxPool) {
        ResourceLimitingJdbcDataSource source = null;
        source = new ResourceLimitingJdbcDataSource();
        DefaultConfiguration config = new DefaultConfiguration("rl-jdbc"); // $NON-NLS-1$

        if (log.isDebugEnabled()) {
            StringBuilder sb = new StringBuilder(40);
            sb.append("MaxPool: ");
            sb.append(maxPool);
            sb.append(" Timeout: ");
            sb.append(getTimeout());
            sb.append(" TrimInt: ");
            sb.append(getTrimInterval());
            sb.append(" Auto-Commit: ");
            sb.append(isAutocommit());
            log.debug(sb.toString());
        }
        DefaultConfiguration poolController = new DefaultConfiguration("pool-controller"); // $NON-NLS-1$
        poolController.setAttribute("max", maxPool); // $NON-NLS-1$
        poolController.setAttribute("max-strict", "true"); // $NON-NLS-1$ $NON-NLS-2$
        poolController.setAttribute("blocking", "true"); // $NON-NLS-1$ $NON-NLS-2$
        poolController.setAttribute("timeout", getTimeout()); // $NON-NLS-1$
        poolController.setAttribute("trim-interval", getTrimInterval()); // $NON-NLS-1$
        config.addChild(poolController);

        DefaultConfiguration autoCommit = new DefaultConfiguration("auto-commit"); // $NON-NLS-1$
        autoCommit.setValue(String.valueOf(isAutocommit()));
        config.addChild(autoCommit);

        if (log.isDebugEnabled()) {
            StringBuilder sb = new StringBuilder(40);
            sb.append("KeepAlive: ");
            sb.append(isKeepAlive());
            sb.append(" Age: ");
            sb.append(getConnectionAge());
            sb.append(" CheckQuery: ");
            sb.append(getCheckQuery());
            log.debug(sb.toString());
        }
        DefaultConfiguration cfgKeepAlive = new DefaultConfiguration("keep-alive"); // $NON-NLS-1$
        cfgKeepAlive.setAttribute("disable", String.valueOf(!isKeepAlive())); // $NON-NLS-1$
        cfgKeepAlive.setAttribute("age", getConnectionAge()); // $NON-NLS-1$
        cfgKeepAlive.setValue(getCheckQuery());
        poolController.addChild(cfgKeepAlive);

        String _username = getUsername();
        if (log.isDebugEnabled()) {
            StringBuilder sb = new StringBuilder(40);
            sb.append("Driver: ");
            sb.append(getDriver());
            sb.append(" DbUrl: ");
            sb.append(getDbUrl());
            sb.append(" User: ");
            sb.append(_username);
            log.debug(sb.toString());
        }
        DefaultConfiguration cfgDriver = new DefaultConfiguration("driver"); // $NON-NLS-1$
        cfgDriver.setValue(getDriver());
        config.addChild(cfgDriver);
        DefaultConfiguration cfgDbUrl = new DefaultConfiguration("dburl"); // $NON-NLS-1$
        cfgDbUrl.setValue(getDbUrl());
        config.addChild(cfgDbUrl);

        if (_username.length() > 0){
            DefaultConfiguration cfgUsername = new DefaultConfiguration("user"); // $NON-NLS-1$
            cfgUsername.setValue(_username);
            config.addChild(cfgUsername);
            DefaultConfiguration cfgPassword = new DefaultConfiguration("password"); // $NON-NLS-1$
            cfgPassword.setValue(getPassword());
            config.addChild(cfgPassword);
        }

        // log is required to ensure errors are available
        source.enableLogging(new LogKitLogger(log));
View Full Code Here

     * Checks that the <code>serializeToFile</code> method closes the output stream
     * when it is done.
     */
    public void testSerializeToFile() throws Exception
    {
        DefaultConfiguration config = new DefaultConfiguration("root", "");
        config.setAttribute( "attribute", "value" );
       
        File file = new File( testDirectory, "DefaultConfigurationSerializerTestCase.xml" );
       
        DefaultConfigurationSerializer serializer = new DefaultConfigurationSerializer();
        serializer.serializeToFile( file, config );
View Full Code Here

TOP

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

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.