org.jwarp.service.param
Class ParamService
java.lang.Object
|
+--org.jwarp.service.AService
|
+--org.jwarp.service.param.ParamService
- All Implemented Interfaces:
- IConfigurable, IExceptionProvider, IParamService, IReferenceable, IService
- public class ParamService
- extends AService
- implements IParamService
This is the parameters providing and validating service interface. You can initiliaze all
setting and sub-services by a configuration file. Most of time you will define all you need
in such a configuration file and you do not dynamically add new settings and definitions. But if you need do - do it!
|
Field Summary |
protected java.util.Hashtable |
validations
The currently available validations |
protected java.util.Hashtable |
validators
The currently available validators |
| Fields inherited from class org.jwarp.service.AService |
context, createdDate, dependencies, emptyProperties, exceptionListeners, log, resumedDate, serviceName, serviceStatus, serviceType, startedDate, stoppedDate, suspendedDate, systemTicket |
|
Constructor Summary |
ParamService()
Creates a new parameter service |
| Methods inherited from class org.jwarp.service.AService |
addExceptionListener, checkContext, createLogFromXML, getContext, getCreationDate, getDependencies, getExceptionListeners, getLog, getLogLevel, getName, getReference, getResumedDate, getShutDownDate, getStartDate, getStatus, getSuspendedDate, getType, removeAllExceptionListeners, removeExceptionListener, resume, sendExceptionEvent, setContext, setDependencies, setLogLevel, setName, shutdown, start, suspend |
| Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.jwarp.service.IService |
checkContext, getDependencies, getLogLevel, getName, getStatus, getType, resume, setContext, setDependencies, setLogLevel, shutdown, start, suspend |
validators
protected java.util.Hashtable validators
- The currently available validators
validations
protected java.util.Hashtable validations
- The currently available validations
ParamService
public ParamService()
- Creates a new parameter service
configure
public void configure(org.jdom.Element config)
throws ConfigurationException
- Configure this object.
- Specified by:
configure in interface IConfigurable- Overrides:
configure in class AService
- Following copied from interface:
org.jwarp.service.configuration.IConfigurable
- Parameters:
configuration - the class configurations.
getValidator
public IValidator getValidator(java.lang.String paramName)
- Returns the validator with the given name. If the validator can not be found, null is returned.
- Specified by:
getValidator in interface IParamService
- Returns:
- The validator to the parameter type
addValidator
public IValidator addValidator(IValidator validator,
java.lang.String name)
- Add a validator. A previous existing validator is returned as a method result.
- Specified by:
addValidator in interface IParamService
- Parameters:
The - new validator- Returns:
- The previous validator or null
removeValidator
public IValidator removeValidator(java.lang.String name)
throws NotFoundException
- Remove a validator. The validator is returned as a method result.
- Specified by:
removeValidator in interface IParamService
- Parameters:
The - new validator- Returns:
- The previous validator
- Throws:
NotFoundException - Raised when no validator with the given name exists.
getValidators
public java.util.Iterator getValidators()
- Returns an iteratotr with all currently defined validators.
- Specified by:
getValidators in interface IParamService
- Returns:
- All validators.
getValidations
public java.util.Iterator getValidations()
- Return all defined validations.
- Specified by:
getValidations in interface IParamService
- Returns:
- All validations.
addValidation
public void addValidation(IValidation validation,
java.lang.String name)
- Add a new validation. A previous validation is returned as method result.
- Specified by:
addValidation in interface IParamService
- Parameters:
validation - The new validation- Returns:
- The previous validation or null
removeValidation
public IValidation removeValidation(java.lang.String name)
- Removes and returns the validation given.
- Specified by:
removeValidation in interface IParamService
- Parameters:
name - The name of the validation to be removed.- Returns:
- The validation removed.
- Throws:
NotFoundException - If the validation doesnot exist
getValidation
public IValidation getValidation(java.lang.String name)
- Gets the validation with the givwen name.
- Specified by:
getValidation in interface IParamService
- Returns:
- The validation or null
validate
public void validate(Parameter[] params,
java.lang.String validationName)
throws NotFoundException,
ParameterNotFoundException,
ParameterException
- Validates a parameter block with the validation given by its name.
- Specified by:
validate in interface IParamService
- Parameters:
params - The parameters.validationName - The name of the validation.- Throws:
NotFoundExceptino - If the validation could not be found.ParameterNotFoundException - If a parameter is missingParameterException - If a parameter could not be validated
validate
public void validate(Parameter param,
java.lang.String validatorName)
throws NotFoundException,
ParameterNotFoundException,
ParameterException
- Validates a parameter with the validator given by its name.
- Specified by:
validate in interface IParamService
- Parameters:
param - The parameter.validatorName - The name of the validator.- Throws:
NotFoundExceptino - If the validator could not be found.ParameterNotFoundException - If the parameter is missingParameterException - If the parameter could not be validated