feat(jdk8): move files to new folder to avoid resources compiled.

This commit is contained in:
2025-09-07 15:25:52 +08:00
parent 3f0047bf6f
commit 8c35cfb1c0
17415 changed files with 217 additions and 213 deletions

View File

@@ -0,0 +1,178 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.wsdl.parser;
import com.sun.xml.internal.ws.api.model.wsdl.editable.*;
import com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtension;
import com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtensionContext;
import javax.xml.stream.XMLStreamReader;
/**
* Delegate to another {@link WSDLParserExtension}
* useful for the base class for filtering.
*
* @author Kohsuke Kawaguchi
*/
class DelegatingParserExtension extends WSDLParserExtension {
protected final WSDLParserExtension core;
public DelegatingParserExtension(WSDLParserExtension core) {
this.core = core;
}
public void start(WSDLParserExtensionContext context) {
core.start(context);
}
public void serviceAttributes(EditableWSDLService service, XMLStreamReader reader) {
core.serviceAttributes(service, reader);
}
public boolean serviceElements(EditableWSDLService service, XMLStreamReader reader) {
return core.serviceElements(service, reader);
}
public void portAttributes(EditableWSDLPort port, XMLStreamReader reader) {
core.portAttributes(port, reader);
}
public boolean portElements(EditableWSDLPort port, XMLStreamReader reader) {
return core.portElements(port, reader);
}
public boolean portTypeOperationInput(EditableWSDLOperation op, XMLStreamReader reader) {
return core.portTypeOperationInput(op, reader);
}
public boolean portTypeOperationOutput(EditableWSDLOperation op, XMLStreamReader reader) {
return core.portTypeOperationOutput(op, reader);
}
public boolean portTypeOperationFault(EditableWSDLOperation op, XMLStreamReader reader) {
return core.portTypeOperationFault(op, reader);
}
public boolean definitionsElements(XMLStreamReader reader) {
return core.definitionsElements(reader);
}
public boolean bindingElements(EditableWSDLBoundPortType binding, XMLStreamReader reader) {
return core.bindingElements(binding, reader);
}
public void bindingAttributes(EditableWSDLBoundPortType binding, XMLStreamReader reader) {
core.bindingAttributes(binding, reader);
}
public boolean portTypeElements(EditableWSDLPortType portType, XMLStreamReader reader) {
return core.portTypeElements(portType, reader);
}
public void portTypeAttributes(EditableWSDLPortType portType, XMLStreamReader reader) {
core.portTypeAttributes(portType, reader);
}
public boolean portTypeOperationElements(EditableWSDLOperation operation, XMLStreamReader reader) {
return core.portTypeOperationElements(operation, reader);
}
public void portTypeOperationAttributes(EditableWSDLOperation operation, XMLStreamReader reader) {
core.portTypeOperationAttributes(operation, reader);
}
public boolean bindingOperationElements(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
return core.bindingOperationElements(operation, reader);
}
public void bindingOperationAttributes(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
core.bindingOperationAttributes(operation, reader);
}
public boolean messageElements(EditableWSDLMessage msg, XMLStreamReader reader) {
return core.messageElements(msg, reader);
}
public void messageAttributes(EditableWSDLMessage msg, XMLStreamReader reader) {
core.messageAttributes(msg, reader);
}
public boolean portTypeOperationInputElements(EditableWSDLInput input, XMLStreamReader reader) {
return core.portTypeOperationInputElements(input, reader);
}
public void portTypeOperationInputAttributes(EditableWSDLInput input, XMLStreamReader reader) {
core.portTypeOperationInputAttributes(input, reader);
}
public boolean portTypeOperationOutputElements(EditableWSDLOutput output, XMLStreamReader reader) {
return core.portTypeOperationOutputElements(output, reader);
}
public void portTypeOperationOutputAttributes(EditableWSDLOutput output, XMLStreamReader reader) {
core.portTypeOperationOutputAttributes(output, reader);
}
public boolean portTypeOperationFaultElements(EditableWSDLFault fault, XMLStreamReader reader) {
return core.portTypeOperationFaultElements(fault, reader);
}
public void portTypeOperationFaultAttributes(EditableWSDLFault fault, XMLStreamReader reader) {
core.portTypeOperationFaultAttributes(fault, reader);
}
public boolean bindingOperationInputElements(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
return core.bindingOperationInputElements(operation, reader);
}
public void bindingOperationInputAttributes(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
core.bindingOperationInputAttributes(operation, reader);
}
public boolean bindingOperationOutputElements(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
return core.bindingOperationOutputElements(operation, reader);
}
public void bindingOperationOutputAttributes(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
core.bindingOperationOutputAttributes(operation, reader);
}
public boolean bindingOperationFaultElements(EditableWSDLBoundFault fault, XMLStreamReader reader) {
return core.bindingOperationFaultElements(fault, reader);
}
public void bindingOperationFaultAttributes(EditableWSDLBoundFault fault, XMLStreamReader reader) {
core.bindingOperationFaultAttributes(fault, reader);
}
public void finished(WSDLParserExtensionContext context) {
core.finished(context);
}
public void postFinished(WSDLParserExtensionContext context) {
core.postFinished(context);
}
}

View File

