class InterceptorDescriptorParser implements NodeParser<InterceptorDescriptor> {

    @Override
    public InterceptorDescriptor parseNode(final Node interceptorNode, final Document document) {
        InterceptorDescriptor interceptorDescriptor = null;
        if (interceptorNode != null) {
            Element el = (Element) interceptorNode;
            String name = el.getAttribute("name");
            String clazz = el.getAttribute("class");
            //check for dummy problem of not giving class attribute, or giving 'class' to the end of the class name
            if (clazz == null) {
                throw new DescriptorValidationFailedException("Validation of stub descriptor failed - Class name is missing.");
            }
            if (clazz.toLowerCase().endsWith(".class")) {
                throw new DescriptorValidationFailedException("Validation of stub descriptor failed - Class name '" + clazz
                        + "' should not contain 'class' at its end.");
            }
            ParameterList params = parseInterceptorParameters(el.getElementsByTagName("param"));
            RequestInterceptor requestInterceptor = null;
            ResponseInterceptor responseInterceptor = null;
            try {
                requestInterceptor = requestInterceptorInitializer.getExternalClassObject(clazz);
            } catch (InterfaceValidationFailedException e) {
                // don't worry
                LOGGER.debug("No Request interceptor in class:" + clazz, e);
            }
            try {
                responseInterceptor = responseInterceptorInitializer.getExternalClassObject(clazz);
            } catch (InterfaceValidationFailedException e) {
                //don't worry
                LOGGER.debug("No Response interceptor in class:" + clazz, e);
            }
            if (requestInterceptor == null && responseInterceptor == null) {
                throw new DescriptorValidationFailedException("Validation of stub descriptor failed - Class '" + clazz
                        + "' does not implement any of the necessary interfaces.");
            }
            interceptorDescriptor = new InterceptorDescriptor(name, requestInterceptor, responseInterceptor, params);
        }
        return interceptorDescriptor;
    }

}