Search in sources :

Example 1 with ServiceValidator

use of org.apache.cxf.tools.validator.ServiceValidator in project cxf by apache.

the class JavaScriptContainer method validate.

public void validate(final ServiceInfo service) throws ToolException {
    for (ServiceValidator validator : getServiceValidators()) {
        service.setProperty(ToolContext.class.getName(), context);
        validator.setService(service);
        if (!validator.isValid()) {
            throw new ToolException(validator.getErrorMessage());
        }
    }
}
Also used : ServiceValidator(org.apache.cxf.tools.validator.ServiceValidator) ToolContext(org.apache.cxf.tools.common.ToolContext) ToolException(org.apache.cxf.tools.common.ToolException)

Example 2 with ServiceValidator

use of org.apache.cxf.tools.validator.ServiceValidator in project cxf by apache.

the class WSDLToJavaContainer method validate.

public void validate(final ServiceInfo service) throws ToolException {
    for (ServiceValidator validator : getServiceValidators()) {
        service.setProperty(ToolContext.class.getName(), context);
        validator.setService(service);
        if (!validator.isValid()) {
            throw new ToolException(validator.getErrorMessage());
        }
    }
}
Also used : ServiceValidator(org.apache.cxf.tools.validator.ServiceValidator) ToolContext(org.apache.cxf.tools.common.ToolContext) ToolException(org.apache.cxf.tools.common.ToolException)

Example 3 with ServiceValidator

use of org.apache.cxf.tools.validator.ServiceValidator in project cxf by apache.

the class JavaScriptContainer method getServiceValidators.

public List<ServiceValidator> getServiceValidators() {
    List<ServiceValidator> validators = new ArrayList<>();
    Properties initialExtensions = null;
    try {
        initialExtensions = PropertiesLoaderUtils.loadAllProperties(SERVICE_VALIDATOR, Thread.currentThread().getContextClassLoader());
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
    for (Object element : initialExtensions.values()) {
        String validatorClass = (String) element;
        try {
            if (LOG.isLoggable(Level.FINE)) {
                LOG.fine("Found service validator : " + validatorClass);
            }
            ServiceValidator validator = (ServiceValidator) Class.forName(validatorClass, true, Thread.currentThread().getContextClassLoader()).newInstance();
            validators.add(validator);
        } catch (Exception ex) {
            LOG.log(Level.WARNING, "EXTENSION_ADD_FAILED_MSG", ex);
        }
    }
    return validators;
}
Also used : ServiceValidator(org.apache.cxf.tools.validator.ServiceValidator) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Properties(java.util.Properties) IOException(java.io.IOException) ToolException(org.apache.cxf.tools.common.ToolException) BadUsageException(org.apache.cxf.tools.common.toolspec.parser.BadUsageException)

Example 4 with ServiceValidator

use of org.apache.cxf.tools.validator.ServiceValidator in project cxf by apache.

the class WSDLToJavaContainer method getServiceValidators.

public List<ServiceValidator> getServiceValidators() {
    List<ServiceValidator> validators = new ArrayList<>();
    Properties initialExtensions = null;
    try {
        initialExtensions = PropertiesLoaderUtils.loadAllProperties(SERVICE_VALIDATOR, Thread.currentThread().getContextClassLoader());
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
    for (Iterator<?> it = initialExtensions.values().iterator(); it.hasNext(); ) {
        String validatorClass = (String) it.next();
        try {
            if (LOG.isLoggable(Level.FINE)) {
                LOG.fine("Found service validator : " + validatorClass);
            }
            ServiceValidator validator = (ServiceValidator) Class.forName(validatorClass, true, Thread.currentThread().getContextClassLoader()).newInstance();
            validators.add(validator);
        } catch (Exception ex) {
            LOG.log(Level.WARNING, "EXTENSION_ADD_FAILED_MSG", ex);
        }
    }
    return validators;
}
Also used : ServiceValidator(org.apache.cxf.tools.validator.ServiceValidator) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Properties(java.util.Properties) BadUsageException(org.apache.cxf.tools.common.toolspec.parser.BadUsageException) IOException(java.io.IOException) ToolException(org.apache.cxf.tools.common.ToolException)

Example 5 with ServiceValidator

use of org.apache.cxf.tools.validator.ServiceValidator in project cxf by apache.

the class JAXWSContainerTest method testGetServceValidator.

@Test
public void testGetServceValidator() throws Exception {
    JAXWSContainer container = new JAXWSContainer(null);
    List<ServiceValidator> validators = container.getServiceValidators();
    assertNotNull(validators);
    assertTrue(!validators.isEmpty());
}
Also used : ServiceValidator(org.apache.cxf.tools.validator.ServiceValidator) JAXWSContainer(org.apache.cxf.tools.wsdlto.frontend.jaxws.JAXWSContainer) Test(org.junit.Test)

Aggregations

ServiceValidator (org.apache.cxf.tools.validator.ServiceValidator)5 ToolException (org.apache.cxf.tools.common.ToolException)4 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Properties (java.util.Properties)2 ToolContext (org.apache.cxf.tools.common.ToolContext)2 BadUsageException (org.apache.cxf.tools.common.toolspec.parser.BadUsageException)2 JAXWSContainer (org.apache.cxf.tools.wsdlto.frontend.jaxws.JAXWSContainer)1 Test (org.junit.Test)1