com.sun.xml.ws.api.server.SDDocument Maven / Gradle / Ivy
/*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the license at
* https://glassfish.dev.java.net/public/CDDLv1.0.html.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at https://glassfish.dev.java.net/public/CDDLv1.0.html.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* you own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* Copyright 2006 Sun Microsystems Inc. All Rights Reserved
*/
package com.sun.xml.ws.api.server;
import com.sun.istack.Nullable;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.stream.XMLStreamException;
import javax.xml.namespace.QName;
import java.io.OutputStream;
import java.io.IOException;
import java.net.URL;
/**
* Represents an individual document that forms a {@link ServiceDefinition}.
*
*
* TODO:
* how does those documents refer to each other?
*
*
*
* @author Jitendra Kotamraju
*/
public interface SDDocument {
/**
* Gets the root tag name of this document.
*
*
* This can be used to identify a kind of document quickly
* (such as schema, WSDL, ...)
*
* @return
* always non-null.
*/
QName getRootName();
/**
* Returns true if this document is WSDL.
*/
boolean isWSDL();
/**
* Returns true if this document is schema.
*/
boolean isSchema();
/**
* Gets the system ID of the document where it's taken from. Generated documents
* use a fake URL that can be used to resolve relative URLs. So donot use this URL
* for reading or writing.
*/
URL getURL();
/**
* Writes the document to the given {@link OutputStream}.
*
*
* Since {@link ServiceDefinition} doesn't know which endpoint address
* {@link Adapter} is serving to, (and often it serves multiple URLs
* simultaneously), this method takes the PortAddressResolver as a parameter,
* so that it can produce the corret address information in the generated WSDL.
*
* @param portAddressResolver
* An endpoint address resolver that gives endpoint address for a WSDL
* port. Can be null.
* @param resolver
* Used to resolve relative references among documents.
* @param os
* The {@link OutputStream} that receives the generated document.
*
* @throws IOException
* if there was a failure reported from the {@link OutputStream}.
*/
void writeTo(@Nullable PortAddressResolver portAddressResolver,
DocumentAddressResolver resolver, OutputStream os) throws IOException;
/**
* Writes the document to the given {@link XMLStreamWriter}.
*
*
* The same as {@link #writeTo(PortAddressResolver,DocumentAddressResolver,OutputStream)} except
* it writes to an {@link XMLStreamWriter}.
*
*
* The implementation must not call {@link XMLStreamWriter#writeStartDocument()}
* nor {@link XMLStreamWriter#writeEndDocument()}. Those are the caller's
* responsibility.
*
* @throws XMLStreamException
* if the {@link XMLStreamWriter} reports an error.
*/
void writeTo(PortAddressResolver portAddressResolver,
DocumentAddressResolver resolver, XMLStreamWriter out) throws XMLStreamException, IOException;
/**
* {@link SDDocument} that represents an XML Schema.
*/
interface Schema extends SDDocument {
/**
* Gets the target namepsace of this schema.
*/
String getTargetNamespace();
}
/**
* {@link SDDocument} that represents a WSDL.
*/
interface WSDL extends SDDocument {
/**
* Gets the target namepsace of this schema.
*/
String getTargetNamespace();
/**
* This WSDL has a portType definition
* that matches what {@link WSEndpoint} is serving.
*
* TODO: does this info needs to be exposed?
*/
boolean hasPortType();
/**
* This WSDL has a service definition
* that matches the {@link WSEndpoint}.
*
* TODO: does this info need to be exposed?
*/
boolean hasService();
}
}