class JVoiceXmlDocumentServer implements DocumentServer {

    @Override
    public VoiceXmlDocument getDocument(final String sessionId,
            final DocumentDescriptor descriptor) throws BadFetchError {
        final URI uri = descriptor.getUri();
        final SchemeStrategy strategy = getSchemeStrategy(uri);
        final RequestMethod method = descriptor.getMethod();
        final Collection<KeyValuePair> parameters = descriptor.getParameters();
        final FetchAttributes attrs = descriptor.getAttributes();
        final FetchAttributes mergedAttrs = mergeFetchAttributes(attrs);
        final long timeout = mergedAttrs.getFetchTimeout();
        LOGGER.info("loading document with URI '" + uri + "...");
        InputStream input = null;
        final VoiceXmlDocument document;
        try {
            input = strategy.getInputStream(sessionId, uri, method, timeout,
                    parameters);
            document = readDocument(input);
        } catch (UnsupportedElementError e) {
            throw new BadFetchError(e.getMessage(), e);
        } catch (IOException e) {
            throw new BadFetchError(e.getMessage(), e);
        } finally {
            if (input != null) {
                try {
                    input.close();
                } catch (IOException e) {
                    throw new BadFetchError(e);
                }
            }
        }

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("...read document");
            LOGGER.debug(document);
        }

        final Vxml vxml = document.getVxml();
        final String version = vxml.getVersion();
        if (version == null) {
            throw new BadFetchError("The document at '" + uri
                    + "' does not provide a version attribute!");
        }
        return document;
    }

    public  JVoiceXmlDocumentServer();

}