001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036:
037: package com.sun.xml.ws.api.server;
038:
039: import com.sun.istack.Nullable;
040: import javax.xml.stream.XMLStreamWriter;
041: import javax.xml.stream.XMLStreamException;
042: import javax.xml.namespace.QName;
043: import java.io.OutputStream;
044: import java.io.IOException;
045: import java.net.URL;
046:
047: /**
048: * Represents an individual document that forms a {@link ServiceDefinition}.
049: *
050: * <pre>
051: * TODO:
052: * how does those documents refer to each other?
053: *
054: * </pre>
055: *
056: * @author Jitendra Kotamraju
057: */
058: public interface SDDocument {
059:
060: /**
061: * Gets the root tag name of this document.
062: *
063: * <p>
064: * This can be used to identify a kind of document quickly
065: * (such as schema, WSDL, ...)
066: *
067: * @return
068: * always non-null.
069: */
070: QName getRootName();
071:
072: /**
073: * Returns true if this document is WSDL.
074: */
075: boolean isWSDL();
076:
077: /**
078: * Returns true if this document is schema.
079: */
080: boolean isSchema();
081:
082: /**
083: * Gets the system ID of the document where it's taken from. Generated documents
084: * use a fake URL that can be used to resolve relative URLs. So donot use this URL
085: * for reading or writing.
086: */
087: URL getURL();
088:
089: /**
090: * Writes the document to the given {@link OutputStream}.
091: *
092: * <p>
093: * Since {@link ServiceDefinition} doesn't know which endpoint address
094: * {@link Adapter} is serving to, (and often it serves multiple URLs
095: * simultaneously), this method takes the PortAddressResolver as a parameter,
096: * so that it can produce the corret address information in the generated WSDL.
097: *
098: * @param portAddressResolver
099: * An endpoint address resolver that gives endpoint address for a WSDL
100: * port. Can be null.
101: * @param resolver
102: * Used to resolve relative references among documents.
103: * @param os
104: * The {@link OutputStream} that receives the generated document.
105: *
106: * @throws IOException
107: * if there was a failure reported from the {@link OutputStream}.
108: */
109: void writeTo(@Nullable
110: PortAddressResolver portAddressResolver,
111: DocumentAddressResolver resolver, OutputStream os)
112: throws IOException;
113:
114: /**
115: * Writes the document to the given {@link XMLStreamWriter}.
116: *
117: * <p>
118: * The same as {@link #writeTo(PortAddressResolver,DocumentAddressResolver,OutputStream)} except
119: * it writes to an {@link XMLStreamWriter}.
120: *
121: * <p>
122: * The implementation must not call {@link XMLStreamWriter#writeStartDocument()}
123: * nor {@link XMLStreamWriter#writeEndDocument()}. Those are the caller's
124: * responsibility.
125: *
126: * @throws XMLStreamException
127: * if the {@link XMLStreamWriter} reports an error.
128: */
129: void writeTo(PortAddressResolver portAddressResolver,
130: DocumentAddressResolver resolver, XMLStreamWriter out)
131: throws XMLStreamException, IOException;
132:
133: /**
134: * {@link SDDocument} that represents an XML Schema.
135: */
136: interface Schema extends SDDocument {
137: /**
138: * Gets the target namepsace of this schema.
139: */
140: String getTargetNamespace();
141: }
142:
143: /**
144: * {@link SDDocument} that represents a WSDL.
145: */
146: interface WSDL extends SDDocument {
147: /**
148: * Gets the target namepsace of this schema.
149: */
150: String getTargetNamespace();
151:
152: /**
153: * This WSDL has a portType definition
154: * that matches what {@link WSEndpoint} is serving.
155: *
156: * TODO: does this info needs to be exposed?
157: */
158: boolean hasPortType();
159:
160: /**
161: * This WSDL has a service definition
162: * that matches the {@link WSEndpoint}.
163: *
164: * TODO: does this info need to be exposed?
165: */
166: boolean hasService();
167: }
168: }
|