public interface ServiceConfigurationValidator
Title: Open Service Framework
Description: The IServiceConfigurationValidator
provides a general interface for creating a
service configuration validator class.
Users should not implement this interface directly but rather extend from the abstract implementation
AbstractServiceConfigurationValidator
. This interface is a signiture class that may be used to
encapsulate a validator in a run-time framework, as is the case with AbstractServiceConfigurationObject
.
Copyright: Copyright (c) 2008
Company: StreamScape Technologies
Modifier and Type | Method and Description |
---|---|
ServiceConfigurationValidatorResults |
validate()
The
validate() method must be implemented by the developer in order to perform validation on the Service Configuration
Properties . |
ServiceConfigurationValidatorResults validate()
validate()
method must be implemented by the developer in order to perform validation on the Service Configuration
Properties
. A typical implementation would work on a list of configuration property values. For example:
public ServiceConfigurationValidatorResults validate() { Enumeration properties = getProperties().getPropertyNames(); while(properties.hasMoreElements()) { ServiceConfigurationProperty prop = (ServiceConfigurationProperty) properties.nextElement(); this.eval(prop); } return this.getValidationResultSet(); }
Then later in the code.. ..
private void eval(ServiceConfigurationProperty p) { String type = p.getType(); // Validate if a property is required if( (p.isRequired()) && (p.getValue().equalsIgnoreCase("")) ) { ServiceConfigurationValidatorResults.ValidatorResult result = this.getValidationResultSet().createValidationResult(p.getName()); result.setType(ServiceConfigurationValidatorResults.Type.PROPERTY_SEVERE); result.setMessage("Property is a required property but no value was specified." ); this.getValidationResultSet().addResult(result); } // Validate for types if(p.getType().equalsIgnoreCase(Types.STRING)) { .. Some logic here } else if(p.getType().equalsIgnoreCase(Types.XML)) { .. Some logic here } . . }
Copyright © 2015-2024 StreamScape Technologies. All rights reserved.