/** * Retrieve the <code>String</code> value of the specified parameter. * <p /> * If the specified parameter cannot be found, an exception is thrown. * * @param name the name of parameter * @return the value of parameter * @throws ParameterException if the specified parameter cannot be found */ public String getParameter( final String name ) throws ParameterException { if( null == name ) { throw new ParameterException( "You cannot lookup a null parameter" ); } final String test = (String)m_parameters.get( name ); if( null == test ) { throw new ParameterException( "The parameter '" + name + "' does not contain a value" ); } else { return test; } }
/** * Helper method to create a single instance from a class name. Assumes * given class name has a no-parameter constructor. * * @param className class name to instantiate * @return instantiated class * @exception ParameterException if an error occurs */ private Object getInstance( final String className ) throws ParameterException { try { return Class.forName( className ).newInstance(); } catch ( final Exception e ) { throw new ParameterException( "Unable to instantiate: " + className, e ); } } }
/** * Retrieve the <code>float</code> value of the specified parameter. * <p /> * If the specified parameter cannot be found, an exception is thrown. * * @param name the parameter name * @return the value * @throws ParameterException if the specified parameter cannot be found * or is not a Float value */ public float getParameterAsFloat( final String name ) throws ParameterException { try { return Float.parseFloat( getParameter( name ) ); } catch( final NumberFormatException e ) { throw new ParameterException( "Could not return a float value", e ); } }
/** * Retrieve the <code>boolean</code> value of the specified parameter. * <p /> * If the specified parameter cannot be found, an exception is thrown. * * @param name the parameter name * @return the value * @throws ParameterException if an error occurs * @throws ParameterException */ public boolean getParameterAsBoolean( final String name ) throws ParameterException { final String value = getParameter( name ); if( value.equalsIgnoreCase( "true" ) ) { return true; } else if( value.equalsIgnoreCase( "false" ) ) { return false; } else { throw new ParameterException( "Could not return a boolean value" ); } }
/** * @see org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters) */ public void parameterize(Parameters parameters) throws ParameterException { this.preemptiveLoaderURI = parameters.getParameter("preemptive-loader-url", null); if ( null != this.preemptiveLoaderURI && this.preemptiveLoaderURI.indexOf("://") == -1) { throw new ParameterException("The preemptive-loader-url must be absolute: " + this.preemptiveLoaderURI); } final String storeRole = parameters.getParameter("use-store", Store.ROLE); try { this.store = (Store)this.manager.lookup(storeRole); } catch (ServiceException e) { throw new ParameterException("Unable to lookup store with role " + storeRole, e); } this.defaultCacheStorage = new StoreIncludeCacheStorageProxy(this.store); }
/** * Retrieve the <code>long</code> value of the specified parameter. * <p /> * If the specified parameter cannot be found, an exception is thrown. * * Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary * numbers begin with 0b, all other values are assumed to be decimal. * * @param name the name of parameter * @return the long parameter type * @throws ParameterException if the specified parameter cannot be found * or is not a Long value. */ public long getParameterAsLong( final String name ) throws ParameterException { try { return parseLong( getParameter( name ) ); } catch( final NumberFormatException e ) { throw new ParameterException( "Could not return a long value", e ); } }
/** * Retrieve the <code>int</code> value of the specified parameter. * <p /> * If the specified parameter cannot be found, an exception is thrown. * * Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary * numbers begin with 0b, all other values are assumed to be decimal. * * @param name the name of parameter * @return the integer parameter type * @throws ParameterException if the specified parameter cannot be found * or is not an Integer value */ public int getParameterAsInteger( final String name ) throws ParameterException { try { return parseInt( getParameter( name ) ); } catch( final NumberFormatException e ) { throw new ParameterException( "Could not return an integer value", e ); } }
if( ( m_maxobjects < 1 ) ) throw new ParameterException( "MRUMemoryStore maxobjects must be at least 1!" ); throw new ParameterException("Unable to look up persistent store.", se);
/** * Configure the component */ public void parameterize(final Parameters params) throws ParameterException { m_useStore = params.getParameterAsBoolean("use-store", this.m_useStore); m_incrementalProcessing = params.getParameterAsBoolean("incremental-processing", this.m_incrementalProcessing); m_transformerFactory = params.getParameter("transformer-factory", null); m_checkIncludes = params.getParameterAsBoolean("check-includes", true); if (!m_useStore) { // release the store, if we don't need it anymore m_manager.release(m_store); m_store = null; } 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); } }
throw new ParameterException("StoreJanitorImpl freememory parameter has to be greater then 1"); throw new ParameterException("StoreJanitorImpl heapsize parameter has to be greater then 1"); throw new ParameterException("StoreJanitorImpl cleanupthreadinterval parameter has to be greater then 1"); throw new ParameterException("StoreJanitorImpl threadpriority has to be between 1 and 10"); throw new ParameterException("StoreJanitorImpl percent_to_free, has to be between 1 and 100");
throw new ParameterException("Unable to set directory", e);
throw new ParameterException(msg,t);
/** * @see org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters) * @param parameters the parameters * @throws ParameterException if unable to set the parameters */ public void parameterize(Parameters parameters) throws ParameterException { Object rawInstance = this.getRawInstance(false); if( rawInstance instanceof Parameterizable ) { try { this.getParentLogger().debug( "Parameterizable.parametrize() for " + this.getShorthand() ); ((Parameterizable) rawInstance).parameterize(parameters); } catch (ParameterException e) { String msg = "Parameterizing the following service failed : " + this.getShorthand(); this.getParentLogger().error(msg,e); throw e; } catch (Throwable t) { String msg = "Parameterizing the following service failed : " + this.getShorthand(); this.getParentLogger().error(msg,t); throw new ParameterException(msg,t); } } }