@@ -0,0 +1,78 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.wsdl.parser;
import com.sun.xml.internal.ws.api.streaming.XMLStreamReaderFactory;
import com.sun.xml.internal.ws.api.wsdl.parser.XMLEntityResolver;
import com.sun.xml.internal.ws.streaming.TidyXMLStreamReader;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
/**
* Wraps {@link EntityResolver} into {@link com.sun.xml.internal.ws.api.wsdl.parser.XMLEntityResolver}.
*
* @author Kohsuke Kawaguchi
*/
final class EntityResolverWrapper implements XMLEntityResolver {
private final EntityResolver core;
private boolean useStreamFromEntityResolver = false;
public EntityResolverWrapper(EntityResolver core) {
this.core = core;
}
public EntityResolverWrapper(EntityResolver core, boolean useStreamFromEntityResolver) {
this.core = core;
this.useStreamFromEntityResolver = useStreamFromEntityResolver;
}
public Parser resolveEntity(String publicId, String systemId) throws SAXException, IOException {
InputSource source = core.resolveEntity(publicId,systemId);
if(source==null)
return null; // default
// ideally entity resolvers should be giving us the system ID for the resource
// (or otherwise we won't be able to resolve references within this imported WSDL correctly),
// but if none is given, the system ID before the entity resolution is better than nothing.
if(source.getSystemId()!=null)
systemId = source.getSystemId();
URL url = new URL(systemId);
InputStream stream;
if (useStreamFromEntityResolver) {
stream = source.getByteStream();
} else {
stream = url.openStream();
}
return new Parser(url,
new TidyXMLStreamReader(XMLStreamReaderFactory.create(url.toExternalForm(), stream, true), stream));
}
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.wsdl.parser;
import javax.xml.ws.WebServiceException;
/**
* listen to static errors found during building a the WSDL Model.
*
* @author Vivek Pandey
*/
public interface ErrorHandler {
/**
* Receives a notification for an error in the annotated code.
*/
void error( Throwable e );
}

View File

@@ -0,0 +1,131 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.wsdl.parser;
import com.sun.xml.internal.ws.api.model.wsdl.editable.*;
import com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtension;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamReader;
/**
* {@link WSDLParserExtension} filter that checks if
* another {@link WSDLParserExtension} is following the contract.
*
* <p>
* This code protects the JAX-WS RI from broken extensions.
*
* <p>
* For now it just checks if {@link XMLStreamReader} is placed
* at the expected start/end element.
*
* @author Kohsuke Kawaguchi
*/
final class FoolProofParserExtension extends DelegatingParserExtension {
public FoolProofParserExtension(WSDLParserExtension core) {
super(core);
}
private QName pre(XMLStreamReader xsr) {
return xsr.getName();
}
private boolean post(QName tagName, XMLStreamReader xsr, boolean result) {
if(!tagName.equals(xsr.getName()))
return foundFool();
if(result) {
if(xsr.getEventType()!=XMLStreamConstants.END_ELEMENT)
foundFool();
} else {
if(xsr.getEventType()!=XMLStreamConstants.START_ELEMENT)
foundFool();
}
return result;
}
private boolean foundFool() {
throw new AssertionError("XMLStreamReader is placed at the wrong place after invoking "+core);
}
public boolean serviceElements(EditableWSDLService service, XMLStreamReader reader) {
return post(pre(reader),reader,super.serviceElements(service, reader));
}
public boolean portElements(EditableWSDLPort port, XMLStreamReader reader) {
return post(pre(reader),reader,super.portElements(port, reader));
}
public boolean definitionsElements(XMLStreamReader reader) {
return post(pre(reader),reader,super.definitionsElements(reader));
}
public boolean bindingElements(EditableWSDLBoundPortType binding, XMLStreamReader reader) {
return post(pre(reader),reader,super.bindingElements(binding, reader));
}
public boolean portTypeElements(EditableWSDLPortType portType, XMLStreamReader reader) {
return post(pre(reader),reader,super.portTypeElements(portType, reader));
}
public boolean portTypeOperationElements(EditableWSDLOperation operation, XMLStreamReader reader) {
return post(pre(reader),reader,super.portTypeOperationElements(operation, reader));
}
public boolean bindingOperationElements(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
return post(pre(reader),reader,super.bindingOperationElements(operation, reader));
}
public boolean messageElements(EditableWSDLMessage msg, XMLStreamReader reader) {
return post(pre(reader),reader,super.messageElements(msg, reader));
}
public boolean portTypeOperationInputElements(EditableWSDLInput input, XMLStreamReader reader) {
return post(pre(reader),reader,super.portTypeOperationInputElements(input, reader));
}
public boolean portTypeOperationOutputElements(EditableWSDLOutput output, XMLStreamReader reader) {
return post(pre(reader),reader,super.portTypeOperationOutputElements(output, reader));
}
public boolean portTypeOperationFaultElements(EditableWSDLFault fault, XMLStreamReader reader) {
return post(pre(reader),reader,super.portTypeOperationFaultElements(fault, reader));
}
public boolean bindingOperationInputElements(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
return super.bindingOperationInputElements(operation, reader);
}
public boolean bindingOperationOutputElements(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
return post(pre(reader),reader,super.bindingOperationOutputElements(operation, reader));
}
public boolean bindingOperationFaultElements(EditableWSDLBoundFault fault, XMLStreamReader reader) {
return post(pre(reader),reader,super.bindingOperationFaultElements(fault, reader));
}
}

View File

@@ -0,0 +1,90 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.wsdl.parser;
import javax.xml.ws.WebServiceException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* A list of {@link InaccessibleWSDLException} wrapped in one exception.
*
* <p>
* This exception is used to report all the errors during WSDL parsing from {@link RuntimeWSDLParser#parse(java.net.URL, javax.xml.transform.Source, org.xml.sax.EntityResolver, boolean, com.sun.xml.internal.ws.api.server.Container, com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtension[])}
*
* @author Vivek Pandey
*/
public class InaccessibleWSDLException extends WebServiceException {
private final List<Throwable> errors;
private static final long serialVersionUID = 1L;
public InaccessibleWSDLException(List<Throwable> errors) {
super(errors.size()+" counts of InaccessibleWSDLException.\n");
assert !errors.isEmpty() : "there must be at least one error";
this.errors = Collections.unmodifiableList(new ArrayList<Throwable>(errors));
}
public String toString() {
StringBuilder sb = new StringBuilder(super.toString());
sb.append('\n');
for( Throwable error : errors )
sb.append(error.toString()).append('\n');
return sb.toString();
}
/**
* Returns a read-only list of {@link InaccessibleWSDLException}s
* wrapped in this exception.
*
* @return
* a non-null list.
*/
public List<Throwable> getErrors() {
return errors;
}
public static class Builder implements ErrorHandler {
private final List<Throwable> list = new ArrayList<Throwable>();
public void error(Throwable e) {
list.add(e);
}
/**
* If an error was reported, throw the exception.
* Otherwise exit normally.
*/
public void check() throws InaccessibleWSDLException {
if(list.isEmpty())
return;
throw new InaccessibleWSDLException(list);
}
}
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.wsdl.parser;
import javax.xml.namespace.QName;
interface MIMEConstants {
// namespace URIs
static final String NS_WSDL_MIME = "http://schemas.xmlsoap.org/wsdl/mime/";
// QNames
static final QName QNAME_CONTENT = new QName(NS_WSDL_MIME, "content");
static final QName QNAME_MULTIPART_RELATED = new QName(NS_WSDL_MIME, "multipartRelated");
static final QName QNAME_PART = new QName(NS_WSDL_MIME, "part");
static final QName QNAME_MIME_XML = new QName(NS_WSDL_MIME, "mimeXml");
}

View File

@@ -0,0 +1,83 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.wsdl.parser;
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
import com.sun.xml.internal.ws.developer.MemberSubmissionAddressingFeature;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLFeaturedObject;
import com.sun.xml.internal.ws.api.model.wsdl.editable.*;
import com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
/**
* Member Submission WS-Addressing Runtime WSDL parser extension
*
* @author Arun Gupta
*/
public class MemberSubmissionAddressingWSDLParserExtension extends W3CAddressingWSDLParserExtension {
@Override
public boolean bindingElements(EditableWSDLBoundPortType binding, XMLStreamReader reader) {
return addressibleElement(reader, binding);
}
@Override
public boolean portElements(EditableWSDLPort port, XMLStreamReader reader) {
return addressibleElement(reader, port);
}
private boolean addressibleElement(XMLStreamReader reader, WSDLFeaturedObject binding) {
QName ua = reader.getName();
if (ua.equals(AddressingVersion.MEMBER.wsdlExtensionTag)) {
String required = reader.getAttributeValue(WSDLConstants.NS_WSDL, "required");
binding.addFeature(new MemberSubmissionAddressingFeature(Boolean.parseBoolean(required)));
XMLStreamReaderUtil.skipElement(reader);
return true; // UsingAddressing is consumed
}
return false;
}
@Override
public boolean bindingOperationElements(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
return false;
}
@Override
protected void patchAnonymousDefault(EditableWSDLBoundPortType binding) {
}
@Override
protected String getNamespaceURI() {
return AddressingVersion.MEMBER.wsdlNsUri;
}
@Override
protected QName getWsdlActionTag() {
return AddressingVersion.MEMBER.wsdlActionTag;
}
}

View File

@@ -0,0 +1,80 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.wsdl.parser;
import com.sun.xml.internal.stream.buffer.XMLStreamBufferResult;
import com.sun.xml.internal.ws.api.server.SDDocumentSource;
import com.sun.xml.internal.ws.api.wsdl.parser.XMLEntityResolver;
import com.sun.xml.internal.ws.util.JAXWSUtils;
import com.sun.xml.internal.ws.util.xml.XmlUtil;
import org.xml.sax.SAXException;
import javax.xml.stream.XMLStreamException;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.ws.WebServiceException;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Entity resolver that works on MEX Metadata
*
* @author Vivek Pandey
*/
public final class MexEntityResolver implements XMLEntityResolver {
private final Map<String, SDDocumentSource> wsdls = new HashMap<String, SDDocumentSource>();
public MexEntityResolver(List<? extends Source> wsdls) throws IOException {
Transformer transformer = XmlUtil.newTransformer();
for (Source source : wsdls) {
XMLStreamBufferResult xsbr = new XMLStreamBufferResult();
try {
transformer.transform(source, xsbr);
} catch (TransformerException e) {
throw new WebServiceException(e);
}
String systemId = source.getSystemId();
//TODO: can we do anything if the given mex Source has no systemId?
if(systemId != null){
SDDocumentSource doc = SDDocumentSource.create(JAXWSUtils.getFileOrURL(systemId), xsbr.getXMLStreamBuffer());
this.wsdls.put(systemId, doc);
}
}
}
public Parser resolveEntity(String publicId, String systemId) throws SAXException, IOException, XMLStreamException {
if (systemId != null) {
SDDocumentSource src = wsdls.get(systemId);
if (src != null)
return new Parser(src);
}
return null;
}
}

View File

@@ -0,0 +1,109 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.wsdl.parser;
import com.sun.xml.internal.ws.streaming.Attributes;
import com.sun.xml.internal.ws.streaming.XMLReaderException;
import com.sun.xml.internal.ws.util.xml.XmlUtil;
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
/**
*
* TODO: made public just for now
* @author WS Development Team
*/
public class ParserUtil {
public static String getAttribute(XMLStreamReader reader, String name) {
return reader.getAttributeValue(null, name);
}
public static String getAttribute(XMLStreamReader reader, String nsUri, String name) {
return reader.getAttributeValue(nsUri, name);
}
public static String getAttribute(XMLStreamReader reader, QName name) {
return reader.getAttributeValue(name.getNamespaceURI(), name.getLocalPart());
}
public static QName getQName(XMLStreamReader reader, String tag){
String localName = XmlUtil.getLocalPart(tag);
String pfix = XmlUtil.getPrefix(tag);
String uri = reader.getNamespaceURI(fixNull(pfix));
return new QName(uri, localName);
}
public static String getMandatoryNonEmptyAttribute(XMLStreamReader reader,
String name) {
// String value = getAttribute(reader, name);
String value = reader.getAttributeValue(null, name);
if (value == null) {
failWithLocalName("client.missing.attribute", reader, name);
} else if (value.equals("")) {
failWithLocalName("client.invalidAttributeValue", reader, name);
}
return value;
}
public static void failWithFullName(String key, XMLStreamReader reader) {
// throw new WebServicesClientException(key,
// new Object[]{
// Integer.toString(reader.getLineNumber()),
// reader.getName().toString()});
}
public static void failWithLocalName(String key, XMLStreamReader reader) {
//throw new WebServicesClientException(key,
// new Object[]{
// Integer.toString(reader.getLineNumber()),
// reader.getLocalName()});
}
public static void failWithLocalName(String key, XMLStreamReader reader,
String arg) {
//throw new WebServicesClientException(key,
// new Object[]{
// Integer.toString(reader.getLineNumber()),
// reader.getLocalName(),
// arg});
}
private static @NotNull String fixNull(@Nullable String s) {
if (s == null) return "";
else return s;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,73 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.wsdl.parser;
import com.sun.xml.internal.ws.encoding.soap.streaming.SOAPNamespaceConstants;
import com.sun.xml.internal.ws.encoding.soap.streaming.SOAP12NamespaceConstants;
import javax.xml.namespace.QName;
public interface SOAPConstants {
// namespace URIs
public static final String URI_ENVELOPE = SOAPNamespaceConstants.ENVELOPE;
public static final String URI_ENVELOPE12 = SOAP12NamespaceConstants.ENVELOPE;
public static final String NS_WSDL_SOAP =
"http://schemas.xmlsoap.org/wsdl/soap/";
public static final String NS_WSDL_SOAP12 =
"http://schemas.xmlsoap.org/wsdl/soap12/";
public static final String NS_SOAP_ENCODING = "http://schemas.xmlsoap.org/soap/encoding/";
// other URIs
public final String URI_SOAP_TRANSPORT_HTTP =
"http://schemas.xmlsoap.org/soap/http";
// QNames
public static final QName QNAME_ADDRESS =
new QName(NS_WSDL_SOAP, "address");
public static final QName QNAME_SOAP12ADDRESS =
new QName(NS_WSDL_SOAP12, "address");
public static final QName QNAME_BINDING =
new QName(NS_WSDL_SOAP, "binding");
public static final QName QNAME_BODY = new QName(NS_WSDL_SOAP, "body");
public static final QName QNAME_SOAP12BODY = new QName(NS_WSDL_SOAP12, "body");
public static final QName QNAME_FAULT = new QName(NS_WSDL_SOAP, "fault");
public static final QName QNAME_HEADER = new QName(NS_WSDL_SOAP, "header");
public static final QName QNAME_SOAP12HEADER = new QName(NS_WSDL_SOAP12, "header");
public static final QName QNAME_HEADERFAULT =
new QName(NS_WSDL_SOAP, "headerfault");
public static final QName QNAME_OPERATION =
new QName(NS_WSDL_SOAP, "operation");
public static final QName QNAME_SOAP12OPERATION =
new QName(NS_WSDL_SOAP12, "operation");
public static final QName QNAME_MUSTUNDERSTAND =
new QName(URI_ENVELOPE, "mustUnderstand");
}

View File

@@ -0,0 +1,71 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.wsdl.parser;
import com.sun.xml.internal.ws.api.model.wsdl.editable.*;
import javax.xml.stream.XMLStreamReader;
import javax.xml.namespace.QName;
/**
* W3C WS-Addressing Runtime WSDL parser extension that parses
* WS-Addressing Metadata wsdl extensibility elements
* This mainly reads wsam:Action element on input/output/fault messages in wsdl.
*
* @author Rama Pulavarthi
*/
public class W3CAddressingMetadataWSDLParserExtension extends W3CAddressingWSDLParserExtension {
String METADATA_WSDL_EXTN_NS = "http://www.w3.org/2007/05/addressing/metadata";
QName METADATA_WSDL_ACTION_TAG = new QName(METADATA_WSDL_EXTN_NS, "Action", "wsam");
@Override
public boolean bindingElements(EditableWSDLBoundPortType binding, XMLStreamReader reader) {
return false;
}
@Override
public boolean portElements(EditableWSDLPort port, XMLStreamReader reader) {
return false;
}
@Override
public boolean bindingOperationElements(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
return false;
}
@Override
protected void patchAnonymousDefault(EditableWSDLBoundPortType binding) {
}
@Override
protected String getNamespaceURI() {
return METADATA_WSDL_EXTN_NS;
}
@Override
protected QName getWsdlActionTag() {
return METADATA_WSDL_ACTION_TAG;
}
}

View File

@@ -0,0 +1,261 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.wsdl.parser;
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLFeaturedObject;
import static com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation.ANONYMOUS;
import com.sun.xml.internal.ws.api.model.wsdl.editable.*;
import com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtension;
import com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtensionContext;
import com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.soap.AddressingFeature;
/**
* W3C WS-Addressing Runtime WSDL parser extension
*
* @author Arun Gupta
*/
public class W3CAddressingWSDLParserExtension extends WSDLParserExtension {
@Override
public boolean bindingElements(EditableWSDLBoundPortType binding, XMLStreamReader reader) {
return addressibleElement(reader, binding);
}
@Override
public boolean portElements(EditableWSDLPort port, XMLStreamReader reader) {
return addressibleElement(reader, port);
}
private boolean addressibleElement(XMLStreamReader reader, WSDLFeaturedObject binding) {
QName ua = reader.getName();
if (ua.equals(AddressingVersion.W3C.wsdlExtensionTag)) {
String required = reader.getAttributeValue(WSDLConstants.NS_WSDL, "required");
binding.addFeature(new AddressingFeature(true, Boolean.parseBoolean(required)));
XMLStreamReaderUtil.skipElement(reader);
return true; // UsingAddressing is consumed
}
return false;
}
@Override
public boolean bindingOperationElements(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
EditableWSDLBoundOperation edit = (EditableWSDLBoundOperation) operation;
QName anon = reader.getName();
if (anon.equals(AddressingVersion.W3C.wsdlAnonymousTag)) {
try {
String value = reader.getElementText();
if (value == null || value.trim().equals("")) {
throw new WebServiceException("Null values not permitted in wsaw:Anonymous.");
// TODO: throw exception only if wsdl:required=true
// TODO: is this the right exception ?
} else if (value.equals("optional")) {
edit.setAnonymous(ANONYMOUS.optional);
} else if (value.equals("required")) {
edit.setAnonymous(ANONYMOUS.required);
} else if (value.equals("prohibited")) {
edit.setAnonymous(ANONYMOUS.prohibited);
} else {
throw new WebServiceException("wsaw:Anonymous value \"" + value + "\" not understood.");
// TODO: throw exception only if wsdl:required=true
// TODO: is this the right exception ?
}
} catch (XMLStreamException e) {
throw new WebServiceException(e); // TODO: is this the correct behavior ?
}
return true; // consumed the element
}
return false;
}
public void portTypeOperationInputAttributes(EditableWSDLInput input, XMLStreamReader reader) {
String action = ParserUtil.getAttribute(reader, getWsdlActionTag());
if (action != null) {
input.setAction(action);
input.setDefaultAction(false);
}
}
public void portTypeOperationOutputAttributes(EditableWSDLOutput output, XMLStreamReader reader) {
String action = ParserUtil.getAttribute(reader, getWsdlActionTag());
if (action != null) {
output.setAction(action);
output.setDefaultAction(false);
}
}
public void portTypeOperationFaultAttributes(EditableWSDLFault fault, XMLStreamReader reader) {
String action = ParserUtil.getAttribute(reader, getWsdlActionTag());
if (action != null) {
fault.setAction(action);
fault.setDefaultAction(false);
}
}
/**
* Process wsdl:portType operation after the entire WSDL model has been populated.
* The task list includes: <p>
* <ul>
* <li>Patch the value of UsingAddressing in wsdl:port and wsdl:binding</li>
* <li>Populate actions for the messages that do not have an explicit wsaw:Action</li>
* <li>Patch the default value of wsaw:Anonymous=optional if none is specified</li>
* </ul>
* @param context
*/
@Override
public void finished(WSDLParserExtensionContext context) {
EditableWSDLModel model = context.getWSDLModel();
for (EditableWSDLService service : model.getServices().values()) {
for (EditableWSDLPort port : service.getPorts()) {
EditableWSDLBoundPortType binding = port.getBinding();
// populate actions for the messages that do not have an explicit wsaw:Action
populateActions(binding);
// patch the default value of wsaw:Anonymous=optional if none is specified
patchAnonymousDefault(binding);
}
}
}
protected String getNamespaceURI() {
return AddressingVersion.W3C.wsdlNsUri;
}
protected QName getWsdlActionTag() {
return AddressingVersion.W3C.wsdlActionTag;
}
/**
* Populate all the Actions
*
* @param binding soapbinding:operation
*/
private void populateActions(EditableWSDLBoundPortType binding) {
EditableWSDLPortType porttype = binding.getPortType();
for (EditableWSDLOperation o : porttype.getOperations()) {
// TODO: this may be performance intensive. Alternatively default action
// TODO: can be calculated when the operation is actually invoked.
EditableWSDLBoundOperation wboi = binding.get(o.getName());
if (wboi == null) {
//If this operation is unbound set the action to default
o.getInput().setAction(defaultInputAction(o));
continue;
}
String soapAction = wboi.getSOAPAction();
if (o.getInput().getAction() == null || o.getInput().getAction().equals("")) {
// explicit wsaw:Action is not specified
if (soapAction != null && !soapAction.equals("")) {
// if soapAction is non-empty, use that
o.getInput().setAction(soapAction);
} else {
// otherwise generate default Action
o.getInput().setAction(defaultInputAction(o));
}
}
// skip output and fault processing for one-way methods
if (o.getOutput() == null)
continue;
if (o.getOutput().getAction() == null || o.getOutput().getAction().equals("")) {
o.getOutput().setAction(defaultOutputAction(o));
}
if (o.getFaults() == null || !o.getFaults().iterator().hasNext())
continue;
for (EditableWSDLFault f : o.getFaults()) {
if (f.getAction() == null || f.getAction().equals("")) {
f.setAction(defaultFaultAction(f.getName(), o));
}
}
}
}
/**
* Patch the default value of wsaw:Anonymous=optional if none is specified
*
* @param binding WSDLBoundPortTypeImpl
*/
protected void patchAnonymousDefault(EditableWSDLBoundPortType binding) {
for (EditableWSDLBoundOperation wbo : binding.getBindingOperations()) {
if (wbo.getAnonymous() == null)
wbo.setAnonymous(ANONYMOUS.optional);
}
}
private String defaultInputAction(EditableWSDLOperation o) {
return buildAction(o.getInput().getName(), o, false);
}
private String defaultOutputAction(EditableWSDLOperation o) {
return buildAction(o.getOutput().getName(), o, false);
}
private String defaultFaultAction(String name, EditableWSDLOperation o) {
return buildAction(name, o, true);
}
protected static final String buildAction(String name, EditableWSDLOperation o, boolean isFault) {
String tns = o.getName().getNamespaceURI();
String delim = SLASH_DELIMITER;
// TODO: is this the correct way to find the separator ?
if (!tns.startsWith("http"))
delim = COLON_DELIMITER;
if (tns.endsWith(delim))
tns = tns.substring(0, tns.length()-1);
if (o.getPortTypeName() == null)
throw new WebServiceException("\"" + o.getName() + "\" operation's owning portType name is null.");
return tns +
delim +
o.getPortTypeName().getLocalPart() +
delim +
(isFault ? o.getName().getLocalPart() + delim + "Fault" + delim : "") +
name;
}
protected static final String COLON_DELIMITER = ":";
protected static final String SLASH_DELIMITER = "/";
}

View File

@@ -0,0 +1,79 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.wsdl.parser;
import javax.xml.namespace.QName;
/**
* Interface defining WSDL-related constants.
*
* @author WS Development Team
*/
public interface WSDLConstants {
// namespace URIs
static final String PREFIX_NS_WSDL = "wsdl";
static final String NS_XMLNS = "http://www.w3.org/2001/XMLSchema";
static final String NS_WSDL = "http://schemas.xmlsoap.org/wsdl/";
static final String NS_SOAP11_HTTP_BINDING = "http://schemas.xmlsoap.org/soap/http";
static final QName QNAME_SCHEMA = new QName(NS_XMLNS, "schema");
// QNames
static final QName QNAME_BINDING = new QName(NS_WSDL, "binding");
static final QName QNAME_DEFINITIONS = new QName(NS_WSDL, "definitions");
static final QName QNAME_DOCUMENTATION = new QName(NS_WSDL, "documentation");
static final QName NS_SOAP_BINDING_ADDRESS = new QName("http://schemas.xmlsoap.org/wsdl/soap/", "address");
static final QName NS_SOAP_BINDING = new QName("http://schemas.xmlsoap.org/wsdl/soap/", "binding");
static final QName NS_SOAP12_BINDING = new QName("http://schemas.xmlsoap.org/wsdl/soap12/", "binding");
static final QName NS_SOAP12_BINDING_ADDRESS = new QName("http://schemas.xmlsoap.org/wsdl/soap12/", "address");
//static final QName QNAME_FAULT = new QName(NS_WSDL, "fault");
static final QName QNAME_IMPORT = new QName(NS_WSDL, "import");
//static final QName QNAME_INPUT = new QName(NS_WSDL, "input");
static final QName QNAME_MESSAGE = new QName(NS_WSDL, "message");
static final QName QNAME_PART = new QName(NS_WSDL, "part");
static final QName QNAME_OPERATION = new QName(NS_WSDL, "operation");
static final QName QNAME_INPUT = new QName(NS_WSDL, "input");
static final QName QNAME_OUTPUT = new QName(NS_WSDL, "output");
//static final QName QNAME_OUTPUT = new QName(NS_WSDL, "output");
//static final QName QNAME_PART = new QName(NS_WSDL, "part");
static final QName QNAME_PORT = new QName(NS_WSDL, "port");
static final QName QNAME_ADDRESS = new QName(NS_WSDL, "address");
static final QName QNAME_PORT_TYPE = new QName(NS_WSDL, "portType");
static final QName QNAME_FAULT = new QName(NS_WSDL, "fault");
static final QName QNAME_SERVICE = new QName(NS_WSDL, "service");
static final QName QNAME_TYPES = new QName(NS_WSDL, "types");
static final String ATTR_TRANSPORT = "transport";
static final String ATTR_LOCATION = "location";
static final String ATTR_NAME = "name";
static final String ATTR_TNS = "targetNamespace";
//static final QName QNAME_ATTR_ARRAY_TYPE = new QName(NS_WSDL, "arrayType");
}

View File

@@ -0,0 +1,71 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.wsdl.parser;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLModel;
import com.sun.xml.internal.ws.api.server.Container;
import com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtensionContext;
import com.sun.xml.internal.ws.api.policy.PolicyResolver;
/**
* Provides implementation of {@link WSDLParserExtensionContext}
*
* @author Vivek Pandey
* @author Fabian Ritzmann
*/
final class WSDLParserExtensionContextImpl implements WSDLParserExtensionContext {
private final boolean isClientSide;
private final EditableWSDLModel wsdlModel;
private final Container container;
private final PolicyResolver policyResolver;
/**
* Construct {@link WSDLParserExtensionContextImpl} with information that whether its on client side
* or server side.
*/
protected WSDLParserExtensionContextImpl(EditableWSDLModel model, boolean isClientSide, Container container, PolicyResolver policyResolver) {
this.wsdlModel = model;
this.isClientSide = isClientSide;
this.container = container;
this.policyResolver = policyResolver;
}
public boolean isClientSide() {
return isClientSide;
}
public EditableWSDLModel getWSDLModel() {
return wsdlModel;
}
public Container getContainer() {
return this.container;
}
public PolicyResolver getPolicyResolver() {
return policyResolver;
}
}

View File

@@ -0,0 +1,345 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.wsdl.parser;
import com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtension;
import com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtensionContext;
import com.sun.xml.internal.ws.api.model.wsdl.editable.*;
import com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.Location;
import org.xml.sax.Locator;
import org.xml.sax.helpers.LocatorImpl;
/**
* {@link WSDLParserExtension} that delegates to
* multiple {@link WSDLParserExtension}s.
*
* <p>
* This simplifies {@link RuntimeWSDLParser} since it now
* only needs to work with one {@link WSDLParserExtension}.
*
* <p>
* This class is guaranteed to return true from
* all the extension callback methods.
*
* @author Kohsuke Kawaguchi
*/
final class WSDLParserExtensionFacade extends WSDLParserExtension {
private final WSDLParserExtension[] extensions;
WSDLParserExtensionFacade(WSDLParserExtension... extensions) {
assert extensions!=null;
this.extensions = extensions;
}
public void start(WSDLParserExtensionContext context) {
for (WSDLParserExtension e : extensions) {
e.start(context);
}
}
public boolean serviceElements(EditableWSDLService service, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions) {
if(e.serviceElements(service,reader))
return true;
}
XMLStreamReaderUtil.skipElement(reader);
return true;
}
public void serviceAttributes(EditableWSDLService service, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions)
e.serviceAttributes(service,reader);
}
public boolean portElements(EditableWSDLPort port, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions) {
if(e.portElements(port,reader))
return true;
}
//extension is not understood by any WSDlParserExtension
//Check if it must be understood.
if(isRequiredExtension(reader)) {
port.addNotUnderstoodExtension(reader.getName(),getLocator(reader));
}
XMLStreamReaderUtil.skipElement(reader);
return true;
}
public boolean portTypeOperationInput(EditableWSDLOperation op, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions)
e.portTypeOperationInput(op,reader);
return false;
}
public boolean portTypeOperationOutput(EditableWSDLOperation op, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions)
e.portTypeOperationOutput(op,reader);
return false;
}
public boolean portTypeOperationFault(EditableWSDLOperation op, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions)
e.portTypeOperationFault(op,reader);
return false;
}
public void portAttributes(EditableWSDLPort port, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions)
e.portAttributes(port,reader);
}
public boolean definitionsElements(XMLStreamReader reader){
for (WSDLParserExtension e : extensions) {
if (e.definitionsElements(reader)) {
return true;
}
}
XMLStreamReaderUtil.skipElement(reader);
return true;
}
public boolean bindingElements(EditableWSDLBoundPortType binding, XMLStreamReader reader){
for (WSDLParserExtension e : extensions) {
if (e.bindingElements(binding, reader)) {
return true;
}
}
//extension is not understood by any WSDlParserExtension
//Check if it must be understood.
if (isRequiredExtension(reader)) {
binding.addNotUnderstoodExtension(
reader.getName(), getLocator(reader));
}
XMLStreamReaderUtil.skipElement(reader);
return true;
}
public void bindingAttributes(EditableWSDLBoundPortType binding, XMLStreamReader reader){
for (WSDLParserExtension e : extensions) {
e.bindingAttributes(binding, reader);
}
}
public boolean portTypeElements(EditableWSDLPortType portType, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions) {
if (e.portTypeElements(portType, reader)) {
return true;
}
}
XMLStreamReaderUtil.skipElement(reader);
return true;
}
public void portTypeAttributes(EditableWSDLPortType portType, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions) {
e.portTypeAttributes(portType, reader);
}
}
public boolean portTypeOperationElements(EditableWSDLOperation operation, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions) {
if (e.portTypeOperationElements(operation, reader)) {
return true;
}
}
XMLStreamReaderUtil.skipElement(reader);
return true;
}
public void portTypeOperationAttributes(EditableWSDLOperation operation, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions) {
e.portTypeOperationAttributes(operation, reader);
}
}
public boolean bindingOperationElements(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions) {
if (e.bindingOperationElements(operation, reader)) {
return true;
}
}
XMLStreamReaderUtil.skipElement(reader);
return true;
}
public void bindingOperationAttributes(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions) {
e.bindingOperationAttributes(operation, reader);
}
}
public boolean messageElements(EditableWSDLMessage msg, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions) {
if (e.messageElements(msg, reader)) {
return true;
}
}
XMLStreamReaderUtil.skipElement(reader);
return true;
}
public void messageAttributes(EditableWSDLMessage msg, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions) {
e.messageAttributes(msg, reader);
}
}
public boolean portTypeOperationInputElements(EditableWSDLInput input, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions) {
if (e.portTypeOperationInputElements(input, reader)) {
return true;
}
}
XMLStreamReaderUtil.skipElement(reader);
return true;
}
public void portTypeOperationInputAttributes(EditableWSDLInput input, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions) {
e.portTypeOperationInputAttributes(input, reader);
}
}
public boolean portTypeOperationOutputElements(EditableWSDLOutput output, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions) {
if (e.portTypeOperationOutputElements(output, reader)) {
return true;
}
}
XMLStreamReaderUtil.skipElement(reader);
return true;
}
public void portTypeOperationOutputAttributes(EditableWSDLOutput output, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions) {
e.portTypeOperationOutputAttributes(output, reader);
}
}
public boolean portTypeOperationFaultElements(EditableWSDLFault fault, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions) {
if (e.portTypeOperationFaultElements(fault, reader)) {
return true;
}
}
XMLStreamReaderUtil.skipElement(reader);
return true;
}
public void portTypeOperationFaultAttributes(EditableWSDLFault fault, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions) {
e.portTypeOperationFaultAttributes(fault, reader);
}
}
public boolean bindingOperationInputElements(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions) {
if (e.bindingOperationInputElements(operation, reader)) {
return true;
}
}
XMLStreamReaderUtil.skipElement(reader);
return true;
}
public void bindingOperationInputAttributes(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions) {
e.bindingOperationInputAttributes(operation, reader);
}
}
public boolean bindingOperationOutputElements(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions) {
if (e.bindingOperationOutputElements(operation, reader)) {
return true;
}
}
XMLStreamReaderUtil.skipElement(reader);
return true;
}
public void bindingOperationOutputAttributes(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions) {
e.bindingOperationOutputAttributes(operation, reader);
}
}
public boolean bindingOperationFaultElements(EditableWSDLBoundFault fault, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions) {
if (e.bindingOperationFaultElements(fault, reader)) {
return true;
}
}
XMLStreamReaderUtil.skipElement(reader);
return true;
}
public void bindingOperationFaultAttributes(EditableWSDLBoundFault fault, XMLStreamReader reader) {
for (WSDLParserExtension e : extensions) {
e.bindingOperationFaultAttributes(fault, reader);
}
}
public void finished(WSDLParserExtensionContext context) {
for (WSDLParserExtension e : extensions) {
e.finished(context);
}
}
public void postFinished(WSDLParserExtensionContext context) {
for (WSDLParserExtension e : extensions) {
e.postFinished(context);
}
}
/**
*
* @param reader
* @return If the element has wsdl:required attribute set to true
*/
private boolean isRequiredExtension(XMLStreamReader reader) {
String required = reader.getAttributeValue(WSDLConstants.NS_WSDL, "required");
if(required != null)
return Boolean.parseBoolean(required);
return false;
}
private Locator getLocator(XMLStreamReader reader) {
Location location = reader.getLocation();
LocatorImpl loc = new LocatorImpl();
loc.setSystemId(location.getSystemId());
loc.setLineNumber(location.getLineNumber());
return loc;
}
}