Package org.apache.avalon.framework.parameters

Examples of org.apache.avalon.framework.parameters.ParameterException


        {
            return Class.forName( className ).newInstance();
        }
        catch ( final Exception e )
        {
            throw new ParameterException(
                "Unable to instantiate: " + className, e
            );
        }
    }
View Full Code Here


        {
            return Class.forName( className ).newInstance();
        }
        catch ( final Exception e )
        {
            throw new ParameterException(
                "Unable to instantiate: " + className, e
            );
        }
    }
View Full Code Here

        int percent = params.getParameterAsInteger("percent_to_free", 10);
        this.invokeGC = params.getParameterAsBoolean("invokegc", this.invokeGC);

        if (getMinFreeMemory() < 1)
        {
            throw new ParameterException("StoreJanitorImpl freememory parameter has to be greater then 1");
        }
        if (getMaxHeapSize() < 1)
        {
            throw new ParameterException("StoreJanitorImpl heapsize parameter has to be greater then 1");
        }
        if (getThreadInterval() < 1)
        {
            throw new ParameterException("StoreJanitorImpl cleanupthreadinterval parameter has to be greater then 1");
        }
        if (getPriority() < 1 || getPriority() > 10)
        {
            throw new ParameterException("StoreJanitorImpl threadpriority has to be between 1 and 10");
        }
        if (percent > 100 && percent < 1)
        {
            throw new ParameterException("StoreJanitorImpl percent_to_free, has to be between 1 and 100");
        }

        this.fraction = percent / 100.0D;
        this.storelist = new ArrayList();
View Full Code Here

    {
        m_maxobjects = params.getParameterAsInteger( "maxobjects", 100 );
        m_persistent = params.getParameterAsBoolean( "use-persistent-cache", false );
        if( ( m_maxobjects < 1 ) )
        {
            throw new ParameterException( "MRUMemoryStore maxobjects must be at least 1!" );
        }

        if ( m_persistent )
        {
            if( getLogger().isDebugEnabled() )
            {
                getLogger().debug( "Looking up " + Store.PERSISTENT_STORE );
            }
            try
            {
                m_persistentStore = (Store)m_manager.lookup( Store.PERSISTENT_STORE );
            }
            catch (ServiceException se)
            {
                throw new ParameterException("Unable to look up persistent store.", se);
            }
        }

        m_cache = new Hashtable( (int)( m_maxobjects * 1.2 ) );
        m_mrulist = new LinkedList();
View Full Code Here

        else if( null == m_store )
        {
            final String message =
                "XSLTProcessor: use-store is set to true, " +
                "but unable to aquire the Store.";
            throw new ParameterException( message );
        }
    }
View Full Code Here

                final Class factoryClass = loadClass( saxParserFactoryName );
                m_factory = (SAXParserFactory)factoryClass.newInstance();
            }
            catch( Exception e )
            {
                throw new ParameterException( "Cannot load SAXParserFactory class " + saxParserFactoryName, e );
            }
        }
        m_factory.setNamespaceAware( true );
        m_factory.setValidating( validate );

        // Get the DocumentFactory
        final String documentBuilderFactoryName = params.getParameter( "document-builder-factory",
                                                                       "javax.xml.parsers.DocumentBuilderFactory" );
        if( "javax.xml.parsers.DocumentBuilderFactory".equals( documentBuilderFactoryName ) )
        {
            m_docFactory = DocumentBuilderFactory.newInstance();
        }
        else
        {
            try
            {
                final Class factoryClass = loadClass( documentBuilderFactoryName );
                m_docFactory = (DocumentBuilderFactory)factoryClass.newInstance();
            }
            catch( Exception e )
            {
                throw new ParameterException( "Cannot load DocumentBuilderFactory class " + documentBuilderFactoryName, e );
            }
        }
        m_docFactory.setNamespaceAware( true );
        m_docFactory.setValidating( validate );
View Full Code Here

            final String dir = params.getParameter("directory");
            this.setDirectory(new File(dir));
        }
        catch (IOException e)
        {
            throw new ParameterException("Unable to set directory", e);
        }

        final String databaseName = params.getParameter("data-file", "store.dat");
        final String indexName = params.getParameter("index-file", "store.idx");
        final int order = params.getParameterAsInteger("order", 301);
View Full Code Here

            // Will use specific class
            try {
                Class factoryClass = ClassUtils.loadClass(className);
                factory = (SAXParserFactory)factoryClass.newInstance();
            } catch(Exception e) {
                throw new ParameterException("Cannot load SAXParserFactory class " + className, e);
            }
        }
        factory.setNamespaceAware(true);
        factory.setValidating(validate);

        // Get the DocumentFactory
        className = params.getParameter("document-builder-factory", null);
        if (className == null) {
            this.docFactory = DocumentBuilderFactory.newInstance();
        } else {
            // Will use specific class
            try {
                Class factoryClass = ClassUtils.loadClass(className);
                this.docFactory = (DocumentBuilderFactory)factoryClass.newInstance();
            } catch(Exception e) {
                throw new ParameterException("Cannot load DocumentBuilderFactory class " + className, e);
            }
        }

        docFactory.setNamespaceAware(true);
        docFactory.setValidating(validate);
View Full Code Here

            if (defaultsFile != null) {
                defaults.load(Thread.currentThread().getContextClassLoader().
                    getResourceAsStream(defaultsFile));
            }
        } catch (IOException e) {
            throw new ParameterException("Failure loading cache defaults",e);
        }

        this.properties = new Properties(defaults);
        String[] names = parameters.getNames();
        for (int i = 0; i < names.length; i++) {
            if (names[i].startsWith("jcs.")) {
                this.properties.put(names[i], parameters.getParameter(names[i]));
            }
        }

        int maxobjects = parameters.getParameterAsInteger("maxobjects", -1);
        if (maxobjects != -1) {
            String key = "jcs.region." + region + ".cacheattributes.MaxObjects";
            this.properties.setProperty(key, String.valueOf(maxobjects));
        }

        // get the directory to use
        try {
            final File workDir = (File) context.get(Constants.CONTEXT_WORK_DIR);
            if (parameters.getParameterAsBoolean("use-cache-directory", false)) {
                final File cacheDir = (File) context.get(Constants.CONTEXT_CACHE_DIR);
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("Using cache directory: " + cacheDir);
                }
                setDirectory(cacheDir);
            } else if (parameters.getParameterAsBoolean("use-work-directory", false)) {
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("Using work directory: " + workDir);
                }
                setDirectory(workDir);
            } else if (parameters.getParameter("directory", null) != null) {
                String dir = parameters.getParameter("directory");
                dir = IOUtils.getContextFilePath(workDir.getPath(), dir);
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("Using directory: " + dir);
                }
                setDirectory(new File(dir));
            } else {
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("Using default directory: " + workDir);
                }
                setDirectory(workDir);
            }
        } catch (ContextException ce) {
            throw new ParameterException("Unable to get directory information from context.", ce);
        } catch (IOException e) {
            throw new ParameterException("Unable to set directory", e);
        }
    }
View Full Code Here

                    setDirectory(workDir);
                } catch (IOException e) {
                }
            }
        } catch (IOException e) {
            throw new ParameterException("Unable to set directory", e);
        }

    }
View Full Code Here

TOP

Related Classes of org.apache.avalon.framework.parameters.ParameterException

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.