feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
450
jdkSrc/jdk8/com/sun/xml/internal/ws/api/BindingID.java
Normal file
450
jdkSrc/jdk8/com/sun/xml/internal/ws/api/BindingID.java
Normal file
@@ -0,0 +1,450 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.xml.internal.ws.api.message.Message;
|
||||
import com.sun.xml.internal.ws.api.pipe.Codec;
|
||||
import com.sun.xml.internal.ws.api.pipe.Tube;
|
||||
import com.sun.xml.internal.ws.binding.BindingImpl;
|
||||
import com.sun.xml.internal.ws.binding.SOAPBindingImpl;
|
||||
import com.sun.xml.internal.ws.binding.WebServiceFeatureList;
|
||||
import com.sun.xml.internal.ws.encoding.SOAPBindingCodec;
|
||||
import com.sun.xml.internal.ws.encoding.XMLHTTPBindingCodec;
|
||||
import com.sun.xml.internal.ws.encoding.soap.streaming.SOAPNamespaceConstants;
|
||||
import com.sun.xml.internal.ws.util.ServiceFinder;
|
||||
import com.sun.xml.internal.ws.developer.JAXWSProperties;
|
||||
|
||||
import javax.xml.ws.BindingType;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import javax.xml.ws.handler.Handler;
|
||||
import javax.xml.ws.http.HTTPBinding;
|
||||
import javax.xml.ws.soap.MTOMFeature;
|
||||
import javax.xml.ws.soap.SOAPBinding;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Parsed binding ID string.
|
||||
*
|
||||
* <p>
|
||||
* {@link BindingID} is an immutable object that represents a binding ID,
|
||||
* much like how {@link URL} is a representation of an URL.
|
||||
* Like {@link URL}, this class offers a bunch of methods that let you
|
||||
* query various traits/properties of a binding ID.
|
||||
*
|
||||
* <p>
|
||||
* {@link BindingID} is extensible; one can plug in a parser from
|
||||
* {@link String} to {@link BindingID} to interpret binding IDs that
|
||||
* the JAX-WS RI does no a-priori knowledge of.
|
||||
* Technologies such as Tango uses this to make the JAX-WS RI understand
|
||||
* binding IDs defined in their world.
|
||||
*
|
||||
* Such technologies are free to extend this class and expose more characterstics.
|
||||
*
|
||||
* <p>
|
||||
* Even though this class defines a few well known constants, {@link BindingID}
|
||||
* instances do not necessarily have singleton semantics. Use {@link #equals(Object)}
|
||||
* for the comparison.
|
||||
*
|
||||
* <h3>{@link BindingID} and {@link WSBinding}</h3>
|
||||
* <p>
|
||||
* {@link WSBinding} is mutable and represents a particular "use" of a {@link BindingID}.
|
||||
* As such, it has state like a list of {@link Handler}s, which are inherently local
|
||||
* to a particular usage. For example, if you have two proxies, you need two instances.
|
||||
*
|
||||
* {@link BindingID}, OTOH, is immutable and thus the single instance
|
||||
* that represents "SOAP1.2/HTTP" can be shared and reused by all proxies in the same VM.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public abstract class BindingID {
|
||||
|
||||
/**
|
||||
* Creates an instance of {@link WSBinding} (which is conceptually an "use"
|
||||
* of {@link BindingID}) from a {@link BindingID}.
|
||||
*
|
||||
* @return
|
||||
* Always a new instance.
|
||||
*/
|
||||
public final @NotNull WSBinding createBinding() {
|
||||
return BindingImpl.create(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns wsdl:binding@transport attribute. Sub classes
|
||||
* are expected to override this method to provide their transport
|
||||
* attribute.
|
||||
*
|
||||
* @return wsdl:binding@transport attribute
|
||||
* @since JAX-WS RI 2.1.6
|
||||
*/
|
||||
public @NotNull String getTransport() {
|
||||
return SOAPNamespaceConstants.TRANSPORT_HTTP;
|
||||
}
|
||||
|
||||
public final @NotNull WSBinding createBinding(WebServiceFeature... features) {
|
||||
return BindingImpl.create(this, features);
|
||||
}
|
||||
|
||||
public final @NotNull WSBinding createBinding(WSFeatureList features) {
|
||||
return createBinding(features.toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the SOAP version of this binding.
|
||||
*
|
||||
* TODO: clarify what to do with XML/HTTP binding
|
||||
*
|
||||
* @return
|
||||
* If the binding is using SOAP, this method returns
|
||||
* a {@link SOAPVersion} constant.
|
||||
*
|
||||
* If the binding is not based on SOAP, this method
|
||||
* returns null. See {@link Message} for how a non-SOAP
|
||||
* binding shall be handled by {@link Tube}s.
|
||||
*/
|
||||
public abstract SOAPVersion getSOAPVersion();
|
||||
|
||||
/**
|
||||
* Creates a new {@link Codec} for this binding.
|
||||
*
|
||||
* @param binding
|
||||
* Ocassionally some aspects of binding can be overridden by
|
||||
* {@link WSBinding} at runtime by users, so some {@link Codec}s
|
||||
* need to have access to {@link WSBinding} that it's working for.
|
||||
*/
|
||||
public abstract @NotNull Codec createEncoder(@NotNull WSBinding binding);
|
||||
|
||||
/**
|
||||
* Gets the binding ID, which uniquely identifies the binding.
|
||||
*
|
||||
* <p>
|
||||
* The relevant specs define the binding IDs and what they mean.
|
||||
* The ID is used in many places to identify the kind of binding
|
||||
* (such as SOAP1.1, SOAP1.2, REST, ...)
|
||||
*
|
||||
* @return
|
||||
* Always non-null same value.
|
||||
*/
|
||||
@Override
|
||||
public abstract String toString();
|
||||
|
||||
/**
|
||||
* Returna a new {@link WebServiceFeatureList} instance
|
||||
* that represents the features that are built into this binding ID.
|
||||
*
|
||||
* <p>
|
||||
* For example, {@link BindingID} for
|
||||
* <tt>"{@value SOAPBinding#SOAP11HTTP_MTOM_BINDING}"</tt>
|
||||
* would always return a list that has {@link MTOMFeature} enabled.
|
||||
*/
|
||||
public WebServiceFeatureList createBuiltinFeatureList() {
|
||||
return new WebServiceFeatureList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this binding can generate WSDL.
|
||||
*
|
||||
* <p>
|
||||
* For e.g.: SOAP 1.1 and "XSOAP 1.2" is supposed to return true
|
||||
* from this method. For SOAP1.2, there is no standard WSDL, so the
|
||||
* runtime is not generating one and it expects the WSDL is packaged.
|
||||
*
|
||||
*/
|
||||
public boolean canGenerateWSDL() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a parameter of this binding ID.
|
||||
*
|
||||
* <p>
|
||||
* Some binding ID, such as those for SOAP/HTTP, uses the URL
|
||||
* query syntax (like <tt>?mtom=true</tt>) to control
|
||||
* the optional part of the binding. This method obtains
|
||||
* the value for such optional parts.
|
||||
*
|
||||
* <p>
|
||||
* For implementors of the derived classes, if your binding ID
|
||||
* does not define such optional parts (such as the XML/HTTP binding ID),
|
||||
* then you should simply return the specified default value
|
||||
* (which is what this implementation does.)
|
||||
*
|
||||
* @param parameterName
|
||||
* The parameter name, such as "mtom" in the above example.
|
||||
* @param defaultValue
|
||||
* If this binding ID doesn't have the specified parameter explicitly,
|
||||
* this value will be returned.
|
||||
*
|
||||
* @return
|
||||
* the value of the parameter, if it's present (such as "true"
|
||||
* in the above example.) If not present, this method returns
|
||||
* the {@code defaultValue}.
|
||||
*/
|
||||
public String getParameter(String parameterName, String defaultValue) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the equality based on {@link #toString()}.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof BindingID))
|
||||
return false;
|
||||
return toString().equals(obj.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return toString().hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a binding ID string into a {@link BindingID} object.
|
||||
*
|
||||
* <p>
|
||||
* This method first checks for a few known values and then delegate
|
||||
* the parsing to {@link BindingIDFactory}.
|
||||
*
|
||||
* <p>
|
||||
* If parsing succeeds this method returns a value. Otherwise
|
||||
* throws {@link WebServiceException}.
|
||||
*
|
||||
* @throws WebServiceException
|
||||
* If the binding ID is not understood.
|
||||
*/
|
||||
public static @NotNull BindingID parse(String lexical) {
|
||||
if(lexical.equals(XML_HTTP.toString()))
|
||||
return XML_HTTP;
|
||||
if(lexical.equals(REST_HTTP.toString()))
|
||||
return REST_HTTP;
|
||||
if(belongsTo(lexical,SOAP11_HTTP.toString()))
|
||||
return customize(lexical,SOAP11_HTTP);
|
||||
if(belongsTo(lexical,SOAP12_HTTP.toString()))
|
||||
return customize(lexical,SOAP12_HTTP);
|
||||
if(belongsTo(lexical,SOAPBindingImpl.X_SOAP12HTTP_BINDING))
|
||||
return customize(lexical,X_SOAP12_HTTP);
|
||||
|
||||
// OK, it's none of the values JAX-WS understands.
|
||||
for( BindingIDFactory f : ServiceFinder.find(BindingIDFactory.class) ) {
|
||||
BindingID r = f.parse(lexical);
|
||||
if(r!=null)
|
||||
return r;
|
||||
}
|
||||
|
||||
// nobody understood this value
|
||||
throw new WebServiceException("Wrong binding ID: "+lexical);
|
||||
}
|
||||
|
||||
private static boolean belongsTo(String lexical, String id) {
|
||||
return lexical.equals(id) || lexical.startsWith(id+'?');
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses parameter portion and returns appropriately populated {@link SOAPHTTPImpl}
|
||||
*/
|
||||
private static SOAPHTTPImpl customize(String lexical, SOAPHTTPImpl base) {
|
||||
if(lexical.equals(base.toString()))
|
||||
return base;
|
||||
|
||||
// otherwise we must have query parameter
|
||||
// we assume the spec won't define any tricky parameters that require
|
||||
// complicated handling (such as %HH or non-ASCII char), so this parser
|
||||
// is quite simple-minded.
|
||||
SOAPHTTPImpl r = new SOAPHTTPImpl(base.getSOAPVersion(), lexical, base.canGenerateWSDL());
|
||||
try {
|
||||
// With X_SOAP12_HTTP, base != lexical and lexical does n't have any query string
|
||||
if(lexical.indexOf('?') == -1) {
|
||||
return r;
|
||||
}
|
||||
String query = URLDecoder.decode(lexical.substring(lexical.indexOf('?')+1),"UTF-8");
|
||||
for( String token : query.split("&") ) {
|
||||
int idx = token.indexOf('=');
|
||||
if(idx<0)
|
||||
throw new WebServiceException("Malformed binding ID (no '=' in "+token+")");
|
||||
r.parameters.put(token.substring(0,idx),token.substring(idx+1));
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new AssertionError(e); // UTF-8 is supported everywhere
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Figures out the binding from {@link BindingType} annotation.
|
||||
*
|
||||
* @return
|
||||
* default to {@link BindingID#SOAP11_HTTP}, if no such annotation is present.
|
||||
* @see #parse(String)
|
||||
*/
|
||||
public static @NotNull BindingID parse(Class<?> implClass) {
|
||||
BindingType bindingType = implClass.getAnnotation(BindingType.class);
|
||||
if (bindingType != null) {
|
||||
String bindingId = bindingType.value();
|
||||
if (bindingId.length() > 0) {
|
||||
return BindingID.parse(bindingId);
|
||||
}
|
||||
}
|
||||
return SOAP11_HTTP;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constant that represents implementation specific SOAP1.2/HTTP which is
|
||||
* used to generate non-standard WSDLs
|
||||
*/
|
||||
public static final SOAPHTTPImpl X_SOAP12_HTTP = new SOAPHTTPImpl(
|
||||
SOAPVersion.SOAP_12, SOAPBindingImpl.X_SOAP12HTTP_BINDING, true);
|
||||
|
||||
/**
|
||||
* Constant that represents SOAP1.2/HTTP.
|
||||
*/
|
||||
public static final SOAPHTTPImpl SOAP12_HTTP = new SOAPHTTPImpl(
|
||||
SOAPVersion.SOAP_12, SOAPBinding.SOAP12HTTP_BINDING, true);
|
||||
/**
|
||||
* Constant that represents SOAP1.1/HTTP.
|
||||
*/
|
||||
public static final SOAPHTTPImpl SOAP11_HTTP = new SOAPHTTPImpl(
|
||||
SOAPVersion.SOAP_11, SOAPBinding.SOAP11HTTP_BINDING, true);
|
||||
|
||||
/**
|
||||
* Constant that represents SOAP1.2/HTTP.
|
||||
*/
|
||||
public static final SOAPHTTPImpl SOAP12_HTTP_MTOM = new SOAPHTTPImpl(
|
||||
SOAPVersion.SOAP_12, SOAPBinding.SOAP12HTTP_MTOM_BINDING, true, true);
|
||||
/**
|
||||
* Constant that represents SOAP1.1/HTTP.
|
||||
*/
|
||||
public static final SOAPHTTPImpl SOAP11_HTTP_MTOM = new SOAPHTTPImpl(
|
||||
SOAPVersion.SOAP_11, SOAPBinding.SOAP11HTTP_MTOM_BINDING, true, true);
|
||||
|
||||
|
||||
/**
|
||||
* Constant that represents REST.
|
||||
*/
|
||||
public static final BindingID XML_HTTP = new Impl(SOAPVersion.SOAP_11, HTTPBinding.HTTP_BINDING,false) {
|
||||
@Override
|
||||
public Codec createEncoder(WSBinding binding) {
|
||||
return new XMLHTTPBindingCodec(binding.getFeatures());
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Constant that represents REST.
|
||||
*/
|
||||
private static final BindingID REST_HTTP = new Impl(SOAPVersion.SOAP_11, JAXWSProperties.REST_BINDING,true) {
|
||||
@Override
|
||||
public Codec createEncoder(WSBinding binding) {
|
||||
return new XMLHTTPBindingCodec(binding.getFeatures());
|
||||
}
|
||||
};
|
||||
|
||||
private static abstract class Impl extends BindingID {
|
||||
final SOAPVersion version;
|
||||
private final String lexical;
|
||||
private final boolean canGenerateWSDL;
|
||||
|
||||
public Impl(SOAPVersion version, String lexical, boolean canGenerateWSDL) {
|
||||
this.version = version;
|
||||
this.lexical = lexical;
|
||||
this.canGenerateWSDL = canGenerateWSDL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SOAPVersion getSOAPVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return lexical;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean canGenerateWSDL() {
|
||||
return canGenerateWSDL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal implementation for SOAP/HTTP.
|
||||
*/
|
||||
private static final class SOAPHTTPImpl extends Impl implements Cloneable {
|
||||
/*final*/ Map<String,String> parameters = new HashMap<String,String>();
|
||||
|
||||
static final String MTOM_PARAM = "mtom";
|
||||
|
||||
public SOAPHTTPImpl(SOAPVersion version, String lexical, boolean canGenerateWSDL) {
|
||||
super(version, lexical, canGenerateWSDL);
|
||||
}
|
||||
|
||||
public SOAPHTTPImpl(SOAPVersion version, String lexical, boolean canGenerateWSDL,
|
||||
boolean mtomEnabled) {
|
||||
this(version, lexical, canGenerateWSDL);
|
||||
String mtomStr = mtomEnabled ? "true" : "false";
|
||||
parameters.put(MTOM_PARAM, mtomStr);
|
||||
}
|
||||
|
||||
public @NotNull @Override Codec createEncoder(WSBinding binding) {
|
||||
return new SOAPBindingCodec(binding.getFeatures());
|
||||
}
|
||||
|
||||
private Boolean isMTOMEnabled() {
|
||||
String mtom = parameters.get(MTOM_PARAM);
|
||||
return mtom==null?null:Boolean.valueOf(mtom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebServiceFeatureList createBuiltinFeatureList() {
|
||||
WebServiceFeatureList r=super.createBuiltinFeatureList();
|
||||
Boolean mtom = isMTOMEnabled();
|
||||
if(mtom != null)
|
||||
r.add(new MTOMFeature(mtom));
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParameter(String parameterName, String defaultValue) {
|
||||
if (parameters.get(parameterName) == null)
|
||||
return super.getParameter(parameterName, defaultValue);
|
||||
return parameters.get(parameterName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SOAPHTTPImpl clone() throws CloneNotSupportedException {
|
||||
return (SOAPHTTPImpl) super.clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.istack.internal.NotNull;
|
||||
|
||||
import javax.xml.ws.WebServiceException;
|
||||
|
||||
/**
|
||||
* Extension point to plug in additional {@link BindingID} parsing logic.
|
||||
*
|
||||
* <p>
|
||||
* When the JAX-WS RI is asked to parse a binding ID string into a {@link BindingID}
|
||||
* object, it uses service idiom to look for the implementations of this class
|
||||
* in the <tt>META-INF/services/...</tt>.
|
||||
*
|
||||
* @since JAX-WS 2.0.next
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see BindingID#parse(String)
|
||||
*/
|
||||
public abstract class BindingIDFactory {
|
||||
/**
|
||||
* Parses a binding ID string into {@link BindingID} if possible.
|
||||
*
|
||||
* @return
|
||||
* a non-null return value would cause the JAX-WS RI to consider
|
||||
* the parsing to be successful. No furhter {@link BindingIDFactory}
|
||||
* will be consulted.
|
||||
*
|
||||
* <p>
|
||||
* Retruning a null value indicates that this factory doesn't understand
|
||||
* this string, in which case the JAX-WS RI will keep asking next
|
||||
* {@link BindingIDFactory}.
|
||||
*
|
||||
* @throws WebServiceException
|
||||
* if the implementation understood the lexical value but it is not correct,
|
||||
* this exception can be thrown to abort the parsing with error.
|
||||
* No further {@link BindingIDFactory} will be consulted, and
|
||||
* {@link BindingID#parse(String)} will throw the exception.
|
||||
*/
|
||||
public abstract @Nullable BindingID parse(@NotNull String lexical) throws WebServiceException;
|
||||
|
||||
/**
|
||||
* Creates a {@link BindingID} for given transport and SOAPVersion.
|
||||
*
|
||||
* @return
|
||||
* a non-null return value would cause the JAX-WS RI to consider
|
||||
* the creation to be successful. No furhter {@link BindingIDFactory}
|
||||
* will be consulted.
|
||||
*
|
||||
* <p>
|
||||
* Retruning a null value indicates that this factory doesn't understand
|
||||
* the transport, in which case the JAX-WS RI will keep asking next
|
||||
* {@link BindingIDFactory}.
|
||||
*
|
||||
* @throws WebServiceException
|
||||
* if the implementation understood the transport but it is not correct,
|
||||
* this exception can be thrown to abort the creation with error.
|
||||
* No further {@link BindingIDFactory} will be consulted, and
|
||||
* {@link BindingID#create(String, SOAPVersion)} will throw the exception.
|
||||
*/
|
||||
public @Nullable BindingID create(@NotNull String transport, @NotNull SOAPVersion soapVersion) throws WebServiceException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
52
jdkSrc/jdk8/com/sun/xml/internal/ws/api/Cancelable.java
Normal file
52
jdkSrc/jdk8/com/sun/xml/internal/ws/api/Cancelable.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
/**
|
||||
* Interface for tasks that may be cancelled
|
||||
*
|
||||
* @since 2.2.6
|
||||
*/
|
||||
public interface Cancelable {
|
||||
/**
|
||||
* Attempts to cancel execution of this task. This attempt will
|
||||
* fail if the task has already completed, has already been cancelled,
|
||||
* or could not be cancelled for some other reason. If successful,
|
||||
* and this task has not started when <tt>cancel</tt> is called,
|
||||
* this task should never run. If the task has already started,
|
||||
* then the <tt>mayInterruptIfRunning</tt> parameter determines
|
||||
* whether the thread executing this task should be interrupted in
|
||||
* an attempt to stop the task.
|
||||
*
|
||||
* @param mayInterruptIfRunning <tt>true</tt> if the thread executing this
|
||||
* task should be interrupted; otherwise, in-progress tasks are allowed
|
||||
* to complete
|
||||
* @return <tt>false</tt> if the task could not be cancelled,
|
||||
* typically because it has already completed normally;
|
||||
* <tt>true</tt> otherwise
|
||||
*/
|
||||
public void cancel(boolean mayInterruptIfRunning);
|
||||
}
|
||||
54
jdkSrc/jdk8/com/sun/xml/internal/ws/api/Component.java
Normal file
54
jdkSrc/jdk8/com/sun/xml/internal/ws/api/Component.java
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.api.server.WSEndpoint;
|
||||
|
||||
/**
|
||||
* Interface that allows components to hook up with each other.
|
||||
* Replaces {@link com.sun.xml.internal.ws.api.server.EndpointComponent} so that component
|
||||
* pattern can apply to more RI types.
|
||||
*
|
||||
* @since 2.2.6
|
||||
* @see WSEndpoint#getComponents()
|
||||
* @see ComponentRegistry
|
||||
*/
|
||||
public interface Component {
|
||||
/**
|
||||
* Gets the specified SPI.
|
||||
*
|
||||
* <p>
|
||||
* This method works as a kind of directory service
|
||||
* for SPIs, allowing various components to define private contract
|
||||
* and talk to each other.
|
||||
*
|
||||
* @return
|
||||
* null if such an SPI is not provided by this object.
|
||||
*/
|
||||
@Nullable <S> S getSPI(@NotNull Class<S> spiType);
|
||||
}
|
||||
53
jdkSrc/jdk8/com/sun/xml/internal/ws/api/ComponentEx.java
Normal file
53
jdkSrc/jdk8/com/sun/xml/internal/ws/api/ComponentEx.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
|
||||
/**
|
||||
* Extended version of {@link Component}. Allows component to return multiple
|
||||
* SPI implementations through an {@link Iterable}.
|
||||
*
|
||||
* @since 2.2.6
|
||||
*/
|
||||
public interface ComponentEx extends Component {
|
||||
/**
|
||||
* Gets an iterator of implementations of the specified SPI.
|
||||
*
|
||||
* <p>
|
||||
* This method works as a kind of directory service
|
||||
* for SPIs, allowing various components to define private contract
|
||||
* and talk to each other. However unlike {@link Component#getSPI(java.lang.Class)}, this
|
||||
* method can support cases where there is an ordered collection (defined
|
||||
* by {@link Iterable} of implementations. The SPI contract should define
|
||||
* whether lookups are for the first appropriate implementation or whether
|
||||
* all returned implementations should be used.
|
||||
*
|
||||
* @return
|
||||
* non-null {@link Iterable} of the SPI's provided by this object. Iterator may have no values.
|
||||
*/
|
||||
@NotNull <S> Iterable<S> getIterableSPI(@NotNull Class<S> spiType);
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
import com.sun.xml.internal.ws.api.server.Container;
|
||||
import com.sun.xml.internal.ws.api.server.WSEndpoint;
|
||||
import com.sun.xml.internal.ws.client.Stub;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
/**
|
||||
* Allows registration of a {@link Component} against the {@link ComponentRegistry} implementations
|
||||
* of the {@link Container}, {@link WSEndpoint}, {@link WSService}, or {@link Stub}. The
|
||||
* registration is guaranteed to occur early in the initialization of these objects prior to tubeline creation
|
||||
* (applicable to endpoint and stub only).
|
||||
* <p>
|
||||
* Because the Container is shared among all Stubs created from a common WSService object, this feature must
|
||||
* be passed during WSService initialization in order to register a Component against the client-side Container.
|
||||
* <p>
|
||||
* IllegalArgumentException will be thrown if the feature is used with an inappropriate target, e.g. stub target
|
||||
* used during WSEndpoint initialization.
|
||||
*
|
||||
* @since 2.2.6
|
||||
*/
|
||||
public class ComponentFeature extends WebServiceFeature implements ServiceSharedFeatureMarker {
|
||||
/**
|
||||
* Targets the object on which the Component will be registered
|
||||
*
|
||||
*/
|
||||
public static enum Target {
|
||||
CONTAINER, ENDPOINT, SERVICE, STUB
|
||||
}
|
||||
|
||||
private final Component component;
|
||||
private final Target target;
|
||||
|
||||
/**
|
||||
* Constructs ComponentFeature with indicated component and that is targeted at the Container.
|
||||
* @param component component
|
||||
*/
|
||||
public ComponentFeature(Component component) {
|
||||
this(component, Target.CONTAINER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs ComponentFeature with indicated component and target
|
||||
* @param component component
|
||||
* @param target target
|
||||
*/
|
||||
public ComponentFeature(Component component, Target target) {
|
||||
this.enabled = true;
|
||||
this.component = component;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return ComponentFeature.class.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves component
|
||||
* @return component
|
||||
*/
|
||||
public Component getComponent() {
|
||||
return component;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves target
|
||||
* @return target
|
||||
*/
|
||||
public Target getTarget() {
|
||||
return target;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
|
||||
/**
|
||||
* Registry for component delegates. It is expected that implementations of
|
||||
* ComponentRegistry will delegate to registered {@link Component}s in its own
|
||||
* implementation of {@link Component#getSPI(java.lang.Class)}, either before or after it
|
||||
* considers its own SPI implementations.
|
||||
*
|
||||
* @since 2.2.6
|
||||
*/
|
||||
public interface ComponentRegistry extends Component {
|
||||
/**
|
||||
* Returns the set of {@link Component}s registered with this object
|
||||
* @return set of registered components
|
||||
*/
|
||||
public @NotNull Set<Component> getComponents();
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.xml.internal.ws.api.server.Container;
|
||||
import com.sun.xml.internal.ws.api.server.WSEndpoint;
|
||||
import com.sun.xml.internal.ws.client.Stub;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
/**
|
||||
* Allows registration of multiple {@link Component}s against the {@link ComponentRegistry} implementations
|
||||
* of the {@link Container}, {@link WSEndpoint}, {@link WSService}, or {@link Stub}. The
|
||||
* registration is guaranteed to occur early in the initialization of these objects prior to tubeline creation
|
||||
* (applicable to endpoint and stub only).
|
||||
* <p>
|
||||
* Because the Container is shared among all Stubs created from a common WSService object, this feature must
|
||||
* be passed during WSService initialization in order to register a Component against the client-side Container.
|
||||
* <p>
|
||||
* IllegalArgumentException will be thrown if the feature is used with an inappropriate target, e.g. stub target
|
||||
* used during WSEndpoint initialization.
|
||||
*
|
||||
* @since 2.2.8
|
||||
*/
|
||||
public class ComponentsFeature extends WebServiceFeature implements ServiceSharedFeatureMarker {
|
||||
private final List<ComponentFeature> componentFeatures;
|
||||
|
||||
/**
|
||||
* Constructs ComponentFeature with indicated component and target
|
||||
* @param component component
|
||||
* @param target target
|
||||
*/
|
||||
public ComponentsFeature(List<ComponentFeature> componentFeatures) {
|
||||
this.enabled = true;
|
||||
this.componentFeatures = componentFeatures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return ComponentsFeature.class.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves component
|
||||
* @return component
|
||||
*/
|
||||
public List<ComponentFeature> getComponentFeatures() {
|
||||
return componentFeatures;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
|
||||
/**
|
||||
* Placeholder for backwards compatibility.
|
||||
*
|
||||
* @deprecated Use com.oracle.webservices.internal.api.message.DistributedPropertySet instead.
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public abstract class DistributedPropertySet extends com.oracle.webservices.internal.api.message.BaseDistributedPropertySet {
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public void addSatellite(@NotNull PropertySet satellite) {
|
||||
super.addSatellite(satellite);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public void addSatellite(@NotNull Class keyClass, @NotNull PropertySet satellite) {
|
||||
super.addSatellite(keyClass, satellite);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public void copySatelliteInto(@NotNull DistributedPropertySet r) {
|
||||
super.copySatelliteInto(r);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public void removeSatellite(PropertySet satellite) {
|
||||
super.removeSatellite(satellite);
|
||||
}
|
||||
}
|
||||
232
jdkSrc/jdk8/com/sun/xml/internal/ws/api/EndpointAddress.java
Normal file
232
jdkSrc/jdk8/com/sun/xml/internal/ws/api/EndpointAddress.java
Normal file
@@ -0,0 +1,232 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
import com.sun.istack.internal.Nullable;
|
||||
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.Proxy;
|
||||
import java.net.ProxySelector;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLStreamHandler;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Represents the endpoint address URI.
|
||||
*
|
||||
* <p>
|
||||
* Conceptually this can be really thought of as an {@link URI},
|
||||
* but it hides some of the details that improve the performance.
|
||||
*
|
||||
* <p>
|
||||
* Being an {@link URI} allows this class to represent custom made-up URIs
|
||||
* (like "jms" for example.) Whenever possible, this object
|
||||
* also creates an {@link URL} (this is only possible when the address
|
||||
* has a registered {@link URLStreamHandler}), so that if the clients
|
||||
* of this code wants to use it, it can do so.
|
||||
*
|
||||
*
|
||||
* <h3>How it improves the performance</h3>
|
||||
* <ol>
|
||||
* <li>
|
||||
* Endpoint address is often eventually turned into an {@link URLConnection},
|
||||
* and given that generally this value is read more often than being set,
|
||||
* it makes sense to eagerly turn it into an {@link URL},
|
||||
* thereby avoiding a repeated conversion.
|
||||
*
|
||||
* <li>
|
||||
* JDK spends a lot of time choosing a list of {@link Proxy}
|
||||
* to connect to an {@link URL}. Since the default proxy selector
|
||||
* implementation always return the same proxy for the same URL,
|
||||
* we can determine the proxy by ourselves to let JDK skip its
|
||||
* proxy-discovery step.
|
||||
*
|
||||
* (That said, user-defined proxy selector can do a lot of interesting things
|
||||
* --- like doing a round-robin, or pick one from a proxy farm randomly,
|
||||
* and so it's dangerous to stick to one proxy. For this case,
|
||||
* we still let JDK decide the proxy. This shouldn't be that much of an
|
||||
* disappointment, since most people only mess with system properties,
|
||||
* and never with {@link ProxySelector}. Also, avoiding optimization
|
||||
* with non-standard proxy selector allows people to effectively disable
|
||||
* this optimization, which may come in handy for a trouble-shooting.)
|
||||
* </ol>
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public final class EndpointAddress {
|
||||
@Nullable
|
||||
private URL url;
|
||||
private final URI uri;
|
||||
private final String stringForm;
|
||||
private volatile boolean dontUseProxyMethod;
|
||||
/**
|
||||
* Pre-selected proxy.
|
||||
*
|
||||
* If {@link #url} is null, this field is null.
|
||||
* Otherwise, this field could still be null if the proxy couldn't be chosen
|
||||
* upfront.
|
||||
*/
|
||||
private Proxy proxy;
|
||||
|
||||
public EndpointAddress(URI uri) {
|
||||
this.uri = uri;
|
||||
this.stringForm = uri.toString();
|
||||
try {
|
||||
initURL();
|
||||
proxy = chooseProxy();
|
||||
} catch (MalformedURLException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see #create(String)
|
||||
*/
|
||||
public EndpointAddress(String url) throws URISyntaxException {
|
||||
this.uri = new URI(url);
|
||||
this.stringForm = url;
|
||||
try {
|
||||
initURL();
|
||||
proxy = chooseProxy();
|
||||
} catch (MalformedURLException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void initURL() throws MalformedURLException {
|
||||
String scheme = uri.getScheme();
|
||||
//URI.toURL() only works when scheme is not null.
|
||||
if (scheme == null) {
|
||||
this.url = new URL(uri.toString());
|
||||
return;
|
||||
}
|
||||
scheme =scheme.toLowerCase();
|
||||
if ("http".equals(scheme) || "https".equals(scheme)) {
|
||||
url = new URL(uri.toASCIIString());
|
||||
} else {
|
||||
this.url = uri.toURL();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link EndpointAddress} with a reasonably
|
||||
* generic error handling.
|
||||
*/
|
||||
public static EndpointAddress create(String url) {
|
||||
try {
|
||||
return new EndpointAddress(url);
|
||||
} catch(URISyntaxException e) {
|
||||
throw new WebServiceException("Illegal endpoint address: "+url,e);
|
||||
}
|
||||
}
|
||||
|
||||
private Proxy chooseProxy() {
|
||||
ProxySelector sel =
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<ProxySelector>() {
|
||||
@Override
|
||||
public ProxySelector run() {
|
||||
return ProxySelector.getDefault();
|
||||
}
|
||||
});
|
||||
|
||||
if(sel==null)
|
||||
return Proxy.NO_PROXY;
|
||||
|
||||
|
||||
if(!sel.getClass().getName().equals("sun.net.spi.DefaultProxySelector"))
|
||||
// user-defined proxy. may return a different proxy for each invocation
|
||||
return null;
|
||||
|
||||
Iterator<Proxy> it = sel.select(uri).iterator();
|
||||
if(it.hasNext())
|
||||
return it.next();
|
||||
|
||||
return Proxy.NO_PROXY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an URL of this endpoint adress.
|
||||
*
|
||||
* @return
|
||||
* null if this endpoint address doesn't have a registered {@link URLStreamHandler}.
|
||||
*/
|
||||
public URL getURL() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an URI of the endpoint address.
|
||||
*
|
||||
* @return
|
||||
* always non-null.
|
||||
*/
|
||||
public URI getURI() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to open {@link URLConnection} for this endpoint.
|
||||
*
|
||||
* <p>
|
||||
* This is possible only when an endpoint address has
|
||||
* the corresponding {@link URLStreamHandler}.
|
||||
*
|
||||
* @throws IOException
|
||||
* if {@link URL#openConnection()} reports an error.
|
||||
* @throws AssertionError
|
||||
* if this endpoint doesn't have an associated URL.
|
||||
* if the code is written correctly this shall never happen.
|
||||
*/
|
||||
public URLConnection openConnection() throws IOException {
|
||||
if (url == null) {
|
||||
throw new WebServiceException("URI="+uri+" doesn't have the corresponding URL");
|
||||
}
|
||||
if(proxy!=null && !dontUseProxyMethod) {
|
||||
try {
|
||||
return url.openConnection(proxy);
|
||||
} catch(UnsupportedOperationException e) {
|
||||
// Some OSGi and app server environments donot
|
||||
// override URLStreamHandler.openConnection(URL, Proxy) as it
|
||||
// is introduced in Java SE 5 API. Fallback to the other method.
|
||||
dontUseProxyMethod = true;
|
||||
}
|
||||
}
|
||||
return url.openConnection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return stringForm;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
import com.sun.xml.internal.ws.developer.MemberSubmissionAddressing;
|
||||
import com.sun.xml.internal.ws.developer.MemberSubmissionAddressingFeature;
|
||||
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This annotation should be used on a constructor of classes extending {@link WebServiceFeature} other than
|
||||
* Spec defined features, to help JAX-WS runtime recognize feature extensions.
|
||||
* </p>
|
||||
* <p>
|
||||
* For WebServiceFeature annotations to be recognizable by JAX-WS runtime, the feature annotation should point
|
||||
* to a corresponding bean (class extending WebServiceFeature). Only one of the constructors in the bean MUST be marked
|
||||
* with @FeatureConstructor whose value captures the annotaion attribute names for the corresponding parameters.
|
||||
* </p>
|
||||
* For example,
|
||||
* @see MemberSubmissionAddressingFeature
|
||||
* @see MemberSubmissionAddressing
|
||||
*
|
||||
* @see com.sun.xml.internal.ws.developer.Stateful
|
||||
* @see com.sun.xml.internal.ws.developer.StatefulFeature
|
||||
*
|
||||
* @author Rama Pulavarthi
|
||||
*/
|
||||
@Retention(RUNTIME)
|
||||
@Target(ElementType.CONSTRUCTOR)
|
||||
|
||||
public @interface FeatureConstructor {
|
||||
/**
|
||||
* The name of the parameter.
|
||||
*/
|
||||
String[] value() default {};
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
|
||||
/**
|
||||
* Validates a list of {@link WebServiceFeature} instances when they are added to
|
||||
* the client or service binding.
|
||||
* <p>
|
||||
* {@link WebServiceFeature} classes may specify validator beans using {@link FeatureListValidatorAnnotation}.
|
||||
* <p>
|
||||
* Current behavior will allow runtime components to add features to the binding after initial validation; however,
|
||||
* this behavior is discouraged and will not be supported in later releases of the reference
|
||||
* implementation.
|
||||
*
|
||||
* @since 2.2.8
|
||||
* @see FeatureListValidatorAnnotation
|
||||
*/
|
||||
public interface FeatureListValidator {
|
||||
/**
|
||||
* Validates feature list. Implementations should throw {@link WebServiceException} if the
|
||||
* list of features is invalid. Implementations may add features to the list or make other
|
||||
* changes; however, only validators belonging to features on the original list will be
|
||||
* invoked.
|
||||
*
|
||||
* @param list feature list
|
||||
*/
|
||||
public void validate(WSFeatureList list);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
/**
|
||||
* This annotation should be used on classes that extend {@link WebServiceFeature} in
|
||||
* order to specify the type of {@link FeatureListValidator} bean that will be invoked when
|
||||
* instances of the {@link WebServiceFeature} class are included in the list of features
|
||||
* that are added to a client or service binding.
|
||||
*
|
||||
* @since 2.2.8
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface FeatureListValidatorAnnotation {
|
||||
/**
|
||||
* The <code>FeatureListValidator</code> bean that is associated
|
||||
* with the <code>FeatureListValidator</code> annotation
|
||||
*/
|
||||
Class<? extends FeatureListValidator> bean();
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
/**
|
||||
* Features, Providers, and JWS implementations can implement this interface to
|
||||
* receive a callback allowing them to modify the features enabled for a client
|
||||
* or endpoint binding.
|
||||
*
|
||||
* Implementations of this interface can make any changes they like to the set of
|
||||
* features; however, general best practice is that implementations should not
|
||||
* override features specified by the developer. For instance, a Feature object
|
||||
* for WS-ReliableMessaging might use this interface to automatically enable
|
||||
* WS-Addressing (by adding the AddressingFeature), but not modify addressing if the
|
||||
* user had already specified a different addressing version.
|
||||
*
|
||||
* @since 2.2.6
|
||||
* @deprecated use {@link FeatureListValidatorAnnotation}
|
||||
*/
|
||||
public interface ImpliesWebServiceFeature {
|
||||
/**
|
||||
* Callback that may inspect the current feature list and add additional features
|
||||
* @param list Feature list
|
||||
*/
|
||||
public void implyFeatures(WSFeatureList list);
|
||||
}
|
||||
135
jdkSrc/jdk8/com/sun/xml/internal/ws/api/PropertySet.java
Normal file
135
jdkSrc/jdk8/com/sun/xml/internal/ws/api/PropertySet.java
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* Placeholder for backwards compatibility.
|
||||
*
|
||||
* @deprecated Use com.oracle.webservices.internal.api.message.PropertySet instead.
|
||||
* @author snajper
|
||||
*/
|
||||
public abstract class PropertySet extends com.oracle.webservices.internal.api.message.BasePropertySet {
|
||||
/**
|
||||
* Represents the list of strongly-typed known properties
|
||||
* (keyed by property names.)
|
||||
*
|
||||
* <p>
|
||||
* Just giving it an alias to make the use of this class more fool-proof.
|
||||
* @deprecated
|
||||
*/
|
||||
protected static class PropertyMap extends com.oracle.webservices.internal.api.message.BasePropertySet.PropertyMap {}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
protected static PropertyMap parse(final Class clazz) {
|
||||
com.oracle.webservices.internal.api.message.BasePropertySet.PropertyMap pm = com.oracle.webservices.internal.api.message.BasePropertySet.parse(clazz);
|
||||
PropertyMap map = new PropertyMap();
|
||||
map.putAll(pm);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the property.
|
||||
*
|
||||
* @param key
|
||||
* This field is typed as {@link Object} to follow the {@link Map#get(Object)}
|
||||
* convention, but if anything but {@link String} is passed, this method
|
||||
* just returns null.
|
||||
*/
|
||||
public Object get(Object key) {
|
||||
Accessor sp = getPropertyMap().get(key);
|
||||
if(sp!=null)
|
||||
return sp.get(this);
|
||||
throw new IllegalArgumentException("Undefined property "+key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a property.
|
||||
*
|
||||
* <h3>Implementation Note</h3>
|
||||
* This method is slow. Code inside JAX-WS should define strongly-typed
|
||||
* fields in this class and access them directly, instead of using this.
|
||||
*
|
||||
* @throws ReadOnlyPropertyException
|
||||
* if the given key is an alias of a strongly-typed field,
|
||||
* and if the name object given is not assignable to the field.
|
||||
*
|
||||
* @see Property
|
||||
*/
|
||||
public Object put(String key, Object value) {
|
||||
Accessor sp = getPropertyMap().get(key);
|
||||
if(sp!=null) {
|
||||
Object old = sp.get(this);
|
||||
sp.set(this,value);
|
||||
return old;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Undefined property "+key);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean supports(Object key) {
|
||||
return getPropertyMap().containsKey(key);
|
||||
}
|
||||
|
||||
public Object remove(Object key) {
|
||||
Accessor sp = getPropertyMap().get(key);
|
||||
if(sp!=null) {
|
||||
Object old = sp.get(this);
|
||||
sp.set(this,null);
|
||||
return old;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Undefined property "+key);
|
||||
}
|
||||
}
|
||||
|
||||
protected void createEntrySet(Set<Entry<String,Object>> core) {
|
||||
for (final Entry<String, Accessor> e : getPropertyMap().entrySet()) {
|
||||
core.add(new Entry<String, Object>() {
|
||||
public String getKey() {
|
||||
return e.getKey();
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return e.getValue().get(PropertySet.this);
|
||||
}
|
||||
|
||||
public Object setValue(Object value) {
|
||||
Accessor acc = e.getValue();
|
||||
Object old = acc.get(PropertySet.this);
|
||||
acc.set(PropertySet.this,value);
|
||||
return old;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract PropertyMap getPropertyMap();
|
||||
}
|
||||
68
jdkSrc/jdk8/com/sun/xml/internal/ws/api/ResourceLoader.java
Normal file
68
jdkSrc/jdk8/com/sun/xml/internal/ws/api/ResourceLoader.java
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
import com.sun.xml.internal.ws.api.server.Container;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Used to locate resources for jax-ws extensions. Using this, extensions
|
||||
* do not to have to write container specific code to locate resources.
|
||||
*
|
||||
* @author Jitendra Kotamraju
|
||||
*/
|
||||
public abstract class ResourceLoader {
|
||||
|
||||
/**
|
||||
* Returns the actual location of the resource from the 'resource' arg
|
||||
* that represents a virtual locaion of a file understood by a container.
|
||||
* ResourceLoader impl for a Container knows how to map this
|
||||
* virtual location to actual location.
|
||||
* <p>
|
||||
* Extensions can get hold of this object using {@link Container}.
|
||||
* <p/>
|
||||
* for e.g.:
|
||||
* <pre>
|
||||
* ResourceLoader loader = container.getSPI(ResourceLoader.class);
|
||||
* URL catalog = loader.get("jax-ws-catalog.xml");
|
||||
* </pre>
|
||||
* A ResourceLoader for servlet environment, may do the following.
|
||||
* <pre>
|
||||
* URL getResource(String resource) {
|
||||
* return servletContext.getResource("/WEB-INF/"+resource);
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @param resource Designates a path that is understood by the container. The
|
||||
* implementations must support "jax-ws-catalog.xml" resource.
|
||||
* @return the actual location, if found, or null if not found.
|
||||
* @throws MalformedURLException if there is an error in creating URL
|
||||
*/
|
||||
public abstract URL getResource(String resource) throws MalformedURLException;
|
||||
|
||||
}
|
||||
279
jdkSrc/jdk8/com/sun/xml/internal/ws/api/SOAPVersion.java
Normal file
279
jdkSrc/jdk8/com/sun/xml/internal/ws/api/SOAPVersion.java
Normal file
@@ -0,0 +1,279 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
import com.sun.xml.internal.bind.util.Which;
|
||||
import com.sun.xml.internal.ws.api.message.saaj.SAAJFactory;
|
||||
import com.sun.xml.internal.ws.encoding.soap.SOAP12Constants;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.MessageFactory;
|
||||
import javax.xml.soap.SOAPConstants;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.soap.SOAPFactory;
|
||||
import javax.xml.ws.soap.SOAPBinding;
|
||||
|
||||
import com.oracle.webservices.internal.api.EnvelopeStyle;
|
||||
import com.oracle.webservices.internal.api.EnvelopeStyleFeature;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Version of SOAP (1.1 and 1.2).
|
||||
*
|
||||
* <p>
|
||||
* This class defines various constants for SOAP 1.1 and SOAP 1.2,
|
||||
* and also defines convenience methods to simplify the processing
|
||||
* of multiple SOAP versions.
|
||||
*
|
||||
* <p>
|
||||
* This constant alows you to do:
|
||||
*
|
||||
* <pre>
|
||||
* SOAPVersion version = ...;
|
||||
* version.someOp(...);
|
||||
* </pre>
|
||||
*
|
||||
* As opposed to:
|
||||
*
|
||||
* <pre>
|
||||
* if(binding is SOAP11) {
|
||||
* doSomeOp11(...);
|
||||
* } else {
|
||||
* doSomeOp12(...);
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public enum SOAPVersion {
|
||||
SOAP_11(SOAPBinding.SOAP11HTTP_BINDING,
|
||||
com.sun.xml.internal.ws.encoding.soap.SOAPConstants.URI_ENVELOPE,
|
||||
"text/xml",
|
||||
SOAPConstants.URI_SOAP_ACTOR_NEXT, "actor",
|
||||
javax.xml.soap.SOAPConstants.SOAP_1_1_PROTOCOL,
|
||||
new QName(com.sun.xml.internal.ws.encoding.soap.SOAPConstants.URI_ENVELOPE, "MustUnderstand"),
|
||||
"Client",
|
||||
"Server",
|
||||
Collections.singleton(SOAPConstants.URI_SOAP_ACTOR_NEXT)),
|
||||
|
||||
SOAP_12(SOAPBinding.SOAP12HTTP_BINDING,
|
||||
SOAP12Constants.URI_ENVELOPE,
|
||||
"application/soap+xml",
|
||||
SOAPConstants.URI_SOAP_1_2_ROLE_ULTIMATE_RECEIVER, "role",
|
||||
javax.xml.soap.SOAPConstants.SOAP_1_2_PROTOCOL,
|
||||
new QName(com.sun.xml.internal.ws.encoding.soap.SOAP12Constants.URI_ENVELOPE, "MustUnderstand"),
|
||||
"Sender",
|
||||
"Receiver",
|
||||
new HashSet<String>(Arrays.asList(SOAPConstants.URI_SOAP_1_2_ROLE_NEXT,SOAPConstants.URI_SOAP_1_2_ROLE_ULTIMATE_RECEIVER)));
|
||||
|
||||
/**
|
||||
* Binding ID for SOAP/HTTP binding of this SOAP version.
|
||||
*
|
||||
* <p>
|
||||
* Either {@link SOAPBinding#SOAP11HTTP_BINDING} or
|
||||
* {@link SOAPBinding#SOAP12HTTP_BINDING}
|
||||
*/
|
||||
public final String httpBindingId;
|
||||
|
||||
/**
|
||||
* SOAP envelope namespace URI.
|
||||
*/
|
||||
public final String nsUri;
|
||||
|
||||
/**
|
||||
* Content-type. Either "text/xml" or "application/soap+xml".
|
||||
*/
|
||||
public final String contentType;
|
||||
|
||||
/**
|
||||
* SOAP MustUnderstand FaultCode for this SOAP version
|
||||
*/
|
||||
public final QName faultCodeMustUnderstand;
|
||||
|
||||
/**
|
||||
* SAAJ {@link MessageFactory} for this SOAP version.
|
||||
* @deprecated
|
||||
*/
|
||||
public final MessageFactory saajMessageFactory;
|
||||
|
||||
/**
|
||||
* SAAJ {@link SOAPFactory} for this SOAP version.
|
||||
* @deprecated
|
||||
*/
|
||||
public final SOAPFactory saajSoapFactory;
|
||||
|
||||
private final String saajFactoryString;
|
||||
|
||||
/**
|
||||
* If the actor/role attribute is absent, this SOAP version assumes this value.
|
||||
*/
|
||||
public final String implicitRole;
|
||||
|
||||
/**
|
||||
* Singleton set that contains {@link #implicitRole}.
|
||||
*/
|
||||
public final Set<String> implicitRoleSet;
|
||||
|
||||
/**
|
||||
* This represents the roles required to be assumed by SOAP binding implementation.
|
||||
*/
|
||||
public final Set<String> requiredRoles;
|
||||
|
||||
/**
|
||||
* "role" (SOAP 1.2) or "actor" (SOAP 1.1)
|
||||
*/
|
||||
public final String roleAttributeName;
|
||||
|
||||
/**
|
||||
* "{nsUri}Client" or "{nsUri}Sender"
|
||||
*/
|
||||
public final QName faultCodeClient;
|
||||
|
||||
/**
|
||||
* "{nsUri}Server" or "{nsUri}Receiver"
|
||||
*/
|
||||
public final QName faultCodeServer;
|
||||
|
||||
private SOAPVersion(String httpBindingId, String nsUri, String contentType, String implicitRole, String roleAttributeName,
|
||||
String saajFactoryString, QName faultCodeMustUnderstand, String faultCodeClientLocalName,
|
||||
String faultCodeServerLocalName,Set<String> requiredRoles) {
|
||||
this.httpBindingId = httpBindingId;
|
||||
this.nsUri = nsUri;
|
||||
this.contentType = contentType;
|
||||
this.implicitRole = implicitRole;
|
||||
this.implicitRoleSet = Collections.singleton(implicitRole);
|
||||
this.roleAttributeName = roleAttributeName;
|
||||
this.saajFactoryString = saajFactoryString;
|
||||
try {
|
||||
saajMessageFactory = MessageFactory.newInstance(saajFactoryString);
|
||||
saajSoapFactory = SOAPFactory.newInstance(saajFactoryString);
|
||||
} catch (SOAPException e) {
|
||||
throw new Error(e);
|
||||
} catch (NoSuchMethodError e) {
|
||||
// SAAJ 1.3 is not in the classpath
|
||||
LinkageError x = new LinkageError("You are loading old SAAJ from "+ Which.which(MessageFactory.class));
|
||||
x.initCause(e);
|
||||
throw x;
|
||||
}
|
||||
this.faultCodeMustUnderstand = faultCodeMustUnderstand;
|
||||
this.requiredRoles = requiredRoles;
|
||||
this.faultCodeClient = new QName(nsUri,faultCodeClientLocalName);
|
||||
this.faultCodeServer = new QName(nsUri,faultCodeServerLocalName);
|
||||
}
|
||||
|
||||
public SOAPFactory getSOAPFactory() {
|
||||
try {
|
||||
return SAAJFactory.getSOAPFactory(saajFactoryString);
|
||||
} catch (SOAPException e) {
|
||||
throw new Error(e);
|
||||
} catch (NoSuchMethodError e) {
|
||||
// SAAJ 1.3 is not in the classpath
|
||||
LinkageError x = new LinkageError("You are loading old SAAJ from "+ Which.which(MessageFactory.class));
|
||||
x.initCause(e);
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
|
||||
public MessageFactory getMessageFactory() {
|
||||
try {
|
||||
return SAAJFactory.getMessageFactory(saajFactoryString);
|
||||
} catch (SOAPException e) {
|
||||
throw new Error(e);
|
||||
} catch (NoSuchMethodError e) {
|
||||
// SAAJ 1.3 is not in the classpath
|
||||
LinkageError x = new LinkageError("You are loading old SAAJ from "+ Which.which(MessageFactory.class));
|
||||
x.initCause(e);
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return httpBindingId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link SOAPVersion} whose {@link #httpBindingId} equals to
|
||||
* the given string.
|
||||
*
|
||||
* This method does not perform input string validation.
|
||||
*
|
||||
* @param binding
|
||||
* for historical reason, we treat null as {@link #SOAP_11},
|
||||
* but you really shouldn't be passing null.
|
||||
* @return always non-null.
|
||||
*/
|
||||
public static SOAPVersion fromHttpBinding(String binding) {
|
||||
if(binding==null)
|
||||
return SOAP_11;
|
||||
|
||||
if(binding.equals(SOAP_12.httpBindingId))
|
||||
return SOAP_12;
|
||||
else
|
||||
return SOAP_11;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link SOAPVersion} whose {@link #nsUri} equals to
|
||||
* the given string.
|
||||
*
|
||||
* This method does not perform input string validation.
|
||||
*
|
||||
* @param nsUri
|
||||
* must not be null.
|
||||
* @return always non-null.
|
||||
*/
|
||||
public static SOAPVersion fromNsUri(String nsUri) {
|
||||
if(nsUri.equals(SOAP_12.nsUri))
|
||||
return SOAP_12;
|
||||
else
|
||||
return SOAP_11;
|
||||
}
|
||||
|
||||
public static SOAPVersion from(EnvelopeStyleFeature f) {
|
||||
EnvelopeStyle.Style[] style = f.getStyles();
|
||||
if (style.length != 1) throw new IllegalArgumentException ("The EnvelopingFeature must has exactly one Enveloping.Style");
|
||||
return from(style[0]);
|
||||
}
|
||||
|
||||
public static SOAPVersion from(EnvelopeStyle.Style style) {
|
||||
switch (style) {
|
||||
case SOAP11: return SOAP_11;
|
||||
case SOAP12: return SOAP_12;
|
||||
case XML: //ERROR??
|
||||
default: return SOAP_11;
|
||||
}
|
||||
}
|
||||
|
||||
public EnvelopeStyleFeature toFeature() {
|
||||
return SOAP_11.equals(this) ?
|
||||
new EnvelopeStyleFeature(new EnvelopeStyle.Style[]{EnvelopeStyle.Style.SOAP11}) :
|
||||
new EnvelopeStyleFeature(new EnvelopeStyle.Style[]{EnvelopeStyle.Style.SOAP12});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
/**
|
||||
* Marker interface for {@link WebServiceFeature} derived classes that when instances are specified in the feature list to a service delegate must be
|
||||
* added to the feature list of any Stubs created by that delegate. WebServiceFeature instances passed directly in the parameters of get...() or createDispatch()
|
||||
* must take precedence over feature instances passed during service delegate initialization.
|
||||
*
|
||||
* @since 2.2.6
|
||||
*/
|
||||
public interface ServiceSharedFeatureMarker {
|
||||
|
||||
}
|
||||
209
jdkSrc/jdk8/com/sun/xml/internal/ws/api/WSBinding.java
Normal file
209
jdkSrc/jdk8/com/sun/xml/internal/ws/api/WSBinding.java
Normal file
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
||||
import com.sun.xml.internal.ws.api.message.Message;
|
||||
import com.sun.xml.internal.ws.api.pipe.Codec;
|
||||
import com.sun.xml.internal.ws.api.pipe.Tube;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.ws.Binding;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import javax.xml.ws.handler.Handler;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* JAX-WS implementation of {@link Binding}.
|
||||
*
|
||||
* <p>
|
||||
* This object can be created by {@link BindingID#createBinding()}.
|
||||
*
|
||||
* <p>
|
||||
* Binding conceptually includes the on-the-wire format of the message,
|
||||
* this this object owns {@link Codec}.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public interface WSBinding extends Binding {
|
||||
/**
|
||||
* Gets the SOAP version of this binding.
|
||||
*
|
||||
* TODO: clarify what to do with XML/HTTP binding
|
||||
*
|
||||
* <p>
|
||||
* This is just a short-cut for {@code getBindingID().getSOAPVersion()}
|
||||
*
|
||||
* @return
|
||||
* If the binding is using SOAP, this method returns
|
||||
* a {@link SOAPVersion} constant.
|
||||
*
|
||||
* If the binding is not based on SOAP, this method
|
||||
* returns null. See {@link Message} for how a non-SOAP
|
||||
* binding shall be handled by {@link Tube}s.
|
||||
*/
|
||||
SOAPVersion getSOAPVersion();
|
||||
/**
|
||||
* Gets the WS-Addressing version of this binding.
|
||||
* <p/>
|
||||
* TODO: clarify what to do with XML/HTTP binding
|
||||
*
|
||||
* @return If the binding is using SOAP and WS-Addressing is enabled,
|
||||
* this method returns a {@link AddressingVersion} constant.
|
||||
* If binding is not using SOAP or WS-Addressing is not enabled,
|
||||
* this method returns null.
|
||||
*
|
||||
* This might be little slow as it has to go over all the features on binding.
|
||||
* Its advisable to cache the addressingVersion wherever possible and reuse it.
|
||||
*/
|
||||
AddressingVersion getAddressingVersion();
|
||||
|
||||
/**
|
||||
* Gets the binding ID, which uniquely identifies the binding.
|
||||
*
|
||||
* <p>
|
||||
* The relevant specs define the binding IDs and what they mean.
|
||||
* The ID is used in many places to identify the kind of binding
|
||||
* (such as SOAP1.1, SOAP1.2, REST, ...)
|
||||
*
|
||||
* @return
|
||||
* Always non-null same value.
|
||||
*/
|
||||
@NotNull BindingID getBindingId();
|
||||
|
||||
@NotNull@Override
|
||||
List<Handler> getHandlerChain();
|
||||
|
||||
/**
|
||||
* Checks if a particular {@link WebServiceFeature} is enabled.
|
||||
*
|
||||
* @return
|
||||
* true if enabled.
|
||||
*/
|
||||
boolean isFeatureEnabled(@NotNull Class<? extends WebServiceFeature> feature);
|
||||
|
||||
/**
|
||||
* Experimental: Checks if a particular {@link WebServiceFeature} on an operation is enabled.
|
||||
*
|
||||
* @param operationName
|
||||
* The WSDL name of the operation.
|
||||
* @return
|
||||
* true if enabled.
|
||||
*/
|
||||
boolean isOperationFeatureEnabled(@NotNull Class<? extends WebServiceFeature> feature,
|
||||
@NotNull final QName operationName);
|
||||
|
||||
/**
|
||||
* Gets a {@link WebServiceFeature} of the specific type.
|
||||
*
|
||||
* @param featureType
|
||||
* The type of the feature to retrieve.
|
||||
* @return
|
||||
* If the feature is present and enabled, return a non-null instance.
|
||||
* Otherwise null.
|
||||
*/
|
||||
@Nullable <F extends WebServiceFeature> F getFeature(@NotNull Class<F> featureType);
|
||||
|
||||
/**
|
||||
* Experimental: Gets a {@link WebServiceFeature} of the specific type that applies to an operation.
|
||||
*
|
||||
* @param featureType
|
||||
* The type of the feature to retrieve.
|
||||
* @param operationName
|
||||
* The WSDL name of the operation.
|
||||
* @return
|
||||
* If the feature is present and enabled, return a non-null instance.
|
||||
* Otherwise null.
|
||||
*/
|
||||
@Nullable <F extends WebServiceFeature> F getOperationFeature(@NotNull Class<F> featureType,
|
||||
@NotNull final QName operationName);
|
||||
|
||||
/**
|
||||
* Returns a list of features associated with {@link WSBinding}.
|
||||
*/
|
||||
@NotNull WSFeatureList getFeatures();
|
||||
|
||||
/**
|
||||
* Experimental: Returns a list of features associated with {@link WSBinding} that apply to
|
||||
* a particular operation.
|
||||
*
|
||||
* @param operationName
|
||||
* The WSDL name of the operation.
|
||||
*/
|
||||
@NotNull WSFeatureList getOperationFeatures(@NotNull final QName operationName);
|
||||
|
||||
/**
|
||||
* Experimental: Returns a list of features associated with {@link WSBinding} that apply to
|
||||
* the input message of an operation.
|
||||
*
|
||||
* @param operationName
|
||||
* The WSDL name of the operation.
|
||||
*/
|
||||
@NotNull WSFeatureList getInputMessageFeatures(@NotNull final QName operationName);
|
||||
|
||||
/**
|
||||
* Experimental: Returns a list of features associated with {@link WSBinding} that apply to
|
||||
* the output message of an operation.
|
||||
*
|
||||
* @param operationName
|
||||
* The WSDL name of the operation.
|
||||
*/
|
||||
@NotNull WSFeatureList getOutputMessageFeatures(@NotNull final QName operationName);
|
||||
|
||||
/**
|
||||
* Experimental: Returns a list of features associated with {@link WSBinding} that apply to
|
||||
* one of the fault messages of an operation.
|
||||
*
|
||||
* @param operationName
|
||||
* The WSDL name of the operation.
|
||||
* @param messageName
|
||||
* The WSDL name of the fault message.
|
||||
*/
|
||||
@NotNull WSFeatureList getFaultMessageFeatures(@NotNull final QName operationName,
|
||||
@NotNull final QName messageName);
|
||||
|
||||
/**
|
||||
* Returns set of header QNames known to be supported by this binding.
|
||||
* @return Set of known QNames
|
||||
*/
|
||||
@NotNull Set<QName> getKnownHeaders();
|
||||
|
||||
/**
|
||||
* Adds header QName to set known to be supported by this binding
|
||||
* @param knownHeader Known header QName
|
||||
* @return true, if new entry was added; false, if known header QName was already known
|
||||
*/
|
||||
boolean addKnownHeader(QName knownHeader);
|
||||
|
||||
/**
|
||||
* @return A MessageContextFactory configured according to the binding's features.
|
||||
*/
|
||||
@NotNull com.oracle.webservices.internal.api.message.MessageContextFactory getMessageContextFactory();
|
||||
}
|
||||
51
jdkSrc/jdk8/com/sun/xml/internal/ws/api/WSDLLocator.java
Normal file
51
jdkSrc/jdk8/com/sun/xml/internal/ws/api/WSDLLocator.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.xml.ws.Service;
|
||||
|
||||
/**
|
||||
* Used to locate WSDL documents; particularly useful for J2EE deployment archives
|
||||
*
|
||||
* @since 2.2.6
|
||||
*/
|
||||
public abstract class WSDLLocator {
|
||||
|
||||
/**
|
||||
* Returns the actual WSDL location
|
||||
*
|
||||
* @param service Service class
|
||||
* @param wsdlLoc Designates the WSDL location either from the service class
|
||||
* or through other means
|
||||
* @return the actual WSDL location, if found, or null if not found.
|
||||
* @throws MalformedURLException if there is an error in creating URL
|
||||
*/
|
||||
public abstract URL locateWSDL(Class<Service> service, String wsdlLoc) throws MalformedURLException;
|
||||
|
||||
}
|
||||
84
jdkSrc/jdk8/com/sun/xml/internal/ws/api/WSFeatureList.java
Normal file
84
jdkSrc/jdk8/com/sun/xml/internal/ws/api/WSFeatureList.java
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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.api;import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
/**
|
||||
* Read-only list of {@link WebServiceFeature}s.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public interface WSFeatureList extends Iterable<WebServiceFeature> {
|
||||
/**
|
||||
* Checks if a particular {@link WebServiceFeature} is enabled.
|
||||
*
|
||||
* @return
|
||||
* true if enabled.
|
||||
*/
|
||||
boolean isEnabled(@NotNull Class<? extends WebServiceFeature> feature);
|
||||
|
||||
/**
|
||||
* Gets a {@link WebServiceFeature} of the specific type.
|
||||
*
|
||||
* @param featureType
|
||||
* The type of the feature to retrieve.
|
||||
* @return
|
||||
* If the feature is present and enabled, return a non-null instance.
|
||||
* Otherwise null.
|
||||
*/
|
||||
@Nullable <F extends WebServiceFeature> F get(@NotNull Class<F> featureType);
|
||||
|
||||
/**
|
||||
* Obtains all the features in the array.
|
||||
*/
|
||||
@NotNull WebServiceFeature[] toArray();
|
||||
|
||||
/**
|
||||
* Merges the extra features that are not already set on binding.
|
||||
* i.e, if a feature is set already on binding through some other API
|
||||
* the corresponding wsdlFeature is not set.
|
||||
*
|
||||
* @param features Web Service features that need to be merged with already configured features.
|
||||
* @param reportConflicts If true, checks if the feature setting in WSDL (wsdl extension or
|
||||
* policy configuration) conflicts with feature setting in Deployed Service and
|
||||
* logs warning if there are any conflicts.
|
||||
*/
|
||||
void mergeFeatures(@NotNull WebServiceFeature[] features, boolean reportConflicts);
|
||||
|
||||
/**
|
||||
* Merges the extra features that are not already set on binding.
|
||||
* i.e, if a feature is set already on binding through some other API
|
||||
* the corresponding wsdlFeature is not set.
|
||||
*
|
||||
* @param features Web Service features that need to be merged with already configured features.
|
||||
* @param reportConflicts If true, checks if the feature setting in WSDL (wsdl extension or
|
||||
* policy configuration) conflicts with feature setting in Deployed Service and
|
||||
* logs warning if there are any conflicts.
|
||||
*/
|
||||
void mergeFeatures(@NotNull Iterable<WebServiceFeature> features, boolean reportConflicts);
|
||||
}
|
||||
248
jdkSrc/jdk8/com/sun/xml/internal/ws/api/WSService.java
Normal file
248
jdkSrc/jdk8/com/sun/xml/internal/ws/api/WSService.java
Normal file
@@ -0,0 +1,248 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
|
||||
import com.sun.xml.internal.ws.api.server.Container;
|
||||
import com.sun.xml.internal.ws.api.server.ContainerResolver;
|
||||
import com.sun.xml.internal.ws.api.server.WSEndpoint;
|
||||
import com.sun.xml.internal.ws.client.WSServiceDelegate;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.ws.Dispatch;
|
||||
import javax.xml.ws.EndpointReference;
|
||||
import javax.xml.ws.Service;
|
||||
import javax.xml.ws.Service.Mode;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import javax.xml.ws.spi.ServiceDelegate;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URL;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
/**
|
||||
* JAX-WS implementation of {@link ServiceDelegate}.
|
||||
*
|
||||
* <p>
|
||||
* This abstract class is used only to improve the static type safety
|
||||
* of the JAX-WS internal API.
|
||||
*
|
||||
* <p>
|
||||
* The class name intentionally doesn't include "Delegate",
|
||||
* because the fact that it's a delegate is a detail of
|
||||
* the JSR-224 API, and for the layers above us this object
|
||||
* nevertheless represents {@link Service}. We want them
|
||||
* to think of this as an internal representation of a service.
|
||||
*
|
||||
* <p>
|
||||
* Only JAX-WS internal code may downcast this to {@link WSServiceDelegate}.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public abstract class WSService extends ServiceDelegate implements ComponentRegistry {
|
||||
private final Set<Component> components = new CopyOnWriteArraySet<Component>();
|
||||
|
||||
protected WSService() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Works like {@link #getPort(EndpointReference, Class, WebServiceFeature...)}
|
||||
* but takes {@link WSEndpointReference}.
|
||||
*/
|
||||
public abstract <T> T getPort(WSEndpointReference epr, Class<T> portInterface, WebServiceFeature... features);
|
||||
|
||||
/**
|
||||
* Works like {@link #createDispatch(javax.xml.ws.EndpointReference, java.lang.Class, javax.xml.ws.Service.Mode, javax.xml.ws.WebServiceFeature[])}
|
||||
* but it takes the port name separately, so that EPR without embedded metadata can be used.
|
||||
*/
|
||||
public abstract <T> Dispatch<T> createDispatch(QName portName, WSEndpointReference wsepr, Class<T> aClass, Service.Mode mode, WebServiceFeature... features);
|
||||
|
||||
/**
|
||||
* Works like {@link #createDispatch(javax.xml.ws.EndpointReference, javax.xml.bind.JAXBContext, javax.xml.ws.Service.Mode, javax.xml.ws.WebServiceFeature[])}
|
||||
* but it takes the port name separately, so that EPR without embedded metadata can be used.
|
||||
*/
|
||||
public abstract Dispatch<Object> createDispatch(QName portName, WSEndpointReference wsepr, JAXBContext jaxbContext, Service.Mode mode, WebServiceFeature... features);
|
||||
|
||||
/**
|
||||
* Gets the {@link Container} object.
|
||||
*
|
||||
* <p>
|
||||
* The components inside {@link WSEndpoint} uses this reference
|
||||
* to communicate with the hosting environment.
|
||||
*
|
||||
* @return
|
||||
* always same object. If no "real" {@link Container} instance
|
||||
* is given, {@link Container#NONE} will be returned.
|
||||
*/
|
||||
public abstract @NotNull Container getContainer();
|
||||
|
||||
public @Nullable <S> S getSPI(@NotNull Class<S> spiType) {
|
||||
for (Component c : components) {
|
||||
S s = c.getSPI(spiType);
|
||||
if (s != null)
|
||||
return s;
|
||||
}
|
||||
|
||||
return getContainer().getSPI(spiType);
|
||||
}
|
||||
|
||||
public @NotNull Set<Component> getComponents() {
|
||||
return components;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a <code>Service</code> instance.
|
||||
*
|
||||
* The specified WSDL document location and service qualified name MUST
|
||||
* uniquely identify a <code>wsdl:service</code> element.
|
||||
*
|
||||
* @param wsdlDocumentLocation URL for the WSDL document location
|
||||
* for the service
|
||||
* @param serviceName QName for the service
|
||||
* @throws WebServiceException If any error in creation of the
|
||||
* specified service.
|
||||
**/
|
||||
public static WSService create( URL wsdlDocumentLocation, QName serviceName) {
|
||||
return new WSServiceDelegate(wsdlDocumentLocation,serviceName,Service.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a <code>Service</code> instance.
|
||||
*
|
||||
* @param serviceName QName for the service
|
||||
* @throws WebServiceException If any error in creation of the
|
||||
* specified service
|
||||
*/
|
||||
public static WSService create(QName serviceName) {
|
||||
return create(null,serviceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a service with a dummy service name.
|
||||
*/
|
||||
public static WSService create() {
|
||||
return create(null,new QName(WSService.class.getName(),"dummy"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Typed parameter bag used by {@link WSService#create(URL, QName, InitParams)}
|
||||
*
|
||||
* @since 2.1.3
|
||||
*/
|
||||
public static final class InitParams {
|
||||
private Container container;
|
||||
/**
|
||||
* Sets the {@link Container} object used by the created service.
|
||||
* This allows the client to use a specific {@link Container} instance
|
||||
* as opposed to the one obtained by {@link ContainerResolver}.
|
||||
*/
|
||||
public void setContainer(Container c) {
|
||||
this.container = c;
|
||||
}
|
||||
public Container getContainer() {
|
||||
return container;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To create a {@link Service}, we need to go through the API that doesn't let us
|
||||
* pass parameters, so as a hack we use thread local.
|
||||
*/
|
||||
protected static final ThreadLocal<InitParams> INIT_PARAMS = new ThreadLocal<InitParams>();
|
||||
|
||||
/**
|
||||
* Used as a immutable constant so that we can avoid null check.
|
||||
*/
|
||||
protected static final InitParams EMPTY_PARAMS = new InitParams();
|
||||
|
||||
/**
|
||||
* Creates a {@link Service} instance.
|
||||
*
|
||||
* <p>
|
||||
* This method works really like {@link Service#create(URL, QName)}
|
||||
* except it takes one more RI specific parameter.
|
||||
*
|
||||
* @param wsdlDocumentLocation
|
||||
* {@code URL} for the WSDL document location for the service.
|
||||
* Can be null, in which case WSDL is not loaded.
|
||||
* @param serviceName
|
||||
* {@code QName} for the service.
|
||||
* @param properties
|
||||
* Additional RI specific initialization parameters. Can be null.
|
||||
* @throws WebServiceException
|
||||
* If any error in creation of the specified service.
|
||||
**/
|
||||
public static Service create( URL wsdlDocumentLocation, QName serviceName, InitParams properties) {
|
||||
if(INIT_PARAMS.get()!=null)
|
||||
throw new IllegalStateException("someone left non-null InitParams");
|
||||
INIT_PARAMS.set(properties);
|
||||
try {
|
||||
Service svc = Service.create(wsdlDocumentLocation, serviceName);
|
||||
if(INIT_PARAMS.get()!=null)
|
||||
throw new IllegalStateException("Service "+svc+" didn't recognize InitParams");
|
||||
return svc;
|
||||
} finally {
|
||||
// even in case of an exception still reset INIT_PARAMS
|
||||
INIT_PARAMS.set(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the {@link WSService} that's encapsulated inside a {@link Service}.
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* if the given service object is not from the JAX-WS RI.
|
||||
*/
|
||||
public static WSService unwrap(final Service svc) {
|
||||
return AccessController.doPrivileged(new PrivilegedAction<WSService>() {
|
||||
public WSService run() {
|
||||
try {
|
||||
Field f = svc.getClass().getField("delegate");
|
||||
f.setAccessible(true);
|
||||
Object delegate = f.get(svc);
|
||||
if(!(delegate instanceof WSService))
|
||||
throw new IllegalArgumentException();
|
||||
return (WSService) delegate;
|
||||
} catch (NoSuchFieldException e) {
|
||||
AssertionError x = new AssertionError("Unexpected service API implementation");
|
||||
x.initCause(e);
|
||||
throw x;
|
||||
} catch (IllegalAccessException e) {
|
||||
IllegalAccessError x = new IllegalAccessError(e.getMessage());
|
||||
x.initCause(e);
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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.api;
|
||||
|
||||
import com.sun.xml.internal.ws.binding.WebServiceFeatureList;
|
||||
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
/**
|
||||
* Factory methods to get web service features from the corresponding
|
||||
* feature annotations
|
||||
*
|
||||
* @author Jitendra Kotamraju
|
||||
*/
|
||||
public class WebServiceFeatureFactory {
|
||||
|
||||
/**
|
||||
* Returns a feature list for feature annotations(i.e which have
|
||||
* {@link javax.xml.ws.spi.WebServiceFeatureAnnotation} meta annotation)
|
||||
*
|
||||
* @param ann list of annotations(that can also have non-feature annotations)
|
||||
* @return non-null feature list object
|
||||
*/
|
||||
public static WSFeatureList getWSFeatureList(Iterable<Annotation> ann) {
|
||||
WebServiceFeatureList list = new WebServiceFeatureList();
|
||||
list.parseAnnotations(ann);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a corresponding feature for a feature annotation(i.e which has
|
||||
* {@link javax.xml.ws.spi.WebServiceFeatureAnnotation} meta annotation)
|
||||
*
|
||||
* @param ann any annotation, not required to be a feature annotation
|
||||
* @return corresponding feature for the annotation
|
||||
* null, if the annotation is not a feature annotation
|
||||
*/
|
||||
public static WebServiceFeature getWebServiceFeature(Annotation ann) {
|
||||
return WebServiceFeatureList.getFeature(ann);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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.api.addressing;
|
||||
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.oracle.webservices.internal.api.message.BasePropertySet;
|
||||
import javax.xml.ws.handler.MessageContext;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>This property set exists so the upper stack can SET addressing info
|
||||
* on a PER-REQUEST basis (instead of a per proxy/dispatch basis via OneWayFeature).</p>
|
||||
*
|
||||
* <p>This class is NOT used for reading addressing header values.</p>
|
||||
*/
|
||||
public class AddressingPropertySet extends BasePropertySet {
|
||||
|
||||
// NOTE: Setting ACTION on client side is covered by standard BindingProvider.
|
||||
|
||||
public static final String ADDRESSING_FAULT_TO = "com.sun.xml.internal.ws.api.addressing.fault.to";
|
||||
private String faultTo;
|
||||
@Property(ADDRESSING_FAULT_TO)
|
||||
public String getFaultTo() { return faultTo; }
|
||||
public void setFaultTo(final String x) { faultTo = x; }
|
||||
|
||||
public static final String ADDRESSING_MESSAGE_ID = "com.sun.xml.internal.ws.api.addressing.message.id";
|
||||
private String messageId;
|
||||
public String getMessageId() { return messageId; }
|
||||
public void setMessageId(final String x) { messageId = x; }
|
||||
|
||||
public static final String ADDRESSING_RELATES_TO = "com.sun.xml.internal.ws.api.addressing.relates.to";
|
||||
@Property(ADDRESSING_RELATES_TO)
|
||||
private String relatesTo;
|
||||
public String getRelatesTo() { return relatesTo; }
|
||||
public void setRelatesTo(final String x) { relatesTo = x; }
|
||||
|
||||
public static final String ADDRESSING_REPLY_TO = "com.sun.xml.internal.ws.api.addressing.reply.to";
|
||||
@Property(ADDRESSING_REPLY_TO)
|
||||
private String replyTo;
|
||||
public String getReplyTo() { return replyTo; }
|
||||
public void setReplyTo(final String x) { replyTo = x; }
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
// PropertySet boilerplate
|
||||
//
|
||||
|
||||
private static final PropertyMap model;
|
||||
|
||||
static {
|
||||
model = parse(AddressingPropertySet.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PropertyMap getPropertyMap() {
|
||||
return model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,753 @@
|
||||
/*
|
||||
* 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.api.addressing;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.stream.buffer.XMLStreamBuffer;
|
||||
import com.sun.xml.internal.ws.addressing.W3CAddressingConstants;
|
||||
import com.sun.xml.internal.ws.addressing.WsaTubeHelper;
|
||||
import com.sun.xml.internal.ws.addressing.v200408.MemberSubmissionAddressingConstants;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.message.Header;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.api.model.SEIModel;
|
||||
import com.sun.xml.internal.ws.developer.MemberSubmissionAddressingFeature;
|
||||
import com.sun.xml.internal.ws.developer.MemberSubmissionEndpointReference;
|
||||
import com.sun.xml.internal.ws.message.stream.OutboundStreamHeader;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.ws.EndpointReference;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import javax.xml.ws.soap.AddressingFeature;
|
||||
import javax.xml.ws.wsaddressing.W3CEndpointReference;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
/**
|
||||
* 'Traits' object that absorbs differences of WS-Addressing versions.
|
||||
*
|
||||
* @author Arun Gupta
|
||||
*/
|
||||
public enum AddressingVersion {
|
||||
|
||||
W3C("http://www.w3.org/2005/08/addressing",
|
||||
"wsa",
|
||||
W3CAddressingConstants.ANONYMOUS_EPR,
|
||||
"http://www.w3.org/2006/05/addressing/wsdl",
|
||||
"http://www.w3.org/2006/05/addressing/wsdl",
|
||||
"http://www.w3.org/2005/08/addressing/anonymous",
|
||||
"http://www.w3.org/2005/08/addressing/none",
|
||||
new EPR(W3CEndpointReference.class,
|
||||
"Address",
|
||||
"ServiceName",
|
||||
"EndpointName",
|
||||
"InterfaceName",
|
||||
new QName("http://www.w3.org/2005/08/addressing","Metadata","wsa"),
|
||||
"ReferenceParameters",
|
||||
null )) {
|
||||
|
||||
/* package */ String getActionMismatchLocalName() {
|
||||
return "ActionMismatch";
|
||||
}
|
||||
@Override
|
||||
public boolean isReferenceParameter(String localName) {
|
||||
return localName.equals("ReferenceParameters");
|
||||
}
|
||||
|
||||
@Override
|
||||
public WsaTubeHelper getWsaHelper(WSDLPort wsdlPort, SEIModel seiModel, WSBinding binding) {
|
||||
return new com.sun.xml.internal.ws.addressing.WsaTubeHelperImpl(wsdlPort, seiModel, binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
/* package */ String getMapRequiredLocalName() {
|
||||
return "MessageAddressingHeaderRequired";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMapRequiredText() {
|
||||
return "A required header representing a Message Addressing Property is not present";
|
||||
}
|
||||
|
||||
/* package */ String getInvalidAddressLocalName() {
|
||||
return "InvalidAddress";
|
||||
}
|
||||
|
||||
@Override
|
||||
/* package */ String getInvalidMapLocalName() {
|
||||
return "InvalidAddressingHeader";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvalidMapText() {
|
||||
return "A header representing a Message Addressing Property is not valid and the message cannot be processed";
|
||||
}
|
||||
|
||||
@Override
|
||||
/* package */ String getInvalidCardinalityLocalName() {
|
||||
return "InvalidCardinality";
|
||||
}
|
||||
|
||||
/*package*/ Header createReferenceParameterHeader(XMLStreamBuffer mark, String nsUri, String localName) {
|
||||
return new OutboundReferenceParameterHeader(mark,nsUri,localName);
|
||||
}
|
||||
|
||||
/*package*/ String getIsReferenceParameterLocalName() {
|
||||
return "IsReferenceParameter";
|
||||
}
|
||||
|
||||
/* package */ String getWsdlAnonymousLocalName() {
|
||||
return "Anonymous";
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return "wsa";
|
||||
}
|
||||
|
||||
public String getWsdlPrefix() {
|
||||
return "wsaw";
|
||||
}
|
||||
|
||||
public Class<? extends WebServiceFeature> getFeatureClass() {
|
||||
return AddressingFeature.class;
|
||||
}
|
||||
},
|
||||
MEMBER("http://schemas.xmlsoap.org/ws/2004/08/addressing",
|
||||
"wsa",
|
||||
MemberSubmissionAddressingConstants.ANONYMOUS_EPR,
|
||||
"http://schemas.xmlsoap.org/ws/2004/08/addressing",
|
||||
"http://schemas.xmlsoap.org/ws/2004/08/addressing/policy",
|
||||
"http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
|
||||
"",
|
||||
new EPR(MemberSubmissionEndpointReference.class,
|
||||
"Address",
|
||||
"ServiceName",
|
||||
"PortName",
|
||||
"PortType",
|
||||
MemberSubmissionAddressingConstants.MEX_METADATA,
|
||||
"ReferenceParameters",
|
||||
"ReferenceProperties")) {
|
||||
/* package */ String getActionMismatchLocalName() {
|
||||
return "InvalidMessageInformationHeader";
|
||||
}
|
||||
@Override
|
||||
public boolean isReferenceParameter(String localName) {
|
||||
return localName.equals("ReferenceParameters") || localName.equals("ReferenceProperties");
|
||||
}
|
||||
|
||||
@Override
|
||||
public WsaTubeHelper getWsaHelper(WSDLPort wsdlPort, SEIModel seiModel, WSBinding binding) {
|
||||
return new com.sun.xml.internal.ws.addressing.v200408.WsaTubeHelperImpl(wsdlPort, seiModel, binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
/* package */ String getMapRequiredLocalName() {
|
||||
return "MessageInformationHeaderRequired";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMapRequiredText() {
|
||||
return "A required message information header, To, MessageID, or Action, is not present.";
|
||||
}
|
||||
|
||||
/* package */ String getInvalidAddressLocalName() {
|
||||
return getInvalidMapLocalName();
|
||||
}
|
||||
|
||||
@Override
|
||||
/* package */ String getInvalidMapLocalName() {
|
||||
return "InvalidMessageInformationHeader";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvalidMapText() {
|
||||
return "A message information header is not valid and the message cannot be processed.";
|
||||
}
|
||||
|
||||
@Override
|
||||
/* package */ String getInvalidCardinalityLocalName() {
|
||||
return getInvalidMapLocalName();
|
||||
}
|
||||
|
||||
/*package*/ Header createReferenceParameterHeader(XMLStreamBuffer mark, String nsUri, String localName) {
|
||||
return new OutboundStreamHeader(mark,nsUri,localName);
|
||||
}
|
||||
|
||||
/*package*/ String getIsReferenceParameterLocalName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/* package */ String getWsdlAnonymousLocalName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return "wsa";
|
||||
}
|
||||
|
||||
public String getWsdlPrefix() {
|
||||
return "wsaw";
|
||||
}
|
||||
|
||||
public Class<? extends WebServiceFeature> getFeatureClass() {
|
||||
return MemberSubmissionAddressingFeature.class;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Namespace URI
|
||||
*/
|
||||
public final String nsUri;
|
||||
|
||||
/**
|
||||
* Namespace URI for the WSDL Binding
|
||||
*/
|
||||
public final String wsdlNsUri;
|
||||
|
||||
/**
|
||||
* Representing either {@link W3CEndpointReference} or
|
||||
* {@link MemberSubmissionEndpointReference}.
|
||||
*/
|
||||
public final EPR eprType;
|
||||
|
||||
/**
|
||||
* Namespace URI for the WSDL Binding
|
||||
*/
|
||||
public final String policyNsUri;
|
||||
|
||||
/**
|
||||
* Gets the anonymous URI value associated with this WS-Addressing version.
|
||||
*/
|
||||
public final @NotNull String anonymousUri;
|
||||
|
||||
/**
|
||||
* Gets the none URI value associated with this WS-Addressing version.
|
||||
*/
|
||||
public final @NotNull String noneUri;
|
||||
|
||||
/**
|
||||
* Represents the anonymous EPR.
|
||||
*/
|
||||
public final WSEndpointReference anonymousEpr;
|
||||
|
||||
/**
|
||||
* Represents the To QName in the SOAP message for a specific WS-Addressing Version.
|
||||
*/
|
||||
public final QName toTag;
|
||||
|
||||
/**
|
||||
* Represents the From QName in the SOAP message for a specific WS-Addressing Version.
|
||||
*/
|
||||
public final QName fromTag;
|
||||
|
||||
/**
|
||||
* Represents the ReplyTo QName in the SOAP message for a specific WS-Addressing Version.
|
||||
*/
|
||||
public final QName replyToTag;
|
||||
|
||||
/**
|
||||
* Represents the FaultTo QName for a specific WS-Addressing Version.
|
||||
*/
|
||||
public final QName faultToTag;
|
||||
|
||||
/**
|
||||
* Represents the Action QName in the SOAP message for a specific WS-Addressing Version.
|
||||
*/
|
||||
public final QName actionTag;
|
||||
|
||||
/**
|
||||
* Represents the MessageID QName in the SOAP message for a specific WS-Addressing Version.
|
||||
*/
|
||||
public final QName messageIDTag;
|
||||
|
||||
/**
|
||||
* Represents the RelatesTo QName in the SOAP message for a specific WS-Addressing Version.
|
||||
*/
|
||||
public final QName relatesToTag;
|
||||
|
||||
/**
|
||||
* Represents the QName of the fault code when a required header representing a
|
||||
* WS-Addressing Message Addressing Property is not present.
|
||||
*/
|
||||
public final QName mapRequiredTag;
|
||||
|
||||
/**
|
||||
* Represents the QName of the fault code when Action is not supported at this endpoint.
|
||||
*/
|
||||
public final QName actionMismatchTag;
|
||||
|
||||
/**
|
||||
* Represents the QName of the fault code when Action is not supported at this endpoint.
|
||||
*/
|
||||
public final QName actionNotSupportedTag;
|
||||
|
||||
/**
|
||||
* Represents the text of the fault when Action is not supported at this endpoint.
|
||||
*/
|
||||
public final String actionNotSupportedText;
|
||||
|
||||
/**
|
||||
* Represents the QName of the fault code when a header representing a
|
||||
* WS-Addressing Message Addressing Property is invalid and cannot be processed.
|
||||
*/
|
||||
public final QName invalidMapTag;
|
||||
|
||||
/**
|
||||
* Represents the QName of the fault code when a header representing a
|
||||
* WS-Addressing Message Addressing Property occurs greater than expected number.
|
||||
*/
|
||||
public final QName invalidCardinalityTag;
|
||||
|
||||
/**
|
||||
* Represents the QName of the fault code when a header representing an
|
||||
* address is not valid.
|
||||
*/
|
||||
public final QName invalidAddressTag;
|
||||
|
||||
/**
|
||||
* Represents the QName of the element that conveys additional information
|
||||
* on the pre-defined WS-Addressing faults.
|
||||
*/
|
||||
public final QName problemHeaderQNameTag;
|
||||
|
||||
/**
|
||||
* Represents the QName of the element that conveys additional information
|
||||
* if Action is not matching with that expected.
|
||||
*/
|
||||
public final QName problemActionTag;
|
||||
|
||||
/**
|
||||
* Represents the QName of the header element that is used to capture the fault detail
|
||||
* if there is a fault processing WS-Addressing Message Addressing Property. This is
|
||||
* only used for SOAP 1.1.
|
||||
*/
|
||||
public final QName faultDetailTag;
|
||||
|
||||
/**
|
||||
* Fault sub-sub-code that represents
|
||||
* "Specifies that the invalid header was expected to be an EPR but did not contain an [address]."
|
||||
*/
|
||||
public final QName fault_missingAddressInEpr;
|
||||
|
||||
/**
|
||||
* Represents the Action QName in the WSDL for a specific WS-Addressing Version.
|
||||
*/
|
||||
public final QName wsdlActionTag;
|
||||
|
||||
/**
|
||||
* Represents the WSDL extension QName for a specific WS-Addressing Version.
|
||||
*/
|
||||
public final QName wsdlExtensionTag;
|
||||
|
||||
/**
|
||||
* Represents the WSDL anonymous QName for a specific WS-Addressing Version.
|
||||
*/
|
||||
public final QName wsdlAnonymousTag;
|
||||
|
||||
/**
|
||||
* Represents the QName of the reference parameter in a SOAP message. This is
|
||||
* only valid for W3C WS-Addressing.
|
||||
*/
|
||||
public final QName isReferenceParameterTag;
|
||||
|
||||
private static final String EXTENDED_FAULT_NAMESPACE = "http://jax-ws.dev.java.net/addressing/fault";
|
||||
public static final String UNSET_OUTPUT_ACTION = "http://jax-ws.dev.java.net/addressing/output-action-not-set";
|
||||
public static final String UNSET_INPUT_ACTION = "http://jax-ws.dev.java.net/addressing/input-action-not-set";
|
||||
|
||||
/**
|
||||
* Fault sub-sub-code that represents duplicate <Address> element in EPR.
|
||||
* This is a fault code not defined in the spec.
|
||||
*/
|
||||
public static final QName fault_duplicateAddressInEpr = new QName(
|
||||
EXTENDED_FAULT_NAMESPACE, "DuplicateAddressInEpr", "wsa"
|
||||
);
|
||||
|
||||
private AddressingVersion(String nsUri, String prefix, String anonymousEprString, String wsdlNsUri, String policyNsUri,
|
||||
String anonymousUri, String noneUri,
|
||||
EPR eprType ) {
|
||||
this.nsUri = nsUri;
|
||||
this.wsdlNsUri = wsdlNsUri;
|
||||
this.policyNsUri = policyNsUri;
|
||||
this.anonymousUri = anonymousUri;
|
||||
this.noneUri = noneUri;
|
||||
toTag = new QName(nsUri,"To", prefix);
|
||||
fromTag = new QName(nsUri,"From", prefix);
|
||||
replyToTag = new QName(nsUri,"ReplyTo", prefix);
|
||||
faultToTag = new QName(nsUri,"FaultTo", prefix);
|
||||
actionTag = new QName(nsUri,"Action", prefix);
|
||||
messageIDTag = new QName(nsUri,"MessageID", prefix);
|
||||
relatesToTag = new QName(nsUri,"RelatesTo", prefix);
|
||||
|
||||
mapRequiredTag = new QName(nsUri,getMapRequiredLocalName(), prefix);
|
||||
actionMismatchTag = new QName(nsUri,getActionMismatchLocalName(), prefix);
|
||||
actionNotSupportedTag = new QName(nsUri,"ActionNotSupported", prefix);
|
||||
actionNotSupportedText = "The \"%s\" cannot be processed at the receiver";
|
||||
invalidMapTag = new QName(nsUri,getInvalidMapLocalName(), prefix);
|
||||
invalidAddressTag = new QName(nsUri,getInvalidAddressLocalName(), prefix);
|
||||
invalidCardinalityTag = new QName(nsUri,getInvalidCardinalityLocalName(), prefix);
|
||||
faultDetailTag = new QName(nsUri,"FaultDetail", prefix);
|
||||
|
||||
problemHeaderQNameTag = new QName(nsUri,"ProblemHeaderQName", prefix);
|
||||
problemActionTag = new QName(nsUri, "ProblemAction", prefix);
|
||||
|
||||
fault_missingAddressInEpr = new QName(nsUri,"MissingAddressInEPR", prefix);
|
||||
isReferenceParameterTag = new QName(nsUri,getIsReferenceParameterLocalName(), prefix);
|
||||
|
||||
wsdlActionTag = new QName(wsdlNsUri,"Action", prefix);
|
||||
wsdlExtensionTag = new QName(wsdlNsUri, "UsingAddressing", prefix);
|
||||
wsdlAnonymousTag = new QName(wsdlNsUri, getWsdlAnonymousLocalName(), prefix);
|
||||
|
||||
// create stock anonymous EPR
|
||||
try {
|
||||
this.anonymousEpr = new WSEndpointReference(new ByteArrayInputStream(anonymousEprString.getBytes("UTF-8")),this);
|
||||
} catch (XMLStreamException e) {
|
||||
throw new Error(e); // bug in our code as EPR should parse.
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
this.eprType = eprType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the local name of the fault when a header representing a WS-Addressing Action is not same as SOAPAction
|
||||
*
|
||||
* @return local name
|
||||
*/
|
||||
/* package */ abstract String getActionMismatchLocalName();
|
||||
|
||||
/**
|
||||
* Returns {@link AddressingVersion} whose {@link #nsUri} equals to
|
||||
* the given string.
|
||||
*
|
||||
* This method does not perform input string validation.
|
||||
*
|
||||
* @param nsUri
|
||||
* must not be null.
|
||||
* @return always non-null.
|
||||
*/
|
||||
public static AddressingVersion fromNsUri(String nsUri) {
|
||||
if (nsUri.equals(W3C.nsUri))
|
||||
return W3C;
|
||||
|
||||
if (nsUri.equals(MEMBER.nsUri))
|
||||
return MEMBER;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link AddressingVersion} from a {@link WSBinding}
|
||||
*
|
||||
* @param binding WSDL binding
|
||||
* @return
|
||||
* addresing version enabled, or null if none is enabled.
|
||||
*/
|
||||
public static @Nullable
|
||||
AddressingVersion fromBinding(WSBinding binding) {
|
||||
// TODO: who is responsible for reporting an error if both versions
|
||||
// are on?
|
||||
if (binding.isFeatureEnabled(AddressingFeature.class))
|
||||
return W3C;
|
||||
|
||||
if (binding.isFeatureEnabled(MemberSubmissionAddressingFeature.class))
|
||||
return MEMBER;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link AddressingVersion} from a {@link WSDLPort}
|
||||
*
|
||||
* @param port WSDL port
|
||||
* @return addresing version
|
||||
*/
|
||||
public static AddressingVersion fromPort(WSDLPort port) {
|
||||
if (port == null)
|
||||
return null;
|
||||
|
||||
WebServiceFeature wsf = port.getFeature(AddressingFeature.class);
|
||||
if (wsf == null) {
|
||||
wsf = port.getFeature(MemberSubmissionAddressingFeature.class);
|
||||
}
|
||||
if (wsf == null)
|
||||
return null;
|
||||
|
||||
return fromFeature(wsf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link #nsUri} associated with this {@link AddressingVersion}
|
||||
*
|
||||
* @return namespace URI
|
||||
* @deprecated
|
||||
* Use {@link #nsUri}.
|
||||
*/
|
||||
public String getNsUri() {
|
||||
return nsUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given local name is considered as
|
||||
* a reference parameter in EPR.
|
||||
*
|
||||
* For W3C, this means "ReferenceParameters",
|
||||
* and for the member submission version, this means
|
||||
* either "ReferenceParameters" or "ReferenceProperties".
|
||||
*/
|
||||
public abstract boolean isReferenceParameter(String localName);
|
||||
|
||||
/**
|
||||
* Returns WsaTubeHelper for the WS-Addressing version identified by <code>binding</code>
|
||||
* {@link WSBinding} and for the {@link WSDLPort} port.
|
||||
*
|
||||
* @return WS-A version specific helper
|
||||
*
|
||||
* @deprecated
|
||||
* TODO why are we exposing implementation specificc class through api?
|
||||
* TODO Remove it if no one elase uses it.
|
||||
*/
|
||||
public abstract WsaTubeHelper getWsaHelper(WSDLPort wsdlPort, SEIModel seiModel, WSBinding binding);
|
||||
|
||||
/**
|
||||
* Gets the none URI value associated with this WS-Addressing version.
|
||||
*
|
||||
* @return none URI value
|
||||
* @deprecated
|
||||
* Use {@link #noneUri}.
|
||||
*/
|
||||
public final String getNoneUri() {
|
||||
return noneUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the anonymous URI value associated with this WS-Addressing version.
|
||||
*
|
||||
* @deprecated
|
||||
* Use {@link #anonymousUri}
|
||||
*/
|
||||
public final String getAnonymousUri() {
|
||||
return anonymousUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default fault Action value associated with this WS-Addressing version.
|
||||
*
|
||||
* @return default fault Action value
|
||||
*/
|
||||
public String getDefaultFaultAction() {
|
||||
return nsUri + "/fault";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the local name of the fault when a header representing a WS-Addressing Message
|
||||
* Addresing Property is absent.
|
||||
*
|
||||
* @return local name
|
||||
*/
|
||||
/* package */ abstract String getMapRequiredLocalName();
|
||||
|
||||
/**
|
||||
* Gets the description text when a required WS-Addressing header representing a
|
||||
* Message Addressing Property is absent.
|
||||
*
|
||||
* @return description text
|
||||
*/
|
||||
public abstract String getMapRequiredText();
|
||||
|
||||
/**
|
||||
* Gets the local name of the fault when a header representing anaddress is invalid.
|
||||
* @return local name
|
||||
*/
|
||||
/* package */ abstract String getInvalidAddressLocalName();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the local name of the fault when a header representing a WS-Addressing Message
|
||||
* Addresing Property is invalid and cannot be processed.
|
||||
*
|
||||
* @return local name
|
||||
*/
|
||||
/* package */ abstract String getInvalidMapLocalName();
|
||||
|
||||
/**
|
||||
* Gets the description text when a header representing a WS-Addressing
|
||||
* Message Addressing Property is invalid and cannot be processed.
|
||||
*
|
||||
* @return description text
|
||||
*/
|
||||
public abstract String getInvalidMapText();
|
||||
|
||||
/**
|
||||
* Gets the local name of the fault when a header representing a WS-Addressing Message
|
||||
* Addresing Property occurs greater than expected number.
|
||||
*
|
||||
* @return local name
|
||||
*/
|
||||
/* package */ abstract String getInvalidCardinalityLocalName();
|
||||
|
||||
/* package */ abstract String getWsdlAnonymousLocalName();
|
||||
|
||||
public abstract String getPrefix();
|
||||
|
||||
public abstract String getWsdlPrefix();
|
||||
|
||||
public abstract Class<? extends WebServiceFeature> getFeatureClass();
|
||||
/**
|
||||
* Creates an outbound {@link Header} from a reference parameter.
|
||||
*/
|
||||
/*package*/ abstract Header createReferenceParameterHeader(XMLStreamBuffer mark, String nsUri, String localName);
|
||||
|
||||
/**
|
||||
* Gets the local name for wsa:IsReferenceParameter. This method will return a valid
|
||||
* value only valid for W3C WS-Addressing. For Member Submission WS-Addressing, this method
|
||||
* returns null.
|
||||
*/
|
||||
/*package*/ abstract String getIsReferenceParameterLocalName();
|
||||
|
||||
public static AddressingVersion fromFeature(WebServiceFeature af) {
|
||||
if (af.getID().equals(AddressingFeature.ID))
|
||||
return W3C;
|
||||
else if (af.getID().equals(MemberSubmissionAddressingFeature.ID))
|
||||
return MEMBER;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link WebServiceFeature} corresponding to the namespace URI of
|
||||
* WS-Addressing policy assertion in the WSDL. <code>enabled</code> and
|
||||
* <code>required</code> are used to initialize the value of the feature.
|
||||
*
|
||||
* @param nsUri namespace URI of the WS-Addressing policy assertion in the WSDL
|
||||
* @param enabled true if feature is to be enabled, false otherwise
|
||||
* @param required true if feature is required, false otherwise. Corresponds
|
||||
* to wsdl:required on the extension/assertion.
|
||||
* @return WebServiceFeature corresponding to the assertion namespace URI
|
||||
* @throws WebServiceException if an unsupported namespace URI is passed
|
||||
*/
|
||||
public static @NotNull WebServiceFeature getFeature(String nsUri, boolean enabled, boolean required) {
|
||||
if (nsUri.equals(W3C.policyNsUri))
|
||||
return new AddressingFeature(enabled, required);
|
||||
else if (nsUri.equals(MEMBER.policyNsUri))
|
||||
return new MemberSubmissionAddressingFeature(enabled, required);
|
||||
else
|
||||
throw new WebServiceException("Unsupported namespace URI: " + nsUri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the corresponding {@link AddressingVersion} instance from the
|
||||
* EPR class.
|
||||
*/
|
||||
public static @NotNull AddressingVersion fromSpecClass(Class<? extends EndpointReference> eprClass) {
|
||||
if(eprClass==W3CEndpointReference.class)
|
||||
return W3C;
|
||||
if(eprClass==MemberSubmissionEndpointReference.class)
|
||||
return MEMBER;
|
||||
throw new WebServiceException("Unsupported EPR type: "+eprClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the WebServiceFeature is either a {@link AddressingFeature} or
|
||||
* {@link MemberSubmissionAddressingFeature} and is required.
|
||||
*
|
||||
* @param wsf The WebServiceFeature encaps
|
||||
* @throws WebServiceException if <code>wsf</code> does not contain either {@link AddressingFeature} or
|
||||
* {@link MemberSubmissionAddressingFeature}
|
||||
* @return true if <code>wsf</code> requires WS-Addressing
|
||||
*/
|
||||
public static boolean isRequired(WebServiceFeature wsf) {
|
||||
if (wsf.getID().equals(AddressingFeature.ID)) {
|
||||
return ((AddressingFeature)wsf).isRequired();
|
||||
} else if (wsf.getID().equals(MemberSubmissionAddressingFeature.ID)) {
|
||||
return ((MemberSubmissionAddressingFeature)wsf).isRequired();
|
||||
} else
|
||||
throw new WebServiceException("WebServiceFeature not an Addressing feature: "+ wsf.getID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if <code>binding</code> contains either a {@link AddressingFeature} or
|
||||
* {@link MemberSubmissionAddressingFeature} and is required.
|
||||
*
|
||||
* @param binding The binding
|
||||
* @return true if <code>binding</code> requires WS-Addressing
|
||||
*/
|
||||
public static boolean isRequired(WSBinding binding) {
|
||||
AddressingFeature af = binding.getFeature(AddressingFeature.class);
|
||||
if (af != null)
|
||||
return af.isRequired();
|
||||
MemberSubmissionAddressingFeature msaf = binding.getFeature(MemberSubmissionAddressingFeature.class);
|
||||
if(msaf != null)
|
||||
return msaf.isRequired();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if <code>binding</code> contains either a {@link AddressingFeature} or
|
||||
* {@link MemberSubmissionAddressingFeature} and is enabled.
|
||||
*
|
||||
* @param binding The binding
|
||||
* @return true if WS-Addressing is enabled for <code>binding</code>.
|
||||
*/
|
||||
public static boolean isEnabled(WSBinding binding) {
|
||||
return binding.isFeatureEnabled(MemberSubmissionAddressingFeature.class) ||
|
||||
binding.isFeatureEnabled(AddressingFeature.class);
|
||||
}
|
||||
|
||||
public final static class EPR {
|
||||
public final Class<? extends EndpointReference> eprClass;
|
||||
public final String address;
|
||||
public final String serviceName;
|
||||
public final String portName;
|
||||
public final String portTypeName;
|
||||
public final String referenceParameters;
|
||||
/**
|
||||
* Element under which metadata is specified.
|
||||
* In W3C, it is wsa:Metadata
|
||||
* In Member, it is directly under mex:MetadataSection
|
||||
*/
|
||||
public final QName wsdlMetadata;
|
||||
public final String referenceProperties;
|
||||
|
||||
public EPR(Class<? extends EndpointReference> eprClass, String address, String serviceName, String portName,
|
||||
String portTypeName, QName wsdlMetadata,
|
||||
String referenceParameters, String referenceProperties) {
|
||||
this.eprClass = eprClass;
|
||||
this.address = address;
|
||||
this.serviceName = serviceName;
|
||||
this.portName = portName;
|
||||
this.portTypeName = portTypeName;
|
||||
this.referenceParameters = referenceParameters;
|
||||
this.referenceProperties = referenceProperties;
|
||||
this.wsdlMetadata = wsdlMetadata;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* 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.api.addressing;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.Writer;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.message.AbstractHeaderImpl;
|
||||
import com.sun.xml.internal.ws.util.xml.XmlUtil;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
import javax.xml.soap.SOAPHeader;
|
||||
import javax.xml.stream.XMLOutputFactory;
|
||||
import javax.xml.stream.XMLStreamConstants;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.dom.DOMResult;
|
||||
|
||||
/**
|
||||
* Used to represent outbound endpoint reference header,
|
||||
* such as <ReplyTo> and <FaultTo>.
|
||||
* Used from {@link WSEndpointReference}.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see WSEndpointReference
|
||||
*/
|
||||
final class EPRHeader extends AbstractHeaderImpl {
|
||||
|
||||
private final String nsUri,localName;
|
||||
private final WSEndpointReference epr;
|
||||
|
||||
EPRHeader(QName tagName, WSEndpointReference epr) {
|
||||
this.nsUri = tagName.getNamespaceURI();
|
||||
this.localName = tagName.getLocalPart();
|
||||
this.epr = epr;
|
||||
}
|
||||
|
||||
public @NotNull String getNamespaceURI() {
|
||||
return nsUri;
|
||||
}
|
||||
|
||||
public @NotNull String getLocalPart() {
|
||||
return localName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getAttribute(@NotNull String nsUri, @NotNull String localName) {
|
||||
try {
|
||||
XMLStreamReader sr = epr.read("EndpointReference"/*doesn't matter*/);
|
||||
while(sr.getEventType()!= XMLStreamConstants.START_ELEMENT)
|
||||
sr.next();
|
||||
|
||||
return sr.getAttributeValue(nsUri,localName);
|
||||
} catch (XMLStreamException e) {
|
||||
// since we are reading from buffer, this can't happen.
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public XMLStreamReader readHeader() throws XMLStreamException {
|
||||
return epr.read(localName);
|
||||
}
|
||||
|
||||
public void writeTo(XMLStreamWriter w) throws XMLStreamException {
|
||||
epr.writeTo(localName, w);
|
||||
}
|
||||
|
||||
public void writeTo(SOAPMessage saaj) throws SOAPException {
|
||||
try {
|
||||
// TODO what about in-scope namespaces
|
||||
// Not very efficient consider implementing a stream buffer
|
||||
// processor that produces a DOM node from the buffer.
|
||||
Transformer t = XmlUtil.newTransformer();
|
||||
SOAPHeader header = saaj.getSOAPHeader();
|
||||
if (header == null)
|
||||
header = saaj.getSOAPPart().getEnvelope().addHeader();
|
||||
// TODO workaround for oracle xdk bug 16555545, when this bug is fixed the line below can be
|
||||
// uncommented and all lines below, except the catch block, can be removed.
|
||||
// t.transform(epr.asSource(localName), new DOMResult(header));
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
XMLStreamWriter w = XMLOutputFactory.newFactory().createXMLStreamWriter(baos);
|
||||
epr.writeTo(localName, w);
|
||||
w.flush();
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance();
|
||||
fac.setNamespaceAware(true);
|
||||
Node eprNode = fac.newDocumentBuilder().parse(bais).getDocumentElement();
|
||||
Node eprNodeToAdd = header.getOwnerDocument().importNode(eprNode, true);
|
||||
header.appendChild(eprNodeToAdd);
|
||||
} catch (Exception e) {
|
||||
throw new SOAPException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler) throws SAXException {
|
||||
epr.writeTo(localName,contentHandler,errorHandler,true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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.api.addressing;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.WSService;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.sun.xml.internal.ws.api.pipe.ClientTubeAssemblerContext;
|
||||
import com.sun.xml.internal.ws.api.pipe.Fiber;
|
||||
import com.sun.xml.internal.ws.api.pipe.TransportTubeFactory;
|
||||
import com.sun.xml.internal.ws.api.pipe.Tube;
|
||||
import com.sun.xml.internal.ws.api.server.WSEndpoint;
|
||||
import com.sun.xml.internal.ws.binding.BindingImpl;
|
||||
|
||||
/**
|
||||
* Delivers response messages targeted at non-anonymous endpoint addresses
|
||||
* @since 2.2.6
|
||||
*/
|
||||
public class NonAnonymousResponseProcessor {
|
||||
private static final NonAnonymousResponseProcessor DEFAULT = new NonAnonymousResponseProcessor();
|
||||
|
||||
public static NonAnonymousResponseProcessor getDefault() {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
protected NonAnonymousResponseProcessor() {}
|
||||
|
||||
/**
|
||||
* Send a response to a non-anonymous address. Also closes the transport back channel
|
||||
* of {@link Packet} if it's not closed already.
|
||||
*
|
||||
* @param packet
|
||||
* The response from our server, which will be delivered to the destination.
|
||||
* @return The response packet that should be used to complete the tubeline response processing
|
||||
*/
|
||||
public Packet process(Packet packet) {
|
||||
Fiber.CompletionCallback fiberCallback = null;
|
||||
Fiber currentFiber = Fiber.getCurrentIfSet();
|
||||
if (currentFiber != null) {
|
||||
// Link completion of the current fiber to the new fiber that will
|
||||
// deliver the async response. This allows access to the response
|
||||
// packet that may be generated by sending a new message for the
|
||||
// current async response.
|
||||
|
||||
final Fiber.CompletionCallback currentFiberCallback =
|
||||
currentFiber.getCompletionCallback();
|
||||
|
||||
if (currentFiberCallback != null) {
|
||||
fiberCallback = new Fiber.CompletionCallback() {
|
||||
public void onCompletion(@NotNull Packet response) {
|
||||
currentFiberCallback.onCompletion(response);
|
||||
}
|
||||
|
||||
public void onCompletion(@NotNull Throwable error) {
|
||||
currentFiberCallback.onCompletion(error);
|
||||
}
|
||||
};
|
||||
currentFiber.setCompletionCallback(null);
|
||||
}
|
||||
}
|
||||
|
||||
// we need to assemble a pipeline to talk to this endpoint.
|
||||
WSEndpoint<?> endpoint = packet.endpoint;
|
||||
WSBinding binding = endpoint.getBinding();
|
||||
Tube transport = TransportTubeFactory.create(Thread.currentThread().getContextClassLoader(),
|
||||
new ClientTubeAssemblerContext(
|
||||
packet.endpointAddress, endpoint.getPort(), (WSService) null,
|
||||
binding, endpoint.getContainer(),
|
||||
((BindingImpl) binding).createCodec(), null, null));
|
||||
Fiber fiber = endpoint.getEngine().createFiber();
|
||||
fiber.start(transport, packet, fiberCallback);
|
||||
|
||||
// then we'll proceed the rest like one-way.
|
||||
Packet copy = packet.copy(false);
|
||||
copy.endpointAddress = null;
|
||||
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,311 @@
|
||||
/*
|
||||
* 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.api.addressing;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.api.FeatureConstructor;
|
||||
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
import com.sun.org.glassfish.gmbal.ManagedAttribute;
|
||||
import com.sun.org.glassfish.gmbal.ManagedData;
|
||||
|
||||
/**
|
||||
* Unsupported RI extension to work around an issue in WSIT.
|
||||
*
|
||||
* <p>
|
||||
* <b>This feature is not meant to be used by a common Web service developer</b> as there
|
||||
* is no need to send the above mentioned header for a one-way operation. But these
|
||||
* properties may need to be sent in certain middleware Web services.
|
||||
*
|
||||
* <p>
|
||||
* This feature allows ReplyTo, From and RelatesTo Message Addressing Properties
|
||||
* to be added for all messages that are sent from the port configured with
|
||||
* this annotation. All operations are assumed to be one-way, and
|
||||
* this feature should be used for one-way
|
||||
* operations only.
|
||||
*
|
||||
* If a non-null ReplyTo is specified, then MessageID property is also added.
|
||||
*
|
||||
* @author Arun Gupta
|
||||
*/
|
||||
@ManagedData
|
||||
public class OneWayFeature extends WebServiceFeature {
|
||||
/**
|
||||
* Constant value identifying the {@link OneWayFeature}
|
||||
*/
|
||||
public static final String ID = "http://java.sun.com/xml/ns/jaxws/addressing/oneway";
|
||||
|
||||
private String messageId;
|
||||
private WSEndpointReference replyTo;
|
||||
private WSEndpointReference sslReplyTo;
|
||||
private WSEndpointReference from;
|
||||
private WSEndpointReference faultTo;
|
||||
private WSEndpointReference sslFaultTo;
|
||||
private String relatesToID;
|
||||
private boolean useAsyncWithSyncInvoke = false;
|
||||
|
||||
/**
|
||||
* Create an {@link OneWayFeature}. The instance created will be enabled.
|
||||
*/
|
||||
public OneWayFeature() {
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an {@link OneWayFeature}
|
||||
*
|
||||
* @param enabled specifies whether this feature should
|
||||
* be enabled or not.
|
||||
*/
|
||||
public OneWayFeature(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an {@link OneWayFeature}
|
||||
*
|
||||
* @param enabled specifies whether this feature should be enabled or not.
|
||||
* @param replyTo specifies the {@link WSEndpointReference} of wsa:ReplyTo header.
|
||||
*/
|
||||
public OneWayFeature(boolean enabled, WSEndpointReference replyTo) {
|
||||
this.enabled = enabled;
|
||||
this.replyTo = replyTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an {@link OneWayFeature}
|
||||
*
|
||||
* @param enabled specifies whether this feature should be enabled or not.
|
||||
* @param replyTo specifies the {@link WSEndpointReference} of wsa:ReplyTo header.
|
||||
* @param from specifies the {@link WSEndpointReference} of wsa:From header.
|
||||
* @param relatesTo specifies the MessageID to be used for wsa:RelatesTo header.
|
||||
*/
|
||||
@FeatureConstructor({"enabled","replyTo","from","relatesTo"})
|
||||
public OneWayFeature(boolean enabled, WSEndpointReference replyTo, WSEndpointReference from, String relatesTo) {
|
||||
this.enabled = enabled;
|
||||
this.replyTo = replyTo;
|
||||
this.from = from;
|
||||
this.relatesToID = relatesTo;
|
||||
}
|
||||
|
||||
public OneWayFeature(final AddressingPropertySet a, AddressingVersion v) {
|
||||
this.enabled = true;
|
||||
this.messageId = a.getMessageId();
|
||||
this.relatesToID = a.getRelatesTo();
|
||||
this.replyTo = makeEPR(a.getReplyTo(), v);
|
||||
this.faultTo = makeEPR(a.getFaultTo(), v);
|
||||
}
|
||||
|
||||
private WSEndpointReference makeEPR(final String x, final AddressingVersion v) {
|
||||
if (x == null) { return null; }
|
||||
return new WSEndpointReference(x, v);
|
||||
}
|
||||
|
||||
public String getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@ManagedAttribute
|
||||
public String getID() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
public boolean
|
||||
hasSslEprs() {
|
||||
return sslReplyTo != null || sslFaultTo != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for wsa:ReplyTo header {@link WSEndpointReference} .
|
||||
*
|
||||
* @return address of the wsa:ReplyTo header
|
||||
*/
|
||||
@ManagedAttribute
|
||||
public WSEndpointReference getReplyTo() {
|
||||
return replyTo;
|
||||
}
|
||||
|
||||
public WSEndpointReference getReplyTo(boolean ssl) {
|
||||
return (ssl && sslReplyTo != null) ? sslReplyTo : replyTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for wsa:ReplyTo header {@link WSEndpointReference}.
|
||||
*
|
||||
* @param address
|
||||
*/
|
||||
public void setReplyTo(WSEndpointReference address) {
|
||||
this.replyTo = address;
|
||||
}
|
||||
|
||||
public WSEndpointReference getSslReplyTo() {
|
||||
return sslReplyTo;
|
||||
}
|
||||
|
||||
public void setSslReplyTo(WSEndpointReference sslReplyTo) {
|
||||
this.sslReplyTo = sslReplyTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for wsa:From header {@link WSEndpointReference}.
|
||||
*
|
||||
* @return address of the wsa:From header
|
||||
*/
|
||||
@ManagedAttribute
|
||||
public WSEndpointReference getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for wsa:From header {@link WSEndpointReference}.
|
||||
*
|
||||
* @param address of the wsa:From header
|
||||
*/
|
||||
public void setFrom(WSEndpointReference address) {
|
||||
this.from = address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for MessageID for wsa:RelatesTo header.
|
||||
*
|
||||
* @return address of the wsa:FaultTo header
|
||||
*/
|
||||
@ManagedAttribute
|
||||
public String getRelatesToID() {
|
||||
return relatesToID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for MessageID for wsa:RelatesTo header.
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void setRelatesToID(String id) {
|
||||
this.relatesToID = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for wsa:FaultTo header {@link WSEndpointReference}.
|
||||
*
|
||||
* @return address of the wsa:FaultTo header
|
||||
*/
|
||||
public WSEndpointReference getFaultTo() {
|
||||
return faultTo;
|
||||
}
|
||||
|
||||
public WSEndpointReference getFaultTo(boolean ssl) {
|
||||
return (ssl && sslFaultTo != null) ? sslFaultTo : faultTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for wsa:FaultTo header {@link WSEndpointReference}.
|
||||
*
|
||||
* @param address of the wsa:FaultTo header
|
||||
*/
|
||||
public void setFaultTo(WSEndpointReference address) {
|
||||
this.faultTo = address;
|
||||
}
|
||||
|
||||
public WSEndpointReference getSslFaultTo() {
|
||||
return sslFaultTo;
|
||||
}
|
||||
|
||||
public void setSslFaultTo(WSEndpointReference sslFaultTo) {
|
||||
this.sslFaultTo = sslFaultTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for whether async is to be used with sync invoke
|
||||
*
|
||||
* @return whether async is to be used with sync invoke
|
||||
*/
|
||||
public boolean isUseAsyncWithSyncInvoke() {
|
||||
return useAsyncWithSyncInvoke;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for whether async is to be used with sync invoke
|
||||
*
|
||||
* @param useAsyncWithSyncInvoke whether async is to be used with sync invoke
|
||||
*/
|
||||
public void setUseAsyncWithSyncInvoke(boolean useAsyncWithSyncInvoke) {
|
||||
this.useAsyncWithSyncInvoke = useAsyncWithSyncInvoke;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate a new EPR using an existing one and substituting SSL specific
|
||||
* host and port values.
|
||||
* @param epr Existing EPR that will be the starting point for the SSL
|
||||
* version
|
||||
* @param sslHost New SSL host or null if the existing host should be used
|
||||
* @param sslPort New SSL port or -1 if the existing port should be used
|
||||
* @return
|
||||
*/
|
||||
public static WSEndpointReference
|
||||
enableSslForEpr(@NotNull WSEndpointReference epr,
|
||||
@Nullable String sslHost,
|
||||
int sslPort) {
|
||||
if (!epr.isAnonymous()) {
|
||||
String address = epr.getAddress();
|
||||
URL url;
|
||||
try {
|
||||
url = new URL(address);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
String protocol = url.getProtocol();
|
||||
if (!protocol.equalsIgnoreCase("https")) {
|
||||
protocol = "https";
|
||||
String host = url.getHost();
|
||||
if (sslHost != null) {
|
||||
host = sslHost;
|
||||
}
|
||||
int port = url.getPort();
|
||||
if (sslPort > 0) {
|
||||
port = sslPort;
|
||||
}
|
||||
try {
|
||||
url = new URL(protocol, host, port, url.getFile());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
address = url.toExternalForm();
|
||||
return
|
||||
new WSEndpointReference(address, epr.getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
return epr;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,397 @@
|
||||
/*
|
||||
* 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.api.addressing;
|
||||
|
||||
import com.sun.istack.internal.FinalArrayList;
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.xml.internal.stream.buffer.XMLStreamBuffer;
|
||||
import com.sun.xml.internal.stream.buffer.XMLStreamBufferException;
|
||||
import com.sun.xml.internal.ws.api.message.Header;
|
||||
import com.sun.xml.internal.ws.message.AbstractHeaderImpl;
|
||||
import com.sun.xml.internal.ws.util.xml.XMLStreamWriterFilter;
|
||||
import org.w3c.dom.Element;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
import org.xml.sax.helpers.XMLFilterImpl;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
import javax.xml.soap.SOAPHeader;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.stream.util.StreamReaderDelegate;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
|
||||
/**
|
||||
* Used to represent outbound header created from {@link WSEndpointReference}'s
|
||||
* referenec parameters.
|
||||
*
|
||||
* <p>
|
||||
* This is optimized for outbound use, so it implements some of the methods lazily,
|
||||
* in a slow way.
|
||||
*
|
||||
* <p>
|
||||
* This header adds "wsa:IsReferenceParameter" and thus only used for the W3C version.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
final class OutboundReferenceParameterHeader extends AbstractHeaderImpl {
|
||||
private final XMLStreamBuffer infoset;
|
||||
private final String nsUri,localName;
|
||||
|
||||
/**
|
||||
* The attributes on the header element.
|
||||
* Lazily parsed.
|
||||
* Null if not parsed yet.
|
||||
*/
|
||||
private FinalArrayList<Attribute> attributes;
|
||||
|
||||
OutboundReferenceParameterHeader(XMLStreamBuffer infoset, String nsUri, String localName) {
|
||||
this.infoset = infoset;
|
||||
this.nsUri = nsUri;
|
||||
this.localName = localName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getNamespaceURI() {
|
||||
return nsUri;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getLocalPart() {
|
||||
return localName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttribute(String nsUri, String localName) {
|
||||
if(attributes==null) {
|
||||
parseAttributes();
|
||||
}
|
||||
for(int i=attributes.size()-1; i>=0; i-- ) {
|
||||
Attribute a = attributes.get(i);
|
||||
if (a.localName.equals(localName) && a.nsUri.equals(nsUri)) {
|
||||
return a.value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* We don't really expect this to be used, but just to satisfy
|
||||
* the {@link Header} contract.
|
||||
*
|
||||
* So this is rather slow.
|
||||
*/
|
||||
private void parseAttributes() {
|
||||
try {
|
||||
XMLStreamReader reader = readHeader();
|
||||
reader.nextTag(); // move to the first element, which is the header element
|
||||
|
||||
attributes = new FinalArrayList<Attribute>();
|
||||
boolean refParamAttrWritten = false;
|
||||
for (int i = 0; i < reader.getAttributeCount(); i++) {
|
||||
final String attrLocalName = reader.getAttributeLocalName(i);
|
||||
final String namespaceURI = reader.getAttributeNamespace(i);
|
||||
final String value = reader.getAttributeValue(i);
|
||||
if (namespaceURI.equals(AddressingVersion.W3C.nsUri)&& attrLocalName.equals("IS_REFERENCE_PARAMETER")) {
|
||||
refParamAttrWritten = true;
|
||||
}
|
||||
attributes.add(new Attribute(namespaceURI,attrLocalName,value));
|
||||
}
|
||||
// we are adding one more attribute "wsa:IsReferenceParameter", if its not alrady there
|
||||
if (!refParamAttrWritten) {
|
||||
attributes.add(new Attribute(AddressingVersion.W3C.nsUri,IS_REFERENCE_PARAMETER,TRUE_VALUE));
|
||||
}
|
||||
} catch (XMLStreamException e) {
|
||||
throw new WebServiceException("Unable to read the attributes for {"+nsUri+"}"+localName+" header",e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLStreamReader readHeader() throws XMLStreamException {
|
||||
return new StreamReaderDelegate(infoset.readAsXMLStreamReader()) {
|
||||
int state=0; /* 0:expecting root, 1:in root, 2:past root */
|
||||
@Override
|
||||
public int next() throws XMLStreamException {
|
||||
return check(super.next());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextTag() throws XMLStreamException {
|
||||
return check(super.nextTag());
|
||||
}
|
||||
|
||||
private int check(int type) {
|
||||
switch (state) {
|
||||
case 0:
|
||||
if (type == START_ELEMENT) {
|
||||
state = 1;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
state = 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAttributeCount() {
|
||||
if (state == 1) {
|
||||
return super.getAttributeCount()+1;
|
||||
} else {
|
||||
return super.getAttributeCount();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttributeLocalName(int index) {
|
||||
if (state == 1 && index == super.getAttributeCount()) {
|
||||
return IS_REFERENCE_PARAMETER;
|
||||
} else {
|
||||
return super.getAttributeLocalName(index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttributeNamespace(int index) {
|
||||
if (state == 1 && index==super.getAttributeCount()) {
|
||||
return AddressingVersion.W3C.nsUri;
|
||||
}
|
||||
else {
|
||||
return super.getAttributeNamespace(index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttributePrefix(int index) {
|
||||
if(state==1 && index==super.getAttributeCount()) {
|
||||
return "wsa";
|
||||
} else {
|
||||
return super.getAttributePrefix(index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttributeType(int index) {
|
||||
if(state==1 && index==super.getAttributeCount()) {
|
||||
return "CDATA";
|
||||
} else {
|
||||
return super.getAttributeType(index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttributeValue(int index) {
|
||||
if(state==1 && index==super.getAttributeCount()) {
|
||||
return TRUE_VALUE;
|
||||
} else {
|
||||
return super.getAttributeValue(index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public QName getAttributeName(int index) {
|
||||
if(state==1 && index==super.getAttributeCount()) {
|
||||
return new QName(AddressingVersion.W3C.nsUri, IS_REFERENCE_PARAMETER, "wsa");
|
||||
} else {
|
||||
return super.getAttributeName(index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttributeValue(String namespaceUri, String localName) {
|
||||
if(state==1 && localName.equals(IS_REFERENCE_PARAMETER) && namespaceUri.equals(AddressingVersion.W3C.nsUri)) {
|
||||
return TRUE_VALUE;
|
||||
} else {
|
||||
return super.getAttributeValue(namespaceUri, localName);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(XMLStreamWriter w) throws XMLStreamException {
|
||||
infoset.writeToXMLStreamWriter(new XMLStreamWriterFilter(w) {
|
||||
private boolean root=true;
|
||||
private boolean onRootEl = true;
|
||||
@Override
|
||||
public void writeStartElement(String localName) throws XMLStreamException {
|
||||
super.writeStartElement(localName);
|
||||
writeAddedAttribute();
|
||||
}
|
||||
|
||||
private void writeAddedAttribute() throws XMLStreamException {
|
||||
if(!root) {
|
||||
onRootEl = false;
|
||||
return;
|
||||
}
|
||||
root=false;
|
||||
writeNamespace("wsa",AddressingVersion.W3C.nsUri);
|
||||
super.writeAttribute("wsa",AddressingVersion.W3C.nsUri,IS_REFERENCE_PARAMETER,TRUE_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException {
|
||||
super.writeStartElement(namespaceURI, localName);
|
||||
writeAddedAttribute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeStartElement(String prefix, String localName, String namespaceURI) throws XMLStreamException {
|
||||
//TODO: Verify with KK later
|
||||
//check if prefix is declared before writing start element.
|
||||
boolean prefixDeclared = isPrefixDeclared(prefix,namespaceURI);
|
||||
super.writeStartElement(prefix, localName, namespaceURI);
|
||||
if (!prefixDeclared && !prefix.equals("")) {
|
||||
super.writeNamespace(prefix,namespaceURI);
|
||||
}
|
||||
writeAddedAttribute();
|
||||
}
|
||||
@Override
|
||||
public void writeNamespace(String prefix, String namespaceURI) throws XMLStreamException{
|
||||
if (!isPrefixDeclared(prefix, namespaceURI)) {
|
||||
super.writeNamespace(prefix,namespaceURI);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeAttribute(String prefix, String namespaceURI, String localName, String value) throws XMLStreamException {
|
||||
//skip if its on root element and attribute is wsa;IsReferenceParameter, as we write it.
|
||||
if(onRootEl && namespaceURI.equals(AddressingVersion.W3C.nsUri)
|
||||
&& localName.equals(IS_REFERENCE_PARAMETER)) {
|
||||
return;
|
||||
}
|
||||
writer.writeAttribute(prefix, namespaceURI, localName, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeAttribute(String namespaceURI, String localName, String value) throws XMLStreamException {
|
||||
writer.writeAttribute(namespaceURI, localName, value);
|
||||
}
|
||||
private boolean isPrefixDeclared(String prefix, String namespaceURI ) {
|
||||
return namespaceURI.equals(getNamespaceContext().getNamespaceURI(prefix));
|
||||
}
|
||||
},true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(SOAPMessage saaj) throws SOAPException {
|
||||
//TODO: SAAJ returns null instead of throwing SOAPException,
|
||||
// when there is no SOAPHeader in the message,
|
||||
// which leads to NPE.
|
||||
try {
|
||||
SOAPHeader header = saaj.getSOAPHeader();
|
||||
if (header == null) {
|
||||
header = saaj.getSOAPPart().getEnvelope().addHeader();
|
||||
}
|
||||
Element node = (Element)infoset.writeTo(header);
|
||||
node.setAttributeNS(AddressingVersion.W3C.nsUri,AddressingVersion.W3C.getPrefix()+":"+IS_REFERENCE_PARAMETER,TRUE_VALUE);
|
||||
} catch (XMLStreamBufferException e) {
|
||||
throw new SOAPException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler) throws SAXException {
|
||||
class Filter extends XMLFilterImpl {
|
||||
Filter(ContentHandler ch) { setContentHandler(ch); }
|
||||
private int depth=0;
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
|
||||
if(depth++==0) {
|
||||
// add one more attribute
|
||||
super.startPrefixMapping("wsa",AddressingVersion.W3C.nsUri);
|
||||
|
||||
//Add the attirbute wsa:IsReferenceParameter if not present already
|
||||
if(atts.getIndex(AddressingVersion.W3C.nsUri,IS_REFERENCE_PARAMETER) == -1) {
|
||||
AttributesImpl atts2 = new AttributesImpl(atts);
|
||||
atts2.addAttribute(
|
||||
AddressingVersion.W3C.nsUri,
|
||||
IS_REFERENCE_PARAMETER,
|
||||
"wsa:IsReferenceParameter",
|
||||
"CDATA",
|
||||
TRUE_VALUE);
|
||||
atts = atts2;
|
||||
}
|
||||
}
|
||||
|
||||
super.startElement(uri, localName, qName, atts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(String uri, String localName, String qName) throws SAXException {
|
||||
super.endElement(uri, localName, qName);
|
||||
if (--depth == 0) {
|
||||
super.endPrefixMapping("wsa");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
infoset.writeTo(new Filter(contentHandler),errorHandler);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Keep the information about an attribute on the header element.
|
||||
*/
|
||||
static final class Attribute {
|
||||
/**
|
||||
* Can be empty but never null.
|
||||
*/
|
||||
final String nsUri;
|
||||
final String localName;
|
||||
final String value;
|
||||
|
||||
public Attribute(String nsUri, String localName, String value) {
|
||||
this.nsUri = fixNull(nsUri);
|
||||
this.localName = localName;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert null to "".
|
||||
*/
|
||||
private static String fixNull(String s) {
|
||||
return s == null ? "" : s;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We the performance paranoid people in the JAX-WS RI thinks
|
||||
* saving three bytes is worth while...
|
||||
*/
|
||||
private static final String TRUE_VALUE = "1";
|
||||
private static final String IS_REFERENCE_PARAMETER = "IsReferenceParameter";
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@javax.xml.bind.annotation.XmlSchema(namespace="http://schemas.xmlsoap.org/ws/2004/08/addressing",
|
||||
location = "http://schemas.xmlsoap.org/ws/2004/08/addressing")
|
||||
package com.sun.xml.internal.ws.api.addressing;
|
||||
@@ -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.api.client;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.xml.internal.ws.api.pipe.Pipe;
|
||||
import com.sun.xml.internal.ws.api.pipe.ClientPipeAssemblerContext;
|
||||
|
||||
/**
|
||||
* Allow the container (primarily Glassfish) to inject
|
||||
* their own pipes into the client pipeline.
|
||||
*
|
||||
* <p>
|
||||
* This interface has a rather ad-hoc set of methods, because
|
||||
* we didn't want to define an autonomous pipe-assembly process.
|
||||
* (We thought this is a smaller evil compared to that.)
|
||||
*
|
||||
* <p>
|
||||
* JAX-WS obtains this through {@link com.sun.xml.internal.ws.api.server.Container#getSPI(Class)}.
|
||||
*
|
||||
* @author Jitendra Kotamraju
|
||||
*/
|
||||
public abstract class ClientPipelineHook {
|
||||
|
||||
/**
|
||||
* Called during the pipeline construction process once to allow a container
|
||||
* to register a pipe for security.
|
||||
*
|
||||
* This pipe will be injected to a point very close to the transport, allowing
|
||||
* it to do some security operations.
|
||||
*
|
||||
* @param ctxt
|
||||
* Represents abstraction of SEI, WSDL abstraction etc. Context can be used
|
||||
* whether add a new pipe to the head or not.
|
||||
*
|
||||
* @param tail
|
||||
* Head of the partially constructed pipeline. If the implementation
|
||||
* wishes to add new pipes, it should do so by extending
|
||||
* {@link com.sun.xml.internal.ws.api.pipe.helper.AbstractFilterPipeImpl} and making sure that this {@link com.sun.xml.internal.ws.api.pipe.Pipe}
|
||||
* eventually processes messages.
|
||||
*
|
||||
* @return
|
||||
* The default implementation just returns <tt>tail</tt>, which means
|
||||
* no additional pipe is inserted. If the implementation adds
|
||||
* new pipes, return the new head pipe.
|
||||
*/
|
||||
public @NotNull Pipe createSecurityPipe(ClientPipeAssemblerContext ctxt, @NotNull Pipe tail) {
|
||||
return tail;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* 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.api.client;
|
||||
|
||||
import com.sun.xml.internal.ws.api.FeatureConstructor;
|
||||
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
import com.sun.org.glassfish.gmbal.ManagedAttribute;
|
||||
import com.sun.org.glassfish.gmbal.ManagedData;
|
||||
|
||||
/**
|
||||
* Client side feature to enable or disable the selection of the optimal
|
||||
* encoding by the client when sending outbound messages.
|
||||
* <p>
|
||||
* The following describes the affects of this feature with respect
|
||||
* to being enabled or disabled:
|
||||
* <ul>
|
||||
* <li> ENABLED: In this Mode, the most optimal encoding will be selected
|
||||
* depending on the configuration and capabilities of the client
|
||||
* the capabilities of the Web service.
|
||||
* <li> DISABLED: In this Mode, the default encoding will be selected.
|
||||
* </ul>
|
||||
* <p>
|
||||
* If this feature is not present on a Web service then the default behaviour
|
||||
* is equivalent to this feature being present and disabled.
|
||||
* <p>
|
||||
* If this feature is enabled by the client and the Service supports the
|
||||
* Fast Infoset encoding, as specified by the {@link com.sun.xml.internal.ws.api.fastinfoset.FastInfosetFeature},
|
||||
* and Fast Infoset is determined to be the most optimal encoding, then the
|
||||
* Fast Infoset encoding will be automatically selected by the client.
|
||||
* <p>
|
||||
* TODO: Still not sure if a feature is a server side only thing or can
|
||||
* also be a client side thing. If the former then this class should be
|
||||
* removed.
|
||||
* @author Paul.Sandoz@Sun.Com
|
||||
*/
|
||||
@ManagedData
|
||||
public class SelectOptimalEncodingFeature extends WebServiceFeature {
|
||||
/**
|
||||
* Constant value identifying the {@link SelectOptimalEncodingFeature}
|
||||
*/
|
||||
public static final String ID = "http://java.sun.com/xml/ns/jaxws/client/selectOptimalEncoding";
|
||||
|
||||
/**
|
||||
* Create a {@link SelectOptimalEncodingFeature}.
|
||||
* The instance created will be enabled.
|
||||
*/
|
||||
public SelectOptimalEncodingFeature() {
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link SelectOptimalEncodingFeature}
|
||||
*
|
||||
* @param enabled specifies whether this feature should
|
||||
* be enabled or not.
|
||||
*/
|
||||
@FeatureConstructor({"enabled"})
|
||||
public SelectOptimalEncodingFeature(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@ManagedAttribute
|
||||
public String getID() {
|
||||
return ID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* 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.api.client;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.api.BindingID;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.WSFeatureList;
|
||||
import com.sun.xml.internal.ws.api.WSService;
|
||||
import com.sun.xml.internal.ws.developer.WSBindingProvider;
|
||||
|
||||
import javax.xml.ws.BindingProvider;
|
||||
import javax.xml.ws.Dispatch;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Interception point for inner working of {@link WSService}.
|
||||
*
|
||||
* <p>
|
||||
* System-level code could hook an implementation of this to
|
||||
* {@link WSService} to augument its behavior.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @since 2.1 EA3
|
||||
* @see ServiceInterceptorFactory
|
||||
*/
|
||||
public abstract class ServiceInterceptor {
|
||||
/**
|
||||
* Called before {@link WSBinding} is created, to allow interceptors
|
||||
* to add {@link WebServiceFeature}s to the created {@link WSBinding}.
|
||||
*
|
||||
* @param port
|
||||
* Information about the port for which dispatch/proxy will be created.
|
||||
* @param serviceEndpointInterface
|
||||
* Null if the created binding is for {@link Dispatch}. Otheriwse
|
||||
* it represents the port interface of the proxy to be created.
|
||||
* @param defaultFeatures
|
||||
* The list of features that are currently scheduled to be set for
|
||||
* the newly created {@link WSBinding}.
|
||||
*
|
||||
* @return
|
||||
* A set of features to be added to the newly created {@link WSBinding}.
|
||||
* Can be empty but never null.
|
||||
* <tt>defaultFeatures</tt> will take precedence over what this method
|
||||
* would return (because it includes user-specified ones which will
|
||||
* take the at-most priority), but features you return from this method
|
||||
* will take precedence over {@link BindingID}'s
|
||||
* {@link BindingID#createBuiltinFeatureList() implicit features}.
|
||||
*/
|
||||
public List<WebServiceFeature> preCreateBinding(@NotNull WSPortInfo port, @Nullable Class<?> serviceEndpointInterface, @NotNull WSFeatureList defaultFeatures) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* A callback to notify the event of creation of proxy object for SEI endpoint. The
|
||||
* callback could set some properties on the {@link BindingProvider}.
|
||||
*
|
||||
* @param bp created proxy instance
|
||||
* @param serviceEndpointInterface SEI of the endpoint
|
||||
*/
|
||||
public void postCreateProxy(@NotNull WSBindingProvider bp,@NotNull Class<?> serviceEndpointInterface) {
|
||||
}
|
||||
|
||||
/**
|
||||
* A callback to notify that a {@link Dispatch} object is created. The callback
|
||||
* could set some properties on the {@link BindingProvider}.
|
||||
*
|
||||
* @param bp BindingProvider of dispatch object
|
||||
*/
|
||||
public void postCreateDispatch(@NotNull WSBindingProvider bp) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggregates multiple interceptors into one facade.
|
||||
*/
|
||||
public static ServiceInterceptor aggregate(final ServiceInterceptor... interceptors) {
|
||||
if(interceptors.length==1)
|
||||
return interceptors[0];
|
||||
return new ServiceInterceptor() {
|
||||
public List<WebServiceFeature> preCreateBinding(@NotNull WSPortInfo port, @Nullable Class<?> portInterface, @NotNull WSFeatureList defaultFeatures) {
|
||||
List<WebServiceFeature> r = new ArrayList<WebServiceFeature>();
|
||||
for (ServiceInterceptor si : interceptors)
|
||||
r.addAll(si.preCreateBinding(port,portInterface,defaultFeatures));
|
||||
return r;
|
||||
}
|
||||
|
||||
public void postCreateProxy(@NotNull WSBindingProvider bp, @NotNull Class<?> serviceEndpointInterface) {
|
||||
for (ServiceInterceptor si : interceptors)
|
||||
si.postCreateProxy(bp,serviceEndpointInterface);
|
||||
}
|
||||
|
||||
public void postCreateDispatch(@NotNull WSBindingProvider bp) {
|
||||
for (ServiceInterceptor si : interceptors)
|
||||
si.postCreateDispatch(bp);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* 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.api.client;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.api.WSService;
|
||||
import com.sun.xml.internal.ws.util.ServiceFinder;
|
||||
|
||||
import javax.xml.ws.Service;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Creates {@link ServiceInterceptor}.
|
||||
*
|
||||
* <p>
|
||||
* Code that wishes to inject {@link ServiceInterceptor} into {@link WSService}
|
||||
* must implement this class. There are two ways to have the JAX-WS RI
|
||||
* recognize your {@link ServiceInterceptor}s.
|
||||
*
|
||||
* <h3>Use {@link ServiceFinder}</h3>
|
||||
* <p>
|
||||
* {@link ServiceInterceptorFactory}s discovered via {@link ServiceFinder}
|
||||
* will be incorporated to all {@link WSService} instances.
|
||||
*
|
||||
* <h3>Register per-thread</h3>
|
||||
*
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see ServiceInterceptor
|
||||
* @see 2.1 EA3
|
||||
*/
|
||||
public abstract class ServiceInterceptorFactory {
|
||||
public abstract ServiceInterceptor create(@NotNull WSService service);
|
||||
|
||||
/**
|
||||
* Loads all {@link ServiceInterceptor}s and return aggregated one.
|
||||
*/
|
||||
public static @NotNull ServiceInterceptor load(@NotNull WSService service, @Nullable ClassLoader cl) {
|
||||
List<ServiceInterceptor> l = new ArrayList<ServiceInterceptor>();
|
||||
|
||||
// first service look-up
|
||||
for( ServiceInterceptorFactory f : ServiceFinder.find(ServiceInterceptorFactory.class))
|
||||
l.add(f.create(service));
|
||||
|
||||
// then thread-local
|
||||
for( ServiceInterceptorFactory f : threadLocalFactories.get())
|
||||
l.add(f.create(service));
|
||||
|
||||
return ServiceInterceptor.aggregate(l.toArray(new ServiceInterceptor[l.size()]));
|
||||
}
|
||||
|
||||
private static ThreadLocal<Set<ServiceInterceptorFactory>> threadLocalFactories = new ThreadLocal<Set<ServiceInterceptorFactory>>() {
|
||||
protected Set<ServiceInterceptorFactory> initialValue() {
|
||||
return new HashSet<ServiceInterceptorFactory>();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Registers {@link ServiceInterceptorFactory} for this thread.
|
||||
*
|
||||
* <p>
|
||||
* Once registered, {@link ServiceInterceptorFactory}s are consulted for every
|
||||
* {@link Service} created in this thread, until it gets unregistered.
|
||||
*/
|
||||
public static boolean registerForThread(ServiceInterceptorFactory factory) {
|
||||
return threadLocalFactories.get().add(factory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes previously registered {@link ServiceInterceptorFactory} for this thread.
|
||||
*/
|
||||
public static boolean unregisterForThread(ServiceInterceptorFactory factory) {
|
||||
return threadLocalFactories.get().remove(factory);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.api.client;
|
||||
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import javax.xml.ws.Dispatch;
|
||||
|
||||
import com.sun.xml.internal.ws.api.pipe.ThrowableContainerPropertySet;
|
||||
|
||||
/**
|
||||
* When using {@link Dispatch}<{@link Packet}> and the invocation completes with a Throwable, it is
|
||||
* useful to be able to inspect the Packet in addition to the Throwable as the Packet contains
|
||||
* meta-data about the request and/or response. However, the default behavior is that the caller
|
||||
* only receives the Throwable.
|
||||
*
|
||||
* When an instance of this feature is enabled on the binding, any Throwable generated will be available
|
||||
* on the Packet on the satellite {@link ThrowableContainerPropertySet}.
|
||||
*
|
||||
* @see ThrowableContainerPropertySet
|
||||
*/
|
||||
public class ThrowableInPacketCompletionFeature extends WebServiceFeature {
|
||||
|
||||
public ThrowableInPacketCompletionFeature() {
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return ThrowableInPacketCompletionFeature.class.getName();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* 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.api.client;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.api.BindingID;
|
||||
import com.sun.xml.internal.ws.api.EndpointAddress;
|
||||
import com.sun.xml.internal.ws.api.WSService;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.policy.PolicyMap;
|
||||
|
||||
import javax.xml.ws.handler.PortInfo;
|
||||
|
||||
/**
|
||||
* JAX-WS RI's extension to {@link PortInfo}.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public interface WSPortInfo extends PortInfo {
|
||||
/**
|
||||
* Returns {@link WSService} object that owns this port.
|
||||
*/
|
||||
@NotNull WSService getOwner();
|
||||
|
||||
/**
|
||||
* Returns the same information as {@link #getBindingID()}
|
||||
* but in a strongly-typed fashion
|
||||
*/
|
||||
@NotNull BindingID getBindingId();
|
||||
|
||||
/**
|
||||
* Gets the endpoint address of this port.
|
||||
*/
|
||||
@NotNull EndpointAddress getEndpointAddress();
|
||||
|
||||
/**
|
||||
* Gets the {@link WSDLPort} object that represents this port,
|
||||
* if {@link WSService} is configured with WSDL. Otherwise null.
|
||||
*/
|
||||
@Nullable WSDLPort getPort();
|
||||
|
||||
/**
|
||||
* Gives the PolicMap that captures the Policy for the PortInfo
|
||||
*
|
||||
* @return PolicyMap
|
||||
*
|
||||
* @deprecated
|
||||
* Do not use this method as the PolicyMap API is not final yet and might change in next few months.
|
||||
*/
|
||||
|
||||
public PolicyMap getPolicyMap();
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* 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.api.config.management;
|
||||
|
||||
import com.sun.xml.internal.ws.api.server.Invoker;
|
||||
|
||||
import org.xml.sax.EntityResolver;
|
||||
|
||||
/**
|
||||
* Store the parameters that were passed into the original WSEndpoint instance
|
||||
* upon creation. This allows us to instantiate a new instance with the same
|
||||
* parameters.
|
||||
*
|
||||
* @author Fabian Ritzmann
|
||||
*/
|
||||
public class EndpointCreationAttributes {
|
||||
|
||||
private final boolean processHandlerAnnotation;
|
||||
private final Invoker invoker;
|
||||
private final EntityResolver entityResolver;
|
||||
private final boolean isTransportSynchronous;
|
||||
|
||||
/**
|
||||
* Instantiate this data access object.
|
||||
*
|
||||
* @param processHandlerAnnotation The original processHandlerAnnotation setting.
|
||||
* @param invoker The original Invoker instance.
|
||||
* @param resolver The original EntityResolver instance.
|
||||
* @param isTransportSynchronous The original isTransportSynchronous setting.
|
||||
*/
|
||||
public EndpointCreationAttributes(final boolean processHandlerAnnotation,
|
||||
final Invoker invoker,
|
||||
final EntityResolver resolver,
|
||||
final boolean isTransportSynchronous) {
|
||||
this.processHandlerAnnotation = processHandlerAnnotation;
|
||||
this.invoker = invoker;
|
||||
this.entityResolver = resolver;
|
||||
this.isTransportSynchronous = isTransportSynchronous;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original processHandlerAnnotation setting.
|
||||
*
|
||||
* @return The original processHandlerAnnotation setting.
|
||||
*/
|
||||
public boolean isProcessHandlerAnnotation() {
|
||||
return this.processHandlerAnnotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original Invoker instance.
|
||||
*
|
||||
* @return The original Invoker instance.
|
||||
*/
|
||||
public Invoker getInvoker() {
|
||||
return this.invoker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original EntityResolver instance.
|
||||
*
|
||||
* @return The original EntityResolver instance.
|
||||
*/
|
||||
public EntityResolver getEntityResolver() {
|
||||
return this.entityResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original isTransportSynchronous setting.
|
||||
*
|
||||
* @return The original isTransportSynchronous setting.
|
||||
*/
|
||||
public boolean isTransportSynchronous() {
|
||||
return this.isTransportSynchronous;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.api.config.management;
|
||||
|
||||
import com.sun.xml.internal.ws.api.server.WSEndpoint;
|
||||
|
||||
/**
|
||||
* Interface to create a new WSEndpoint wrapper. This is intended to be implemented
|
||||
* by the configuration management to return a ManagedEndpoint that wraps the
|
||||
* original WSEndpoint instance.
|
||||
*
|
||||
* @author Fabian Ritzmann
|
||||
*/
|
||||
public interface ManagedEndpointFactory {
|
||||
|
||||
/**
|
||||
* This method may return a WSEndpoint implementation that wraps the original
|
||||
* WSEndpoint instance. This allows to interject e.g. management code. If
|
||||
* management has not been enabled for this endpoint, it will return the original
|
||||
* WSEndpoint instance.
|
||||
*
|
||||
* @param <T> The endpoint implementation type.
|
||||
* @param endpoint The endpoint instance.
|
||||
* @param attributes The parameters with which the original endpoint instance
|
||||
* was created.
|
||||
* @return A WSEndpoint that wraps the original WSEndpoint instance or the
|
||||
* original WSEndpoint instance.
|
||||
*/
|
||||
public <T> WSEndpoint<T> createEndpoint(WSEndpoint<T> endpoint, EndpointCreationAttributes attributes);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.api.config.management;
|
||||
|
||||
import javax.xml.ws.WebServiceException;
|
||||
|
||||
/**
|
||||
* Allows to trigger a reconfiguration action on an object.
|
||||
*
|
||||
* @author Fabian Ritzmann
|
||||
*/
|
||||
public interface Reconfigurable {
|
||||
|
||||
/**
|
||||
* Executes any action when an endpoint is reconfigured.
|
||||
*
|
||||
* @throws WebServiceException Thrown if the reconfiguration failed.
|
||||
*/
|
||||
void reconfigure() throws WebServiceException;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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.api.config.management.policy;
|
||||
|
||||
import com.sun.istack.internal.logging.Logger;
|
||||
import com.sun.xml.internal.ws.api.client.WSPortInfo;
|
||||
import com.sun.xml.internal.ws.policy.PolicyAssertion;
|
||||
import com.sun.xml.internal.ws.policy.PolicyMap;
|
||||
import com.sun.xml.internal.ws.policy.PolicyConstants;
|
||||
import com.sun.xml.internal.ws.policy.sourcemodel.AssertionData;
|
||||
import com.sun.xml.internal.ws.policy.spi.AssertionCreationException;
|
||||
import com.sun.xml.internal.ws.resources.ManagementMessages;
|
||||
|
||||
import java.util.Collection;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
|
||||
/**
|
||||
* The client-side ManagedClient policy assertion.
|
||||
*
|
||||
* @author Fabian Ritzmann
|
||||
*/
|
||||
public class ManagedClientAssertion extends ManagementAssertion {
|
||||
|
||||
public static final QName MANAGED_CLIENT_QNAME =
|
||||
new QName(PolicyConstants.SUN_MANAGEMENT_NAMESPACE, "ManagedClient");
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(ManagedClientAssertion.class);
|
||||
|
||||
/**
|
||||
* Return ManagedClient assertion if there is one associated with the client.
|
||||
*
|
||||
* @param portInfo The client PortInfo.
|
||||
* @return The policy assertion if found. Null otherwise.
|
||||
* @throws WebServiceException If computing the effective policy of the port failed.
|
||||
*/
|
||||
public static ManagedClientAssertion getAssertion(WSPortInfo portInfo) throws WebServiceException {
|
||||
if (portInfo == null)
|
||||
return null;
|
||||
|
||||
LOGGER.entering(portInfo);
|
||||
// getPolicyMap is deprecated because it is only supposed to be used by Metro code
|
||||
// and not by other clients.
|
||||
@SuppressWarnings("deprecation")
|
||||
final PolicyMap policyMap = portInfo.getPolicyMap();
|
||||
final ManagedClientAssertion assertion = ManagementAssertion.getAssertion(MANAGED_CLIENT_QNAME,
|
||||
policyMap, portInfo.getServiceName(), portInfo.getPortName(), ManagedClientAssertion.class);
|
||||
LOGGER.exiting(assertion);
|
||||
return assertion;
|
||||
}
|
||||
|
||||
public ManagedClientAssertion(AssertionData data, Collection<PolicyAssertion> assertionParameters)
|
||||
throws AssertionCreationException {
|
||||
super(MANAGED_CLIENT_QNAME, data, assertionParameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clients cannot be managed.
|
||||
*
|
||||
* @return False.
|
||||
*/
|
||||
public boolean isManagementEnabled() {
|
||||
final String management = this.getAttributeValue(MANAGEMENT_ATTRIBUTE_QNAME);
|
||||
if (management != null) {
|
||||
if (management.trim().toLowerCase().equals("on") || Boolean.parseBoolean(management)) {
|
||||
LOGGER.warning(ManagementMessages.WSM_1006_CLIENT_MANAGEMENT_ENABLED());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,391 @@
|
||||
/*
|
||||
* 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.api.config.management.policy;
|
||||
|
||||
import com.sun.istack.internal.logging.Logger;
|
||||
import com.sun.xml.internal.ws.api.server.WSEndpoint;
|
||||
import com.sun.xml.internal.ws.policy.PolicyAssertion;
|
||||
import com.sun.xml.internal.ws.policy.PolicyMap;
|
||||
import com.sun.xml.internal.ws.policy.PolicyConstants;
|
||||
import com.sun.xml.internal.ws.policy.sourcemodel.AssertionData;
|
||||
import com.sun.xml.internal.ws.policy.spi.AssertionCreationException;
|
||||
import com.sun.xml.internal.ws.resources.ManagementMessages;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
|
||||
/**
|
||||
* The server-side ManagedService policy assertion.
|
||||
*
|
||||
* @author Fabian Ritzmann
|
||||
*/
|
||||
public class ManagedServiceAssertion extends ManagementAssertion {
|
||||
|
||||
public static final QName MANAGED_SERVICE_QNAME =
|
||||
new QName(PolicyConstants.SUN_MANAGEMENT_NAMESPACE, "ManagedService");
|
||||
|
||||
private static final QName COMMUNICATION_SERVER_IMPLEMENTATIONS_PARAMETER_QNAME = new QName(
|
||||
PolicyConstants.SUN_MANAGEMENT_NAMESPACE, "CommunicationServerImplementations");
|
||||
private static final QName COMMUNICATION_SERVER_IMPLEMENTATION_PARAMETER_QNAME = new QName(
|
||||
PolicyConstants.SUN_MANAGEMENT_NAMESPACE, "CommunicationServerImplementation");
|
||||
private static final QName CONFIGURATOR_IMPLEMENTATION_PARAMETER_QNAME = new QName(
|
||||
PolicyConstants.SUN_MANAGEMENT_NAMESPACE, "ConfiguratorImplementation");
|
||||
private static final QName CONFIG_SAVER_IMPLEMENTATION_PARAMETER_QNAME = new QName(
|
||||
PolicyConstants.SUN_MANAGEMENT_NAMESPACE, "ConfigSaverImplementation");
|
||||
private static final QName CONFIG_READER_IMPLEMENTATION_PARAMETER_QNAME = new QName(
|
||||
PolicyConstants.SUN_MANAGEMENT_NAMESPACE, "ConfigReaderImplementation");
|
||||
private static final QName CLASS_NAME_ATTRIBUTE_QNAME = new QName("className");
|
||||
/**
|
||||
* The name of the endpointDisposeDelay attribute.
|
||||
*/
|
||||
private static final QName ENDPOINT_DISPOSE_DELAY_ATTRIBUTE_QNAME = new QName("endpointDisposeDelay");
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(ManagedServiceAssertion.class);
|
||||
|
||||
/**
|
||||
* Return ManagedService assertion if there is one associated with the endpoint.
|
||||
*
|
||||
* @param endpoint The endpoint. Must not be null.
|
||||
* @return The policy assertion if found. Null otherwise.
|
||||
* @throws WebServiceException If computing the effective policy of the endpoint failed.
|
||||
*/
|
||||
public static ManagedServiceAssertion getAssertion(WSEndpoint endpoint) throws WebServiceException {
|
||||
LOGGER.entering(endpoint);
|
||||
// getPolicyMap is deprecated because it is only supposed to be used by Metro code
|
||||
// and not by other clients.
|
||||
@SuppressWarnings("deprecation")
|
||||
final PolicyMap policyMap = endpoint.getPolicyMap();
|
||||
final ManagedServiceAssertion assertion = ManagementAssertion.getAssertion(MANAGED_SERVICE_QNAME,
|
||||
policyMap, endpoint.getServiceName(), endpoint.getPortName(), ManagedServiceAssertion.class);
|
||||
LOGGER.exiting(assertion);
|
||||
return assertion;
|
||||
}
|
||||
|
||||
public ManagedServiceAssertion(AssertionData data, Collection<PolicyAssertion> assertionParameters)
|
||||
throws AssertionCreationException {
|
||||
super(MANAGED_SERVICE_QNAME, data, assertionParameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the management attribute. True if unset or set to "true"
|
||||
* or "on". False otherwise.
|
||||
*
|
||||
* @return The value of the management attribute.
|
||||
*/
|
||||
public boolean isManagementEnabled() {
|
||||
final String management = this.getAttributeValue(MANAGEMENT_ATTRIBUTE_QNAME);
|
||||
boolean result = true;
|
||||
if (management != null) {
|
||||
if (management.trim().toLowerCase().equals("on")) {
|
||||
result = true;
|
||||
}
|
||||
else {
|
||||
result = Boolean.parseBoolean(management);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the endpointDisposeDelay attribute or the default value
|
||||
* otherwise.
|
||||
*
|
||||
* @param defaultDelay The default value that is returned if this attribute is
|
||||
* not set
|
||||
* @return The value of the endpointDisposeDelay attribute or the default value
|
||||
* otherwise.
|
||||
*/
|
||||
public long getEndpointDisposeDelay(final long defaultDelay) throws WebServiceException {
|
||||
long result = defaultDelay;
|
||||
final String delayText = getAttributeValue(ENDPOINT_DISPOSE_DELAY_ATTRIBUTE_QNAME);
|
||||
if (delayText != null) {
|
||||
try {
|
||||
result = Long.parseLong(delayText);
|
||||
} catch (NumberFormatException e) {
|
||||
throw LOGGER.logSevereException(new WebServiceException(
|
||||
ManagementMessages.WSM_1008_EXPECTED_INTEGER_DISPOSE_DELAY_VALUE(delayText), e));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of CommunicationServerImplementation elements that were set as
|
||||
* parameters of this assertion.
|
||||
*
|
||||
* @return A list of CommunicationServerImplementation elements that were set as
|
||||
* parameters of this assertion. May be empty.
|
||||
*/
|
||||
public Collection<ImplementationRecord> getCommunicationServerImplementations() {
|
||||
final Collection<ImplementationRecord> result = new LinkedList<ImplementationRecord>();
|
||||
final Iterator<PolicyAssertion> parameters = getParametersIterator();
|
||||
while (parameters.hasNext()) {
|
||||
final PolicyAssertion parameter = parameters.next();
|
||||
if (COMMUNICATION_SERVER_IMPLEMENTATIONS_PARAMETER_QNAME.equals(parameter.getName())) {
|
||||
final Iterator<PolicyAssertion> implementations = parameter.getParametersIterator();
|
||||
if (!implementations.hasNext()) {
|
||||
throw LOGGER.logSevereException(new WebServiceException(
|
||||
ManagementMessages.WSM_1005_EXPECTED_COMMUNICATION_CHILD()));
|
||||
}
|
||||
while (implementations.hasNext()) {
|
||||
final PolicyAssertion implementation = implementations.next();
|
||||
if (COMMUNICATION_SERVER_IMPLEMENTATION_PARAMETER_QNAME.equals(implementation.getName())) {
|
||||
result.add(getImplementation(implementation));
|
||||
}
|
||||
else {
|
||||
throw LOGGER.logSevereException(new WebServiceException(
|
||||
ManagementMessages.WSM_1004_EXPECTED_XML_TAG(
|
||||
COMMUNICATION_SERVER_IMPLEMENTATION_PARAMETER_QNAME, implementation.getName())));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* The ConfiguratorImplementation that was set as parameter of this assertion.
|
||||
*
|
||||
* @return The ConfiguratorImplementation that was set as parameter of this assertion.
|
||||
* May be null.
|
||||
*/
|
||||
public ImplementationRecord getConfiguratorImplementation() {
|
||||
return findImplementation(CONFIGURATOR_IMPLEMENTATION_PARAMETER_QNAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* The ConfigSaverImplementation that was set as parameter of this assertion.
|
||||
*
|
||||
* @return The ConfigSaverImplementation that was set as parameter of this assertion.
|
||||
* May be null.
|
||||
*/
|
||||
public ImplementationRecord getConfigSaverImplementation() {
|
||||
return findImplementation(CONFIG_SAVER_IMPLEMENTATION_PARAMETER_QNAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* The ConfigReaderImplementation that was set as parameter of this assertion.
|
||||
*
|
||||
* @return The ConfigReaderImplementation that was set as parameter of this assertion.
|
||||
* May be null.
|
||||
*/
|
||||
public ImplementationRecord getConfigReaderImplementation() {
|
||||
return findImplementation(CONFIG_READER_IMPLEMENTATION_PARAMETER_QNAME);
|
||||
}
|
||||
|
||||
private ImplementationRecord findImplementation(QName implementationName) {
|
||||
final Iterator<PolicyAssertion> parameters = getParametersIterator();
|
||||
while (parameters.hasNext()) {
|
||||
final PolicyAssertion parameter = parameters.next();
|
||||
if (implementationName.equals(parameter.getName())) {
|
||||
return getImplementation(parameter);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private ImplementationRecord getImplementation(PolicyAssertion rootParameter) {
|
||||
final String className = rootParameter.getAttributeValue(CLASS_NAME_ATTRIBUTE_QNAME);
|
||||
final HashMap<QName, String> parameterMap = new HashMap<QName, String>();
|
||||
final Iterator<PolicyAssertion> implementationParameters = rootParameter.getParametersIterator();
|
||||
final Collection<NestedParameters> nestedParameters = new LinkedList<NestedParameters>();
|
||||
while (implementationParameters.hasNext()) {
|
||||
final PolicyAssertion parameterAssertion = implementationParameters.next();
|
||||
final QName parameterName = parameterAssertion.getName();
|
||||
if (parameterAssertion.hasParameters()) {
|
||||
final Map<QName, String> nestedParameterMap = new HashMap<QName, String>();
|
||||
final Iterator<PolicyAssertion> parameters = parameterAssertion.getParametersIterator();
|
||||
while (parameters.hasNext()) {
|
||||
final PolicyAssertion parameter = parameters.next();
|
||||
String value = parameter.getValue();
|
||||
if (value != null) {
|
||||
value = value.trim();
|
||||
}
|
||||
nestedParameterMap.put(parameter.getName(), value);
|
||||
}
|
||||
nestedParameters.add(new NestedParameters(parameterName, nestedParameterMap));
|
||||
}
|
||||
else {
|
||||
String value = parameterAssertion.getValue();
|
||||
if (value != null) {
|
||||
value = value.trim();
|
||||
}
|
||||
parameterMap.put(parameterName, value);
|
||||
}
|
||||
}
|
||||
return new ImplementationRecord(className, parameterMap, nestedParameters);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the implementation class name along with all parameters for the
|
||||
* implementation.
|
||||
*/
|
||||
public static class ImplementationRecord {
|
||||
|
||||
private final String implementation;
|
||||
private final Map<QName, String> parameters;
|
||||
private final Collection<NestedParameters> nestedParameters;
|
||||
|
||||
protected ImplementationRecord(String implementation, Map<QName, String> parameters,
|
||||
Collection<NestedParameters> nestedParameters) {
|
||||
this.implementation = implementation;
|
||||
this.parameters = parameters;
|
||||
this.nestedParameters = nestedParameters;
|
||||
}
|
||||
|
||||
public String getImplementation() {
|
||||
return this.implementation;
|
||||
}
|
||||
|
||||
/**
|
||||
* The parameters that were set for this implementation element.
|
||||
*
|
||||
* @return The parameters that were set for this implementation element.
|
||||
* May be null.
|
||||
*/
|
||||
public Map<QName, String> getParameters() {
|
||||
return this.parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation elements may contain element parameters that contain
|
||||
* further parameters.
|
||||
*
|
||||
* @return The nested parameters that were set for this implementation element.
|
||||
* May be null.
|
||||
*/
|
||||
public Collection<NestedParameters> getNestedParameters() {
|
||||
return this.nestedParameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final ImplementationRecord other = (ImplementationRecord) obj;
|
||||
if ((this.implementation == null) ?
|
||||
(other.implementation != null) : !this.implementation.equals(other.implementation)) {
|
||||
return false;
|
||||
}
|
||||
if (this.parameters != other.parameters && (this.parameters == null || !this.parameters.equals(other.parameters))) {
|
||||
return false;
|
||||
}
|
||||
if (this.nestedParameters != other.nestedParameters &&
|
||||
(this.nestedParameters == null || !this.nestedParameters.equals(other.nestedParameters))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 3;
|
||||
hash = 53 * hash + (this.implementation != null ? this.implementation.hashCode() : 0);
|
||||
hash = 53 * hash + (this.parameters != null ? this.parameters.hashCode() : 0);
|
||||
hash = 53 * hash + (this.nestedParameters != null ? this.nestedParameters.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder text = new StringBuilder("ImplementationRecord: ");
|
||||
text.append("implementation = \"").append(this.implementation).append("\", ");
|
||||
text.append("parameters = \"").append(this.parameters).append("\", ");
|
||||
text.append("nested parameters = \"").append(this.nestedParameters).append("\"");
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The nested parameters that may be set as part of an implementation element.
|
||||
*/
|
||||
public static class NestedParameters {
|
||||
|
||||
private final QName name;
|
||||
private final Map<QName, String> parameters;
|
||||
|
||||
private NestedParameters(QName name, Map<QName, String> parameters) {
|
||||
this.name = name;
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
public QName getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Map<QName, String> getParameters() {
|
||||
return this.parameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final NestedParameters other = (NestedParameters) obj;
|
||||
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
|
||||
return false;
|
||||
}
|
||||
if (this.parameters != other.parameters && (this.parameters == null || !this.parameters.equals(other.parameters))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 5;
|
||||
hash = 59 * hash + (this.name != null ? this.name.hashCode() : 0);
|
||||
hash = 59 * hash + (this.parameters != null ? this.parameters.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder text = new StringBuilder("NestedParameters: ");
|
||||
text.append("name = \"").append(this.name).append("\", ");
|
||||
text.append("parameters = \"").append(this.parameters).append("\"");
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* 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.api.config.management.policy;
|
||||
|
||||
import com.sun.istack.internal.logging.Logger;
|
||||
import com.sun.xml.internal.ws.policy.AssertionSet;
|
||||
import com.sun.xml.internal.ws.policy.Policy;
|
||||
import com.sun.xml.internal.ws.policy.PolicyAssertion;
|
||||
import com.sun.xml.internal.ws.policy.PolicyException;
|
||||
import com.sun.xml.internal.ws.policy.PolicyMap;
|
||||
import com.sun.xml.internal.ws.policy.PolicyMapKey;
|
||||
import com.sun.xml.internal.ws.policy.SimpleAssertion;
|
||||
import com.sun.xml.internal.ws.policy.sourcemodel.AssertionData;
|
||||
import com.sun.xml.internal.ws.policy.spi.AssertionCreationException;
|
||||
import com.sun.xml.internal.ws.resources.ManagementMessages;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
|
||||
/**
|
||||
* Base class for the #ManagedClientAssertion and #ManagedServiceAssertion. Provides
|
||||
* convenience methods to directly access the policy assertion parameters.
|
||||
*
|
||||
* @author Fabian Ritzmann
|
||||
*/
|
||||
public abstract class ManagementAssertion extends SimpleAssertion {
|
||||
|
||||
/**
|
||||
* To be able to distinguish between explicit settings and no setting.
|
||||
*/
|
||||
public static enum Setting { NOT_SET, OFF, ON }
|
||||
|
||||
/**
|
||||
* The name of the management attribute.
|
||||
*/
|
||||
protected static final QName MANAGEMENT_ATTRIBUTE_QNAME = new QName("management");
|
||||
/**
|
||||
* The name of the monitoring attribute.
|
||||
*/
|
||||
protected static final QName MONITORING_ATTRIBUTE_QNAME = new QName("monitoring");
|
||||
|
||||
/**
|
||||
* The name of the id attribute.
|
||||
*/
|
||||
private static final QName ID_ATTRIBUTE_QNAME = new QName("id");
|
||||
/**
|
||||
* The name of the start attribute.
|
||||
*/
|
||||
private static final QName START_ATTRIBUTE_QNAME = new QName("start");
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(ManagementAssertion.class);
|
||||
|
||||
/**
|
||||
* Return ManagementAssertion if one can be found in the policy map under
|
||||
* the given service and port name.
|
||||
*
|
||||
* @param <T> The implementation class of the assertion.
|
||||
* @param name The fully qualified name of the server or client assertion.
|
||||
* @param policyMap The policy map. May be null.
|
||||
* @param serviceName The WSDL service name. May not be null.
|
||||
* @param portName The WSDL port name. May not be null.
|
||||
* @param type The implementation class of the assertion.
|
||||
* @return An instance of ManagementAssertion or null.
|
||||
* @throws WebServiceException If computing the effective policy of the endpoint scope failed.
|
||||
*/
|
||||
protected static <T extends ManagementAssertion> T getAssertion(final QName name,
|
||||
final PolicyMap policyMap, QName serviceName, QName portName, Class<T> type)
|
||||
throws WebServiceException {
|
||||
try {
|
||||
PolicyAssertion assertion = null;
|
||||
if (policyMap != null) {
|
||||
final PolicyMapKey key = PolicyMap.createWsdlEndpointScopeKey(serviceName, portName);
|
||||
final Policy policy = policyMap.getEndpointEffectivePolicy(key);
|
||||
if (policy != null) {
|
||||
final Iterator<AssertionSet> assertionSets = policy.iterator();
|
||||
if (assertionSets.hasNext()) {
|
||||
final AssertionSet assertionSet = assertionSets.next();
|
||||
final Iterator<PolicyAssertion> assertions = assertionSet.get(name).iterator();
|
||||
if (assertions.hasNext()) {
|
||||
assertion = assertions.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return assertion == null ? null : assertion.getImplementation(type);
|
||||
} catch (PolicyException ex) {
|
||||
throw LOGGER.logSevereException(new WebServiceException(
|
||||
ManagementMessages.WSM_1001_FAILED_ASSERTION(name), ex));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new ManagementAssertion instance.
|
||||
*
|
||||
* @param name The fully qualified name of the server or client assertion. Must
|
||||
* not be null.
|
||||
* @param data The assertion data. Must not be null.
|
||||
* @param assertionParameters Parameters of the assertion. May be null.
|
||||
* @throws AssertionCreationException Thrown if the creation of the assertion failed.
|
||||
*/
|
||||
protected ManagementAssertion(final QName name, AssertionData data, Collection<PolicyAssertion> assertionParameters)
|
||||
throws AssertionCreationException {
|
||||
super(data, assertionParameters);
|
||||
if (!name.equals(data.getName())) {
|
||||
throw LOGGER.logSevereException(new AssertionCreationException(data,
|
||||
ManagementMessages.WSM_1002_EXPECTED_MANAGEMENT_ASSERTION(name)));
|
||||
}
|
||||
if (isManagementEnabled() && !data.containsAttribute(ID_ATTRIBUTE_QNAME)) {
|
||||
throw LOGGER.logSevereException(new AssertionCreationException(data,
|
||||
ManagementMessages.WSM_1003_MANAGEMENT_ASSERTION_MISSING_ID(name)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the id attribute. May not be null.
|
||||
*
|
||||
* @return The value of the id attribute.
|
||||
*/
|
||||
public String getId() {
|
||||
return this.getAttributeValue((ID_ATTRIBUTE_QNAME));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the start attribute. May be null.
|
||||
*
|
||||
* @return The value of the start attribute.
|
||||
*/
|
||||
public String getStart() {
|
||||
return this.getAttributeValue((START_ATTRIBUTE_QNAME));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the managment attribute depending on whether this is
|
||||
* a client-side or server-side assertion.
|
||||
*
|
||||
* @return The value of the managment attribute.
|
||||
*/
|
||||
public abstract boolean isManagementEnabled();
|
||||
|
||||
/**
|
||||
* Returns the value of the monitoring attribute.
|
||||
*
|
||||
* @return The value of the monitoring attribute.
|
||||
*/
|
||||
public Setting monitoringAttribute() {
|
||||
final String monitoring = this.getAttributeValue(MONITORING_ATTRIBUTE_QNAME);
|
||||
Setting result = Setting.NOT_SET;
|
||||
if (monitoring != null) {
|
||||
if (monitoring.trim().toLowerCase().equals("on")
|
||||
|| Boolean.parseBoolean(monitoring)) {
|
||||
result = Setting.ON;
|
||||
}
|
||||
else {
|
||||
result = Setting.OFF;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.api.databinding;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import com.oracle.webservices.internal.api.databinding.JavaCallInfo;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.sun.xml.internal.ws.api.model.JavaMethod;
|
||||
|
||||
public interface ClientCallBridge {
|
||||
|
||||
Packet createRequestPacket(JavaCallInfo call);
|
||||
|
||||
JavaCallInfo readResponse(Packet packet, JavaCallInfo call) throws Throwable;
|
||||
|
||||
Method getMethod();
|
||||
|
||||
JavaMethod getOperationModel();
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* 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.api.databinding;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import com.sun.xml.internal.ws.api.message.MessageContextFactory;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.sun.xml.internal.ws.api.pipe.ContentType;
|
||||
import com.sun.xml.internal.ws.wsdl.DispatchException;
|
||||
|
||||
/**
|
||||
* {@code Databinding} is the entry point for all the WebService databinding
|
||||
* runtime functionality. Primarily, a Databinding is to serialize/deserialize an
|
||||
* XML(SOAP) message to/from a JAVA method invocation and return value which
|
||||
* are represented as <code>JavaCallInfo</code> instances.
|
||||
* <p>
|
||||
* </p>
|
||||
* Each Databinding is associated with a <code>MessageFactory</code> instance
|
||||
* which can be used to create <code>Message</code> instances that can be
|
||||
* deserialized by the Databinding. The <code>MessageFactory</code> also supports
|
||||
* the conversion of Oracle Fabric Normalized messages.
|
||||
* <p>
|
||||
* </p>
|
||||
* <blockquote> Following is an example that creates a {@code Databinding} which
|
||||
* provides the operations to serialize/deserialize a JavaCallInfo to/from a
|
||||
* SOAP message:<br />
|
||||
*
|
||||
* <pre>
|
||||
* DatabindingFactory wsfac = DatabindingFactory();
|
||||
* Databinding rt = wsfac.createDatabinding(DatabindingConfig);
|
||||
* </pre>
|
||||
*
|
||||
* </blockquote>
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public interface Databinding extends com.oracle.webservices.internal.api.databinding.Databinding {
|
||||
|
||||
/**
|
||||
* Gets the MessageFactory instance associated with this WsRuntime
|
||||
*
|
||||
* @return the MessageFactory instance associated with this WsRuntime
|
||||
*/
|
||||
// MessageFactory getMessageFactory();
|
||||
|
||||
/**
|
||||
* Deserializes a request XML(SOAP) message to a JavaCallInfo instance
|
||||
* representing a JAVA method call.
|
||||
*
|
||||
* @param soap
|
||||
* the request message
|
||||
*
|
||||
* @return the JavaCallInfo representing a method call
|
||||
*/
|
||||
// JavaCallInfo deserializeRequest(Packet req);
|
||||
|
||||
EndpointCallBridge getEndpointBridge(Packet soap) throws DispatchException;
|
||||
|
||||
ClientCallBridge getClientBridge(Method method);
|
||||
|
||||
/**
|
||||
* Serializes a JavaCallInfo instance representing a JAVA method call to a
|
||||
* request XML(SOAP) message.
|
||||
*
|
||||
* @param call
|
||||
* the JavaCallInfo representing a method call
|
||||
*
|
||||
* @return the request XML(SOAP) message
|
||||
*/
|
||||
// Packet serializeRequest(JavaCallInfo call);
|
||||
|
||||
/**
|
||||
* Serializes a JavaCallInfo instance representing the return value or
|
||||
* exception of a JAVA method call to a response XML(SOAP) message.
|
||||
*
|
||||
* @param call
|
||||
* the JavaCallInfo representing the return value or exception of
|
||||
* a JAVA method call
|
||||
*
|
||||
* @return the response XML(SOAP) message
|
||||
*/
|
||||
// Packet serializeResponse(JavaCallInfo call);
|
||||
|
||||
/**
|
||||
* Deserializes a response XML(SOAP) message to a JavaCallInfo instance
|
||||
* representing the return value or exception of a JAVA method call.
|
||||
*
|
||||
* @param soap
|
||||
* the response message
|
||||
*
|
||||
* @param call
|
||||
* the JavaCallInfo instance to be updated
|
||||
*
|
||||
* @return the JavaCallInfo updated with the return value or exception of a
|
||||
* JAVA method call
|
||||
*/
|
||||
// JavaCallInfo deserializeResponse(Packet res, JavaCallInfo call);
|
||||
|
||||
/**
|
||||
* Gets the WSDL operation metadata of the specified JAVA method.
|
||||
*
|
||||
* @param method
|
||||
* the JAVA method
|
||||
* @return the operationMetadata
|
||||
*/
|
||||
// OperationMetadata getOperationMetadata(java.lang.reflect.Method method);
|
||||
|
||||
/**
|
||||
* Gets the WebServiceFeatures of this webservice endpoint.
|
||||
*
|
||||
* @return the features
|
||||
*/
|
||||
// WebServiceFeature[] getFeatures();
|
||||
|
||||
void generateWSDL(WSDLGenInfo info);
|
||||
|
||||
/**
|
||||
* @deprecated use MessageContextFactory
|
||||
*/
|
||||
public ContentType encode( Packet packet, OutputStream out ) throws IOException ;
|
||||
|
||||
/**
|
||||
* @deprecated use MessageContextFactory
|
||||
*/
|
||||
public void decode( InputStream in, String ct, Packet packet ) throws IOException;
|
||||
|
||||
public MessageContextFactory getMessageContextFactory();
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* 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.api.databinding;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
import org.xml.sax.EntityResolver;
|
||||
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.WSFeatureList;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.binding.WebServiceFeatureList;
|
||||
|
||||
/**
|
||||
* DatabindingConfig contains the initial states for Databinding. After a Databinding
|
||||
* instance is created, all it's internal states should be considered
|
||||
* 'immutable' and therefore the operations on Databinding are thread-safe.
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public class DatabindingConfig {
|
||||
protected Class contractClass;
|
||||
protected Class endpointClass;
|
||||
protected Set<Class> additionalValueTypes = new HashSet<Class>();
|
||||
protected MappingInfo mappingInfo = new MappingInfo();
|
||||
protected URL wsdlURL;
|
||||
protected ClassLoader classLoader;
|
||||
protected Iterable<WebServiceFeature> features;
|
||||
protected WSBinding wsBinding;
|
||||
protected WSDLPort wsdlPort;
|
||||
protected MetadataReader metadataReader;
|
||||
protected Map<String, Object> properties = new HashMap<String, Object>();
|
||||
protected Source wsdlSource;
|
||||
protected EntityResolver entityResolver;
|
||||
|
||||
public Class getContractClass() {
|
||||
return contractClass;
|
||||
}
|
||||
public void setContractClass(Class contractClass) {
|
||||
this.contractClass = contractClass;
|
||||
}
|
||||
public Class getEndpointClass() {
|
||||
return endpointClass;
|
||||
}
|
||||
public void setEndpointClass(Class implBeanClass) {
|
||||
this.endpointClass = implBeanClass;
|
||||
}
|
||||
public MappingInfo getMappingInfo() {
|
||||
return mappingInfo;
|
||||
}
|
||||
public void setMappingInfo(MappingInfo mappingInfo) {
|
||||
this.mappingInfo = mappingInfo;
|
||||
}
|
||||
public URL getWsdlURL() {
|
||||
return wsdlURL;
|
||||
}
|
||||
public void setWsdlURL(URL wsdlURL) {
|
||||
this.wsdlURL = wsdlURL;
|
||||
}
|
||||
public ClassLoader getClassLoader() {
|
||||
return classLoader;
|
||||
}
|
||||
public void setClassLoader(ClassLoader classLoader) {
|
||||
this.classLoader = classLoader;
|
||||
}
|
||||
public Iterable<WebServiceFeature> getFeatures() {
|
||||
if (features == null && wsBinding != null) return wsBinding.getFeatures();
|
||||
return features;
|
||||
}
|
||||
public void setFeatures(WebServiceFeature[] features) {
|
||||
setFeatures(new WebServiceFeatureList(features));
|
||||
}
|
||||
public void setFeatures(Iterable<WebServiceFeature> features) {
|
||||
this.features = WebServiceFeatureList.toList(features);
|
||||
}
|
||||
public WSDLPort getWsdlPort() {
|
||||
return wsdlPort;
|
||||
}
|
||||
public void setWsdlPort(WSDLPort wsdlPort) {
|
||||
this.wsdlPort = wsdlPort;
|
||||
}
|
||||
public Set<Class> additionalValueTypes() {
|
||||
return additionalValueTypes;
|
||||
}
|
||||
public Map<String, Object> properties() {
|
||||
return properties;
|
||||
}
|
||||
public WSBinding getWSBinding() {
|
||||
return wsBinding;
|
||||
}
|
||||
public void setWSBinding(WSBinding wsBinding) {
|
||||
this.wsBinding = wsBinding;
|
||||
}
|
||||
public MetadataReader getMetadataReader() {
|
||||
return metadataReader;
|
||||
}
|
||||
public void setMetadataReader(MetadataReader reader) {
|
||||
this.metadataReader = reader;
|
||||
}
|
||||
|
||||
public Source getWsdlSource() {
|
||||
return wsdlSource;
|
||||
}
|
||||
public void setWsdlSource(Source wsdlSource) {
|
||||
this.wsdlSource = wsdlSource;
|
||||
}
|
||||
public EntityResolver getEntityResolver() {
|
||||
return entityResolver;
|
||||
}
|
||||
public void setEntityResolver(EntityResolver entityResolver) {
|
||||
this.entityResolver = entityResolver;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* 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.api.databinding;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* WsFactory is the entry point of all the ws-databinding APIs. A WsFactory
|
||||
* instance can be used to create <code>WsTool</code>, <code>WsRuntime</code>,
|
||||
* <code>XsTool</code>, and <code>XsRuntime</code> instances.
|
||||
* <p>
|
||||
* </P>
|
||||
* <blockquote>
|
||||
* Following is an example that creates a {@code WsTool} which provides the
|
||||
* operations for "WSDL to JAVA" and "JAVA to WSDL":<br />
|
||||
* <pre>
|
||||
* WsFactory wsfac = WsFactory.newInstance();
|
||||
* WsTool tool = wsfac.createTool();
|
||||
* GenerationStatus status = tool.generateWsdl(javaToWsdkInfo);
|
||||
* </pre>
|
||||
* </blockquote>
|
||||
*
|
||||
* <blockquote>
|
||||
* Following is an example that creates a {@code WsRuntime} which provides the
|
||||
* operations to serialize/deserialize a JavaCallInfo to/from a SOAP message:<br />
|
||||
* <pre>
|
||||
* WsFactory wsfac = WsFactory.newInstance();
|
||||
* WsRuntime rt = wsfac.createRuntime(wsRuntimeConfig);
|
||||
* </pre>
|
||||
* </blockquote>
|
||||
*
|
||||
* @see com.sun.xml.internal.ws.api.databinding.Databinding
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public abstract class DatabindingFactory extends com.oracle.webservices.internal.api.databinding.DatabindingFactory {
|
||||
|
||||
/**
|
||||
* Creates a new instance of a <code>WsTool</code>.
|
||||
*
|
||||
* @return New instance of a <code>WsTool</code>
|
||||
*/
|
||||
// abstract public WsTool createTool();
|
||||
|
||||
/**
|
||||
* Creates a new instance of a <code>WsRuntime</code> which is initialized
|
||||
* with the specified configuration object.
|
||||
*
|
||||
* @param config
|
||||
* the EndpointRuntimeConfig to init this WsRuntime
|
||||
* @return New instance of a <code>WsRuntime</code>
|
||||
*/
|
||||
abstract public com.oracle.webservices.internal.api.databinding.Databinding createRuntime(DatabindingConfig config);
|
||||
|
||||
/**
|
||||
* Creates a new instance of a <code>XsTool</code>.
|
||||
*
|
||||
* @return New instance of a <code>XsTool</code>
|
||||
*/
|
||||
// abstract public XsTool createXsTool(String mode);
|
||||
|
||||
/**
|
||||
* Creates a new instance of a <code>XsRuntime</code>.
|
||||
*
|
||||
* @return New instance of a <code>XsRuntime</code>
|
||||
*/
|
||||
// abstract public XsRuntime createXsRuntime(String mode);
|
||||
|
||||
/**
|
||||
* Access properties on the <code>WsFactory</code> instance.
|
||||
*
|
||||
* @return properties of this WsFactory
|
||||
*/
|
||||
abstract public Map<String, Object> properties();
|
||||
|
||||
/**
|
||||
* The default implementation class name.
|
||||
*/
|
||||
static final String ImplClass = com.sun.xml.internal.ws.db.DatabindingFactoryImpl.class.getName();
|
||||
|
||||
/**
|
||||
* Create a new instance of a <code>WsFactory</code>. This static method
|
||||
* creates a new factory instance.
|
||||
*
|
||||
* Once an application has obtained a reference to a <code>WsFactory</code>
|
||||
* it can use the factory to configure and obtain <code>WsTool</code> and
|
||||
* <code>WsRuntime</code> instances.
|
||||
*
|
||||
* @return New instance of a <code>WsFactory</code>
|
||||
*/
|
||||
static public DatabindingFactory newInstance() {
|
||||
try {
|
||||
Class<?> cls = Class.forName(ImplClass);
|
||||
return (DatabindingFactory) cls.newInstance();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.api.databinding;
|
||||
|
||||
import com.oracle.webservices.internal.api.databinding.JavaCallInfo;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.sun.xml.internal.ws.api.model.JavaMethod;
|
||||
|
||||
public interface EndpointCallBridge {
|
||||
|
||||
public JavaCallInfo deserializeRequest(Packet req);
|
||||
|
||||
//Change the return type to??
|
||||
public Packet serializeResponse(JavaCallInfo call);
|
||||
|
||||
JavaMethod getOperationModel();
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* 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.api.databinding;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* On the client or service-requestor side, a JavaCallInfo object represents a
|
||||
* method call on the service proxy to be serialized as a SOAP request message
|
||||
* to be sent to the service. A SOAP response message returned to the service
|
||||
* client is deserialized as an update to the JavaCallInfo object which is used
|
||||
* to generated the request.
|
||||
* <p>
|
||||
* </p>
|
||||
* On the server or service provider side, a SOAP request message is
|
||||
* deserialized to a JavaCallInfo object which can be used to determine which
|
||||
* method to call, and get the parameter values to call the back-end service
|
||||
* implementation object. The return value or exception returned from the
|
||||
* service implementation should be set to the JavaCallInfo object which then
|
||||
* can be used to serialize to a A SOAP response or fault message to be sent
|
||||
* back to the service client.
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public class JavaCallInfo implements com.oracle.webservices.internal.api.databinding.JavaCallInfo {
|
||||
|
||||
private Method method;
|
||||
private Object[] parameters;
|
||||
private Object returnValue;
|
||||
private Throwable exception;
|
||||
|
||||
public JavaCallInfo() {
|
||||
}
|
||||
|
||||
public JavaCallInfo(Method m, Object[] args) {
|
||||
method = m;
|
||||
parameters = args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the method of this JavaCallInfo
|
||||
*
|
||||
* @return the method
|
||||
*/
|
||||
public Method getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the method of this JavaCallInfo
|
||||
*
|
||||
* @param method
|
||||
* the method to set
|
||||
*/
|
||||
public void setMethod(Method method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parameters of this JavaCallInfo
|
||||
*
|
||||
* @return the parameters
|
||||
*/
|
||||
public Object[] getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parameters of this JavaCallInfo
|
||||
*
|
||||
* @param parameters
|
||||
* the parameters to set
|
||||
*/
|
||||
public void setParameters(Object[] parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the returnValue of this JavaCallInfo
|
||||
*
|
||||
* @return the returnValue
|
||||
*/
|
||||
public Object getReturnValue() {
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the returnValue of this JavaCallInfo
|
||||
*
|
||||
* @param returnValue
|
||||
* the returnValue to set
|
||||
*/
|
||||
public void setReturnValue(Object returnValue) {
|
||||
this.returnValue = returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the exception of this JavaCallInfo
|
||||
*
|
||||
* @return the exception
|
||||
*/
|
||||
public Throwable getException() {
|
||||
return exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the exception of this JavaCallInfo
|
||||
*
|
||||
* @param exception
|
||||
* the exception to set
|
||||
*/
|
||||
public void setException(Throwable exception) {
|
||||
this.exception = exception;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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.api.databinding;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import com.sun.xml.internal.ws.api.BindingID;
|
||||
|
||||
/**
|
||||
* A MappingInfo object is the collection of all the properties of the mapping
|
||||
* between a JAVA contract class (SEI) and it's corresponding WSDL artifacts
|
||||
* (wsdl:portType and wsdl:binding). A MappingInfo object can be used to provide
|
||||
* additional mapping metadata for WSDL generation and the runtime of WebService
|
||||
* databinding.
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public class MappingInfo {
|
||||
protected String targetNamespace;
|
||||
protected String databindingMode;
|
||||
protected SoapBodyStyle soapBodyStyle;
|
||||
protected BindingID bindingID;
|
||||
protected QName serviceName;
|
||||
protected QName portName;
|
||||
protected String defaultSchemaNamespaceSuffix;
|
||||
|
||||
public String getTargetNamespace() {
|
||||
return targetNamespace;
|
||||
}
|
||||
public void setTargetNamespace(String targetNamespace) {
|
||||
this.targetNamespace = targetNamespace;
|
||||
}
|
||||
public String getDatabindingMode() {
|
||||
return databindingMode;
|
||||
}
|
||||
public void setDatabindingMode(String databindingMode) {
|
||||
this.databindingMode = databindingMode;
|
||||
}
|
||||
public SoapBodyStyle getSoapBodyStyle() {
|
||||
return soapBodyStyle;
|
||||
}
|
||||
public void setSoapBodyStyle(SoapBodyStyle soapBodyStyle) {
|
||||
this.soapBodyStyle = soapBodyStyle;
|
||||
}
|
||||
public BindingID getBindingID() {
|
||||
return bindingID;
|
||||
}
|
||||
public void setBindingID(BindingID bindingID) {
|
||||
this.bindingID = bindingID;
|
||||
}
|
||||
public QName getServiceName() {
|
||||
return serviceName;
|
||||
}
|
||||
public void setServiceName(QName serviceName) {
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
public QName getPortName() {
|
||||
return portName;
|
||||
}
|
||||
public void setPortName(QName portName) {
|
||||
this.portName = portName;
|
||||
}
|
||||
public String getDefaultSchemaNamespaceSuffix() {
|
||||
return defaultSchemaNamespaceSuffix;
|
||||
}
|
||||
public void setDefaultSchemaNamespaceSuffix(String defaultSchemaNamespaceSuffix) {
|
||||
this.defaultSchemaNamespaceSuffix = defaultSchemaNamespaceSuffix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.api.databinding;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* MetadataReader
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public interface MetadataReader {
|
||||
|
||||
public Annotation[] getAnnotations(Method m) ;
|
||||
|
||||
public Annotation[][] getParameterAnnotations(final Method method);
|
||||
|
||||
public <A extends Annotation> A getAnnotation(final Class<A> annType, final Method m);
|
||||
|
||||
public <A extends Annotation> A getAnnotation(final Class<A> annType, final Class<?> cls);
|
||||
|
||||
public Annotation[] getAnnotations(Class<?> c);
|
||||
|
||||
public void getProperties(final Map<String, Object> prop, final Class<?> cls);
|
||||
|
||||
public void getProperties(final Map<String, Object> prop, final Method method);
|
||||
|
||||
public void getProperties(final Map<String, Object> prop, final Method method, int pos);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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.api.databinding;
|
||||
|
||||
/**
|
||||
* The SoapBodyStyle represents the possible choices of the mapping styles
|
||||
* between the SOAP body of a wsdl:operation input/output messages and JAVA
|
||||
* method parameters and return/output values.
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public enum SoapBodyStyle {
|
||||
|
||||
/**
|
||||
* Bare style mapping of a document style with literal use wsdl:operation
|
||||
*/
|
||||
DocumentBare,
|
||||
|
||||
/**
|
||||
* Wrapper style mapping of a document style with literal use wsdl:operation
|
||||
*/
|
||||
DocumentWrapper,
|
||||
|
||||
/**
|
||||
* The mapping style of a RPC style with literal use wsdl:operation
|
||||
*/
|
||||
RpcLiteral,
|
||||
|
||||
/**
|
||||
* The mapping style of a RPC style with encoded use wsdl:operation.
|
||||
*
|
||||
* Note: this is not offically supported in JAX-WS.
|
||||
*/
|
||||
RpcEncoded,
|
||||
|
||||
/**
|
||||
* The mapping style is not specified.
|
||||
*/
|
||||
Unspecificed;
|
||||
|
||||
public boolean isDocument() {
|
||||
return (this.equals(DocumentBare) || this.equals(DocumentWrapper));
|
||||
}
|
||||
|
||||
public boolean isRpc() {
|
||||
return (this.equals(RpcLiteral) || this.equals(RpcEncoded));
|
||||
}
|
||||
|
||||
public boolean isLiteral() {
|
||||
return (this.equals(RpcLiteral) || this.isDocument());
|
||||
}
|
||||
|
||||
public boolean isBare() {
|
||||
return (this.equals(DocumentBare));
|
||||
}
|
||||
|
||||
public boolean isDocumentWrapper() {
|
||||
return (this.equals(DocumentWrapper));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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.api.databinding;
|
||||
|
||||
import com.oracle.webservices.internal.api.databinding.WSDLResolver;
|
||||
import com.sun.xml.internal.ws.api.server.Container;
|
||||
import com.sun.xml.internal.ws.api.wsdl.writer.WSDLGeneratorExtension;
|
||||
|
||||
/**
|
||||
* WSDLGenInfo provides the WSDL generation options
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public class WSDLGenInfo {
|
||||
WSDLResolver wsdlResolver;
|
||||
Container container;
|
||||
boolean inlineSchemas;
|
||||
boolean secureXmlProcessingDisabled;
|
||||
WSDLGeneratorExtension[] extensions;
|
||||
|
||||
public WSDLResolver getWsdlResolver() {
|
||||
return wsdlResolver;
|
||||
}
|
||||
public void setWsdlResolver(WSDLResolver wsdlResolver) {
|
||||
this.wsdlResolver = wsdlResolver;
|
||||
}
|
||||
public Container getContainer() {
|
||||
return container;
|
||||
}
|
||||
public void setContainer(Container container) {
|
||||
this.container = container;
|
||||
}
|
||||
public boolean isInlineSchemas() {
|
||||
return inlineSchemas;
|
||||
}
|
||||
public void setInlineSchemas(boolean inlineSchemas) {
|
||||
this.inlineSchemas = inlineSchemas;
|
||||
}
|
||||
public WSDLGeneratorExtension[] getExtensions() {
|
||||
if (extensions == null) return new WSDLGeneratorExtension[0];
|
||||
return extensions;
|
||||
}
|
||||
public void setExtensions(WSDLGeneratorExtension[] extensions) {
|
||||
this.extensions = extensions;
|
||||
}
|
||||
|
||||
public void setSecureXmlProcessingDisabled(boolean secureXmlProcessingDisabled) {
|
||||
this.secureXmlProcessingDisabled = secureXmlProcessingDisabled;
|
||||
}
|
||||
|
||||
public boolean isSecureXmlProcessingDisabled() {
|
||||
return secureXmlProcessingDisabled;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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.api.fastinfoset;
|
||||
|
||||
import com.sun.xml.internal.ws.api.FeatureConstructor;
|
||||
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
import com.sun.org.glassfish.gmbal.ManagedAttribute;
|
||||
import com.sun.org.glassfish.gmbal.ManagedData;
|
||||
|
||||
/**
|
||||
* Enable or disable Fast Infoset on a Web service.
|
||||
* <p>
|
||||
* The following describes the affects of this feature with respect
|
||||
* to being enabled or disabled:
|
||||
* <ul>
|
||||
* <li> ENABLED: In this Mode, Fast Infoset will be enabled.
|
||||
* <li> DISABLED: In this Mode, Fast Infoset will be disabled and the
|
||||
* Web service will not process incoming messages or produce outgoing
|
||||
* messages encoded using Fast Infoset.
|
||||
* </ul>
|
||||
* <p>
|
||||
* If this feature is not present on a Web service then the default behaviour
|
||||
* is equivalent to this feature being present and enabled.
|
||||
* @author Paul.Sandoz@Sun.Com
|
||||
*/
|
||||
@ManagedData
|
||||
public class FastInfosetFeature extends WebServiceFeature {
|
||||
/**
|
||||
* Constant value identifying the {@link FastInfosetFeature}
|
||||
*/
|
||||
public static final String ID = "http://java.sun.com/xml/ns/jaxws/fastinfoset";
|
||||
|
||||
/**
|
||||
* Create a {@link FastInfosetFeature}. The instance created will be enabled.
|
||||
*/
|
||||
public FastInfosetFeature() {
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link FastInfosetFeature}
|
||||
*
|
||||
* @param enabled specifies whether this feature should
|
||||
* be enabled or not.
|
||||
*/
|
||||
@FeatureConstructor({"enabled"})
|
||||
public FastInfosetFeature(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@ManagedAttribute
|
||||
public String getID() {
|
||||
return ID;
|
||||
}
|
||||
}
|
||||
84
jdkSrc/jdk8/com/sun/xml/internal/ws/api/ha/HaInfo.java
Normal file
84
jdkSrc/jdk8/com/sun/xml/internal/ws/api/ha/HaInfo.java
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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.api.ha;
|
||||
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
|
||||
/**
|
||||
* This class has HA information
|
||||
* <p>
|
||||
*
|
||||
* This would help a loadbalancer to put the request(in case of a fail-over)
|
||||
* on a replica instance that has all the related data. Even if there is no
|
||||
* loadbalancer, a backing store could locate the information by directly
|
||||
* going to the correct replica instance. This would also help any part of
|
||||
* the runtime to know about failover case(and in-turn may invalidate
|
||||
* local caches).
|
||||
*
|
||||
* <p>
|
||||
* To achieve this functionality, it carries two pieces of information:
|
||||
* <ol>
|
||||
* <li>key - Related {@link com.sun.org.glassfish.ha.store.api.BackingStore} keys can
|
||||
* use this info for their HashableKey impl. First store creates this object,
|
||||
* and subsequent related stores use the same key.
|
||||
* <li>replicaInstance - where the related info is replicated
|
||||
* </ol>
|
||||
*
|
||||
* <p>
|
||||
* This can be accessed from {@link Packet} using {@link Packet#HA_INFO}
|
||||
* property by the runtime. This object is created typically
|
||||
* <ul>
|
||||
* <li> When a store happens for the first time
|
||||
* <li> A subsequent inbound transport creates from cookies
|
||||
* <li> A fail-over request stores the data to a different replica
|
||||
* </ul>
|
||||
*
|
||||
* @author Jitendra Kotamraju
|
||||
* @since JAX-WS RI 2.2.2
|
||||
*/
|
||||
public class HaInfo {
|
||||
private final String replicaInstance;
|
||||
private final String key;
|
||||
private final boolean failOver;
|
||||
|
||||
public HaInfo(String key, String replicaInstance, boolean failOver) {
|
||||
this.key = key;
|
||||
this.replicaInstance = replicaInstance;
|
||||
this.failOver = failOver;
|
||||
}
|
||||
|
||||
public String getReplicaInstance() {
|
||||
return replicaInstance;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public boolean isFailOver() {
|
||||
return failOver;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.api.ha;
|
||||
|
||||
|
||||
/**
|
||||
* Provides a way to tell the runtime about stickiness of requests. In a
|
||||
* HA environment, a client's requests need to land on the same instance so
|
||||
* that a {@link com.sun.org.glassfish.ha.store.api.BackingStore} entry for a key is
|
||||
* accessed/modified from the same instance.
|
||||
*
|
||||
* <p>
|
||||
* A web service feature may implement this interface. JAX-WS runtime
|
||||
* checks if any feature needs stickiness of requests, and if HA is configured
|
||||
* ({@link HighAvailabilityProvider#isHaEnvironmentConfigured()}), it will take
|
||||
* an appropriate action. For example, in servlet transport, it would create
|
||||
* JSESSIONID cookie so that a typical loadbalancer would stick the subsequent
|
||||
* client requests to the same instance.
|
||||
*
|
||||
* @author Jitendra Kotamraju
|
||||
* @since JAX-WS RI 2.2.2
|
||||
*/
|
||||
public interface StickyFeature {
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.api.handler;
|
||||
|
||||
import javax.xml.ws.handler.Handler;
|
||||
import javax.xml.namespace.QName;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* The <code>MessageHandler</code> class extends <code>Handler</code>
|
||||
* to provide typesafety for the message context parameter and add a method
|
||||
* to obtain access to the headers that may be processed by the handler.
|
||||
* Its provides similar functionality as a SOAPHandler but provides RI's
|
||||
* Message in the MessageContext.
|
||||
*
|
||||
* @author Rama Pulavarthi
|
||||
* @since JAX-WS 2.1.3
|
||||
*/
|
||||
public interface MessageHandler<C extends MessageHandlerContext> extends Handler<C> {
|
||||
|
||||
|
||||
/** Gets the header blocks that can be processed by this Handler
|
||||
* instance.
|
||||
*
|
||||
* @return Set of <code>QNames</code> of header blocks processed by this
|
||||
* handler instance. <code>QName</code> is the qualified
|
||||
* name of the outermost element of the Header block.
|
||||
**/
|
||||
Set<QName> getHeaders();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* 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.api.handler;
|
||||
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.message.Message;
|
||||
import com.sun.xml.internal.ws.api.model.SEIModel;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
|
||||
import javax.xml.ws.handler.MessageContext;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* The <code>MessageHandlerContext</code> interface extends
|
||||
* <code>MessageContext</code> to provide easy access to the contained message.
|
||||
*
|
||||
* This context provides access to RI's <code>Message</code> model for efficient access
|
||||
* to various things like accessing headers etc. It also provides access to
|
||||
* binding information as <code>WSBinding</code>.
|
||||
*
|
||||
* @author Rama Pulavarthi
|
||||
* @since JAX-WS 2.1.3
|
||||
*/
|
||||
public interface MessageHandlerContext extends MessageContext {
|
||||
/**
|
||||
* Gets the message from this message context
|
||||
*
|
||||
* @return The contained message; returns <code>null</code> if no
|
||||
* message is present in this message context
|
||||
*/
|
||||
public Message getMessage();
|
||||
|
||||
|
||||
/**
|
||||
* Sets the message in this message context
|
||||
*/
|
||||
public void setMessage(Message message);
|
||||
|
||||
/**
|
||||
* @see javax.xml.ws.handler.soap.SOAPMessageContext#getRoles()
|
||||
*/
|
||||
public Set<String> getRoles();
|
||||
|
||||
|
||||
/**
|
||||
* Provides access to <code>WSBinding</code> which can be used in various ways.
|
||||
* for example: <code>WSBinding#getSOAPVersion</code> to get SOAP version of the binding.
|
||||
* <code>WSBinding#isFeatureEnabled(AddressingFeature)</code> to check if addressing is enabled
|
||||
*/
|
||||
public WSBinding getWSBinding();
|
||||
|
||||
/**
|
||||
* Provides access to <code>SEIModel</code>.
|
||||
*/
|
||||
public @Nullable SEIModel getSEIModel();
|
||||
|
||||
/**
|
||||
* Gets the {@link WSDLPort} that represents the port.
|
||||
* @return
|
||||
* returns the WSDLModel of the port that the client/endpoint binds to.
|
||||
* null when the Service is not configured with WSDL information.
|
||||
*/
|
||||
public @Nullable WSDLPort getPort();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,342 @@
|
||||
/*
|
||||
* 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.api.message;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import javax.xml.ws.soap.SOAPBinding;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.xml.internal.ws.addressing.WsaTubeHelper;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingPropertySet;
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
||||
import com.sun.xml.internal.ws.api.addressing.OneWayFeature;
|
||||
import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.message.RelatesToHeader;
|
||||
import com.sun.xml.internal.ws.message.StringHeader;
|
||||
import com.sun.xml.internal.ws.resources.AddressingMessages;
|
||||
import com.sun.xml.internal.ws.resources.ClientMessages;
|
||||
|
||||
public class AddressingUtils {
|
||||
//TODO is MessageHeaders to be implicitly assumed? Or moved to utility class and taken out from interface?
|
||||
public static void fillRequestAddressingHeaders(MessageHeaders headers, Packet packet, AddressingVersion av, SOAPVersion sv, boolean oneway, String action) {
|
||||
fillRequestAddressingHeaders(headers, packet, av, sv, oneway, action, false);
|
||||
}
|
||||
public static void fillRequestAddressingHeaders(MessageHeaders headers, Packet packet, AddressingVersion av, SOAPVersion sv, boolean oneway, String action, boolean mustUnderstand) {
|
||||
fillCommonAddressingHeaders(headers, packet, av, sv, action, mustUnderstand);
|
||||
|
||||
// wsa:ReplyTo
|
||||
// null or "true" is equivalent to request/response MEP
|
||||
if (!oneway) {
|
||||
WSEndpointReference epr = av.anonymousEpr;
|
||||
if (headers.get(av.replyToTag, false) == null) {
|
||||
headers.add(epr.createHeader(av.replyToTag));
|
||||
}
|
||||
|
||||
// wsa:FaultTo
|
||||
if (headers.get(av.faultToTag, false) == null) {
|
||||
headers.add(epr.createHeader(av.faultToTag));
|
||||
}
|
||||
|
||||
// wsa:MessageID
|
||||
if (packet.getMessage().getHeaders().get(av.messageIDTag, false) == null) {
|
||||
if (headers.get(av.messageIDTag, false) == null) {
|
||||
Header h = new StringHeader(av.messageIDTag, Message.generateMessageID());
|
||||
headers.add(h);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// private void fillRequestAddressingHeaders(Packet packet, AddressingVersion av, SOAPVersion sv, OneWayFeature oneWayFeature, boolean oneway, String action);
|
||||
public static void fillRequestAddressingHeaders(MessageHeaders headers, WSDLPort wsdlPort, WSBinding binding, Packet packet) {
|
||||
if (binding == null) {
|
||||
throw new IllegalArgumentException(AddressingMessages.NULL_BINDING());
|
||||
}
|
||||
|
||||
if (binding.isFeatureEnabled(SuppressAutomaticWSARequestHeadersFeature.class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//See if WSA headers are already set by the user.
|
||||
MessageHeaders hl = packet.getMessage().getHeaders();
|
||||
String action = AddressingUtils.getAction(hl, binding.getAddressingVersion(), binding.getSOAPVersion());
|
||||
if (action != null) {
|
||||
//assume that all the WSA headers are set by the user
|
||||
return;
|
||||
}
|
||||
AddressingVersion addressingVersion = binding.getAddressingVersion();
|
||||
//seiModel is passed as null as it is not needed.
|
||||
WsaTubeHelper wsaHelper = addressingVersion.getWsaHelper(wsdlPort, null, binding);
|
||||
|
||||
// wsa:Action
|
||||
String effectiveInputAction = wsaHelper.getEffectiveInputAction(packet);
|
||||
if (effectiveInputAction == null || effectiveInputAction.equals("") && binding.getSOAPVersion() == SOAPVersion.SOAP_11) {
|
||||
throw new WebServiceException(ClientMessages.INVALID_SOAP_ACTION());
|
||||
}
|
||||
boolean oneway = !packet.expectReply;
|
||||
if (wsdlPort != null) {
|
||||
// if WSDL has <wsaw:Anonymous>prohibited</wsaw:Anonymous>, then throw an error
|
||||
// as anonymous ReplyTo MUST NOT be added in that case. BindingProvider need to
|
||||
// disable AddressingFeature and MemberSubmissionAddressingFeature and hand-craft
|
||||
// the SOAP message with non-anonymous ReplyTo/FaultTo.
|
||||
if (!oneway && packet.getMessage() != null && packet.getWSDLOperation() != null) {
|
||||
WSDLBoundOperation wbo = wsdlPort.getBinding().get(packet.getWSDLOperation());
|
||||
if (wbo != null && wbo.getAnonymous() == WSDLBoundOperation.ANONYMOUS.prohibited) {
|
||||
throw new WebServiceException(AddressingMessages.WSAW_ANONYMOUS_PROHIBITED());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OneWayFeature oneWayFeature = binding.getFeature(OneWayFeature.class);
|
||||
final AddressingPropertySet addressingPropertySet = packet.getSatellite(AddressingPropertySet.class);
|
||||
oneWayFeature = addressingPropertySet == null ? oneWayFeature : new OneWayFeature(addressingPropertySet, addressingVersion);
|
||||
|
||||
if (oneWayFeature == null || !oneWayFeature.isEnabled()) {
|
||||
// standard oneway
|
||||
fillRequestAddressingHeaders(headers, packet, addressingVersion, binding.getSOAPVersion(), oneway, effectiveInputAction, AddressingVersion.isRequired(binding));
|
||||
} else {
|
||||
// custom oneway
|
||||
fillRequestAddressingHeaders(headers, packet, addressingVersion, binding.getSOAPVersion(), oneWayFeature, oneway, effectiveInputAction);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getAction(@NotNull MessageHeaders headers, @NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
|
||||
if (av == null) {
|
||||
throw new IllegalArgumentException(AddressingMessages.NULL_ADDRESSING_VERSION());
|
||||
}
|
||||
|
||||
String action = null;
|
||||
Header h = getFirstHeader(headers, av.actionTag, true, sv);
|
||||
if (h != null) {
|
||||
action = h.getStringContent();
|
||||
}
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
public static WSEndpointReference getFaultTo(@NotNull MessageHeaders headers, @NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
|
||||
if (av == null) {
|
||||
throw new IllegalArgumentException(AddressingMessages.NULL_ADDRESSING_VERSION());
|
||||
}
|
||||
|
||||
Header h = getFirstHeader(headers, av.faultToTag, true, sv);
|
||||
WSEndpointReference faultTo = null;
|
||||
if (h != null) {
|
||||
try {
|
||||
faultTo = h.readAsEPR(av);
|
||||
} catch (XMLStreamException e) {
|
||||
throw new WebServiceException(AddressingMessages.FAULT_TO_CANNOT_PARSE(), e);
|
||||
}
|
||||
}
|
||||
|
||||
return faultTo;
|
||||
}
|
||||
|
||||
public static String getMessageID(@NotNull MessageHeaders headers, @NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
|
||||
if (av == null) {
|
||||
throw new IllegalArgumentException(AddressingMessages.NULL_ADDRESSING_VERSION());
|
||||
}
|
||||
|
||||
Header h = getFirstHeader(headers, av.messageIDTag, true, sv);
|
||||
String messageId = null;
|
||||
if (h != null) {
|
||||
messageId = h.getStringContent();
|
||||
}
|
||||
|
||||
return messageId;
|
||||
}
|
||||
public static String getRelatesTo(@NotNull MessageHeaders headers, @NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
|
||||
if (av == null) {
|
||||
throw new IllegalArgumentException(AddressingMessages.NULL_ADDRESSING_VERSION());
|
||||
}
|
||||
|
||||
Header h = getFirstHeader(headers, av.relatesToTag, true, sv);
|
||||
String relatesTo = null;
|
||||
if (h != null) {
|
||||
relatesTo = h.getStringContent();
|
||||
}
|
||||
|
||||
return relatesTo;
|
||||
}
|
||||
public static WSEndpointReference getReplyTo(@NotNull MessageHeaders headers, @NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
|
||||
if (av == null) {
|
||||
throw new IllegalArgumentException(AddressingMessages.NULL_ADDRESSING_VERSION());
|
||||
}
|
||||
|
||||
Header h = getFirstHeader(headers, av.replyToTag, true, sv);
|
||||
WSEndpointReference replyTo;
|
||||
if (h != null) {
|
||||
try {
|
||||
replyTo = h.readAsEPR(av);
|
||||
} catch (XMLStreamException e) {
|
||||
throw new WebServiceException(AddressingMessages.REPLY_TO_CANNOT_PARSE(), e);
|
||||
}
|
||||
} else {
|
||||
replyTo = av.anonymousEpr;
|
||||
}
|
||||
|
||||
return replyTo;
|
||||
}
|
||||
public static String getTo(MessageHeaders headers, AddressingVersion av, SOAPVersion sv) {
|
||||
if (av == null) {
|
||||
throw new IllegalArgumentException(AddressingMessages.NULL_ADDRESSING_VERSION());
|
||||
}
|
||||
|
||||
Header h = getFirstHeader(headers, av.toTag, true, sv);
|
||||
String to;
|
||||
if (h != null) {
|
||||
to = h.getStringContent();
|
||||
} else {
|
||||
to = av.anonymousUri;
|
||||
}
|
||||
|
||||
return to;
|
||||
}
|
||||
|
||||
public static Header getFirstHeader(MessageHeaders headers, QName name, boolean markUnderstood, SOAPVersion sv) {
|
||||
if (sv == null) {
|
||||
throw new IllegalArgumentException(AddressingMessages.NULL_SOAP_VERSION());
|
||||
}
|
||||
|
||||
Iterator<Header> iter = headers.getHeaders(name.getNamespaceURI(), name.getLocalPart(), markUnderstood);
|
||||
while (iter.hasNext()) {
|
||||
Header h = iter.next();
|
||||
if (h.getRole(sv).equals(sv.implicitRole)) {
|
||||
return h;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void fillRequestAddressingHeaders(@NotNull MessageHeaders headers, @NotNull Packet packet, @NotNull AddressingVersion av, @NotNull SOAPVersion sv, @NotNull OneWayFeature oneWayFeature, boolean oneway, @NotNull String action) {
|
||||
if (!oneway&&!oneWayFeature.isUseAsyncWithSyncInvoke() && Boolean.TRUE.equals(packet.isSynchronousMEP)) {
|
||||
fillRequestAddressingHeaders(headers, packet, av, sv, oneway, action);
|
||||
} else {
|
||||
fillCommonAddressingHeaders(headers, packet, av, sv, action, false);
|
||||
|
||||
boolean isMessageIdAdded = false;
|
||||
|
||||
// wsa:ReplyTo
|
||||
// add if it doesn't already exist and OneWayFeature requests a specific ReplyTo
|
||||
if (headers.get(av.replyToTag, false) == null) {
|
||||
WSEndpointReference replyToEpr = oneWayFeature.getReplyTo();
|
||||
if (replyToEpr != null) {
|
||||
headers.add(replyToEpr.createHeader(av.replyToTag));
|
||||
// add wsa:MessageID only for non-null ReplyTo
|
||||
if (packet.getMessage().getHeaders().get(av.messageIDTag, false) == null) {
|
||||
// if header doesn't exist, method getID creates a new random id
|
||||
String newID = oneWayFeature.getMessageId() == null ? Message.generateMessageID() : oneWayFeature.getMessageId();
|
||||
headers.add(new StringHeader(av.messageIDTag, newID));
|
||||
isMessageIdAdded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the user sets a messageId, use it.
|
||||
final String messageId = oneWayFeature.getMessageId();
|
||||
if (!isMessageIdAdded && messageId != null) {
|
||||
headers.add(new StringHeader(av.messageIDTag, messageId));
|
||||
}
|
||||
|
||||
// wsa:FaultTo
|
||||
// add if it doesn't already exist and OneWayFeature requests a specific FaultTo
|
||||
if (headers.get(av.faultToTag, false) == null) {
|
||||
WSEndpointReference faultToEpr = oneWayFeature.getFaultTo();
|
||||
if (faultToEpr != null) {
|
||||
headers.add(faultToEpr.createHeader(av.faultToTag));
|
||||
// add wsa:MessageID only for non-null FaultTo
|
||||
if (headers.get(av.messageIDTag, false) == null) {
|
||||
headers.add(new StringHeader(av.messageIDTag, Message.generateMessageID()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// wsa:From
|
||||
if (oneWayFeature.getFrom() != null) {
|
||||
headers.addOrReplace(oneWayFeature.getFrom().createHeader(av.fromTag));
|
||||
}
|
||||
|
||||
// wsa:RelatesTo
|
||||
if (oneWayFeature.getRelatesToID() != null) {
|
||||
headers.addOrReplace(new RelatesToHeader(av.relatesToTag, oneWayFeature.getRelatesToID()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates wsa:To, wsa:Action and wsa:MessageID header on the client
|
||||
*
|
||||
* @param packet request packet
|
||||
* @param av WS-Addressing version
|
||||
* @param sv SOAP version
|
||||
* @param action Action Message Addressing Property value
|
||||
* @throws IllegalArgumentException if any of the parameters is null.
|
||||
*/
|
||||
private static void fillCommonAddressingHeaders(MessageHeaders headers, Packet packet, @NotNull AddressingVersion av, @NotNull SOAPVersion sv, @NotNull String action, boolean mustUnderstand) {
|
||||
if (packet == null) {
|
||||
throw new IllegalArgumentException(AddressingMessages.NULL_PACKET());
|
||||
}
|
||||
|
||||
if (av == null) {
|
||||
throw new IllegalArgumentException(AddressingMessages.NULL_ADDRESSING_VERSION());
|
||||
}
|
||||
|
||||
if (sv == null) {
|
||||
throw new IllegalArgumentException(AddressingMessages.NULL_SOAP_VERSION());
|
||||
}
|
||||
|
||||
if (action == null && !sv.httpBindingId.equals(SOAPBinding.SOAP12HTTP_BINDING)) {
|
||||
throw new IllegalArgumentException(AddressingMessages.NULL_ACTION());
|
||||
}
|
||||
|
||||
// wsa:To
|
||||
if (headers.get(av.toTag, false) == null) {
|
||||
StringHeader h = new StringHeader(av.toTag, packet.endpointAddress.toString());
|
||||
headers.add(h);
|
||||
}
|
||||
|
||||
// wsa:Action
|
||||
if (action != null) {
|
||||
packet.soapAction = action;
|
||||
if (headers.get(av.actionTag, false) == null) {
|
||||
//As per WS-I BP 1.2/2.0, if one of the WSA headers is MU, then all WSA headers should be treated as MU.,
|
||||
// so just set MU on action header
|
||||
StringHeader h = new StringHeader(av.actionTag, action, sv, mustUnderstand);
|
||||
headers.add(h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
100
jdkSrc/jdk8/com/sun/xml/internal/ws/api/message/Attachment.java
Normal file
100
jdkSrc/jdk8/com/sun/xml/internal/ws/api/message/Attachment.java
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* 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.api.message;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
|
||||
import javax.activation.DataHandler;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.transform.Source;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* Attachment.
|
||||
*/
|
||||
public interface Attachment {
|
||||
|
||||
/**
|
||||
* Content ID of the attachment. Uniquely identifies an attachment.
|
||||
*
|
||||
* http://www.ietf.org/rfc/rfc2392.txt (which is referred by the ws-i attachment profile
|
||||
* http://www.ws-i.org/Profiles/AttachmentsProfile-1.0.html)
|
||||
*
|
||||
* content-id = url-addr-spec
|
||||
* url-addr-spec = addr-spec ; URL encoding of RFC 822 addr-spec
|
||||
* cid-url = "cid" ":" content-id
|
||||
*
|
||||
* A "cid" URL is converted to the corresponding Content-ID message header [MIME] by
|
||||
* removing the "cid:" prefix, converting the % encoded character to their equivalent
|
||||
* US-ASCII characters, and enclosing the remaining parts with an angle bracket pair,
|
||||
* "<" and ">". For example, "cid:foo4%25foo1@bar.net" corresponds to
|
||||
* Content-ID: <foo4%25foo1@bar.net>
|
||||
*
|
||||
* @return
|
||||
* The content ID like "foo-bar-zot@abc.com", without
|
||||
* surrounding '<' and '>' used as the transfer syntax.
|
||||
*/
|
||||
@NotNull String getContentId();
|
||||
|
||||
/**
|
||||
* Gets the MIME content-type of this attachment.
|
||||
*/
|
||||
String getContentType();
|
||||
|
||||
/**
|
||||
* Gets the attachment as an exact-length byte array.
|
||||
*/
|
||||
byte[] asByteArray();
|
||||
|
||||
/**
|
||||
* Gets the attachment as a {@link DataHandler}.
|
||||
*/
|
||||
DataHandler asDataHandler();
|
||||
|
||||
/**
|
||||
* Gets the attachment as a {@link Source}.
|
||||
* Note that there's no guarantee that the attachment is actually an XML.
|
||||
*/
|
||||
Source asSource();
|
||||
|
||||
/**
|
||||
* Obtains this attachment as an {@link InputStream}.
|
||||
*/
|
||||
InputStream asInputStream();
|
||||
|
||||
/**
|
||||
* Writes the contents of the attachment into the given stream.
|
||||
*/
|
||||
void writeTo(OutputStream os) throws IOException;
|
||||
|
||||
/**
|
||||
* Writes this attachment to the given {@link SOAPMessage}.
|
||||
*/
|
||||
void writeTo(SOAPMessage saaj) throws SOAPException;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.api.message;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Attachment extended interface exposing custom MIME headers.
|
||||
* @since 2.2.6
|
||||
*/
|
||||
public interface AttachmentEx extends Attachment {
|
||||
/**
|
||||
* MIME header
|
||||
*/
|
||||
public interface MimeHeader {
|
||||
/**
|
||||
* MIME header name
|
||||
* @return name
|
||||
*/
|
||||
public String getName();
|
||||
/**
|
||||
* MIME header value
|
||||
* @return value
|
||||
*/
|
||||
public String getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterator of custom MIME headers associated with this attachment
|
||||
* @return MIME header iterator
|
||||
*/
|
||||
public @NotNull Iterator<MimeHeader> getMimeHeaders();
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.api.message;
|
||||
|
||||
import com.sun.istack.internal.Nullable;
|
||||
|
||||
/**
|
||||
* A set of {@link Attachment} on a {@link Message}.
|
||||
*
|
||||
* <p>
|
||||
* A particular attention is made to ensure that attachments
|
||||
* can be read and parsed lazily as requested.
|
||||
*
|
||||
* @see Message#getAttachments()
|
||||
*/
|
||||
public interface AttachmentSet extends Iterable<Attachment> {
|
||||
/**
|
||||
* Gets the attachment by the content ID.
|
||||
*
|
||||
* @param contentId
|
||||
* The content ID like "foo-bar-zot@abc.com", without
|
||||
* surrounding '<' and '>' used as the transfer syntax.
|
||||
*
|
||||
* @return null
|
||||
* if no such attachment exist.
|
||||
*/
|
||||
@Nullable
|
||||
Attachment get(String contentId);
|
||||
|
||||
/**
|
||||
* Returns true if there's no attachment.
|
||||
*/
|
||||
boolean isEmpty();
|
||||
|
||||
/**
|
||||
* Adds an attachment to this set.
|
||||
*
|
||||
* <p>
|
||||
* Note that it's OK for an {@link Attachment} to belong to
|
||||
* more than one {@link AttachmentSet} (which is in fact
|
||||
* necessary when you wrap a {@link Message} into another.
|
||||
*
|
||||
* @param att
|
||||
* must not be null.
|
||||
*/
|
||||
public void add(Attachment att);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.api.message;
|
||||
|
||||
import com.sun.xml.internal.ws.util.exception.JAXWSExceptionBase;
|
||||
import com.sun.xml.internal.ws.protocol.soap.VersionMismatchException;
|
||||
|
||||
/**
|
||||
* This class represents an Exception that needs to be marshalled
|
||||
* with a specific protocol wire format. For example, the SOAP's
|
||||
* VersionMismatchFault needs to be written with a correct fault code.
|
||||
* In that case, decoder could throw {@link VersionMismatchException},
|
||||
* and the corresponding fault {@link Message} from {@link ExceptionHasMessage#getFaultMessage()}
|
||||
* is sent on the wire.
|
||||
*
|
||||
* @author Jitendra Kotamraju
|
||||
*/
|
||||
public abstract class ExceptionHasMessage extends JAXWSExceptionBase {
|
||||
|
||||
public ExceptionHasMessage(String key, Object... args) {
|
||||
super(key, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the exception into a fault Message
|
||||
*
|
||||
* @return Message for this exception
|
||||
*/
|
||||
public abstract Message getFaultMessage();
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* 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.api.message;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.bind.api.Bridge;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.spi.db.XMLBridge;
|
||||
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.transform.Source;
|
||||
|
||||
/**
|
||||
* A <code>FilterMessageImpl</code> contains some other Message, which it uses
|
||||
* as its basic source of message data, possibly transforming the data along
|
||||
* the way or providing additional functionality.
|
||||
*
|
||||
* <p>
|
||||
* The class <code>FilterMessageImpl</code> itself simply overrides
|
||||
* all the methods of <code>Message</code> and invokes them on
|
||||
* contained Message delegate. Subclasses of <code>FilterMessageImpl</code>
|
||||
* may further override some of these methods and may also provide
|
||||
* additional methods and fields.
|
||||
*
|
||||
* @author Jitendra Kotamraju
|
||||
*/
|
||||
public class FilterMessageImpl extends Message {
|
||||
private final Message delegate;
|
||||
|
||||
protected FilterMessageImpl(Message delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public boolean hasHeaders() {
|
||||
return delegate.hasHeaders();
|
||||
}
|
||||
|
||||
public @NotNull MessageHeaders getHeaders() {
|
||||
return delegate.getHeaders();
|
||||
}
|
||||
|
||||
public @NotNull AttachmentSet getAttachments() {
|
||||
return delegate.getAttachments();
|
||||
}
|
||||
|
||||
protected boolean hasAttachments() {
|
||||
return delegate.hasAttachments();
|
||||
}
|
||||
|
||||
public boolean isOneWay(@NotNull WSDLPort port) {
|
||||
return delegate.isOneWay(port);
|
||||
}
|
||||
|
||||
public @Nullable String getPayloadLocalPart() {
|
||||
return delegate.getPayloadLocalPart();
|
||||
}
|
||||
|
||||
public String getPayloadNamespaceURI() {
|
||||
return delegate.getPayloadNamespaceURI();
|
||||
}
|
||||
|
||||
public boolean hasPayload() {
|
||||
return delegate.hasPayload();
|
||||
}
|
||||
|
||||
public boolean isFault() {
|
||||
return delegate.isFault();
|
||||
}
|
||||
|
||||
public @Nullable QName getFirstDetailEntryName() {
|
||||
return delegate.getFirstDetailEntryName();
|
||||
}
|
||||
|
||||
public Source readEnvelopeAsSource() {
|
||||
return delegate.readEnvelopeAsSource();
|
||||
}
|
||||
|
||||
public Source readPayloadAsSource() {
|
||||
return delegate.readPayloadAsSource();
|
||||
}
|
||||
|
||||
public SOAPMessage readAsSOAPMessage() throws SOAPException {
|
||||
return delegate.readAsSOAPMessage();
|
||||
}
|
||||
|
||||
public SOAPMessage readAsSOAPMessage(Packet packet, boolean inbound) throws SOAPException {
|
||||
return delegate.readAsSOAPMessage(packet, inbound);
|
||||
}
|
||||
|
||||
public <T> T readPayloadAsJAXB(Unmarshaller unmarshaller) throws JAXBException {
|
||||
return (T)delegate.readPayloadAsJAXB(unmarshaller);
|
||||
}
|
||||
/** @deprecated */
|
||||
public <T> T readPayloadAsJAXB(Bridge<T> bridge) throws JAXBException {
|
||||
return delegate.readPayloadAsJAXB(bridge);
|
||||
}
|
||||
|
||||
public <T> T readPayloadAsJAXB(XMLBridge<T> bridge) throws JAXBException {
|
||||
return delegate.readPayloadAsJAXB(bridge);
|
||||
}
|
||||
|
||||
public XMLStreamReader readPayload() throws XMLStreamException {
|
||||
return delegate.readPayload();
|
||||
}
|
||||
|
||||
public void consume() {
|
||||
delegate.consume();
|
||||
}
|
||||
|
||||
public void writePayloadTo(XMLStreamWriter sw) throws XMLStreamException {
|
||||
delegate.writePayloadTo(sw);
|
||||
}
|
||||
|
||||
public void writeTo(XMLStreamWriter sw) throws XMLStreamException {
|
||||
delegate.writeTo(sw);
|
||||
}
|
||||
|
||||
public void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler) throws SAXException {
|
||||
delegate.writeTo(contentHandler, errorHandler);
|
||||
}
|
||||
|
||||
public Message copy() {
|
||||
return delegate.copy();
|
||||
}
|
||||
|
||||
public @NotNull String getID(@NotNull WSBinding binding) {
|
||||
return delegate.getID(binding);
|
||||
}
|
||||
|
||||
public @NotNull String getID(AddressingVersion av, SOAPVersion sv) {
|
||||
return delegate.getID(av, sv);
|
||||
}
|
||||
|
||||
public SOAPVersion getSOAPVersion() {
|
||||
return delegate.getSOAPVersion();
|
||||
}
|
||||
}
|
||||
334
jdkSrc/jdk8/com/sun/xml/internal/ws/api/message/Header.java
Normal file
334
jdkSrc/jdk8/com/sun/xml/internal/ws/api/message/Header.java
Normal file
@@ -0,0 +1,334 @@
|
||||
/*
|
||||
* 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.api.message;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.bind.api.Bridge;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
||||
import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
|
||||
import com.sun.xml.internal.ws.spi.db.XMLBridge;
|
||||
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* A SOAP header.
|
||||
*
|
||||
* <p>
|
||||
* A header is immutable, but unlike body it can be read
|
||||
* multiple times.
|
||||
* The {@link Header} abstraction hides how the header
|
||||
* data is represented in memory; instead, it commits to
|
||||
* the ability to write itself to XML infoset.
|
||||
*
|
||||
* <p>
|
||||
* When a message is received from the transport and
|
||||
* being processed, the processor needs to "peek"
|
||||
* some information of a header, such as the tag name,
|
||||
* the mustUnderstand attribute, and so on. Therefore,
|
||||
* the {@link Header} interface exposes those information
|
||||
* as properties, so that they can be checked without
|
||||
* replaying the infoset, which is efficiently but still
|
||||
* costly.
|
||||
*
|
||||
* <p>
|
||||
* A {@link Header} may belong to more than one {@link HeaderList}
|
||||
* due to wrapping of {@link Message}.
|
||||
*
|
||||
* @see HeaderList
|
||||
* @see Headers
|
||||
*/
|
||||
public interface Header {
|
||||
// TODO: Vivek pointed out that the only time we are looking at
|
||||
// mustUnderstand and role are when we do the mustUnderstand error check
|
||||
// (that is, to find out if there's any header with @mustUnderstand that
|
||||
// has appropriate role for us.)
|
||||
// if that's the case, it might be better if we define this whole operation
|
||||
// as one method, instead of exposing two properties.
|
||||
|
||||
/**
|
||||
* Checks if this header is ignorable for us (IOW, make sure
|
||||
* that this header has a problematic "mustUnderstand" header value
|
||||
* that we have to reject.)
|
||||
*
|
||||
* <p>
|
||||
* This method is used as a part of the
|
||||
* <a href="HeaderList.html#MU">mustUnderstanx processing</a>.
|
||||
* At the end of the processing, the JAX-WS identifies a list of {@link Header}s
|
||||
* that were not understood. This method is invoked on those {@link Header}s,
|
||||
* to verify that we don't need to report an error for it.
|
||||
*
|
||||
* <p>
|
||||
* specifically, this method has to perform the following tasks:
|
||||
*
|
||||
* <ul>
|
||||
* <li>If this header does not have <tt>mustUnderstand</tt> as "1" nor "true",
|
||||
* then this method must return true.
|
||||
* <li>Otherwise, check the role attribute (for SOAP 1.2) or the actor attribute (for SOAP 1.1).
|
||||
* When those attributes are absent, the default values have to be assumed.
|
||||
* See {@link #getRole(SOAPVersion)} for how the values are defaulted.
|
||||
* Now, see if the {@code roles} set contains the value.
|
||||
* If so, this method must return false (indicating that an error is in order.)
|
||||
* <li>Otherwise return true (since we don't play the role this header is intended for.)
|
||||
* </ul>
|
||||
*
|
||||
* @param soapVersion
|
||||
* The caller specifies the SOAP version that the pipeline is working against.
|
||||
* Often each {@link Header} implementation already knows the SOAP version
|
||||
* anyway, but this allows some {@link Header}s to avoid keeping it.
|
||||
* That's why this redundant parameter is passed in.
|
||||
* @param roles
|
||||
* The set of role values that the current JAX-WS pipeline is assuming.
|
||||
* Note that SOAP 1.1 and SOAP 1.2 use different strings for the same role,
|
||||
* and the caller is responsible for supplying a proper value depending on the
|
||||
* active SOAP version in use.
|
||||
*
|
||||
* @return
|
||||
* true if no error needs to be reported. False if an error needs to be raised.
|
||||
* See the method javadoc for more discussion.
|
||||
*/
|
||||
public boolean isIgnorable(@NotNull SOAPVersion soapVersion, @NotNull Set<String> roles);
|
||||
|
||||
/**
|
||||
* Gets the value of the soap:role attribute (or soap:actor for SOAP 1.1).
|
||||
*
|
||||
* <p>
|
||||
* If the attribute is omitted, the value defaults to {@link SOAPVersion#implicitRole}.
|
||||
*
|
||||
* @param soapVersion
|
||||
* The caller specifies the SOAP version that the pipeline is working against.
|
||||
* Often each {@link Header} implementation already knows the SOAP version
|
||||
* anyway, but this allows some {@link Header}s to avoid keeping it.
|
||||
* That's why this redundant parameter is passed in.
|
||||
* @return
|
||||
* never null. This string need not be interned.
|
||||
*/
|
||||
public @NotNull String getRole(@NotNull SOAPVersion soapVersion);
|
||||
|
||||
/**
|
||||
* True if this header is to be relayed if not processed.
|
||||
* For SOAP 1.1 messages, this method always return false.
|
||||
*
|
||||
* <p>
|
||||
* IOW, this method returns true if there's @soap:relay='true'
|
||||
* is present.
|
||||
*
|
||||
* <h3>Implementation Note</h3>
|
||||
* <p>
|
||||
* The implementation needs to check for both "true" and "1",
|
||||
* but because attribute values are normalized, it doesn't have
|
||||
* to consider " true", " 1 ", and so on.
|
||||
*
|
||||
* @return
|
||||
* false.
|
||||
*/
|
||||
public boolean isRelay();
|
||||
|
||||
/**
|
||||
* Gets the namespace URI of this header element.
|
||||
*
|
||||
* @return
|
||||
* this string must be interned.
|
||||
*/
|
||||
public @NotNull String getNamespaceURI();
|
||||
|
||||
/**
|
||||
* Gets the local name of this header element.
|
||||
*
|
||||
* @return
|
||||
* this string must be interned.
|
||||
*/
|
||||
public @NotNull String getLocalPart();
|
||||
|
||||
/**
|
||||
* Gets the attribute value on the header element.
|
||||
*
|
||||
* @param nsUri
|
||||
* The namespace URI of the attribute. Can be empty.
|
||||
* @param localName
|
||||
* The local name of the attribute.
|
||||
*
|
||||
* @return
|
||||
* if the attribute is found, return the whitespace normalized value.
|
||||
* (meaning no leading/trailing space, no consequtive whitespaces in-between.)
|
||||
* Otherwise null. Note that the XML parsers are responsible for
|
||||
* whitespace-normalizing attributes, so {@link Header} implementation
|
||||
* doesn't have to do anything.
|
||||
*/
|
||||
@Nullable String getAttribute(@NotNull String nsUri, @NotNull String localName);
|
||||
|
||||
/**
|
||||
* Gets the attribute value on the header element.
|
||||
*
|
||||
* <p>
|
||||
* This is a convenience method that calls into {@link #getAttribute(String, String)}
|
||||
*
|
||||
* @param name
|
||||
* Never null.
|
||||
*
|
||||
* @see #getAttribute(String, String)
|
||||
*/
|
||||
@Nullable String getAttribute(@NotNull QName name);
|
||||
|
||||
/**
|
||||
* Reads the header as a {@link XMLStreamReader}.
|
||||
*
|
||||
* <p>
|
||||
* The returned parser points at the start element of this header.
|
||||
* (IOW, {@link XMLStreamReader#getEventType()} would return
|
||||
* {@link XMLStreamReader#START_ELEMENT}.
|
||||
*
|
||||
* <h3>Performance Expectation</h3>
|
||||
* <p>
|
||||
* For some {@link Header} implementations, this operation
|
||||
* is a non-trivial operation. Therefore, use of this method
|
||||
* is discouraged unless the caller is interested in reading
|
||||
* the whole header.
|
||||
*
|
||||
* <p>
|
||||
* Similarly, if the caller wants to use this method only to do
|
||||
* the API conversion (such as simply firing SAX events from
|
||||
* {@link XMLStreamReader}), then the JAX-WS team requests
|
||||
* that you talk to us.
|
||||
*
|
||||
* <p>
|
||||
* {@link Message}s that come from tranport usually provides
|
||||
* a reasonably efficient implementation of this method.
|
||||
*
|
||||
* @return
|
||||
* must not null.
|
||||
*/
|
||||
public XMLStreamReader readHeader() throws XMLStreamException;
|
||||
|
||||
/**
|
||||
* Reads the header as a JAXB object by using the given unmarshaller.
|
||||
*/
|
||||
public <T> T readAsJAXB(Unmarshaller unmarshaller) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Reads the header as a JAXB object by using the given unmarshaller.
|
||||
* @deprecated
|
||||
*/
|
||||
public <T> T readAsJAXB(Bridge<T> bridge) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Reads the header as a data-bond object
|
||||
*/
|
||||
public <T> T readAsJAXB(XMLBridge<T> bridge) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Reads this header as an {@link WSEndpointReference}.
|
||||
*
|
||||
* @param expected
|
||||
* The version of the addressing used to parse the EPR.
|
||||
* If the actual infoset and this doesn't agree, then
|
||||
* you'll get an {@link WebServiceException} stating that fact.
|
||||
*
|
||||
* @return
|
||||
* On a successful return, this method never returns null.
|
||||
*/
|
||||
public @NotNull WSEndpointReference readAsEPR(AddressingVersion expected) throws XMLStreamException;
|
||||
|
||||
/**
|
||||
* Writes out the header as a fragment.
|
||||
*
|
||||
* @throws XMLStreamException
|
||||
* if the operation fails for some reason. This leaves the
|
||||
* writer to an undefined state.
|
||||
*/
|
||||
public void writeTo(XMLStreamWriter w) throws XMLStreamException;
|
||||
|
||||
/**
|
||||
* Writes out the header to the given SOAPMessage.
|
||||
*
|
||||
* <p>
|
||||
* Sometimes a {@link Message} needs to produce itself
|
||||
* as {@link SOAPMessage}, in which case each header needs
|
||||
* to turn itself into a header.
|
||||
*
|
||||
* @throws SOAPException
|
||||
* if the operation fails for some reason. This leaves the
|
||||
* writer to an undefined state.
|
||||
*/
|
||||
public void writeTo(SOAPMessage saaj) throws SOAPException;
|
||||
|
||||
/**
|
||||
* Writes out the header as SAX events.
|
||||
*
|
||||
* <p>
|
||||
* Sometimes a {@link Message} needs to produce SAX events,
|
||||
* and this method is necessary for headers to participate to it.
|
||||
*
|
||||
* <p>
|
||||
* A header is responsible for producing the SAX events for its part,
|
||||
* including <tt>startPrefixMapping</tt> and <tt>endPrefixMapping</tt>,
|
||||
* but not startDocument/endDocument.
|
||||
*
|
||||
* <p>
|
||||
* Note that SAX contract requires that any error that does NOT originate
|
||||
* from {@link ContentHandler} (meaning any parsing error and etc) must
|
||||
* be first reported to {@link ErrorHandler}. If the SAX event production
|
||||
* cannot be continued and the processing needs to abort, the code may
|
||||
* then throw the same {@link SAXParseException} reported to {@link ErrorHandler}.
|
||||
*
|
||||
* @param contentHandler
|
||||
* The {@link ContentHandler} that receives SAX events.
|
||||
*
|
||||
* @param errorHandler
|
||||
* The {@link ErrorHandler} that receives parsing errors.
|
||||
*/
|
||||
public void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler) throws SAXException;
|
||||
|
||||
/**
|
||||
* Used to obtain value XYZ from a header that looks like
|
||||
* "<header>XYZ</header>". The primary use of this header
|
||||
* for now is to access certain Addressing headers quickly.
|
||||
*
|
||||
* @throws WebServiceException
|
||||
* If the structure of the header is more complicated than
|
||||
* a simple string header.
|
||||
*
|
||||
* @return
|
||||
* Can be empty but always non-null.
|
||||
*/
|
||||
public @NotNull String getStringContent();
|
||||
}
|
||||
976
jdkSrc/jdk8/com/sun/xml/internal/ws/api/message/HeaderList.java
Normal file
976
jdkSrc/jdk8/com/sun/xml/internal/ws/api/message/HeaderList.java
Normal file
@@ -0,0 +1,976 @@
|
||||
/*
|
||||
* 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.api.message;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
||||
import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.api.pipe.Codec;
|
||||
import com.sun.xml.internal.ws.api.pipe.Pipe;
|
||||
import com.sun.xml.internal.ws.binding.SOAPBindingImpl;
|
||||
import com.sun.xml.internal.ws.protocol.soap.ClientMUTube;
|
||||
import com.sun.xml.internal.ws.protocol.soap.ServerMUTube;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* A list of {@link Header}s on a {@link Message}.
|
||||
*
|
||||
* <p>
|
||||
* This list can be modified to add headers
|
||||
* from outside a {@link Message}, this is necessary
|
||||
* since intermediate processing layers often need to
|
||||
* put additional headers.
|
||||
*
|
||||
* <p>
|
||||
* Following the SOAP convention, the order among headers
|
||||
* are not significant. However, {@link Codec}s are
|
||||
* expected to preserve the order of headers in the input
|
||||
* message as much as possible.
|
||||
*
|
||||
*
|
||||
* <a name="MU"></a>
|
||||
* <h3>MustUnderstand Processing</h3>
|
||||
* <p>
|
||||
* To perform SOAP mustUnderstang processing correctly, we need to keep
|
||||
* track of headers that are understood and headers that are not.
|
||||
* This is a collaborative process among {@link Pipe}s, thus it's something
|
||||
* a {@link Pipe} author needs to keep in mind.
|
||||
*
|
||||
* <p>
|
||||
* Specifically, when a {@link Pipe} sees a header and processes it
|
||||
* (that is, if it did enough computing with the header to claim that
|
||||
* the header is understood), then it should mark the corresponding
|
||||
* header as "understood". For example, when a pipe that handles JAX-WSA
|
||||
* examins the <wsa:To> header, it can claim that it understood the header.
|
||||
* But for example, if a pipe that does the signature verification checks
|
||||
* <wsa:To> for a signature, that would not be considered as "understood".
|
||||
*
|
||||
* <p>
|
||||
* There are two ways to mark a header as understood:
|
||||
*
|
||||
* <ol>
|
||||
* <li>Use one of the <tt>getXXX</tt> methods that take a
|
||||
* boolean <tt>markAsUnderstood</tt> parameter.
|
||||
* Most often, a {@link Pipe} knows it's going to understand a header
|
||||
* as long as it's present, so this is the easiest and thus the preferred way.
|
||||
*
|
||||
* For example, if JAX-WSA looks for <wsa:To>, then it can set
|
||||
* <tt>markAsUnderstand</tt> to true, to do the obtaining of a header
|
||||
* and marking at the same time.
|
||||
*
|
||||
* <li>Call {@link #understood(int)}.
|
||||
* If under a rare circumstance, a pipe cannot determine whether
|
||||
* it can understand it or not when you are fetching a header, then
|
||||
* you can use this method afterward to mark it as understood.
|
||||
* </ol>
|
||||
*
|
||||
* <p>
|
||||
* Intuitively speaking, at the end of the day, if a header is not
|
||||
* understood but {@link Header#isIgnorable(SOAPVersion, java.util.Set)} is false, a bad thing
|
||||
* will happen. The actual implementation of the checking is more complicated,
|
||||
* for that see {@link ClientMUTube}/{@link ServerMUTube}.
|
||||
*
|
||||
* @see Message#getHeaders()
|
||||
*/
|
||||
public class HeaderList extends ArrayList<Header> implements MessageHeaders {
|
||||
|
||||
private static final long serialVersionUID = -6358045781349627237L;
|
||||
/**
|
||||
* Bit set to keep track of which headers are understood.
|
||||
* <p>
|
||||
* The first 32 headers use this field, and the rest will use
|
||||
* {@link #moreUnderstoodBits}. The expectation is that
|
||||
* most of the time a SOAP message will only have up to 32 headers,
|
||||
* so we can avoid allocating separate objects for {@link BitSet}.
|
||||
*/
|
||||
private int understoodBits;
|
||||
/**
|
||||
* If there are more than 32 headers, we use this {@link BitSet}
|
||||
* to keep track of whether those headers are understood.
|
||||
* Lazily allocated.
|
||||
*/
|
||||
private BitSet moreUnderstoodBits = null;
|
||||
|
||||
private SOAPVersion soapVersion;
|
||||
|
||||
/**
|
||||
* This method is deprecated - instead use this one:
|
||||
* public HeaderList(SOAPVersion)
|
||||
* Creates an empty {@link HeaderList}.
|
||||
*/
|
||||
@Deprecated
|
||||
public HeaderList() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an empty {@link HeaderList} with the given soap version
|
||||
* @param soapVersion
|
||||
*/
|
||||
public HeaderList(SOAPVersion soapVersion) {
|
||||
this.soapVersion = soapVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
*/
|
||||
public HeaderList(HeaderList that) {
|
||||
super(that);
|
||||
this.understoodBits = that.understoodBits;
|
||||
if (that.moreUnderstoodBits != null) {
|
||||
this.moreUnderstoodBits = (BitSet) that.moreUnderstoodBits.clone();
|
||||
}
|
||||
}
|
||||
|
||||
public HeaderList(MessageHeaders that) {
|
||||
super(that.asList());
|
||||
if (that instanceof HeaderList) {
|
||||
HeaderList hThat = (HeaderList) that;
|
||||
this.understoodBits = hThat.understoodBits;
|
||||
if (hThat.moreUnderstoodBits != null) {
|
||||
this.moreUnderstoodBits = (BitSet) hThat.moreUnderstoodBits.clone();
|
||||
}
|
||||
} else {
|
||||
Set<QName> understood = that.getUnderstoodHeaders();
|
||||
if (understood != null) {
|
||||
for (QName qname : understood) {
|
||||
understood(qname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The total number of headers.
|
||||
*/
|
||||
@Override
|
||||
public int size() {
|
||||
return super.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasHeaders() {
|
||||
return !isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all the headers.
|
||||
* @deprecated throws UnsupportedOperationException from some HeaderList implementations - better iterate over items one by one
|
||||
*/
|
||||
@Deprecated
|
||||
public void addAll(Header... headers) {
|
||||
addAll(Arrays.asList(headers));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link Header} at the specified index.
|
||||
*
|
||||
* <p>
|
||||
* This method does not mark the returned {@link Header} as understood.
|
||||
*
|
||||
* @see #understood(int)
|
||||
*/
|
||||
@Override
|
||||
public Header get(int index) {
|
||||
return super.get(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the {@link Header} at the specified index as
|
||||
* <a href="#MU">"understood"</a>.
|
||||
*/
|
||||
public void understood(int index) {
|
||||
// check that index is in range
|
||||
if (index >= size()) {
|
||||
throw new ArrayIndexOutOfBoundsException(index);
|
||||
}
|
||||
|
||||
if (index < 32) {
|
||||
understoodBits |= 1 << index;
|
||||
} else {
|
||||
if (moreUnderstoodBits == null) {
|
||||
moreUnderstoodBits = new BitSet();
|
||||
}
|
||||
moreUnderstoodBits.set(index - 32);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a {@link Header} at the given index
|
||||
* was <a href="#MU">"understood"</a>.
|
||||
*/
|
||||
public boolean isUnderstood(int index) {
|
||||
// check that index is in range
|
||||
if (index >= size()) {
|
||||
throw new ArrayIndexOutOfBoundsException(index);
|
||||
}
|
||||
|
||||
if (index < 32) {
|
||||
return understoodBits == (understoodBits | (1 << index));
|
||||
} else {
|
||||
if (moreUnderstoodBits == null) {
|
||||
return false;
|
||||
}
|
||||
return moreUnderstoodBits.get(index - 32);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the specified {@link Header} as <a href="#MU">"understood"</a>.
|
||||
*
|
||||
* @deprecated
|
||||
* By the definition of {@link ArrayList}, this operation requires
|
||||
* O(n) search of the array, and thus inherently inefficient.
|
||||
*
|
||||
* Because of this, if you are developing a {@link Pipe} for
|
||||
* a performance sensitive environment, do not use this method.
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* if the given header is not {@link #contains(Object) contained}
|
||||
* in this header.
|
||||
*/
|
||||
@Override
|
||||
public void understood(@NotNull Header header) {
|
||||
int sz = size();
|
||||
for (int i = 0; i < sz; i++) {
|
||||
if (get(i) == header) {
|
||||
understood(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first {@link Header} of the specified name.
|
||||
*
|
||||
* @param markAsUnderstood
|
||||
* If this parameter is true, the returned header will
|
||||
* be marked as <a href="#MU">"understood"</a>.
|
||||
* @return null if not found.
|
||||
*/
|
||||
@Override
|
||||
public @Nullable Header get(@NotNull String nsUri, @NotNull String localName, boolean markAsUnderstood) {
|
||||
int len = size();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Header h = get(i);
|
||||
if (h.getLocalPart().equals(localName) && h.getNamespaceURI().equals(nsUri)) {
|
||||
if (markAsUnderstood) {
|
||||
understood(i);
|
||||
}
|
||||
return h;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Use {@link #get(String, String, boolean)}
|
||||
*/
|
||||
public Header get(String nsUri, String localName) {
|
||||
return get(nsUri, localName, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first {@link Header} of the specified name.
|
||||
*
|
||||
* @param markAsUnderstood
|
||||
* If this parameter is true, the returned header will
|
||||
* be marked as <a href="#MU">"understood"</a>.
|
||||
* @return null
|
||||
* if not found.
|
||||
*/
|
||||
@Override
|
||||
public @Nullable Header get(@NotNull QName name, boolean markAsUnderstood) {
|
||||
return get(name.getNamespaceURI(), name.getLocalPart(), markAsUnderstood);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Use {@link #get(QName)}
|
||||
*/
|
||||
public
|
||||
@Nullable
|
||||
Header get(@NotNull QName name) {
|
||||
return get(name, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Use {@link #getHeaders(String, String, boolean)}
|
||||
*/
|
||||
public Iterator<Header> getHeaders(final String nsUri, final String localName) {
|
||||
return getHeaders(nsUri, localName, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the {@link Header}s of the specified name,
|
||||
* including duplicates (if any.)
|
||||
*
|
||||
* @param markAsUnderstood
|
||||
* If this parameter is true, the returned headers will
|
||||
* be marked as <a href="#MU">"understood"</a> when they are returned
|
||||
* from {@link Iterator#next()}.
|
||||
* @return empty iterator if not found.
|
||||
*/
|
||||
public
|
||||
@NotNull
|
||||
@Override
|
||||
Iterator<Header> getHeaders(@NotNull final String nsUri, @NotNull final String localName, final boolean markAsUnderstood) {
|
||||
return new Iterator<Header>() {
|
||||
|
||||
int idx = 0;
|
||||
Header next;
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
if (next == null) {
|
||||
fetch();
|
||||
}
|
||||
return next != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Header next() {
|
||||
if (next == null) {
|
||||
fetch();
|
||||
if (next == null) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
}
|
||||
|
||||
if (markAsUnderstood) {
|
||||
assert get(idx - 1) == next;
|
||||
understood(idx - 1);
|
||||
}
|
||||
|
||||
Header r = next;
|
||||
next = null;
|
||||
return r;
|
||||
}
|
||||
|
||||
private void fetch() {
|
||||
while (idx < size()) {
|
||||
Header h = get(idx++);
|
||||
if (h.getLocalPart().equals(localName) && h.getNamespaceURI().equals(nsUri)) {
|
||||
next = h;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #getHeaders(String, String, boolean)
|
||||
*/
|
||||
public
|
||||
@NotNull
|
||||
@Override
|
||||
Iterator<Header> getHeaders(@NotNull QName headerName, final boolean markAsUnderstood) {
|
||||
return getHeaders(headerName.getNamespaceURI(), headerName.getLocalPart(), markAsUnderstood);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* use {@link #getHeaders(String, boolean)}.
|
||||
*/
|
||||
public
|
||||
@NotNull
|
||||
Iterator<Header> getHeaders(@NotNull final String nsUri) {
|
||||
return getHeaders(nsUri, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an iteration of headers {@link Header} in the specified namespace,
|
||||
* including duplicates (if any.)
|
||||
*
|
||||
* @param markAsUnderstood
|
||||
* If this parameter is true, the returned headers will
|
||||
* be marked as <a href="#MU">"understood"</a> when they are returned
|
||||
* from {@link Iterator#next()}.
|
||||
* @return
|
||||
* empty iterator if not found.
|
||||
*/
|
||||
public
|
||||
@NotNull
|
||||
@Override
|
||||
Iterator<Header> getHeaders(@NotNull final String nsUri, final boolean markAsUnderstood) {
|
||||
return new Iterator<Header>() {
|
||||
|
||||
int idx = 0;
|
||||
Header next;
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
if (next == null) {
|
||||
fetch();
|
||||
}
|
||||
return next != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Header next() {
|
||||
if (next == null) {
|
||||
fetch();
|
||||
if (next == null) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
}
|
||||
|
||||
if (markAsUnderstood) {
|
||||
assert get(idx - 1) == next;
|
||||
understood(idx - 1);
|
||||
}
|
||||
|
||||
Header r = next;
|
||||
next = null;
|
||||
return r;
|
||||
}
|
||||
|
||||
private void fetch() {
|
||||
while (idx < size()) {
|
||||
Header h = get(idx++);
|
||||
if (h.getNamespaceURI().equals(nsUri)) {
|
||||
next = h;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of WS-Addressing <code>To</code> header. The <code>version</code>
|
||||
* identifies the WS-Addressing version and the header returned is targeted at
|
||||
* the current implicit role. Caches the value for subsequent invocation.
|
||||
* Duplicate <code>To</code> headers are detected earlier.
|
||||
*
|
||||
* @param av WS-Addressing version
|
||||
* @param sv SOAP version
|
||||
* @throws IllegalArgumentException if either <code>av</code> or <code>sv</code> is null.
|
||||
* @return Value of WS-Addressing To header, anonymous URI if no header is present
|
||||
*/
|
||||
public String getTo(AddressingVersion av, SOAPVersion sv) {
|
||||
return AddressingUtils.getTo(this, av, sv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of WS-Addressing <code>Action</code> header. The <code>version</code>
|
||||
* identifies the WS-Addressing version and the header returned is targeted at
|
||||
* the current implicit role. Caches the value for subsequent invocation.
|
||||
* Duplicate <code>Action</code> headers are detected earlier.
|
||||
*
|
||||
* @param av WS-Addressing version
|
||||
* @param sv SOAP version
|
||||
* @throws IllegalArgumentException if either <code>av</code> or <code>sv</code> is null.
|
||||
* @return Value of WS-Addressing Action header, null if no header is present
|
||||
*/
|
||||
public String getAction(@NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
|
||||
return AddressingUtils.getAction(this, av, sv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of WS-Addressing <code>ReplyTo</code> header. The <code>version</code>
|
||||
* identifies the WS-Addressing version and the header returned is targeted at
|
||||
* the current implicit role. Caches the value for subsequent invocation.
|
||||
* Duplicate <code>ReplyTo</code> headers are detected earlier.
|
||||
*
|
||||
* @param av WS-Addressing version
|
||||
* @param sv SOAP version
|
||||
* @throws IllegalArgumentException if either <code>av</code> or <code>sv</code> is null.
|
||||
* @return Value of WS-Addressing ReplyTo header, null if no header is present
|
||||
*/
|
||||
public WSEndpointReference getReplyTo(@NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
|
||||
return AddressingUtils.getReplyTo(this, av, sv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of WS-Addressing <code>FaultTo</code> header. The <code>version</code>
|
||||
* identifies the WS-Addressing version and the header returned is targeted at
|
||||
* the current implicit role. Caches the value for subsequent invocation.
|
||||
* Duplicate <code>FaultTo</code> headers are detected earlier.
|
||||
*
|
||||
* @param av WS-Addressing version
|
||||
* @param sv SOAP version
|
||||
* @throws IllegalArgumentException if either <code>av</code> or <code>sv</code> is null.
|
||||
* @return Value of WS-Addressing FaultTo header, null if no header is present
|
||||
*/
|
||||
public WSEndpointReference getFaultTo(@NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
|
||||
return AddressingUtils.getFaultTo(this, av, sv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of WS-Addressing <code>MessageID</code> header. The <code>version</code>
|
||||
* identifies the WS-Addressing version and the header returned is targeted at
|
||||
* the current implicit role. Caches the value for subsequent invocation.
|
||||
* Duplicate <code>MessageID</code> headers are detected earlier.
|
||||
*
|
||||
* @param av WS-Addressing version
|
||||
* @param sv SOAP version
|
||||
* @throws WebServiceException if either <code>av</code> or <code>sv</code> is null.
|
||||
* @return Value of WS-Addressing MessageID header, null if no header is present
|
||||
*/
|
||||
public String getMessageID(@NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
|
||||
return AddressingUtils.getMessageID(this, av, sv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of WS-Addressing <code>RelatesTo</code> header. The <code>version</code>
|
||||
* identifies the WS-Addressing version and the header returned is targeted at
|
||||
* the current implicit role. Caches the value for subsequent invocation.
|
||||
* Duplicate <code>RelatesTo</code> headers are detected earlier.
|
||||
*
|
||||
* @param av WS-Addressing version
|
||||
* @param sv SOAP version
|
||||
* @throws WebServiceException if either <code>av</code> or <code>sv</code> is null.
|
||||
* @return Value of WS-Addressing RelatesTo header, null if no header is present
|
||||
*/
|
||||
public String getRelatesTo(@NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
|
||||
return AddressingUtils.getRelatesTo(this, av, sv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a set of outbound WS-Addressing headers on the client with the
|
||||
* specified Action Message Addressing Property value.
|
||||
* <p><p>
|
||||
* This method needs to be invoked right after such a Message is
|
||||
* created which is error prone but so far only MEX, RM and JAX-WS
|
||||
* creates a request so this ugliness is acceptable. This method is also used
|
||||
* to create protocol messages that are not associated with any {@link WSBinding}
|
||||
* and {@link WSDLPort}.
|
||||
*
|
||||
* @param packet request packet
|
||||
* @param av WS-Addressing version
|
||||
* @param sv SOAP version
|
||||
* @param oneway Indicates if the message exchange pattern is oneway
|
||||
* @param action Action Message Addressing Property value
|
||||
* @param mustUnderstand to indicate if the addressing headers are set with mustUnderstand attribute
|
||||
*/
|
||||
public void fillRequestAddressingHeaders(Packet packet, AddressingVersion av, SOAPVersion sv, boolean oneway, String action, boolean mustUnderstand) {
|
||||
AddressingUtils.fillRequestAddressingHeaders(this, packet, av, sv, oneway, action, mustUnderstand);
|
||||
}
|
||||
|
||||
public void fillRequestAddressingHeaders(Packet packet, AddressingVersion av, SOAPVersion sv, boolean oneway, String action) {
|
||||
AddressingUtils.fillRequestAddressingHeaders(this, packet, av, sv, oneway, action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a set of outbound WS-Addressing headers on the client with the
|
||||
* default Action Message Addressing Property value.
|
||||
* <p><p>
|
||||
* This method needs to be invoked right after such a Message is
|
||||
* created which is error prone but so far only MEX, RM and JAX-WS
|
||||
* creates a request so this ugliness is acceptable. If more components
|
||||
* are identified using this, then we may revisit this.
|
||||
* <p><p>
|
||||
* This method is used if default Action Message Addressing Property is to
|
||||
* be used. See
|
||||
* {@link #fillRequestAddressingHeaders(Packet, com.sun.xml.internal.ws.api.addressing.AddressingVersion, com.sun.xml.internal.ws.api.SOAPVersion, boolean, String)}
|
||||
* if non-default Action is to be used, for example when creating a protocol message not
|
||||
* associated with {@link WSBinding} and {@link WSDLPort}.
|
||||
* This method uses SOAPAction as the Action unless set expplicitly in the wsdl.
|
||||
* @param wsdlPort request WSDL port
|
||||
* @param binding request WSBinding
|
||||
* @param packet request packet
|
||||
*/
|
||||
public void fillRequestAddressingHeaders(WSDLPort wsdlPort, @NotNull WSBinding binding, Packet packet) {
|
||||
AddressingUtils.fillRequestAddressingHeaders(this, wsdlPort, binding, packet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new {@link Header}.
|
||||
*
|
||||
* <p>
|
||||
* Order doesn't matter in headers, so this method
|
||||
* does not make any guarantee as to where the new header
|
||||
* is inserted.
|
||||
*
|
||||
* @return
|
||||
* always true. Don't use the return value.
|
||||
*/
|
||||
@Override
|
||||
public boolean add(Header header) {
|
||||
return super.add(header);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the first {@link Header} of the specified name.
|
||||
* @param nsUri namespace URI of the header to remove
|
||||
* @param localName local part of the FQN of the header to remove
|
||||
*
|
||||
* @return null if not found.
|
||||
*/
|
||||
public
|
||||
@Nullable
|
||||
@Override
|
||||
Header remove(@NotNull String nsUri, @NotNull String localName) {
|
||||
int len = size();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Header h = get(i);
|
||||
if (h.getLocalPart().equals(localName) && h.getNamespaceURI().equals(nsUri)) {
|
||||
return remove(i);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces an existing {@link Header} or adds a new {@link Header}.
|
||||
*
|
||||
* <p>
|
||||
* Order doesn't matter in headers, so this method
|
||||
* does not make any guarantee as to where the new header
|
||||
* is inserted.
|
||||
*
|
||||
* @return
|
||||
* always true. Don't use the return value.
|
||||
*/
|
||||
@Override
|
||||
public boolean addOrReplace(Header header) {
|
||||
for (int i=0; i < size(); i++) {
|
||||
Header hdr = get(i);
|
||||
if (hdr.getNamespaceURI().equals(header.getNamespaceURI()) &&
|
||||
hdr.getLocalPart().equals(header.getLocalPart())) {
|
||||
// Put the new header in the old position. Call super versions
|
||||
// internally to avoid UnsupportedOperationException
|
||||
removeInternal(i);
|
||||
addInternal(i, header);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return add(header);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replace(Header old, Header header) {
|
||||
for (int i=0; i < size(); i++) {
|
||||
Header hdr = get(i);
|
||||
if (hdr.getNamespaceURI().equals(header.getNamespaceURI()) &&
|
||||
hdr.getLocalPart().equals(header.getLocalPart())) {
|
||||
// Put the new header in the old position. Call super versions
|
||||
// internally to avoid UnsupportedOperationException
|
||||
removeInternal(i);
|
||||
addInternal(i, header);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
protected void addInternal(int index, Header header) {
|
||||
super.add(index, header);
|
||||
}
|
||||
|
||||
protected Header removeInternal(int index) {
|
||||
return super.remove(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the first {@link Header} of the specified name.
|
||||
*
|
||||
* @param name fully qualified name of the header to remove
|
||||
*
|
||||
* @return null if not found.
|
||||
*/
|
||||
public
|
||||
@Nullable
|
||||
@Override
|
||||
Header remove(@NotNull QName name) {
|
||||
return remove(name.getNamespaceURI(), name.getLocalPart());
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the first {@link Header} of the specified name.
|
||||
*
|
||||
* @param index index of the header to remove
|
||||
*
|
||||
* @return removed header
|
||||
*/
|
||||
@Override
|
||||
public Header remove(int index) {
|
||||
removeUnderstoodBit(index);
|
||||
return super.remove(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the "understood" bit for header on the position specified by {@code index} parameter
|
||||
* from the set of understood header bits.
|
||||
*
|
||||
* @param index position of the bit to remove
|
||||
*/
|
||||
private void removeUnderstoodBit(int index) {
|
||||
assert index < size();
|
||||
|
||||
if (index < 32) {
|
||||
/**
|
||||
* Let
|
||||
* R be the bit to be removed
|
||||
* M be a more significant "upper" bit than bit R
|
||||
* L be a less significant "lower" bit than bit R
|
||||
*
|
||||
* Then following 3 lines of code produce these results:
|
||||
*
|
||||
* old understoodBits = MMMMMMMMMMMMRLLLLLLLLLLLLLLLLLLL
|
||||
*
|
||||
* shiftedUpperBits = 0MMMMMMMMMMMM0000000000000000000
|
||||
*
|
||||
* lowerBits = 0000000000000LLLLLLLLLLLLLLLLLLL
|
||||
*
|
||||
* new understoodBits = 0MMMMMMMMMMMMLLLLLLLLLLLLLLLLLLL
|
||||
*
|
||||
* The R bit is removed and all the upper bits are shifted right (unsigned)
|
||||
*/
|
||||
int shiftedUpperBits = understoodBits >>> -31 + index << index;
|
||||
int lowerBits = understoodBits << -index >>> 31 - index >>> 1;
|
||||
understoodBits = shiftedUpperBits | lowerBits;
|
||||
|
||||
if (moreUnderstoodBits != null && moreUnderstoodBits.cardinality() > 0) {
|
||||
if (moreUnderstoodBits.get(0)) {
|
||||
understoodBits |= 0x80000000;
|
||||
}
|
||||
|
||||
moreUnderstoodBits.clear(0);
|
||||
for (int i = moreUnderstoodBits.nextSetBit(1); i > 0; i = moreUnderstoodBits.nextSetBit(i + 1)) {
|
||||
moreUnderstoodBits.set(i - 1);
|
||||
moreUnderstoodBits.clear(i);
|
||||
}
|
||||
}
|
||||
} else if (moreUnderstoodBits != null && moreUnderstoodBits.cardinality() > 0) {
|
||||
index -= 32;
|
||||
moreUnderstoodBits.clear(index);
|
||||
for (int i = moreUnderstoodBits.nextSetBit(index); i >= 1; i = moreUnderstoodBits.nextSetBit(i + 1)) {
|
||||
moreUnderstoodBits.set(i - 1);
|
||||
moreUnderstoodBits.clear(i);
|
||||
}
|
||||
}
|
||||
|
||||
// remove bit set if the new size will be < 33 => we fit all bits into int
|
||||
if (size() - 1 <= 33 && moreUnderstoodBits != null) {
|
||||
moreUnderstoodBits = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a single instance of the specified element from this
|
||||
* header list, if it is present. More formally,
|
||||
* removes a header <tt>h</tt> such that <tt>(o==null ? h==null :
|
||||
* o.equals(h))</tt>, if the header list contains one or more such
|
||||
* headers. Returns <tt>true</tt> if the list contained the
|
||||
* specified element (or equivalently, if the list changed as a
|
||||
* result of the call).<p>
|
||||
*
|
||||
* @param o element to be removed from this list, if present.
|
||||
* @return <tt>true</tt> if the list contained the specified element.
|
||||
* @see #remove(javax.xml.namespace.QName)
|
||||
*/
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
if (o != null) {
|
||||
for (int index = 0; index < this.size(); index++) {
|
||||
if (o.equals(this.get(index))) {
|
||||
remove(index);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public Header remove(Header h) {
|
||||
if (remove((Object) h)) {
|
||||
return h;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy.
|
||||
*
|
||||
* This handles null {@link HeaderList} correctly.
|
||||
*
|
||||
* @param original
|
||||
* Can be null, in which case null will be returned.
|
||||
*/
|
||||
public static HeaderList copy(MessageHeaders original) {
|
||||
if (original == null) {
|
||||
return null;
|
||||
} else {
|
||||
return new HeaderList(original);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy.
|
||||
*
|
||||
* This handles null {@link HeaderList} correctly.
|
||||
*
|
||||
* @param original
|
||||
* Can be null, in which case null will be returned.
|
||||
*/
|
||||
public static HeaderList copy(HeaderList original) {
|
||||
return copy((MessageHeaders) original);
|
||||
}
|
||||
|
||||
public void readResponseAddressingHeaders(WSDLPort wsdlPort, WSBinding binding) {
|
||||
// read Action
|
||||
// String wsaAction = getAction(binding.getAddressingVersion(), binding.getSOAPVersion());
|
||||
// TODO: validate client-inbound Action
|
||||
}
|
||||
|
||||
@Override
|
||||
public void understood(QName name) {
|
||||
get(name, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void understood(String nsUri, String localName) {
|
||||
get(nsUri, localName, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<QName> getUnderstoodHeaders() {
|
||||
Set<QName> understoodHdrs = new HashSet<QName>();
|
||||
for (int i = 0; i < size(); i++) {
|
||||
if (isUnderstood(i)) {
|
||||
Header header = get(i);
|
||||
understoodHdrs.add(new QName(header.getNamespaceURI(), header.getLocalPart()));
|
||||
}
|
||||
}
|
||||
return understoodHdrs;
|
||||
// throw new UnsupportedOperationException("getUnderstoodHeaders() is not implemented by HeaderList");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnderstood(Header header) {
|
||||
return isUnderstood(header.getNamespaceURI(), header.getLocalPart());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnderstood(String nsUri, String localName) {
|
||||
for (int i = 0; i < size(); i++) {
|
||||
Header h = get(i);
|
||||
if (h.getLocalPart().equals(localName) && h.getNamespaceURI().equals(nsUri)) {
|
||||
return isUnderstood(i);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnderstood(QName name) {
|
||||
return isUnderstood(name.getNamespaceURI(), name.getLocalPart());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<QName> getNotUnderstoodHeaders(Set<String> roles, Set<QName> knownHeaders, WSBinding binding) {
|
||||
Set<QName> notUnderstoodHeaders = null;
|
||||
if (roles == null) {
|
||||
roles = new HashSet<String>();
|
||||
}
|
||||
SOAPVersion effectiveSoapVersion = getEffectiveSOAPVersion(binding);
|
||||
roles.add(effectiveSoapVersion.implicitRole);
|
||||
for (int i = 0; i < size(); i++) {
|
||||
if (!isUnderstood(i)) {
|
||||
Header header = get(i);
|
||||
if (!header.isIgnorable(effectiveSoapVersion, roles)) {
|
||||
QName qName = new QName(header.getNamespaceURI(), header.getLocalPart());
|
||||
if (binding == null) {
|
||||
//if binding is null, no further checks needed...we already
|
||||
//know this header is not understood from the isUnderstood
|
||||
//check above
|
||||
if (notUnderstoodHeaders == null) {
|
||||
notUnderstoodHeaders = new HashSet<QName>();
|
||||
}
|
||||
notUnderstoodHeaders.add(qName);
|
||||
} else {
|
||||
// if the binding is not null, see if the binding can understand it
|
||||
if (binding instanceof SOAPBindingImpl && !((SOAPBindingImpl) binding).understandsHeader(qName)) {
|
||||
if (!knownHeaders.contains(qName)) {
|
||||
//logger.info("Element not understood=" + qName);
|
||||
if (notUnderstoodHeaders == null) {
|
||||
notUnderstoodHeaders = new HashSet<QName>();
|
||||
}
|
||||
notUnderstoodHeaders.add(qName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return notUnderstoodHeaders;
|
||||
}
|
||||
|
||||
private SOAPVersion getEffectiveSOAPVersion(WSBinding binding) {
|
||||
SOAPVersion mySOAPVersion = (soapVersion != null) ? soapVersion : binding.getSOAPVersion();
|
||||
if (mySOAPVersion == null) {
|
||||
mySOAPVersion = SOAPVersion.SOAP_11;
|
||||
}
|
||||
return mySOAPVersion;
|
||||
}
|
||||
|
||||
public void setSoapVersion(SOAPVersion soapVersion) {
|
||||
this.soapVersion = soapVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Header> getHeaders() {
|
||||
return iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Header> asList() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
185
jdkSrc/jdk8/com/sun/xml/internal/ws/api/message/Headers.java
Normal file
185
jdkSrc/jdk8/com/sun/xml/internal/ws/api/message/Headers.java
Normal file
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* 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.api.message;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.xml.internal.bind.api.Bridge;
|
||||
import com.sun.xml.internal.bind.api.JAXBRIContext;
|
||||
import com.sun.xml.internal.bind.v2.runtime.MarshallerImpl;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.pipe.Pipe;
|
||||
import com.sun.xml.internal.ws.message.DOMHeader;
|
||||
import com.sun.xml.internal.ws.message.StringHeader;
|
||||
import com.sun.xml.internal.ws.message.jaxb.JAXBHeader;
|
||||
import com.sun.xml.internal.ws.message.saaj.SAAJHeader;
|
||||
import com.sun.xml.internal.ws.message.stream.StreamHeader11;
|
||||
import com.sun.xml.internal.ws.message.stream.StreamHeader12;
|
||||
import com.sun.xml.internal.ws.spi.db.BindingContext;
|
||||
import com.sun.xml.internal.ws.spi.db.BindingContextFactory;
|
||||
import com.sun.xml.internal.ws.spi.db.XMLBridge;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.SOAPHeaderElement;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
|
||||
/**
|
||||
* Factory methods for various {@link Header} implementations.
|
||||
*
|
||||
* <p>
|
||||
* This class provides various methods to create different
|
||||
* flavors of {@link Header} classes that store data
|
||||
* in different formats.
|
||||
*
|
||||
* <p>
|
||||
* This is a part of the JAX-WS RI internal API so that
|
||||
* {@link Pipe} implementations can reuse the implementations
|
||||
* done inside the JAX-WS without having a strong dependency
|
||||
* to the actual class.
|
||||
*
|
||||
* <p>
|
||||
* If you find some of the useful convenience methods missing
|
||||
* from this class, please talk to us.
|
||||
*
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public abstract class Headers {
|
||||
private Headers() {}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Use {@link #create(BindingContext, Object)} instead.
|
||||
*/
|
||||
public static Header create(SOAPVersion soapVersion, Marshaller m, Object o) {
|
||||
return new JAXBHeader(BindingContextFactory.getBindingContext(m),o);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Header} backed a by a JAXB bean.
|
||||
*/
|
||||
public static Header create(JAXBContext context, Object o) {
|
||||
return new JAXBHeader(BindingContextFactory.create(context),o);
|
||||
}
|
||||
|
||||
public static Header create(BindingContext context, Object o) {
|
||||
return new JAXBHeader(context,o);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Header} backed a by a JAXB bean, with the given tag name.
|
||||
*
|
||||
* See {@link #create(SOAPVersion, Marshaller, Object)} for the meaning
|
||||
* of other parameters.
|
||||
*
|
||||
* @param tagName
|
||||
* The name of the newly created header. Must not be null.
|
||||
* @param o
|
||||
* The JAXB bean that represents the contents of the header. Must not be null.
|
||||
*/
|
||||
public static Header create(SOAPVersion soapVersion, Marshaller m, QName tagName, Object o) {
|
||||
return create(soapVersion,m,new JAXBElement(tagName,o.getClass(),o));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Header} backed a by a JAXB bean.
|
||||
* @deprecated
|
||||
*/
|
||||
public static Header create(Bridge bridge, Object jaxbObject) {
|
||||
return new JAXBHeader(new com.sun.xml.internal.ws.db.glassfish.BridgeWrapper(null,bridge), jaxbObject);
|
||||
}
|
||||
|
||||
public static Header create(XMLBridge bridge, Object jaxbObject) {
|
||||
return new JAXBHeader(bridge, jaxbObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link Header} backed by a SAAJ object.
|
||||
*/
|
||||
public static Header create(SOAPHeaderElement header) {
|
||||
return new SAAJHeader(header);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link Header} backed by an {@link Element}.
|
||||
*/
|
||||
public static Header create( Element node ) {
|
||||
return new DOMHeader<Element>(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Use {@link #create(Element)}
|
||||
*/
|
||||
public static Header create( SOAPVersion soapVersion, Element node ) {
|
||||
return create(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link Header} that reads from {@link XMLStreamReader}.
|
||||
*
|
||||
* <p>
|
||||
* Note that the header implementation will read the entire data
|
||||
* into memory anyway, so this might not be as efficient as you might hope.
|
||||
*/
|
||||
public static Header create( SOAPVersion soapVersion, XMLStreamReader reader ) throws XMLStreamException {
|
||||
switch(soapVersion) {
|
||||
case SOAP_11:
|
||||
return new StreamHeader11(reader);
|
||||
case SOAP_12:
|
||||
return new StreamHeader12(reader);
|
||||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link Header} that that has a single text value in it
|
||||
* (IOW, of the form <foo>text</foo>.)
|
||||
*
|
||||
* @param name QName of the header element
|
||||
* @param value text value of the header
|
||||
*/
|
||||
public static Header create(QName name, String value) {
|
||||
return new StringHeader(name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link Header} that that has a single text value in it
|
||||
* (IOW, of the form <foo>text</foo>.)
|
||||
*
|
||||
* @param name QName of the header element
|
||||
* @param value text value of the header
|
||||
*/
|
||||
public static Header createMustUnderstand(@NotNull SOAPVersion soapVersion, @NotNull QName name,@NotNull String value) {
|
||||
return new StringHeader(name, value,soapVersion,true);
|
||||
}
|
||||
}
|
||||
789
jdkSrc/jdk8/com/sun/xml/internal/ws/api/message/Message.java
Normal file
789
jdkSrc/jdk8/com/sun/xml/internal/ws/api/message/Message.java
Normal file
@@ -0,0 +1,789 @@
|
||||
/*
|
||||
* 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.api.message;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.bind.api.Bridge;
|
||||
import com.sun.xml.internal.ws.api.BindingID;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
||||
import com.sun.xml.internal.ws.api.model.JavaMethod;
|
||||
import com.sun.xml.internal.ws.api.model.SEIModel;
|
||||
import com.sun.xml.internal.ws.api.model.WSDLOperationMapping;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundPortType;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.api.pipe.Codec;
|
||||
import com.sun.xml.internal.ws.api.pipe.Pipe;
|
||||
import com.sun.xml.internal.ws.api.streaming.XMLStreamReaderFactory;
|
||||
import com.sun.xml.internal.ws.client.dispatch.DispatchImpl;
|
||||
import com.sun.xml.internal.ws.message.AttachmentSetImpl;
|
||||
import com.sun.xml.internal.ws.message.StringHeader;
|
||||
import com.sun.xml.internal.ws.message.jaxb.JAXBMessage;
|
||||
import com.sun.xml.internal.ws.spi.db.XMLBridge;
|
||||
import com.sun.xml.internal.ws.fault.SOAPFaultBuilder;
|
||||
import com.sun.xml.internal.org.jvnet.staxex.XMLStreamReaderEx;
|
||||
import com.sun.xml.internal.org.jvnet.staxex.XMLStreamWriterEx;
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.MimeHeaders;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.ws.Dispatch;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Represents a SOAP message.
|
||||
*
|
||||
*
|
||||
* <h2>What is a message?</h2>
|
||||
* <p>
|
||||
* A {@link Message} consists of the following:
|
||||
*
|
||||
* <ol>
|
||||
* <li>
|
||||
* Random-accessible list of headers.
|
||||
* a header is a representation of an element inside
|
||||
* <soap:Header>.
|
||||
* It can be read multiple times,
|
||||
* can be added or removed, but it is not modifiable.
|
||||
* See {@link HeaderList} for more about headers.
|
||||
*
|
||||
* <li>
|
||||
* The payload of the message, which is a representation
|
||||
* of an element inside <soap:Body>.
|
||||
* the payload is streamed, and therefore it can be
|
||||
* only read once (or can be only written to something once.)
|
||||
* once a payload is used, a message is said to be <b>consumed</b>.
|
||||
* A message {@link #hasPayload() may not have any payload.}
|
||||
*
|
||||
* <li>
|
||||
* Attachments.
|
||||
* TODO: can attachments be streamed? I suspect so.
|
||||
* does anyone need to read attachment twice?
|
||||
*
|
||||
* </ol>
|
||||
*
|
||||
*
|
||||
* <h2>How does this abstraction work?</h2>
|
||||
* <p>
|
||||
* The basic idea behind the {@link Message} is to hide the actual
|
||||
* data representation. For example, a {@link Message} might be
|
||||
* constructed on top of an {@link InputStream} from the accepted HTTP connection,
|
||||
* or it might be constructed on top of a JAXB object as a result
|
||||
* of the method invocation through {@link Proxy}. There will be
|
||||
* a {@link Message} implementation for each of those cases.
|
||||
*
|
||||
* <p>
|
||||
* This interface provides a lot of methods that access the payload
|
||||
* in many different forms, and implementations can implement those
|
||||
* methods in the best possible way.
|
||||
*
|
||||
* <p>
|
||||
* A particular attention is paid to make sure that a {@link Message}
|
||||
* object can be constructed on a stream that is not fully read yet.
|
||||
* We believe this improves the turn-around time on the server side.
|
||||
*
|
||||
* <p>
|
||||
* It is often useful to wrap a {@link Message} into another {@link Message},
|
||||
* for example to encrypt the body, or to verify the signature as the body
|
||||
* is read.
|
||||
*
|
||||
* <p>
|
||||
* This representation is also used for a REST-ful XML message.
|
||||
* In such case we'll construct a {@link Message} with empty
|
||||
* attachments and headers, and when serializing all headers
|
||||
* and attachments will be ignored.
|
||||
*
|
||||
*
|
||||
*
|
||||
* <h2>Message and XOP</h2>
|
||||
* <p>
|
||||
* XOP is considered as an {@link Codec}, and therefore when you are looking at
|
||||
* {@link Message}, you'll never see <xop:Include> or any such elements
|
||||
* (instead you'll see the base64 data inlined.) If a consumer of infoset isn't
|
||||
* interested in handling XOP by himself, this allows him to work with XOP
|
||||
* correctly even without noticing it.
|
||||
*
|
||||
* <p>
|
||||
* For producers and consumers that are interested in accessing the binary data
|
||||
* more efficiently, they can use {@link XMLStreamReaderEx} and
|
||||
* {@link XMLStreamWriterEx}.
|
||||
*
|
||||
*
|
||||
*
|
||||
* <h2>Message lifespan</h2>
|
||||
* <p>
|
||||
* Often {@link Packet} include information local to a particular
|
||||
* invocaion (such as {@code HttpServletRequest}, from this angle, it makes sense
|
||||
* to tie a lifespan of a message to one pipeline invocation.
|
||||
* <p>
|
||||
* On the other hand, if you think about WS-RM, it often needs to hold on to
|
||||
* a message longer than a pipeline invocation (you might get an HTTP request,
|
||||
* get a message X, get a second HTTP request, get another message Y, and
|
||||
* only then you might want to process X.)
|
||||
* <p>
|
||||
* TODO: what do we do about this?
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* TODO: can body element have foreign attributes? maybe ID for security?
|
||||
* Yes, when the SOAP body is signed there will be an ID attribute present
|
||||
* But in this case any security based impl may need access
|
||||
* to the concrete representation.
|
||||
* TODO: HTTP headers?
|
||||
* Yes. Abstracted as transport-based properties.
|
||||
* TODO: who handles SOAP 1.1 and SOAP 1.2 difference?
|
||||
* As separate channel implementations responsible for the creation of the
|
||||
* message?
|
||||
* TODO: session?
|
||||
* TODO: Do we need to expose SOAPMessage explicitly?
|
||||
* SOAPMessage could be the concrete representation but is it necessary to
|
||||
* transform between different concrete representations?
|
||||
* Perhaps this comes down to how use channels for creation and processing.
|
||||
* TODO: Do we need to distinguish better between creation and processing?
|
||||
* Do we really need the requirement that a created message can be resused
|
||||
* for processing. Shall we bifurcate?
|
||||
*
|
||||
* TODO: SOAP version issue
|
||||
* SOAP version is determined by the context, so message itself doesn't carry it around (?)
|
||||
*
|
||||
* TODO: wrapping message needs easier. in particular properties and attachments.
|
||||
* </pre>
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public abstract class Message {
|
||||
|
||||
/**
|
||||
* Returns true if headers are present in the message.
|
||||
*
|
||||
* @return
|
||||
* true if headers are present.
|
||||
*/
|
||||
public abstract boolean hasHeaders();
|
||||
|
||||
/**
|
||||
* Gets all the headers of this message.
|
||||
*
|
||||
* <h3>Implementation Note</h3>
|
||||
* <p>
|
||||
* {@link Message} implementation is allowed to defer
|
||||
* the construction of {@link MessageHeaders} object. So
|
||||
* if you only want to check for the existence of any header
|
||||
* element, use {@link #hasHeaders()}.
|
||||
*
|
||||
* @return
|
||||
* always return the same non-null object.
|
||||
*/
|
||||
public abstract @NotNull MessageHeaders getHeaders();
|
||||
|
||||
/**
|
||||
* Gets the attachments of this message
|
||||
* (attachments live outside a message.)
|
||||
*/
|
||||
public @NotNull AttachmentSet getAttachments() {
|
||||
if (attachmentSet == null) {
|
||||
attachmentSet = new AttachmentSetImpl();
|
||||
}
|
||||
return attachmentSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimization hint for the derived class to check
|
||||
* if we may have some attachments.
|
||||
*/
|
||||
protected boolean hasAttachments() {
|
||||
return attachmentSet!=null;
|
||||
}
|
||||
|
||||
protected AttachmentSet attachmentSet;
|
||||
|
||||
private WSDLBoundOperation operation = null;
|
||||
|
||||
private WSDLOperationMapping wsdlOperationMapping = null;
|
||||
|
||||
private MessageMetadata messageMetadata = null;
|
||||
|
||||
public void setMessageMedadata(MessageMetadata metadata) {
|
||||
messageMetadata = metadata;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the operation of which this message is an instance of.
|
||||
*
|
||||
* <p>
|
||||
* This method relies on {@link WSDLBoundPortType#getOperation(String, String)} but
|
||||
* it does so in an efficient way.
|
||||
*
|
||||
* @deprecated It is not always possible to uniquely identify the WSDL Operation from just the
|
||||
* information in the Message. Instead, Use {@link com.sun.xml.internal.ws.api.message.Packet#getWSDLOperation()}
|
||||
* to get it correctly.
|
||||
*
|
||||
* <p>
|
||||
* This method works only for a request. A pipe can determine an operation for a request,
|
||||
* and then keep it in a local variable to use it with a response, so there should be
|
||||
* no need to find out operation from a response (besides, there might not be any response!).
|
||||
*
|
||||
* @param boundPortType
|
||||
* This represents the port for which this message is used.
|
||||
* Most {@link Pipe}s should get this information when they are created,
|
||||
* since a pippeline always work against a particular type of {@link WSDLPort}.
|
||||
*
|
||||
* @return
|
||||
* Null if the operation was not found. This is possible, for example when a protocol
|
||||
* message is sent through a pipeline, or when we receive an invalid request on the server,
|
||||
* or when we are on the client and the user appliation sends a random DOM through
|
||||
* {@link Dispatch}, so this error needs to be handled gracefully.
|
||||
*/
|
||||
@Deprecated
|
||||
public final @Nullable WSDLBoundOperation getOperation(@NotNull WSDLBoundPortType boundPortType) {
|
||||
if (operation == null && messageMetadata != null) {
|
||||
if (wsdlOperationMapping == null) wsdlOperationMapping = messageMetadata.getWSDLOperationMapping();
|
||||
if (wsdlOperationMapping != null) operation = wsdlOperationMapping.getWSDLBoundOperation();
|
||||
}
|
||||
if(operation==null)
|
||||
operation = boundPortType.getOperation(getPayloadNamespaceURI(),getPayloadLocalPart());
|
||||
return operation;
|
||||
}
|
||||
|
||||
/**
|
||||
* The same as {@link #getOperation(WSDLBoundPortType)} but
|
||||
* takes {@link WSDLPort} for convenience.
|
||||
*
|
||||
* @deprecated It is not always possible to uniquely identify the WSDL Operation from just the
|
||||
* information in the Message. Instead, Use {@link com.sun.xml.internal.ws.api.message.Packet#getWSDLOperation()}
|
||||
* to get it correctly.
|
||||
*/
|
||||
@Deprecated
|
||||
public final @Nullable WSDLBoundOperation getOperation(@NotNull WSDLPort port) {
|
||||
return getOperation(port.getBinding());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the java Method of which this message is an instance of.
|
||||
*
|
||||
* It is not always possible to uniquely identify the WSDL Operation from just the
|
||||
* information in the Message. Instead, Use {@link com.sun.xml.internal.ws.api.message.Packet#getWSDLOperation()}
|
||||
* to get the QName of the associated wsdl operation correctly.
|
||||
*
|
||||
* <p>
|
||||
* This method works only for a request. A pipe can determine a {@link Method}
|
||||
* for a request, and then keep it in a local variable to use it with a response,
|
||||
* so there should be no need to find out operation from a response (besides,
|
||||
* there might not be any response!).
|
||||
*
|
||||
* @param seiModel
|
||||
* This represents the java model for the endpoint
|
||||
* Some server {@link Pipe}s would get this information when they are created.
|
||||
*
|
||||
* @return
|
||||
* Null if there is no corresponding Method for this message. This is
|
||||
* possible, for example when a protocol message is sent through a
|
||||
* pipeline, or when we receive an invalid request on the server,
|
||||
* or when we are on the client and the user appliation sends a random
|
||||
* DOM through {@link Dispatch}, so this error needs to be handled
|
||||
* gracefully.
|
||||
*/
|
||||
@Deprecated
|
||||
public final @Nullable JavaMethod getMethod(@NotNull SEIModel seiModel) {
|
||||
if (wsdlOperationMapping == null && messageMetadata != null) {
|
||||
wsdlOperationMapping = messageMetadata.getWSDLOperationMapping();
|
||||
}
|
||||
if (wsdlOperationMapping != null) {
|
||||
return wsdlOperationMapping.getJavaMethod();
|
||||
}
|
||||
//fall back to the original logic which could be incorrect ...
|
||||
String localPart = getPayloadLocalPart();
|
||||
String nsUri;
|
||||
if (localPart == null) {
|
||||
localPart = "";
|
||||
nsUri = "";
|
||||
} else {
|
||||
nsUri = getPayloadNamespaceURI();
|
||||
}
|
||||
QName name = new QName(nsUri, localPart);
|
||||
return seiModel.getJavaMethod(name);
|
||||
}
|
||||
|
||||
private Boolean isOneWay;
|
||||
|
||||
/**
|
||||
* Returns true if this message is a request message for a
|
||||
* one way operation according to the given WSDL. False otherwise.
|
||||
*
|
||||
* <p>
|
||||
* This method is functionally equivalent as doing
|
||||
* {@code getOperation(port).getOperation().isOneWay()}
|
||||
* (with proper null check and all.) But this method
|
||||
* can sometimes work faster than that (for example,
|
||||
* on the client side when used with SEI.)
|
||||
*
|
||||
* @param port
|
||||
* {@link Message}s are always created under the context of
|
||||
* one {@link WSDLPort} and they never go outside that context.
|
||||
* Pass in that "governing" {@link WSDLPort} object here.
|
||||
* We chose to receive this as a parameter instead of
|
||||
* keeping {@link WSDLPort} in a message, just to save the storage.
|
||||
*
|
||||
* <p>
|
||||
* The implementation of this method involves caching the return
|
||||
* value, so the behavior is undefined if multiple callers provide
|
||||
* different {@link WSDLPort} objects, which is a bug of the caller.
|
||||
*/
|
||||
public boolean isOneWay(@NotNull WSDLPort port) {
|
||||
if(isOneWay==null) {
|
||||
// we don't know, so compute.
|
||||
WSDLBoundOperation op = getOperation(port);
|
||||
if(op!=null)
|
||||
isOneWay = op.getOperation().isOneWay();
|
||||
else
|
||||
// the contract is to return true only when it's known to be one way.
|
||||
isOneWay = false;
|
||||
}
|
||||
return isOneWay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an assertion that this {@link Message} is
|
||||
* a request message for an one-way operation according
|
||||
* to the context WSDL.
|
||||
*
|
||||
* <p>
|
||||
* This method is really only intended to be invoked from within
|
||||
* the JAX-WS runtime, and not by any code building on top of it.
|
||||
*
|
||||
* <p>
|
||||
* This method can be invoked only when the caller "knows" what
|
||||
* WSDL says. Also, there's no point in invoking this method if the caller
|
||||
* is doing {@code getOperation(port).getOperation().isOneWay()},
|
||||
* or sniffing the payload tag name.
|
||||
* In particular, this includes {@link DispatchImpl}.
|
||||
*
|
||||
* <p>
|
||||
* Once called, this allows {@link #isOneWay(WSDLPort)} method
|
||||
* to return a value quickly.
|
||||
*
|
||||
* @see #isOneWay(WSDLPort)
|
||||
*/
|
||||
public final void assertOneWay(boolean value) {
|
||||
// if two callers make different assertions, that's a bug.
|
||||
// this is an assertion, not a runtime check because
|
||||
// nobody outside JAX-WS should be using this.
|
||||
assert isOneWay==null || isOneWay==value;
|
||||
|
||||
isOneWay = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the local name of the payload element.
|
||||
*
|
||||
* @return
|
||||
* null if a {@link Message} doesn't have any payload.
|
||||
*/
|
||||
public abstract @Nullable String getPayloadLocalPart();
|
||||
|
||||
/**
|
||||
* Gets the namespace URI of the payload element.
|
||||
*
|
||||
* @return
|
||||
* null if a {@link Message} doesn't have any payload.
|
||||
*/
|
||||
public abstract String getPayloadNamespaceURI();
|
||||
// I'm not putting @Nullable on it because doing null check on getPayloadLocalPart() should be suffice
|
||||
|
||||
/**
|
||||
* Returns true if a {@link Message} has a payload.
|
||||
*
|
||||
* <p>
|
||||
* A message without a payload is a SOAP message that looks like:
|
||||
* <pre><xmp>
|
||||
* <S:Envelope>
|
||||
* <S:Header>
|
||||
* ...
|
||||
* </S:Header>
|
||||
* <S:Body />
|
||||
* </S:Envelope>
|
||||
* </xmp></pre>
|
||||
*/
|
||||
public abstract boolean hasPayload();
|
||||
|
||||
/**
|
||||
* Returns true if this message is a fault.
|
||||
*
|
||||
* <p>
|
||||
* Just a convenience method built on {@link #getPayloadNamespaceURI()}
|
||||
* and {@link #getPayloadLocalPart()}.
|
||||
*/
|
||||
public boolean isFault() {
|
||||
// TODO: is SOAP version a property of a Message?
|
||||
// or is it defined by external factors?
|
||||
// how do I compare?
|
||||
String localPart = getPayloadLocalPart();
|
||||
if(localPart==null || !localPart.equals("Fault"))
|
||||
return false;
|
||||
|
||||
String nsUri = getPayloadNamespaceURI();
|
||||
return nsUri.equals(SOAPVersion.SOAP_11.nsUri) || nsUri.equals(SOAPVersion.SOAP_12.nsUri);
|
||||
}
|
||||
|
||||
/**
|
||||
* It gives S:Envelope/S:Body/S:Fault/detail 's first child's name. Should
|
||||
* be called for messages that have SOAP Fault.
|
||||
*
|
||||
* <p> This implementation is expensive so concrete implementations are
|
||||
* expected to override this one.
|
||||
*
|
||||
* @return first detail entry's name, if there is one
|
||||
* else null
|
||||
*/
|
||||
public @Nullable QName getFirstDetailEntryName() {
|
||||
assert isFault();
|
||||
Message msg = copy();
|
||||
try {
|
||||
SOAPFaultBuilder fault = SOAPFaultBuilder.create(msg);
|
||||
return fault.getFirstDetailEntryName();
|
||||
} catch (JAXBException e) {
|
||||
throw new WebServiceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Consumes this message including the envelope.
|
||||
* returns it as a {@link Source} object.
|
||||
*/
|
||||
public abstract Source readEnvelopeAsSource();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the payload as a {@link Source} object.
|
||||
*
|
||||
* This consumes the message.
|
||||
*
|
||||
* @return
|
||||
* if there's no payload, this method returns null.
|
||||
*/
|
||||
public abstract Source readPayloadAsSource();
|
||||
|
||||
/**
|
||||
* Creates the equivalent {@link SOAPMessage} from this message.
|
||||
*
|
||||
* This consumes the message.
|
||||
*
|
||||
* @throws SOAPException
|
||||
* if there's any error while creating a {@link SOAPMessage}.
|
||||
*/
|
||||
public abstract SOAPMessage readAsSOAPMessage() throws SOAPException;
|
||||
|
||||
/**
|
||||
* Creates the equivalent {@link SOAPMessage} from this message. It also uses
|
||||
* transport specific headers from Packet during the SOAPMessage construction
|
||||
* so that {@link SOAPMessage#getMimeHeaders()} gives meaningful transport
|
||||
* headers.
|
||||
*
|
||||
* This consumes the message.
|
||||
*
|
||||
* @throws SOAPException
|
||||
* if there's any error while creating a {@link SOAPMessage}.
|
||||
*/
|
||||
public SOAPMessage readAsSOAPMessage(Packet packet, boolean inbound) throws SOAPException {
|
||||
return readAsSOAPMessage();
|
||||
}
|
||||
|
||||
public static Map<String, List<String>> getTransportHeaders(Packet packet) {
|
||||
return getTransportHeaders(packet, packet.getState().isInbound());
|
||||
}
|
||||
|
||||
public static Map<String, List<String>> getTransportHeaders(Packet packet, boolean inbound) {
|
||||
Map<String, List<String>> headers = null;
|
||||
String key = inbound ? Packet.INBOUND_TRANSPORT_HEADERS : Packet.OUTBOUND_TRANSPORT_HEADERS;
|
||||
if (packet.supports(key)) {
|
||||
headers = (Map<String, List<String>>)packet.get(key);
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
|
||||
public static void addSOAPMimeHeaders(MimeHeaders mh, Map<String, List<String>> headers) {
|
||||
for(Map.Entry<String, List<String>> e : headers.entrySet()) {
|
||||
if (!e.getKey().equalsIgnoreCase("Content-Type")) {
|
||||
for(String value : e.getValue()) {
|
||||
mh.addHeader(e.getKey(), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Reads the payload as a JAXB object by using the given unmarshaller.
|
||||
*
|
||||
* This consumes the message.
|
||||
*
|
||||
* @throws JAXBException
|
||||
* If JAXB reports an error during the processing.
|
||||
*/
|
||||
public abstract <T> T readPayloadAsJAXB(Unmarshaller unmarshaller) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Reads the payload as a JAXB object according to the given {@link Bridge}.
|
||||
*
|
||||
* This consumes the message.
|
||||
*
|
||||
* @deprecated
|
||||
* @return null
|
||||
* if there's no payload.
|
||||
* @throws JAXBException
|
||||
* If JAXB reports an error during the processing.
|
||||
*/
|
||||
public abstract <T> T readPayloadAsJAXB(Bridge<T> bridge) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Reads the payload as a Data-Bond object
|
||||
*
|
||||
* This consumes the message.
|
||||
*
|
||||
* @return null
|
||||
* if there's no payload.
|
||||
* @throws JAXBException
|
||||
* If JAXB reports an error during the processing.
|
||||
*/
|
||||
public abstract <T> T readPayloadAsJAXB(XMLBridge<T> bridge) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Reads the payload as a {@link XMLStreamReader}
|
||||
*
|
||||
* This consumes the message. The caller is encouraged to call
|
||||
* {@link XMLStreamReaderFactory#recycle(XMLStreamReader)} when finished using
|
||||
* the instance.
|
||||
*
|
||||
* @return
|
||||
* If there's no payload, this method returns null.
|
||||
* Otherwise always non-null valid {@link XMLStreamReader} that points to
|
||||
* the payload tag name.
|
||||
*/
|
||||
public abstract XMLStreamReader readPayload() throws XMLStreamException;
|
||||
|
||||
/**
|
||||
* Marks the message as consumed, without actually reading the contents.
|
||||
*
|
||||
* <p>
|
||||
* This method provides an opportunity for implementations to reuse
|
||||
* any reusable resources needed for representing the payload.
|
||||
*
|
||||
* <p>
|
||||
* This method may not be called more than once since it may have
|
||||
* released the reusable resources.
|
||||
*/
|
||||
public void consume() {}
|
||||
|
||||
/**
|
||||
* Writes the payload to StAX.
|
||||
*
|
||||
* This method writes just the payload of the message to the writer.
|
||||
* This consumes the message.
|
||||
* The implementation will not write
|
||||
* {@link XMLStreamWriter#writeStartDocument()}
|
||||
* nor
|
||||
* {@link XMLStreamWriter#writeEndDocument()}
|
||||
*
|
||||
* <p>
|
||||
* If there's no payload, this method is no-op.
|
||||
*
|
||||
* @throws XMLStreamException
|
||||
* If the {@link XMLStreamWriter} reports an error,
|
||||
* or some other errors happen during the processing.
|
||||
*/
|
||||
public abstract void writePayloadTo(XMLStreamWriter sw) throws XMLStreamException;
|
||||
|
||||
/**
|
||||
* Writes the whole SOAP message (but not attachments)
|
||||
* to the given writer.
|
||||
*
|
||||
* This consumes the message.
|
||||
*
|
||||
* @throws XMLStreamException
|
||||
* If the {@link XMLStreamWriter} reports an error,
|
||||
* or some other errors happen during the processing.
|
||||
*/
|
||||
public abstract void writeTo(XMLStreamWriter sw) throws XMLStreamException;
|
||||
|
||||
/**
|
||||
* Writes the whole SOAP envelope as SAX events.
|
||||
*
|
||||
* <p>
|
||||
* This consumes the message.
|
||||
*
|
||||
* @param contentHandler
|
||||
* must not be nulll.
|
||||
* @param errorHandler
|
||||
* must not be null.
|
||||
* any error encountered during the SAX event production must be
|
||||
* first reported to this error handler. Fatal errors can be then
|
||||
* thrown as {@link SAXParseException}. {@link SAXException}s thrown
|
||||
* from {@link ErrorHandler} should propagate directly through this method.
|
||||
*/
|
||||
public abstract void writeTo( ContentHandler contentHandler, ErrorHandler errorHandler ) throws SAXException;
|
||||
|
||||
// TODO: do we need a method that reads payload as a fault?
|
||||
// do we want a separte streaming representation of fault?
|
||||
// or would SOAPFault in SAAJ do?
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates a copy of a {@link Message}.
|
||||
*
|
||||
* <p>
|
||||
* This method creates a new {@link Message} whose header/payload/attachments/properties
|
||||
* are identical to this {@link Message}. Once created, the created {@link Message}
|
||||
* and the original {@link Message} behaves independently --- adding header/
|
||||
* attachment to one {@link Message} doesn't affect another {@link Message}
|
||||
* at all.
|
||||
*
|
||||
* <p>
|
||||
* This method does <b>NOT</b> consume a message.
|
||||
*
|
||||
* <p>
|
||||
* To enable efficient copy operations, there's a few restrictions on
|
||||
* how copied message can be used.
|
||||
*
|
||||
* <ol>
|
||||
* <li>The original and the copy may not be
|
||||
* used concurrently by two threads (this allows two {@link Message}s
|
||||
* to share some internal resources, such as JAXB marshallers.)
|
||||
* Note that it's OK for the original and the copy to be processed
|
||||
* by two threads, as long as they are not concurrent.
|
||||
*
|
||||
* <li>The copy has the same 'life scope'
|
||||
* as the original (this allows shallower copy, such as
|
||||
* JAXB beans wrapped in {@link JAXBMessage}.)
|
||||
* </ol>
|
||||
*
|
||||
* <p>
|
||||
* A 'life scope' of a message created during a message processing
|
||||
* in a pipeline is until a pipeline processes the next message.
|
||||
* A message cannot be kept beyond its life scope.
|
||||
*
|
||||
* (This experimental design is to allow message objects to be reused
|
||||
* --- feedback appreciated.)
|
||||
*
|
||||
*
|
||||
*
|
||||
* <h3>Design Rationale</h3>
|
||||
* <p>
|
||||
* Since a {@link Message} body is read-once, sometimes
|
||||
* (such as when you do fail-over, or WS-RM) you need to
|
||||
* create an idential copy of a {@link Message}.
|
||||
*
|
||||
* <p>
|
||||
* The actual copy operation depends on the layout
|
||||
* of the data in memory, hence it's best to be done by
|
||||
* the {@link Message} implementation itself.
|
||||
*
|
||||
* <p>
|
||||
* The restrictions placed on the use of copied {@link Message} can be
|
||||
* relaxed if necessary, but it will make the copy method more expensive.
|
||||
*/
|
||||
// TODO: update the class javadoc with 'lifescope'
|
||||
// and move the discussion about life scope there.
|
||||
public abstract Message copy();
|
||||
|
||||
/**
|
||||
* Retuns a unique id for the message. The id can be used for various things,
|
||||
* like debug assistance, logging, and MIME encoding(say for boundary).
|
||||
*
|
||||
* <p>
|
||||
* This method will check the existence of the addressing <MessageID> header,
|
||||
* and if present uses that value. Otherwise it generates one from UUID.random(),
|
||||
* and return it without adding a new header. But it doesn't add a <MessageID>
|
||||
* to the header list since we expect them to be added before calling this
|
||||
* method.
|
||||
*
|
||||
* <p>
|
||||
* Addressing tube will go do a separate verification on inbound
|
||||
* headers to make sure that <MessageID> header is present when it's
|
||||
* supposed to be.
|
||||
*
|
||||
* @param binding object created by {@link BindingID#createBinding()}
|
||||
*
|
||||
* @return unique id for the message
|
||||
* @deprecated
|
||||
*/
|
||||
public @NotNull String getID(@NotNull WSBinding binding) {
|
||||
return getID(binding.getAddressingVersion(), binding.getSOAPVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retuns a unique id for the message.
|
||||
* <p><p>
|
||||
* @see {@link #getID(com.sun.xml.internal.ws.api.WSBinding)} for detailed description.
|
||||
* @param av WS-Addressing version
|
||||
* @param sv SOAP version
|
||||
* @return unique id for the message
|
||||
* @deprecated
|
||||
*/
|
||||
public @NotNull String getID(AddressingVersion av, SOAPVersion sv) {
|
||||
String uuid = null;
|
||||
if (av != null) {
|
||||
uuid = AddressingUtils.getMessageID(getHeaders(), av, sv);
|
||||
}
|
||||
if (uuid == null) {
|
||||
uuid = generateMessageID();
|
||||
getHeaders().add(new StringHeader(av.messageIDTag, uuid));
|
||||
}
|
||||
return uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a UUID suitable for use as a MessageID value
|
||||
* @return generated UUID
|
||||
*/
|
||||
public static String generateMessageID() {
|
||||
return "uuid:" + UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public SOAPVersion getSOAPVersion() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* 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.api.message;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.soap.MimeHeader;
|
||||
import javax.xml.soap.MimeHeaders;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import javax.xml.ws.soap.MTOMFeature;
|
||||
|
||||
import com.oracle.webservices.internal.api.EnvelopeStyle;
|
||||
import com.oracle.webservices.internal.api.EnvelopeStyleFeature;
|
||||
import com.oracle.webservices.internal.api.message.MessageContext;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.WSFeatureList;
|
||||
import com.sun.xml.internal.ws.api.pipe.Codec;
|
||||
import com.sun.xml.internal.ws.api.pipe.Codecs;
|
||||
import static com.sun.xml.internal.ws.transport.http.HttpAdapter.fixQuotesAroundSoapAction;
|
||||
|
||||
/**
|
||||
* The MessageContextFactory implements com.oracle.webservices.internal.api.message.MessageContextFactory as
|
||||
* a factory of Packet and public facade of Codec(s).
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public class MessageContextFactory extends com.oracle.webservices.internal.api.message.MessageContextFactory {
|
||||
|
||||
private WSFeatureList features;
|
||||
private Codec soapCodec;
|
||||
private Codec xmlCodec;
|
||||
private EnvelopeStyleFeature envelopeStyle;
|
||||
private EnvelopeStyle.Style singleSoapStyle;
|
||||
|
||||
public MessageContextFactory(WebServiceFeature[] wsf) {
|
||||
this(new com.sun.xml.internal.ws.binding.WebServiceFeatureList(wsf));
|
||||
}
|
||||
|
||||
public MessageContextFactory(WSFeatureList wsf) {
|
||||
features = wsf;
|
||||
envelopeStyle = features.get(EnvelopeStyleFeature.class);
|
||||
if (envelopeStyle == null) {//Default to SOAP11
|
||||
envelopeStyle = new EnvelopeStyleFeature(new EnvelopeStyle.Style[]{EnvelopeStyle.Style.SOAP11});
|
||||
features.mergeFeatures(new WebServiceFeature[]{envelopeStyle}, false);
|
||||
}
|
||||
for (EnvelopeStyle.Style s : envelopeStyle.getStyles()) {
|
||||
if (s.isXML()) {
|
||||
if (xmlCodec == null) xmlCodec = Codecs.createXMLCodec(features);
|
||||
} else {
|
||||
if (soapCodec == null) soapCodec = Codecs.createSOAPBindingCodec(features);
|
||||
singleSoapStyle = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected com.oracle.webservices.internal.api.message.MessageContextFactory newFactory(WebServiceFeature... f) {
|
||||
return new com.sun.xml.internal.ws.api.message.MessageContextFactory(f);
|
||||
}
|
||||
|
||||
|
||||
public com.oracle.webservices.internal.api.message.MessageContext createContext() {
|
||||
return packet(null);
|
||||
}
|
||||
|
||||
public com.oracle.webservices.internal.api.message.MessageContext createContext(SOAPMessage soap) {
|
||||
throwIfIllegalMessageArgument(soap);
|
||||
return packet(Messages.create(soap));
|
||||
}
|
||||
|
||||
public MessageContext createContext(Source m, com.oracle.webservices.internal.api.EnvelopeStyle.Style envelopeStyle) {
|
||||
throwIfIllegalMessageArgument(m);
|
||||
return packet(Messages.create(m, SOAPVersion.from(envelopeStyle)));
|
||||
}
|
||||
|
||||
public com.oracle.webservices.internal.api.message.MessageContext createContext(Source m) {
|
||||
throwIfIllegalMessageArgument(m);
|
||||
return packet(Messages.create(m, SOAPVersion.from(singleSoapStyle)));
|
||||
}
|
||||
|
||||
public com.oracle.webservices.internal.api.message.MessageContext createContext(InputStream in, String contentType) throws IOException {
|
||||
throwIfIllegalMessageArgument(in);
|
||||
//TODO when do we use xmlCodec?
|
||||
Packet p = packet(null);
|
||||
soapCodec.decode(in, contentType, p);
|
||||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated http://java.net/jira/browse/JAX_WS-1077
|
||||
*/
|
||||
@Deprecated
|
||||
public com.oracle.webservices.internal.api.message.MessageContext createContext(InputStream in, MimeHeaders headers) throws IOException {
|
||||
String contentType = getHeader(headers, "Content-Type");
|
||||
Packet packet = (Packet) createContext(in, contentType);
|
||||
packet.acceptableMimeTypes = getHeader(headers, "Accept");
|
||||
packet.soapAction = fixQuotesAroundSoapAction(getHeader(headers, "SOAPAction"));
|
||||
// packet.put(Packet.INBOUND_TRANSPORT_HEADERS, toMap(headers));
|
||||
return packet;
|
||||
}
|
||||
|
||||
static String getHeader(MimeHeaders headers, String name) {
|
||||
String[] values = headers.getHeader(name);
|
||||
return (values != null && values.length > 0) ? values[0] : null;
|
||||
}
|
||||
|
||||
static Map<String, List<String>> toMap(MimeHeaders headers) {
|
||||
HashMap<String, List<String>> map = new HashMap<String, List<String>>();
|
||||
for (Iterator<MimeHeader> i = headers.getAllHeaders(); i.hasNext();) {
|
||||
MimeHeader mh = i.next();
|
||||
List<String> values = map.get(mh.getName());
|
||||
if (values == null) {
|
||||
values = new ArrayList<String>();
|
||||
map.put(mh.getName(), values);
|
||||
}
|
||||
values.add(mh.getValue());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public MessageContext createContext(Message m) {
|
||||
throwIfIllegalMessageArgument(m);
|
||||
return packet(m);
|
||||
}
|
||||
|
||||
private Packet packet(Message m) {
|
||||
final Packet p = new Packet();
|
||||
//TODO when do we use xmlCodec?
|
||||
p.codec = soapCodec;
|
||||
if (m != null) p.setMessage(m);
|
||||
MTOMFeature mf = features.get(MTOMFeature.class);
|
||||
if (mf != null) {
|
||||
p.setMtomFeature(mf);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
private void throwIfIllegalMessageArgument(Object message)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
if (message == null) {
|
||||
throw new IllegalArgumentException("null messages are not allowed. Consider using MessageContextFactory.createContext()");
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public com.oracle.webservices.internal.api.message.MessageContext doCreate() {
|
||||
return packet(null);
|
||||
}
|
||||
@Deprecated
|
||||
public com.oracle.webservices.internal.api.message.MessageContext doCreate(SOAPMessage m) {
|
||||
return createContext(m);
|
||||
}
|
||||
@Deprecated
|
||||
public com.oracle.webservices.internal.api.message.MessageContext doCreate(Source x, SOAPVersion soapVersion) {
|
||||
return packet(Messages.create(x, soapVersion));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* 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.api.message;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
|
||||
/**
|
||||
* Interface representing all the headers of a {@link Message}
|
||||
*/
|
||||
public interface MessageHeaders {
|
||||
public void understood(Header header);
|
||||
public void understood(QName name);
|
||||
public void understood(String nsUri, String localName);
|
||||
public Header get(String nsUri, String localName, boolean markAsUnderstood);
|
||||
public Header get(QName name, boolean markAsUnderstood);
|
||||
public Iterator<Header> getHeaders(String nsUri, String localName, final boolean markAsUnderstood);
|
||||
/**
|
||||
* Get all headers in specified namespace
|
||||
* @param nsUri
|
||||
* @param markAsUnderstood
|
||||
* @return
|
||||
*/
|
||||
public Iterator<Header> getHeaders(String nsUri, final boolean markAsUnderstood);
|
||||
public Iterator<Header> getHeaders(QName headerName, final boolean markAsUnderstood);
|
||||
public Iterator<Header> getHeaders();
|
||||
public boolean hasHeaders();
|
||||
public boolean add(Header header);
|
||||
public Header remove(QName name);
|
||||
public Header remove(String nsUri, String localName);
|
||||
//DONT public Header remove(Header header);
|
||||
public void replace(Header old, Header header);
|
||||
|
||||
/**
|
||||
* Replaces an existing {@link Header} or adds a new {@link Header}.
|
||||
*
|
||||
* <p>
|
||||
* Order doesn't matter in headers, so this method
|
||||
* does not make any guarantee as to where the new header
|
||||
* is inserted.
|
||||
*
|
||||
* @return
|
||||
* always true. Don't use the return value.
|
||||
*/
|
||||
public boolean addOrReplace(Header header);
|
||||
|
||||
/**
|
||||
* Return a Set of QNames of headers that have been explicitly marked as understood.
|
||||
* If none have been marked, this method could return null
|
||||
*/
|
||||
public Set<QName> getUnderstoodHeaders();
|
||||
|
||||
/**
|
||||
* Returns a Set of QNames of headers that satisfy ALL the following conditions:
|
||||
* (a) Have mustUnderstand = true
|
||||
* (b) have NOT been explicitly marked as understood
|
||||
* (c) If roles argument is non-null, the header has isIgnorable = false
|
||||
* for the roles argument and SOAP version
|
||||
* (d) If non-null binding is passed in, are NOT understood by the binding
|
||||
* (e) If (d) is met, the header is NOT in the knownHeaders list passed in
|
||||
*
|
||||
* @param roles
|
||||
* @param knownHeaders
|
||||
* @param binding
|
||||
* @return
|
||||
*/
|
||||
public Set<QName> getNotUnderstoodHeaders(Set<String> roles, Set<QName> knownHeaders, WSBinding binding);
|
||||
|
||||
/**
|
||||
* True if the header has been explicitly marked understood, false otherwise
|
||||
* @param header
|
||||
* @return
|
||||
*/
|
||||
public boolean isUnderstood(Header header);
|
||||
|
||||
/**
|
||||
* True if the header has been explicitly marked understood, false otherwise
|
||||
* @param header
|
||||
* @return
|
||||
*/
|
||||
public boolean isUnderstood(QName header);
|
||||
|
||||
/**
|
||||
* True if the header has been explicitly marked understood, false otherwise
|
||||
* @param header
|
||||
* @return
|
||||
*/
|
||||
public boolean isUnderstood(String nsUri, String header);
|
||||
|
||||
/**
|
||||
* Returns <code>Header</code> instances in a <code>List</code>.
|
||||
* @return <code>List</code> containing <code>Header</code> instances
|
||||
*/
|
||||
public List<Header> asList();
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.api.message;
|
||||
|
||||
import com.sun.xml.internal.ws.api.model.WSDLOperationMapping;
|
||||
|
||||
/**
|
||||
* In order for the Message to get properties from the Packet ...
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public interface MessageMetadata {
|
||||
public WSDLOperationMapping getWSDLOperationMapping();
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
* 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.api.message;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.transform.Source;
|
||||
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.xml.internal.bind.api.Bridge;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.message.saaj.SAAJMessage;
|
||||
import com.sun.xml.internal.ws.message.stream.StreamMessage;
|
||||
import com.sun.xml.internal.ws.spi.db.XMLBridge;
|
||||
|
||||
/**
|
||||
* A <code>MessageWrapper</code> wraps the Message for the access through Packet.
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
class MessageWrapper extends StreamMessage {
|
||||
|
||||
Packet packet;
|
||||
Message delegate;
|
||||
StreamMessage streamDelegate;
|
||||
|
||||
@Override
|
||||
public void writePayloadTo(ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment) throws SAXException {
|
||||
streamDelegate.writePayloadTo(contentHandler, errorHandler, fragment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBodyPrologue() {
|
||||
return streamDelegate.getBodyPrologue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBodyEpilogue() {
|
||||
return streamDelegate.getBodyEpilogue();
|
||||
}
|
||||
|
||||
MessageWrapper(Packet p, Message m) {
|
||||
super(m.getSOAPVersion());
|
||||
packet = p;
|
||||
delegate = m;
|
||||
streamDelegate = (m instanceof StreamMessage) ? (StreamMessage) m : null;
|
||||
setMessageMedadata(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return delegate.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return delegate.equals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasHeaders() {
|
||||
return delegate.hasHeaders();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttachmentSet getAttachments() {
|
||||
return delegate.getAttachments();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return delegate.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOneWay(WSDLPort port) {
|
||||
return delegate.isOneWay(port);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPayloadLocalPart() {
|
||||
return delegate.getPayloadLocalPart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPayloadNamespaceURI() {
|
||||
return delegate.getPayloadNamespaceURI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPayload() {
|
||||
return delegate.hasPayload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFault() {
|
||||
return delegate.isFault();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QName getFirstDetailEntryName() {
|
||||
return delegate.getFirstDetailEntryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Source readEnvelopeAsSource() {
|
||||
//TODO if (delegate instanceof SAAJMessage)
|
||||
return delegate.readEnvelopeAsSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Source readPayloadAsSource() {
|
||||
//TODO if (delegate instanceof SAAJMessage)
|
||||
return delegate.readPayloadAsSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SOAPMessage readAsSOAPMessage() throws SOAPException {
|
||||
if (!(delegate instanceof SAAJMessage)) {
|
||||
delegate = toSAAJ(packet, null);
|
||||
}
|
||||
return delegate.readAsSOAPMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SOAPMessage readAsSOAPMessage(Packet p, boolean inbound) throws SOAPException {
|
||||
if (!(delegate instanceof SAAJMessage)) {
|
||||
delegate = toSAAJ(p, inbound);
|
||||
}
|
||||
return delegate.readAsSOAPMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object readPayloadAsJAXB(Unmarshaller unmarshaller) throws JAXBException {
|
||||
return delegate.readPayloadAsJAXB(unmarshaller);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T readPayloadAsJAXB(Bridge<T> bridge) throws JAXBException {
|
||||
return delegate.readPayloadAsJAXB(bridge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T readPayloadAsJAXB(XMLBridge<T> bridge) throws JAXBException {
|
||||
return delegate.readPayloadAsJAXB(bridge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLStreamReader readPayload() {
|
||||
try {
|
||||
return delegate.readPayload();
|
||||
} catch (XMLStreamException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consume() {
|
||||
delegate.consume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePayloadTo(XMLStreamWriter sw) throws XMLStreamException {
|
||||
delegate.writePayloadTo(sw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(XMLStreamWriter sw) throws XMLStreamException {
|
||||
delegate.writeTo(sw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler)
|
||||
throws SAXException {
|
||||
delegate.writeTo(contentHandler, errorHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message copy() {
|
||||
return delegate.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID(WSBinding binding) {
|
||||
return delegate.getID(binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID(AddressingVersion av, SOAPVersion sv) {
|
||||
return delegate.getID(av, sv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SOAPVersion getSOAPVersion() {
|
||||
return delegate.getSOAPVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull MessageHeaders getHeaders() {
|
||||
return delegate.getHeaders();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMessageMedadata(MessageMetadata metadata) {
|
||||
super.setMessageMedadata(metadata);
|
||||
delegate.setMessageMedadata(metadata);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 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.api.message;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import javax.xml.ws.soap.MTOMFeature;
|
||||
|
||||
import com.oracle.webservices.internal.api.message.ContentType;
|
||||
|
||||
/**
|
||||
* A Message implementation may implement this interface as an alternative way to write the
|
||||
* message into the OutputStream.
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public interface MessageWritable {
|
||||
|
||||
/**
|
||||
* Gets the Content-type of this message.
|
||||
*
|
||||
* @return The MIME content type of this message
|
||||
*/
|
||||
ContentType getContentType();
|
||||
|
||||
/**
|
||||
* Writes the XML infoset portion of this MessageContext
|
||||
* (from <soap:Envelope> to </soap:Envelope>).
|
||||
*
|
||||
* @param out
|
||||
* Must not be null. The caller is responsible for closing the stream,
|
||||
* not the callee.
|
||||
*
|
||||
* @return
|
||||
* The MIME content type of this message (such as "application/xml").
|
||||
* This information is often ncessary by transport.
|
||||
*
|
||||
* @throws IOException
|
||||
* if a {@link OutputStream} throws {@link IOException}.
|
||||
*/
|
||||
ContentType writeTo( OutputStream out ) throws IOException;
|
||||
|
||||
/**
|
||||
* Passes configuration information to this message to ensure the proper
|
||||
* wire format is created. (from <soap:Envelope> to </soap:Envelope>).
|
||||
*
|
||||
* @param mtomFeature
|
||||
* The standard <code>WebServicesFeature</code> for specifying
|
||||
* the MTOM enablement and possibly threshold for the endpoint.
|
||||
* This value may be <code>null</code>.
|
||||
*/
|
||||
void setMTOMConfiguration(final MTOMFeature mtomFeature);
|
||||
}
|
||||
420
jdkSrc/jdk8/com/sun/xml/internal/ws/api/message/Messages.java
Normal file
420
jdkSrc/jdk8/com/sun/xml/internal/ws/api/message/Messages.java
Normal file
@@ -0,0 +1,420 @@
|
||||
/*
|
||||
* 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.api.message;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.stream.buffer.XMLStreamBuffer;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
||||
import com.sun.xml.internal.ws.api.message.saaj.SAAJFactory;
|
||||
import com.sun.xml.internal.ws.api.pipe.Tube;
|
||||
import com.sun.xml.internal.ws.api.pipe.Codecs;
|
||||
import com.sun.xml.internal.ws.fault.SOAPFaultBuilder;
|
||||
import com.sun.xml.internal.ws.message.AttachmentSetImpl;
|
||||
import com.sun.xml.internal.ws.message.DOMMessage;
|
||||
import com.sun.xml.internal.ws.message.EmptyMessageImpl;
|
||||
import com.sun.xml.internal.ws.message.ProblemActionHeader;
|
||||
import com.sun.xml.internal.ws.message.stream.PayloadStreamReaderMessage;
|
||||
import com.sun.xml.internal.ws.message.jaxb.JAXBMessage;
|
||||
import com.sun.xml.internal.ws.message.source.PayloadSourceMessage;
|
||||
import com.sun.xml.internal.ws.message.source.ProtocolSourceMessage;
|
||||
import com.sun.xml.internal.ws.spi.db.BindingContextFactory;
|
||||
import com.sun.xml.internal.ws.streaming.XMLStreamReaderException;
|
||||
import com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil;
|
||||
import com.sun.xml.internal.ws.util.DOMUtil;
|
||||
import com.sun.xml.internal.ws.addressing.WsaTubeHelper;
|
||||
import com.sun.xml.internal.ws.addressing.model.MissingAddressingHeaderException;
|
||||
import com.sun.xml.internal.ws.resources.AddressingMessages;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.*;
|
||||
import javax.xml.stream.XMLStreamConstants;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.sax.SAXSource;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.ws.ProtocolException;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
|
||||
/**
|
||||
* Factory methods for various {@link Message} implementations.
|
||||
*
|
||||
* <p>
|
||||
* This class provides various methods to create different
|
||||
* flavors of {@link Message} classes that store data
|
||||
* in different formats.
|
||||
*
|
||||
* <p>
|
||||
* This is a part of the JAX-WS RI internal API so that
|
||||
* {@link Tube} implementations can reuse the implementations
|
||||
* done inside the JAX-WS.
|
||||
*
|
||||
* <p>
|
||||
* If you find some of the useful convenience methods missing
|
||||
* from this class, please talk to us.
|
||||
*
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public abstract class Messages {
|
||||
private Messages() {}
|
||||
|
||||
/**
|
||||
* Creates a {@link Message} backed by a JAXB bean.
|
||||
* @deprecated
|
||||
* @param context
|
||||
* The context to be used to produce infoset from the object. Must not be null.
|
||||
* @param jaxbObject
|
||||
* The JAXB object that represents the payload. must not be null. This object
|
||||
* must be bound to an element (which means it either is a {@link JAXBElement} or
|
||||
* an instanceof a class with {@link XmlRootElement}).
|
||||
* @param soapVersion
|
||||
* The SOAP version of the message. Must not be null.
|
||||
*/
|
||||
public static Message create(JAXBContext context, Object jaxbObject, SOAPVersion soapVersion) {
|
||||
return JAXBMessage.create(context,jaxbObject,soapVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* For use when creating a Dispatch object with an unknown JAXB implementation
|
||||
* for he JAXBContext parameter.
|
||||
*
|
||||
*/
|
||||
public static Message createRaw(JAXBContext context, Object jaxbObject, SOAPVersion soapVersion) {
|
||||
return JAXBMessage.createRaw(context,jaxbObject,soapVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Use {@link #create(JAXBRIContext, Object, SOAPVersion)}
|
||||
*/
|
||||
public static Message create(Marshaller marshaller, Object jaxbObject, SOAPVersion soapVersion) {
|
||||
return create(BindingContextFactory.getBindingContext(marshaller).getJAXBContext(),jaxbObject,soapVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Message} backed by a SAAJ {@link SOAPMessage} object.
|
||||
*
|
||||
* <p>
|
||||
* If the {@link SOAPMessage} contains headers and attachments, this method
|
||||
* does the right thing.
|
||||
*
|
||||
* @param saaj
|
||||
* The SOAP message to be represented as a {@link Message}.
|
||||
* Must not be null. Once this method is invoked, the created
|
||||
* {@link Message} will own the {@link SOAPMessage}, so it shall
|
||||
* never be touched directly.
|
||||
*/
|
||||
public static Message create(SOAPMessage saaj) {
|
||||
return SAAJFactory.create(saaj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Message} using {@link Source} as payload.
|
||||
*
|
||||
* @param payload
|
||||
* Source payload is {@link Message}'s payload
|
||||
* Must not be null. Once this method is invoked, the created
|
||||
* {@link Message} will own the {@link Source}, so it shall
|
||||
* never be touched directly.
|
||||
*
|
||||
* @param ver
|
||||
* The SOAP version of the message. Must not be null.
|
||||
*/
|
||||
public static Message createUsingPayload(Source payload, SOAPVersion ver) {
|
||||
if (payload instanceof DOMSource) {
|
||||
if (((DOMSource)payload).getNode() == null) {
|
||||
return new EmptyMessageImpl(ver);
|
||||
}
|
||||
} else if (payload instanceof StreamSource) {
|
||||
StreamSource ss = (StreamSource)payload;
|
||||
if (ss.getInputStream() == null && ss.getReader() == null && ss.getSystemId() == null) {
|
||||
return new EmptyMessageImpl(ver);
|
||||
}
|
||||
} else if (payload instanceof SAXSource) {
|
||||
SAXSource ss = (SAXSource)payload;
|
||||
if (ss.getInputSource() == null && ss.getXMLReader() == null) {
|
||||
return new EmptyMessageImpl(ver);
|
||||
}
|
||||
}
|
||||
return new PayloadSourceMessage(payload, ver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Message} using {@link XMLStreamReader} as payload.
|
||||
*
|
||||
* @param payload
|
||||
* XMLStreamReader payload is {@link Message}'s payload
|
||||
* Must not be null. Once this method is invoked, the created
|
||||
* {@link Message} will own the {@link XMLStreamReader}, so it shall
|
||||
* never be touched directly.
|
||||
*
|
||||
* @param ver
|
||||
* The SOAP version of the message. Must not be null.
|
||||
*/
|
||||
public static Message createUsingPayload(XMLStreamReader payload, SOAPVersion ver) {
|
||||
return new PayloadStreamReaderMessage(payload, ver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Message} from an {@link Element} that represents
|
||||
* a payload.
|
||||
*
|
||||
* @param payload
|
||||
* The element that becomes the child element of the SOAP body.
|
||||
* Must not be null.
|
||||
*
|
||||
* @param ver
|
||||
* The SOAP version of the message. Must not be null.
|
||||
*/
|
||||
public static Message createUsingPayload(Element payload, SOAPVersion ver) {
|
||||
return new DOMMessage(ver,payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Message} from an {@link Element} that represents
|
||||
* the whole SOAP message.
|
||||
*
|
||||
* @param soapEnvelope
|
||||
* The SOAP envelope element.
|
||||
*/
|
||||
public static Message create(Element soapEnvelope) {
|
||||
SOAPVersion ver = SOAPVersion.fromNsUri(soapEnvelope.getNamespaceURI());
|
||||
// find the headers
|
||||
Element header = DOMUtil.getFirstChild(soapEnvelope, ver.nsUri, "Header");
|
||||
HeaderList headers = null;
|
||||
if(header!=null) {
|
||||
for( Node n=header.getFirstChild(); n!=null; n=n.getNextSibling() ) {
|
||||
if(n.getNodeType()==Node.ELEMENT_NODE) {
|
||||
if(headers==null)
|
||||
headers = new HeaderList(ver);
|
||||
headers.add(Headers.create((Element)n));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// find the payload
|
||||
Element body = DOMUtil.getFirstChild(soapEnvelope, ver.nsUri, "Body");
|
||||
if(body==null)
|
||||
throw new WebServiceException("Message doesn't have <S:Body> "+soapEnvelope);
|
||||
Element payload = DOMUtil.getFirstChild(soapEnvelope, ver.nsUri, "Body");
|
||||
|
||||
if(payload==null) {
|
||||
return new EmptyMessageImpl(headers, new AttachmentSetImpl(), ver);
|
||||
} else {
|
||||
return new DOMMessage(ver,headers,payload);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Message} using Source as entire envelope.
|
||||
*
|
||||
* @param envelope
|
||||
* Source envelope is used to create {@link Message}
|
||||
* Must not be null. Once this method is invoked, the created
|
||||
* {@link Message} will own the {@link Source}, so it shall
|
||||
* never be touched directly.
|
||||
*
|
||||
*/
|
||||
public static Message create(Source envelope, SOAPVersion soapVersion) {
|
||||
return new ProtocolSourceMessage(envelope, soapVersion);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a {@link Message} that doesn't have any payload.
|
||||
*/
|
||||
public static Message createEmpty(SOAPVersion soapVersion) {
|
||||
return new EmptyMessageImpl(soapVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Message} from {@link XMLStreamReader} that points to
|
||||
* the start of the envelope.
|
||||
*
|
||||
* @param reader
|
||||
* can point to the start document or the start element (of <s:Envelope>)
|
||||
*/
|
||||
public static @NotNull Message create(@NotNull XMLStreamReader reader) {
|
||||
// skip until the root element
|
||||
if(reader.getEventType()!=XMLStreamConstants.START_ELEMENT)
|
||||
XMLStreamReaderUtil.nextElementContent(reader);
|
||||
assert reader.getEventType()== XMLStreamConstants.START_ELEMENT :reader.getEventType();
|
||||
|
||||
SOAPVersion ver = SOAPVersion.fromNsUri(reader.getNamespaceURI());
|
||||
|
||||
return Codecs.createSOAPEnvelopeXmlCodec(ver).decode(reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Message} from {@link XMLStreamBuffer} that retains the
|
||||
* whole envelope infoset.
|
||||
*
|
||||
* @param xsb
|
||||
* This buffer must contain the infoset of the whole envelope.
|
||||
*/
|
||||
public static @NotNull Message create(@NotNull XMLStreamBuffer xsb) {
|
||||
// TODO: we should be able to let Messae know that it's working off from a buffer,
|
||||
// to make some of the operations more efficient.
|
||||
// meanwhile, adding this as an API so that our users can take advantage of it
|
||||
// when we get around to such an implementation later.
|
||||
try {
|
||||
return create(xsb.readAsXMLStreamReader());
|
||||
} catch (XMLStreamException e) {
|
||||
throw new XMLStreamReaderException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Message} that represents an exception as a fault. The
|
||||
* created message reflects if t or t.getCause() is SOAPFaultException.
|
||||
*
|
||||
* creates a fault message with default faultCode env:Server if t or t.getCause()
|
||||
* is not SOAPFaultException. Otherwise, it use SOAPFaultException's faultCode
|
||||
*
|
||||
* @return
|
||||
* Always non-null. A message that wraps this {@link Throwable}.
|
||||
*
|
||||
*/
|
||||
public static Message create(Throwable t, SOAPVersion soapVersion) {
|
||||
return SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a fault {@link Message}.
|
||||
*
|
||||
* <p>
|
||||
* This method is not designed for efficiency, and we don't expect
|
||||
* to be used for the performance critical codepath.
|
||||
*
|
||||
* @param fault
|
||||
* The populated SAAJ data structure that represents a fault
|
||||
* in detail.
|
||||
*
|
||||
* @return
|
||||
* Always non-null. A message that wraps this {@link SOAPFault}.
|
||||
*/
|
||||
public static Message create(SOAPFault fault) {
|
||||
SOAPVersion ver = SOAPVersion.fromNsUri(fault.getNamespaceURI());
|
||||
return new DOMMessage(ver,fault);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Use {@link #createAddressingFaultMessage(WSBinding, Packet, QName)}
|
||||
*/
|
||||
public static Message createAddressingFaultMessage(WSBinding binding, QName missingHeader) {
|
||||
return createAddressingFaultMessage(binding,null,missingHeader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a fault {@link Message} that captures the code/subcode/subsubcode
|
||||
* defined by WS-Addressing if one of the expected WS-Addressing headers is
|
||||
* missing in the message
|
||||
*
|
||||
* @param binding WSBinding
|
||||
* @param p
|
||||
* {@link Packet} that was missing a WS-Addressing header.
|
||||
* @param missingHeader The missing WS-Addressing Header
|
||||
* @return
|
||||
* A message representing SOAPFault that contains the WS-Addressing code/subcode/subsubcode.
|
||||
*/
|
||||
public static Message createAddressingFaultMessage(WSBinding binding, Packet p, QName missingHeader) {
|
||||
AddressingVersion av = binding.getAddressingVersion();
|
||||
if(av == null) {
|
||||
// Addressing is not enabled.
|
||||
throw new WebServiceException(AddressingMessages.ADDRESSING_SHOULD_BE_ENABLED());
|
||||
}
|
||||
WsaTubeHelper helper = av.getWsaHelper(null,null,binding);
|
||||
return create(helper.newMapRequiredFault(new MissingAddressingHeaderException(missingHeader,p)));
|
||||
}
|
||||
/**
|
||||
* Creates a fault {@link Message} that captures the code/subcode/subsubcode
|
||||
* defined by WS-Addressing if wsa:Action is not supported.
|
||||
*
|
||||
* @param unsupportedAction The unsupported Action. Must not be null.
|
||||
* @param av The WS-Addressing version of the message. Must not be null.
|
||||
* @param sv The SOAP Version of the message. Must not be null.
|
||||
*
|
||||
* @return
|
||||
* A message representing SOAPFault that contains the WS-Addressing code/subcode/subsubcode.
|
||||
*/
|
||||
public static Message create(@NotNull String unsupportedAction, @NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
|
||||
QName subcode = av.actionNotSupportedTag;
|
||||
String faultstring = String.format(av.actionNotSupportedText, unsupportedAction);
|
||||
|
||||
Message faultMessage;
|
||||
SOAPFault fault;
|
||||
try {
|
||||
if (sv == SOAPVersion.SOAP_12) {
|
||||
fault = SOAPVersion.SOAP_12.getSOAPFactory().createFault();
|
||||
fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
|
||||
fault.appendFaultSubcode(subcode);
|
||||
Detail detail = fault.addDetail();
|
||||
SOAPElement se = detail.addChildElement(av.problemActionTag);
|
||||
se = se.addChildElement(av.actionTag);
|
||||
se.addTextNode(unsupportedAction);
|
||||
} else {
|
||||
fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault();
|
||||
fault.setFaultCode(subcode);
|
||||
}
|
||||
fault.setFaultString(faultstring);
|
||||
|
||||
faultMessage = SOAPFaultBuilder.createSOAPFaultMessage(sv, fault);
|
||||
if (sv == SOAPVersion.SOAP_11) {
|
||||
faultMessage.getHeaders().add(new ProblemActionHeader(unsupportedAction, av));
|
||||
}
|
||||
} catch (SOAPException e) {
|
||||
throw new WebServiceException(e);
|
||||
}
|
||||
|
||||
return faultMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* To be called to convert a {@link ProtocolException} and faultcode for a given {@link SOAPVersion} in to a {@link Message}.
|
||||
*
|
||||
* @param soapVersion {@link SOAPVersion#SOAP_11} or {@link SOAPVersion#SOAP_12}
|
||||
* @param pex a ProtocolException
|
||||
* @param faultcode soap faultcode. Its ignored if the {@link ProtocolException} instance is {@link javax.xml.ws.soap.SOAPFaultException} and it has a
|
||||
* faultcode present in the underlying {@link SOAPFault}.
|
||||
* @return {@link Message} representing SOAP fault
|
||||
*/
|
||||
public static @NotNull Message create(@NotNull SOAPVersion soapVersion, @NotNull ProtocolException pex, @Nullable QName faultcode){
|
||||
return SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, pex, faultcode);
|
||||
}
|
||||
}
|
||||
1475
jdkSrc/jdk8/com/sun/xml/internal/ws/api/message/Packet.java
Normal file
1475
jdkSrc/jdk8/com/sun/xml/internal/ws/api/message/Packet.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 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.api.message;
|
||||
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
|
||||
public interface StreamingSOAP {
|
||||
public XMLStreamReader readEnvelope();
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 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.api.message;
|
||||
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
/**
|
||||
* Suppresses automatic generation of WS-Addressing headers in request messages. Use this in cases
|
||||
* where required headers will be generated by other means.
|
||||
*
|
||||
* @since 2.2.6
|
||||
*/
|
||||
public class SuppressAutomaticWSARequestHeadersFeature extends
|
||||
WebServiceFeature {
|
||||
|
||||
public SuppressAutomaticWSARequestHeadersFeature() {
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return SuppressAutomaticWSARequestHeadersFeature.class.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* {@link com.sun.xml.internal.ws.api.message.Message} and related abstractions that represent a SOAP message.
|
||||
*/
|
||||
package com.sun.xml.internal.ws.api.message;
|
||||
@@ -0,0 +1,339 @@
|
||||
/*
|
||||
* 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.api.message.saaj;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.xml.soap.AttachmentPart;
|
||||
import javax.xml.soap.MessageFactory;
|
||||
import javax.xml.soap.SAAJMetaFactory;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.soap.SOAPFactory;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.sun.xml.internal.bind.marshaller.SAX2DOMEx;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.message.Attachment;
|
||||
import com.sun.xml.internal.ws.api.message.AttachmentEx;
|
||||
import com.sun.xml.internal.ws.api.message.Message;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.sun.xml.internal.ws.message.saaj.SAAJMessage;
|
||||
import com.sun.xml.internal.ws.util.ServiceFinder;
|
||||
import com.sun.xml.internal.ws.util.xml.XmlUtil;
|
||||
|
||||
/**
|
||||
* Factory SPI for SAAJ implementations
|
||||
*
|
||||
* @since 2.2.6
|
||||
*/
|
||||
public class SAAJFactory {
|
||||
private static final SAAJFactory instance = new SAAJFactory();
|
||||
|
||||
/**
|
||||
* Creates a new <code>MessageFactory</code> object that is an instance
|
||||
* of the specified implementation. May be a dynamic message factory,
|
||||
* a SOAP 1.1 message factory, or a SOAP 1.2 message factory. A dynamic
|
||||
* message factory creates messages based on the MIME headers specified
|
||||
* as arguments to the <code>createMessage</code> method.
|
||||
*
|
||||
* This method uses the SAAJMetaFactory to locate the implementation class
|
||||
* and create the MessageFactory instance.
|
||||
*
|
||||
* @return a new instance of a <code>MessageFactory</code>
|
||||
*
|
||||
* @param protocol a string constant representing the class of the
|
||||
* specified message factory implementation. May be
|
||||
* either <code>DYNAMIC_SOAP_PROTOCOL</code>,
|
||||
* <code>DEFAULT_SOAP_PROTOCOL</code> (which is the same
|
||||
* as) <code>SOAP_1_1_PROTOCOL</code>, or
|
||||
* <code>SOAP_1_2_PROTOCOL</code>.
|
||||
*
|
||||
* @exception SOAPException if there was an error in creating the
|
||||
* specified implementation of <code>MessageFactory</code>.
|
||||
* @see SAAJMetaFactory
|
||||
*/
|
||||
public static MessageFactory getMessageFactory(String protocol) throws SOAPException {
|
||||
for (SAAJFactory s : ServiceFinder.find(SAAJFactory.class)) {
|
||||
MessageFactory mf = s.createMessageFactory(protocol);
|
||||
if (mf != null)
|
||||
return mf;
|
||||
}
|
||||
|
||||
return instance.createMessageFactory(protocol);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new <code>SOAPFactory</code> object that is an instance of
|
||||
* the specified implementation, this method uses the SAAJMetaFactory to
|
||||
* locate the implementation class and create the SOAPFactory instance.
|
||||
*
|
||||
* @return a new instance of a <code>SOAPFactory</code>
|
||||
*
|
||||
* @param protocol a string constant representing the protocol of the
|
||||
* specified SOAP factory implementation. May be
|
||||
* either <code>DYNAMIC_SOAP_PROTOCOL</code>,
|
||||
* <code>DEFAULT_SOAP_PROTOCOL</code> (which is the same
|
||||
* as) <code>SOAP_1_1_PROTOCOL</code>, or
|
||||
* <code>SOAP_1_2_PROTOCOL</code>.
|
||||
*
|
||||
* @exception SOAPException if there was an error creating the
|
||||
* specified <code>SOAPFactory</code>
|
||||
* @see SAAJMetaFactory
|
||||
*/
|
||||
public static SOAPFactory getSOAPFactory(String protocol) throws SOAPException {
|
||||
for (SAAJFactory s : ServiceFinder.find(SAAJFactory.class)) {
|
||||
SOAPFactory sf = s.createSOAPFactory(protocol);
|
||||
if (sf != null)
|
||||
return sf;
|
||||
}
|
||||
|
||||
return instance.createSOAPFactory(protocol);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates Message from SOAPMessage
|
||||
* @param saaj SOAPMessage
|
||||
* @return created Message
|
||||
*/
|
||||
public static Message create(SOAPMessage saaj) {
|
||||
for (SAAJFactory s : ServiceFinder.find(SAAJFactory.class)) {
|
||||
Message m = s.createMessage(saaj);
|
||||
if (m != null)
|
||||
return m;
|
||||
}
|
||||
|
||||
return instance.createMessage(saaj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads Message as SOAPMessage. After this call message is consumed.
|
||||
* @param soapVersion SOAP version
|
||||
* @param message Message
|
||||
* @return Created SOAPMessage
|
||||
* @throws SOAPException if SAAJ processing fails
|
||||
*/
|
||||
public static SOAPMessage read(SOAPVersion soapVersion, Message message) throws SOAPException {
|
||||
for (SAAJFactory s : ServiceFinder.find(SAAJFactory.class)) {
|
||||
SOAPMessage msg = s.readAsSOAPMessage(soapVersion, message);
|
||||
if (msg != null)
|
||||
return msg;
|
||||
}
|
||||
|
||||
return instance.readAsSOAPMessage(soapVersion, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads Message as SOAPMessage. After this call message is consumed.
|
||||
* @param soapVersion SOAP version
|
||||
* @param message Message
|
||||
* @param packet The packet that owns the Message
|
||||
* @return Created SOAPMessage
|
||||
* @throws SOAPException if SAAJ processing fails
|
||||
*/
|
||||
public static SOAPMessage read(SOAPVersion soapVersion, Message message, Packet packet) throws SOAPException {
|
||||
for (SAAJFactory s : ServiceFinder.find(SAAJFactory.class)) {
|
||||
SOAPMessage msg = s.readAsSOAPMessage(soapVersion, message, packet);
|
||||
if (msg != null)
|
||||
return msg;
|
||||
}
|
||||
|
||||
return instance.readAsSOAPMessage(soapVersion, message, packet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the message within the Packet to a SAAJMessage. After this call message is consumed.
|
||||
* @param packet Packet
|
||||
* @return Created SAAJPMessage
|
||||
* @throws SOAPException if SAAJ processing fails
|
||||
*/
|
||||
public static SAAJMessage read(Packet packet) throws SOAPException {
|
||||
// Use the Component from the Packet if it exists. Note the logic
|
||||
// in the ServiceFinder is such that find(Class) is not equivalent
|
||||
// to find (Class, null), so the ternary operator is needed.
|
||||
ServiceFinder<SAAJFactory> factories = (packet.component != null ?
|
||||
ServiceFinder.find(SAAJFactory.class, packet.component) :
|
||||
ServiceFinder.find(SAAJFactory.class));
|
||||
for (SAAJFactory s : factories) {
|
||||
SAAJMessage msg = s.readAsSAAJ(packet);
|
||||
if (msg != null) return msg;
|
||||
}
|
||||
return instance.readAsSAAJ(packet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the message within the Packet to a SAAJMessage. After this call message is consumed.
|
||||
* @param packet Packet
|
||||
* @return Created SAAJPMessage
|
||||
* @throws SOAPException if SAAJ processing fails
|
||||
*/
|
||||
public SAAJMessage readAsSAAJ(Packet packet) throws SOAPException {
|
||||
SOAPVersion v = packet.getMessage().getSOAPVersion();
|
||||
SOAPMessage msg = readAsSOAPMessage(v, packet.getMessage());
|
||||
return new SAAJMessage(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new <code>MessageFactory</code> object that is an instance
|
||||
* of the specified implementation. May be a dynamic message factory,
|
||||
* a SOAP 1.1 message factory, or a SOAP 1.2 message factory. A dynamic
|
||||
* message factory creates messages based on the MIME headers specified
|
||||
* as arguments to the <code>createMessage</code> method.
|
||||
*
|
||||
* This method uses the SAAJMetaFactory to locate the implementation class
|
||||
* and create the MessageFactory instance.
|
||||
*
|
||||
* @return a new instance of a <code>MessageFactory</code>
|
||||
*
|
||||
* @param protocol a string constant representing the class of the
|
||||
* specified message factory implementation. May be
|
||||
* either <code>DYNAMIC_SOAP_PROTOCOL</code>,
|
||||
* <code>DEFAULT_SOAP_PROTOCOL</code> (which is the same
|
||||
* as) <code>SOAP_1_1_PROTOCOL</code>, or
|
||||
* <code>SOAP_1_2_PROTOCOL</code>.
|
||||
*
|
||||
* @exception SOAPException if there was an error in creating the
|
||||
* specified implementation of <code>MessageFactory</code>.
|
||||
* @see SAAJMetaFactory
|
||||
*/
|
||||
public MessageFactory createMessageFactory(String protocol) throws SOAPException {
|
||||
return MessageFactory.newInstance(protocol);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new <code>SOAPFactory</code> object that is an instance of
|
||||
* the specified implementation, this method uses the SAAJMetaFactory to
|
||||
* locate the implementation class and create the SOAPFactory instance.
|
||||
*
|
||||
* @return a new instance of a <code>SOAPFactory</code>
|
||||
*
|
||||
* @param protocol a string constant representing the protocol of the
|
||||
* specified SOAP factory implementation. May be
|
||||
* either <code>DYNAMIC_SOAP_PROTOCOL</code>,
|
||||
* <code>DEFAULT_SOAP_PROTOCOL</code> (which is the same
|
||||
* as) <code>SOAP_1_1_PROTOCOL</code>, or
|
||||
* <code>SOAP_1_2_PROTOCOL</code>.
|
||||
*
|
||||
* @exception SOAPException if there was an error creating the
|
||||
* specified <code>SOAPFactory</code>
|
||||
* @see SAAJMetaFactory
|
||||
*/
|
||||
public SOAPFactory createSOAPFactory(String protocol) throws SOAPException {
|
||||
return SOAPFactory.newInstance(protocol);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates Message from SOAPMessage
|
||||
* @param saaj SOAPMessage
|
||||
* @return created Message
|
||||
*/
|
||||
public Message createMessage(SOAPMessage saaj) {
|
||||
return new SAAJMessage(saaj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads Message as SOAPMessage. After this call message is consumed.
|
||||
* @param soapVersion SOAP version
|
||||
* @param message Message
|
||||
* @return Created SOAPMessage
|
||||
* @throws SOAPException if SAAJ processing fails
|
||||
*/
|
||||
public SOAPMessage readAsSOAPMessage(final SOAPVersion soapVersion, final Message message) throws SOAPException {
|
||||
SOAPMessage msg = soapVersion.getMessageFactory().createMessage();
|
||||
SaajStaxWriter writer = new SaajStaxWriter(msg);
|
||||
try {
|
||||
message.writeTo(writer);
|
||||
} catch (XMLStreamException e) {
|
||||
throw (e.getCause() instanceof SOAPException) ? (SOAPException) e.getCause() : new SOAPException(e);
|
||||
}
|
||||
msg = writer.getSOAPMessage();
|
||||
addAttachmentsToSOAPMessage(msg, message);
|
||||
if (msg.saveRequired())
|
||||
msg.saveChanges();
|
||||
return msg;
|
||||
}
|
||||
|
||||
public SOAPMessage readAsSOAPMessageSax2Dom(final SOAPVersion soapVersion, final Message message) throws SOAPException {
|
||||
SOAPMessage msg = soapVersion.getMessageFactory().createMessage();
|
||||
SAX2DOMEx s2d = new SAX2DOMEx(msg.getSOAPPart());
|
||||
try {
|
||||
message.writeTo(s2d, XmlUtil.DRACONIAN_ERROR_HANDLER);
|
||||
} catch (SAXException e) {
|
||||
throw new SOAPException(e);
|
||||
}
|
||||
addAttachmentsToSOAPMessage(msg, message);
|
||||
if (msg.saveRequired())
|
||||
msg.saveChanges();
|
||||
return msg;
|
||||
}
|
||||
|
||||
static protected void addAttachmentsToSOAPMessage(SOAPMessage msg, Message message) {
|
||||
for(Attachment att : message.getAttachments()) {
|
||||
AttachmentPart part = msg.createAttachmentPart();
|
||||
part.setDataHandler(att.asDataHandler());
|
||||
|
||||
// Be safe and avoid double angle-brackets.
|
||||
String cid = att.getContentId();
|
||||
if (cid != null) {
|
||||
if (cid.startsWith("<") && cid.endsWith(">"))
|
||||
part.setContentId(cid);
|
||||
else
|
||||
part.setContentId('<' + cid + '>');
|
||||
}
|
||||
|
||||
// Add any MIME headers beside Content-ID, which is already
|
||||
// accounted for above, and Content-Type, which is provided
|
||||
// by the DataHandler above.
|
||||
if (att instanceof AttachmentEx) {
|
||||
AttachmentEx ax = (AttachmentEx) att;
|
||||
Iterator<AttachmentEx.MimeHeader> imh = ax.getMimeHeaders();
|
||||
while (imh.hasNext()) {
|
||||
AttachmentEx.MimeHeader ame = imh.next();
|
||||
if ((!"Content-ID".equals(ame.getName()))
|
||||
&& (!"Content-Type".equals(ame.getName())))
|
||||
part.addMimeHeader(ame.getName(), ame.getValue());
|
||||
}
|
||||
}
|
||||
msg.addAttachmentPart(part);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads Message as SOAPMessage. After this call message is consumed.
|
||||
* The implementation in this class simply calls readAsSOAPMessage(SOAPVersion, Message),
|
||||
* and ignores the other parameters
|
||||
* Subclasses can override and choose to base SOAPMessage creation on Packet properties if needed
|
||||
* @param soapVersion SOAP version
|
||||
* @param message Message
|
||||
* @return Created SOAPMessage
|
||||
* @throws SOAPException if SAAJ processing fails
|
||||
*/
|
||||
public SOAPMessage readAsSOAPMessage(SOAPVersion soapVersion, Message message, Packet packet) throws SOAPException {
|
||||
return readAsSOAPMessage(soapVersion, message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,498 @@
|
||||
/*
|
||||
* 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.api.message.saaj;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.soap.SOAPHeader;
|
||||
import javax.xml.soap.SOAPHeaderElement;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.message.Header;
|
||||
import com.sun.xml.internal.ws.api.message.MessageHeaders;
|
||||
import com.sun.xml.internal.ws.binding.SOAPBindingImpl;
|
||||
import com.sun.xml.internal.ws.message.saaj.SAAJHeader;
|
||||
|
||||
public class SAAJMessageHeaders implements MessageHeaders {
|
||||
SOAPMessage sm;
|
||||
Map<SOAPHeaderElement, Header> nonSAAJHeaders;
|
||||
Map<QName, Integer> notUnderstoodCount;
|
||||
SOAPVersion soapVersion;
|
||||
private Set<QName> understoodHeaders;
|
||||
|
||||
public SAAJMessageHeaders(SOAPMessage sm, SOAPVersion version) {
|
||||
this.sm = sm;
|
||||
this.soapVersion = version;
|
||||
initHeaderUnderstanding();
|
||||
}
|
||||
|
||||
/** Set the initial understood/not understood state of the headers in this
|
||||
* object
|
||||
*/
|
||||
private void initHeaderUnderstanding() {
|
||||
SOAPHeader soapHeader = ensureSOAPHeader();
|
||||
if (soapHeader == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator allHeaders = soapHeader.examineAllHeaderElements();
|
||||
while(allHeaders.hasNext()) {
|
||||
SOAPHeaderElement nextHdrElem = (SOAPHeaderElement) allHeaders.next();
|
||||
if (nextHdrElem == null) {
|
||||
continue;
|
||||
}
|
||||
if (nextHdrElem.getMustUnderstand()) {
|
||||
notUnderstood(nextHdrElem.getElementQName());
|
||||
}
|
||||
//only headers explicitly marked as understood should be
|
||||
//in the understoodHeaders set, so don't add anything to
|
||||
//that set at the beginning
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void understood(Header header) {
|
||||
understood(header.getNamespaceURI(), header.getLocalPart());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void understood(String nsUri, String localName) {
|
||||
understood(new QName(nsUri, localName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void understood(QName qName) {
|
||||
if (notUnderstoodCount == null) {
|
||||
notUnderstoodCount = new HashMap<QName, Integer>();
|
||||
}
|
||||
|
||||
Integer count = notUnderstoodCount.get(qName);
|
||||
if (count != null && count.intValue() > 0) {
|
||||
//found the header in notUnderstood headers - decrement count
|
||||
count = count.intValue() - 1;
|
||||
if (count <= 0) {
|
||||
//if the value is zero or negative, remove that header name
|
||||
//since all headers by that name are understood now
|
||||
notUnderstoodCount.remove(qName);
|
||||
} else {
|
||||
notUnderstoodCount.put(qName, count);
|
||||
}
|
||||
}
|
||||
|
||||
if (understoodHeaders == null) {
|
||||
understoodHeaders = new HashSet<QName>();
|
||||
}
|
||||
//also add it to the understood headers list (optimization for getUnderstoodHeaders)
|
||||
understoodHeaders.add(qName);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnderstood(Header header) {
|
||||
return isUnderstood(header.getNamespaceURI(), header.getLocalPart());
|
||||
}
|
||||
@Override
|
||||
public boolean isUnderstood(String nsUri, String localName) {
|
||||
return isUnderstood(new QName(nsUri, localName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnderstood(QName name) {
|
||||
if (understoodHeaders == null) {
|
||||
return false;
|
||||
}
|
||||
return understoodHeaders.contains(name);
|
||||
}
|
||||
|
||||
public boolean isUnderstood(int index) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Header get(String nsUri, String localName, boolean markAsUnderstood) {
|
||||
SOAPHeaderElement h = find(nsUri, localName);
|
||||
if (h != null) {
|
||||
if (markAsUnderstood) {
|
||||
understood(nsUri, localName);
|
||||
}
|
||||
return new SAAJHeader(h);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Header get(QName name, boolean markAsUnderstood) {
|
||||
return get(name.getNamespaceURI(), name.getLocalPart(), markAsUnderstood);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Header> getHeaders(QName headerName,
|
||||
boolean markAsUnderstood) {
|
||||
return getHeaders(headerName.getNamespaceURI(), headerName.getLocalPart(), markAsUnderstood);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Header> getHeaders(final String nsUri, final String localName,
|
||||
final boolean markAsUnderstood) {
|
||||
SOAPHeader soapHeader = ensureSOAPHeader();
|
||||
if (soapHeader == null) {
|
||||
return null;
|
||||
}
|
||||
Iterator allHeaders = soapHeader.examineAllHeaderElements();
|
||||
if (markAsUnderstood) {
|
||||
//mark all the matchingheaders as understood up front
|
||||
//make an iterator while we're doing that
|
||||
List<Header> headers = new ArrayList<Header>();
|
||||
while (allHeaders.hasNext()) {
|
||||
SOAPHeaderElement nextHdr = (SOAPHeaderElement) allHeaders.next();
|
||||
if (nextHdr != null &&
|
||||
nextHdr.getNamespaceURI().equals(nsUri)) {
|
||||
if (localName == null ||
|
||||
nextHdr.getLocalName().equals(localName)) {
|
||||
understood(nextHdr.getNamespaceURI(), nextHdr.getLocalName());
|
||||
headers.add(new SAAJHeader(nextHdr));
|
||||
}
|
||||
}
|
||||
}
|
||||
return headers.iterator();
|
||||
}
|
||||
//if we got here markAsUnderstood is false - return a lazy iterator rather
|
||||
//than traverse the entire list of headers now
|
||||
return new HeaderReadIterator(allHeaders, nsUri, localName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Header> getHeaders(String nsUri, boolean markAsUnderstood) {
|
||||
return getHeaders(nsUri, null, markAsUnderstood);
|
||||
}
|
||||
@Override
|
||||
public boolean add(Header header) {
|
||||
try {
|
||||
header.writeTo(sm);
|
||||
} catch (SOAPException e) {
|
||||
//TODO log exception
|
||||
return false;
|
||||
}
|
||||
|
||||
//the newly added header is not understood by default
|
||||
notUnderstood(new QName(header.getNamespaceURI(), header.getLocalPart()));
|
||||
|
||||
//track non saaj headers so that they can be retrieved later
|
||||
if (isNonSAAJHeader(header)) {
|
||||
//TODO assumes only one header with that name?
|
||||
addNonSAAJHeader(find(header.getNamespaceURI(), header.getLocalPart()),
|
||||
header);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Header remove(QName name) {
|
||||
return remove(name.getNamespaceURI(), name.getLocalPart());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Header remove(String nsUri, String localName) {
|
||||
SOAPHeader soapHeader = ensureSOAPHeader();
|
||||
if (soapHeader == null) {
|
||||
return null;
|
||||
}
|
||||
SOAPHeaderElement headerElem = find(nsUri, localName);
|
||||
if (headerElem == null) {
|
||||
return null;
|
||||
}
|
||||
headerElem = (SOAPHeaderElement) soapHeader.removeChild(headerElem);
|
||||
|
||||
//it might have been a nonSAAJHeader - remove from that map
|
||||
removeNonSAAJHeader(headerElem);
|
||||
|
||||
//remove it from understoodHeaders and notUnderstoodHeaders if present
|
||||
QName hdrName = (nsUri == null) ? new QName(localName) : new QName(nsUri, localName);
|
||||
if (understoodHeaders != null) {
|
||||
understoodHeaders.remove(hdrName);
|
||||
}
|
||||
removeNotUnderstood(hdrName);
|
||||
|
||||
return new SAAJHeader(headerElem);
|
||||
}
|
||||
|
||||
private void removeNotUnderstood(QName hdrName) {
|
||||
if (notUnderstoodCount == null) {
|
||||
return;
|
||||
}
|
||||
Integer notUnderstood = notUnderstoodCount.get(hdrName);
|
||||
if (notUnderstood != null) {
|
||||
int intNotUnderstood = notUnderstood;
|
||||
intNotUnderstood--;
|
||||
if (intNotUnderstood <= 0) {
|
||||
notUnderstoodCount.remove(hdrName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private SOAPHeaderElement find(QName qName) {
|
||||
return find(qName.getNamespaceURI(), qName.getLocalPart());
|
||||
}
|
||||
|
||||
private SOAPHeaderElement find(String nsUri, String localName) {
|
||||
SOAPHeader soapHeader = ensureSOAPHeader();
|
||||
if (soapHeader == null) {
|
||||
return null;
|
||||
}
|
||||
Iterator allHeaders = soapHeader.examineAllHeaderElements();
|
||||
while(allHeaders.hasNext()) {
|
||||
SOAPHeaderElement nextHdrElem = (SOAPHeaderElement) allHeaders.next();
|
||||
if (nextHdrElem.getNamespaceURI().equals(nsUri) &&
|
||||
nextHdrElem.getLocalName().equals(localName)) {
|
||||
return nextHdrElem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void notUnderstood(QName qName) {
|
||||
if (notUnderstoodCount == null) {
|
||||
notUnderstoodCount = new HashMap<QName, Integer>();
|
||||
}
|
||||
Integer count = notUnderstoodCount.get(qName);
|
||||
if (count == null) {
|
||||
notUnderstoodCount.put(qName, 1);
|
||||
} else {
|
||||
notUnderstoodCount.put(qName, count + 1);
|
||||
}
|
||||
|
||||
//if for some strange reason it was previously understood and now is not,
|
||||
//remove it from understoodHeaders if it exists there
|
||||
if (understoodHeaders != null) {
|
||||
understoodHeaders.remove(qName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to get the SOAPHeader from a SOAPMessage, adding one if
|
||||
* one is not present in the original message.
|
||||
*/
|
||||
private SOAPHeader ensureSOAPHeader() {
|
||||
SOAPHeader header;
|
||||
try {
|
||||
header = sm.getSOAPPart().getEnvelope().getHeader();
|
||||
if (header != null) {
|
||||
return header;
|
||||
} else {
|
||||
return sm.getSOAPPart().getEnvelope().addHeader();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isNonSAAJHeader(Header header) {
|
||||
return !(header instanceof SAAJHeader);
|
||||
}
|
||||
|
||||
private void addNonSAAJHeader(SOAPHeaderElement headerElem, Header header) {
|
||||
if (nonSAAJHeaders == null) {
|
||||
nonSAAJHeaders = new HashMap<SOAPHeaderElement, Header>();
|
||||
}
|
||||
nonSAAJHeaders.put(headerElem, header);
|
||||
}
|
||||
|
||||
private void removeNonSAAJHeader(SOAPHeaderElement headerElem) {
|
||||
if (nonSAAJHeaders != null) {
|
||||
nonSAAJHeaders.remove(headerElem);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addOrReplace(Header header) {
|
||||
remove(header.getNamespaceURI(), header.getLocalPart());
|
||||
return add(header);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replace(Header old, Header header) {
|
||||
if (remove(old.getNamespaceURI(), old.getLocalPart()) == null)
|
||||
throw new IllegalArgumentException();
|
||||
add(header);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<QName> getUnderstoodHeaders() {
|
||||
return understoodHeaders;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<QName> getNotUnderstoodHeaders(Set<String> roles,
|
||||
Set<QName> knownHeaders, WSBinding binding) {
|
||||
Set<QName> notUnderstoodHeaderNames = new HashSet<QName>();
|
||||
if (notUnderstoodCount == null) {
|
||||
return notUnderstoodHeaderNames;
|
||||
}
|
||||
for (QName headerName : notUnderstoodCount.keySet()) {
|
||||
int count = notUnderstoodCount.get(headerName);
|
||||
if (count <= 0) {
|
||||
continue;
|
||||
}
|
||||
SOAPHeaderElement hdrElem = find(headerName);
|
||||
if (!hdrElem.getMustUnderstand()) {
|
||||
continue;
|
||||
}
|
||||
SAAJHeader hdr = new SAAJHeader(hdrElem);
|
||||
//mustUnderstand attribute is true - but there may be
|
||||
//additional criteria
|
||||
boolean understood = false;
|
||||
if (roles != null) {
|
||||
understood = !roles.contains(hdr.getRole(soapVersion));
|
||||
}
|
||||
if (understood) {
|
||||
continue;
|
||||
}
|
||||
//if it must be understood see if it is understood by the binding
|
||||
//or is in knownheaders
|
||||
if (binding != null && binding instanceof SOAPBindingImpl) {
|
||||
understood = ((SOAPBindingImpl) binding).understandsHeader(headerName);
|
||||
if (!understood) {
|
||||
if (knownHeaders != null && knownHeaders.contains(headerName)) {
|
||||
understood = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!understood) {
|
||||
notUnderstoodHeaderNames.add(headerName);
|
||||
}
|
||||
}
|
||||
return notUnderstoodHeaderNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Header> getHeaders() {
|
||||
SOAPHeader soapHeader = ensureSOAPHeader();
|
||||
if (soapHeader == null) {
|
||||
return null;
|
||||
}
|
||||
Iterator allHeaders = soapHeader.examineAllHeaderElements();
|
||||
return new HeaderReadIterator(allHeaders, null, null);
|
||||
}
|
||||
|
||||
private static class HeaderReadIterator implements Iterator<Header> {
|
||||
SOAPHeaderElement current;
|
||||
Iterator soapHeaders;
|
||||
String myNsUri;
|
||||
String myLocalName;
|
||||
|
||||
public HeaderReadIterator(Iterator allHeaders, String nsUri,
|
||||
String localName) {
|
||||
this.soapHeaders = allHeaders;
|
||||
this.myNsUri = nsUri;
|
||||
this.myLocalName = localName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
if (current == null) {
|
||||
advance();
|
||||
}
|
||||
return (current != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Header next() {
|
||||
if (!hasNext()) {
|
||||
return null;
|
||||
}
|
||||
if (current == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
SAAJHeader ret = new SAAJHeader(current);
|
||||
current = null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
private void advance() {
|
||||
while (soapHeaders.hasNext()) {
|
||||
SOAPHeaderElement nextHdr = (SOAPHeaderElement) soapHeaders.next();
|
||||
if (nextHdr != null &&
|
||||
(myNsUri == null || nextHdr.getNamespaceURI().equals(myNsUri)) &&
|
||||
(myLocalName == null || nextHdr.getLocalName().equals(myLocalName))) {
|
||||
current = nextHdr;
|
||||
//found it
|
||||
return;
|
||||
}
|
||||
}
|
||||
//if we got here we didn't find a match
|
||||
current = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasHeaders() {
|
||||
SOAPHeader soapHeader = ensureSOAPHeader();
|
||||
if (soapHeader == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Iterator allHeaders = soapHeader.examineAllHeaderElements();
|
||||
return allHeaders.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Header> asList() {
|
||||
SOAPHeader soapHeader = ensureSOAPHeader();
|
||||
if (soapHeader == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Iterator allHeaders = soapHeader.examineAllHeaderElements();
|
||||
List<Header> headers = new ArrayList<Header>();
|
||||
while (allHeaders.hasNext()) {
|
||||
SOAPHeaderElement nextHdr = (SOAPHeaderElement) allHeaders.next();
|
||||
headers.add(new SAAJHeader(nextHdr));
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,559 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2017, 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.api.message.saaj;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import javax.xml.namespace.NamespaceContext;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.SOAPElement;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
|
||||
import org.w3c.dom.Comment;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* SaajStaxWriter builds a SAAJ SOAPMessage by using XMLStreamWriter interface.
|
||||
*
|
||||
* <p>
|
||||
* Defers creation of SOAPElement until all the aspects of the name of the element are known.
|
||||
* In some cases, the namespace uri is indicated only by the {@link #writeNamespace(String, String)} call.
|
||||
* After opening an element ({@code writeStartElement}, {@code writeEmptyElement} methods), all attributes
|
||||
* and namespace assignments are retained within {@link DeferredElement} object ({@code deferredElement} field).
|
||||
* As soon as any other method than {@code writeAttribute}, {@code writeNamespace}, {@code writeDefaultNamespace}
|
||||
* or {@code setNamespace} is called, the contents of {@code deferredElement} is transformed into new SOAPElement
|
||||
* (which is appropriately inserted into the SOAPMessage under construction).
|
||||
* This mechanism is necessary to fix JDK-8159058 issue.
|
||||
* </p>
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public class SaajStaxWriter implements XMLStreamWriter {
|
||||
|
||||
protected SOAPMessage soap;
|
||||
protected String envURI;
|
||||
protected SOAPElement currentElement;
|
||||
protected DeferredElement deferredElement;
|
||||
|
||||
static final protected String Envelope = "Envelope";
|
||||
static final protected String Header = "Header";
|
||||
static final protected String Body = "Body";
|
||||
static final protected String xmlns = "xmlns";
|
||||
|
||||
public SaajStaxWriter(final SOAPMessage msg) throws SOAPException {
|
||||
soap = msg;
|
||||
currentElement = soap.getSOAPPart().getEnvelope();
|
||||
envURI = currentElement.getNamespaceURI();
|
||||
this.deferredElement = new DeferredElement();
|
||||
}
|
||||
|
||||
public SOAPMessage getSOAPMessage() {
|
||||
return soap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeStartElement(final String localName) throws XMLStreamException {
|
||||
currentElement = deferredElement.flushTo(currentElement);
|
||||
deferredElement.setLocalName(localName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeStartElement(final String ns, final String ln) throws XMLStreamException {
|
||||
writeStartElement(null, ln, ns);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeStartElement(final String prefix, final String ln, final String ns) throws XMLStreamException {
|
||||
currentElement = deferredElement.flushTo(currentElement);
|
||||
|
||||
if (envURI.equals(ns)) {
|
||||
try {
|
||||
if (Envelope.equals(ln)) {
|
||||
currentElement = soap.getSOAPPart().getEnvelope();
|
||||
fixPrefix(prefix);
|
||||
return;
|
||||
} else if (Header.equals(ln)) {
|
||||
currentElement = soap.getSOAPHeader();
|
||||
fixPrefix(prefix);
|
||||
return;
|
||||
} else if (Body.equals(ln)) {
|
||||
currentElement = soap.getSOAPBody();
|
||||
fixPrefix(prefix);
|
||||
return;
|
||||
}
|
||||
} catch (SOAPException e) {
|
||||
throw new XMLStreamException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
deferredElement.setLocalName(ln);
|
||||
deferredElement.setNamespaceUri(ns);
|
||||
deferredElement.setPrefix(prefix);
|
||||
|
||||
}
|
||||
|
||||
private void fixPrefix(final String prfx) throws XMLStreamException {
|
||||
String oldPrfx = currentElement.getPrefix();
|
||||
if (prfx != null && !prfx.equals(oldPrfx)) {
|
||||
currentElement.setPrefix(prfx);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEmptyElement(final String uri, final String ln) throws XMLStreamException {
|
||||
writeStartElement(null, ln, uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEmptyElement(final String prefix, final String ln, final String uri) throws XMLStreamException {
|
||||
writeStartElement(prefix, ln, uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEmptyElement(final String ln) throws XMLStreamException {
|
||||
writeStartElement(null, ln, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEndElement() throws XMLStreamException {
|
||||
currentElement = deferredElement.flushTo(currentElement);
|
||||
if (currentElement != null) currentElement = currentElement.getParentElement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEndDocument() throws XMLStreamException {
|
||||
currentElement = deferredElement.flushTo(currentElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws XMLStreamException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws XMLStreamException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeAttribute(final String ln, final String val) throws XMLStreamException {
|
||||
writeAttribute(null, null, ln, val);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeAttribute(final String prefix, final String ns, final String ln, final String value) throws XMLStreamException {
|
||||
if (ns == null && prefix == null && xmlns.equals(ln)) {
|
||||
writeNamespace("", value);
|
||||
} else {
|
||||
if (deferredElement.isInitialized()) {
|
||||
deferredElement.addAttribute(prefix, ns, ln, value);
|
||||
} else {
|
||||
addAttibuteToElement(currentElement, prefix, ns, ln, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeAttribute(final String ns, final String ln, final String val) throws XMLStreamException {
|
||||
writeAttribute(null, ns, ln, val);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNamespace(String prefix, final String uri) throws XMLStreamException {
|
||||
// make prefix default if null or "xmlns" (according to javadoc)
|
||||
String thePrefix = prefix == null || "xmlns".equals(prefix) ? "" : prefix;
|
||||
if (deferredElement.isInitialized()) {
|
||||
deferredElement.addNamespaceDeclaration(thePrefix, uri);
|
||||
} else {
|
||||
try {
|
||||
currentElement.addNamespaceDeclaration(thePrefix, uri);
|
||||
} catch (SOAPException e) {
|
||||
throw new XMLStreamException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDefaultNamespace(final String uri) throws XMLStreamException {
|
||||
writeNamespace("", uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeComment(final String data) throws XMLStreamException {
|
||||
currentElement = deferredElement.flushTo(currentElement);
|
||||
Comment c = soap.getSOAPPart().createComment(data);
|
||||
currentElement.appendChild(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeProcessingInstruction(final String target) throws XMLStreamException {
|
||||
currentElement = deferredElement.flushTo(currentElement);
|
||||
Node n = soap.getSOAPPart().createProcessingInstruction(target, "");
|
||||
currentElement.appendChild(n);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeProcessingInstruction(final String target, final String data) throws XMLStreamException {
|
||||
currentElement = deferredElement.flushTo(currentElement);
|
||||
Node n = soap.getSOAPPart().createProcessingInstruction(target, data);
|
||||
currentElement.appendChild(n);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCData(final String data) throws XMLStreamException {
|
||||
currentElement = deferredElement.flushTo(currentElement);
|
||||
Node n = soap.getSOAPPart().createCDATASection(data);
|
||||
currentElement.appendChild(n);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDTD(final String dtd) throws XMLStreamException {
|
||||
currentElement = deferredElement.flushTo(currentElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEntityRef(final String name) throws XMLStreamException {
|
||||
currentElement = deferredElement.flushTo(currentElement);
|
||||
Node n = soap.getSOAPPart().createEntityReference(name);
|
||||
currentElement.appendChild(n);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeStartDocument() throws XMLStreamException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeStartDocument(final String version) throws XMLStreamException {
|
||||
if (version != null) soap.getSOAPPart().setXmlVersion(version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeStartDocument(final String encoding, final String version) throws XMLStreamException {
|
||||
if (version != null) soap.getSOAPPart().setXmlVersion(version);
|
||||
if (encoding != null) {
|
||||
try {
|
||||
soap.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, encoding);
|
||||
} catch (SOAPException e) {
|
||||
throw new XMLStreamException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCharacters(final String text) throws XMLStreamException {
|
||||
currentElement = deferredElement.flushTo(currentElement);
|
||||
try {
|
||||
currentElement.addTextNode(text);
|
||||
} catch (SOAPException e) {
|
||||
throw new XMLStreamException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCharacters(final char[] text, final int start, final int len) throws XMLStreamException {
|
||||
currentElement = deferredElement.flushTo(currentElement);
|
||||
char[] chr = (start == 0 && len == text.length) ? text : Arrays.copyOfRange(text, start, start + len);
|
||||
try {
|
||||
currentElement.addTextNode(new String(chr));
|
||||
} catch (SOAPException e) {
|
||||
throw new XMLStreamException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix(final String uri) throws XMLStreamException {
|
||||
return currentElement.lookupPrefix(uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrefix(final String prefix, final String uri) throws XMLStreamException {
|
||||
// TODO: this in fact is not what would be expected from XMLStreamWriter
|
||||
// (e.g. XMLStreamWriter for writing to output stream does not write anything as result of
|
||||
// this method, it just rememebers that given prefix is associated with the given uri
|
||||
// for the scope; to actually declare the prefix assignment in the resulting XML, one
|
||||
// needs to call writeNamespace(...) method
|
||||
// Kept for backwards compatibility reasons - this might be worth of further investigation.
|
||||
if (deferredElement.isInitialized()) {
|
||||
deferredElement.addNamespaceDeclaration(prefix, uri);
|
||||
} else {
|
||||
throw new XMLStreamException("Namespace not associated with any element");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultNamespace(final String uri) throws XMLStreamException {
|
||||
setPrefix("", uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNamespaceContext(final NamespaceContext context)throws XMLStreamException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getProperty(final String name) throws IllegalArgumentException {
|
||||
//TODO the following line is to make eclipselink happy ... they are aware of this problem -
|
||||
if (javax.xml.stream.XMLOutputFactory.IS_REPAIRING_NAMESPACES.equals(name)) return Boolean.FALSE;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespaceContext getNamespaceContext() {
|
||||
return new NamespaceContext() {
|
||||
public String getNamespaceURI(final String prefix) {
|
||||
return currentElement.getNamespaceURI(prefix);
|
||||
}
|
||||
public String getPrefix(final String namespaceURI) {
|
||||
return currentElement.lookupPrefix(namespaceURI);
|
||||
}
|
||||
public Iterator getPrefixes(final String namespaceURI) {
|
||||
return new Iterator<String>() {
|
||||
String prefix = getPrefix(namespaceURI);
|
||||
public boolean hasNext() {
|
||||
return (prefix != null);
|
||||
}
|
||||
public String next() {
|
||||
if (!hasNext()) throw new java.util.NoSuchElementException();
|
||||
String next = prefix;
|
||||
prefix = null;
|
||||
return next;
|
||||
}
|
||||
public void remove() {}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static void addAttibuteToElement(SOAPElement element, String prefix, String ns, String ln, String value)
|
||||
throws XMLStreamException {
|
||||
try {
|
||||
if (ns == null) {
|
||||
element.setAttributeNS("", ln, value);
|
||||
} else {
|
||||
QName name = prefix == null ? new QName(ns, ln) : new QName(ns, ln, prefix);
|
||||
element.addAttribute(name, value);
|
||||
}
|
||||
} catch (SOAPException e) {
|
||||
throw new XMLStreamException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds details of element that needs to be deferred in order to manage namespace assignments correctly.
|
||||
*
|
||||
* <p>
|
||||
* An instance of can be set with all the aspects of the element name (local name, prefix, namespace uri).
|
||||
* Attributes and namespace declarations (special case of attribute) can be added.
|
||||
* Namespace declarations are handled so that the element namespace is updated if it is implied by the namespace
|
||||
* declaration and the namespace was not set to non-{@code null} value previously.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* The state of this object can be {@link #flushTo(SOAPElement) flushed} to SOAPElement - new SOAPElement will
|
||||
* be added a child element; the new element will have exactly the shape as represented by the state of this
|
||||
* object. Note that the {@link #flushTo(SOAPElement)} method does nothing
|
||||
* (and returns the argument immediately) if the state of this object is not initialized
|
||||
* (i.e. local name is null).
|
||||
* </p>
|
||||
*
|
||||
* @author ondrej.cerny@oracle.com
|
||||
*/
|
||||
static class DeferredElement {
|
||||
private String prefix;
|
||||
private String localName;
|
||||
private String namespaceUri;
|
||||
private final List<NamespaceDeclaration> namespaceDeclarations;
|
||||
private final List<AttributeDeclaration> attributeDeclarations;
|
||||
|
||||
DeferredElement() {
|
||||
this.namespaceDeclarations = new LinkedList<NamespaceDeclaration>();
|
||||
this.attributeDeclarations = new LinkedList<AttributeDeclaration>();
|
||||
reset();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set prefix of the element.
|
||||
* @param prefix namespace prefix
|
||||
*/
|
||||
public void setPrefix(final String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set local name of the element.
|
||||
*
|
||||
* <p>
|
||||
* This method initializes the element.
|
||||
* </p>
|
||||
*
|
||||
* @param localName local name {@code not null}
|
||||
*/
|
||||
public void setLocalName(final String localName) {
|
||||
if (localName == null) {
|
||||
throw new IllegalArgumentException("localName can not be null");
|
||||
}
|
||||
this.localName = localName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set namespace uri.
|
||||
*
|
||||
* @param namespaceUri namespace uri
|
||||
*/
|
||||
public void setNamespaceUri(final String namespaceUri) {
|
||||
this.namespaceUri = namespaceUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds namespace prefix assignment to the element.
|
||||
*
|
||||
* @param prefix prefix (not {@code null})
|
||||
* @param namespaceUri namespace uri
|
||||
*/
|
||||
public void addNamespaceDeclaration(final String prefix, final String namespaceUri) {
|
||||
if (null == this.namespaceUri && null != namespaceUri && prefix.equals(emptyIfNull(this.prefix))) {
|
||||
this.namespaceUri = namespaceUri;
|
||||
}
|
||||
this.namespaceDeclarations.add(new NamespaceDeclaration(prefix, namespaceUri));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds attribute to the element.
|
||||
* @param prefix prefix
|
||||
* @param ns namespace
|
||||
* @param ln local name
|
||||
* @param value value
|
||||
*/
|
||||
public void addAttribute(final String prefix, final String ns, final String ln, final String value) {
|
||||
if (ns == null && prefix == null && xmlns.equals(ln)) {
|
||||
this.addNamespaceDeclaration(prefix, value);
|
||||
} else {
|
||||
this.attributeDeclarations.add(new AttributeDeclaration(prefix, ns, ln, value));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flushes state of this element to the {@code target} element.
|
||||
*
|
||||
* <p>
|
||||
* If this element is initialized then it is added with all the namespace declarations and attributes
|
||||
* to the {@code target} element as a child. The state of this element is reset to uninitialized.
|
||||
* The newly added element object is returned.
|
||||
* </p>
|
||||
* <p>
|
||||
* If this element is not initialized then the {@code target} is returned immediately, nothing else is done.
|
||||
* </p>
|
||||
*
|
||||
* @param target target element
|
||||
* @return {@code target} or new element
|
||||
* @throws XMLStreamException on error
|
||||
*/
|
||||
public SOAPElement flushTo(final SOAPElement target) throws XMLStreamException {
|
||||
try {
|
||||
if (this.localName != null) {
|
||||
// add the element appropriately (based on namespace declaration)
|
||||
final SOAPElement newElement;
|
||||
if (this.namespaceUri == null) {
|
||||
// add element with inherited scope
|
||||
newElement = target.addChildElement(this.localName);
|
||||
} else if (prefix == null) {
|
||||
newElement = target.addChildElement(new QName(this.namespaceUri, this.localName));
|
||||
} else {
|
||||
newElement = target.addChildElement(this.localName, this.prefix, this.namespaceUri);
|
||||
}
|
||||
// add namespace declarations
|
||||
for (NamespaceDeclaration namespace : this.namespaceDeclarations) {
|
||||
newElement.addNamespaceDeclaration(namespace.prefix, namespace.namespaceUri);
|
||||
}
|
||||
// add attribute declarations
|
||||
for (AttributeDeclaration attribute : this.attributeDeclarations) {
|
||||
addAttibuteToElement(newElement,
|
||||
attribute.prefix, attribute.namespaceUri, attribute.localName, attribute.value);
|
||||
}
|
||||
// reset state
|
||||
this.reset();
|
||||
|
||||
return newElement;
|
||||
} else {
|
||||
return target;
|
||||
}
|
||||
// else after reset state -> not initialized
|
||||
} catch (SOAPException e) {
|
||||
throw new XMLStreamException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the element initialized?
|
||||
* @return boolean indicating whether it was initialized after last flush
|
||||
*/
|
||||
public boolean isInitialized() {
|
||||
return this.localName != null;
|
||||
}
|
||||
|
||||
private void reset() {
|
||||
this.localName = null;
|
||||
this.prefix = null;
|
||||
this.namespaceUri = null;
|
||||
this.namespaceDeclarations.clear();
|
||||
this.attributeDeclarations.clear();
|
||||
}
|
||||
|
||||
private static String emptyIfNull(String s) {
|
||||
return s == null ? "" : s;
|
||||
}
|
||||
}
|
||||
|
||||
static class NamespaceDeclaration {
|
||||
final String prefix;
|
||||
final String namespaceUri;
|
||||
|
||||
NamespaceDeclaration(String prefix, String namespaceUri) {
|
||||
this.prefix = prefix;
|
||||
this.namespaceUri = namespaceUri;
|
||||
}
|
||||
}
|
||||
|
||||
static class AttributeDeclaration {
|
||||
final String prefix;
|
||||
final String namespaceUri;
|
||||
final String localName;
|
||||
final String value;
|
||||
|
||||
AttributeDeclaration(String prefix, String namespaceUri, String localName, String value) {
|
||||
this.prefix = prefix;
|
||||
this.namespaceUri = namespaceUri;
|
||||
this.localName = localName;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.api.message.stream;
|
||||
|
||||
import com.sun.xml.internal.ws.api.message.AttachmentSet;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Low level representation of an XML or SOAP message as an {@link InputStream}.
|
||||
*
|
||||
*/
|
||||
public class InputStreamMessage extends StreamBasedMessage {
|
||||
/**
|
||||
* The MIME content-type of the encoding.
|
||||
*/
|
||||
public final String contentType;
|
||||
|
||||
/**
|
||||
* The message represented as an {@link InputStream}.
|
||||
*/
|
||||
public final InputStream msg;
|
||||
|
||||
/**
|
||||
* Create a new message.
|
||||
*
|
||||
* @param properties
|
||||
* the properties of the message.
|
||||
*
|
||||
* @param contentType
|
||||
* the MIME content-type of the encoding.
|
||||
*
|
||||
* @param msg
|
||||
* always a non-null unconsumed {@link InputStream} that
|
||||
* represents a request.
|
||||
*/
|
||||
public InputStreamMessage(Packet properties, String contentType, InputStream msg) {
|
||||
super(properties);
|
||||
|
||||
this.contentType = contentType;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new message.
|
||||
*
|
||||
* @param properties
|
||||
* the properties of the message.
|
||||
*
|
||||
* @param attachments
|
||||
* the attachments of the message.
|
||||
*
|
||||
* @param contentType
|
||||
* the MIME content-type of the encoding.
|
||||
*
|
||||
* @param msg
|
||||
* always a non-null unconsumed {@link InputStream} that
|
||||
* represents a request.
|
||||
*/
|
||||
public InputStreamMessage(Packet properties, AttachmentSet attachments,
|
||||
String contentType, InputStream msg) {
|
||||
super(properties, attachments);
|
||||
|
||||
this.contentType = contentType;
|
||||
this.msg = msg;
|
||||
}
|
||||
}
|
||||
@@ -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.api.message.stream;
|
||||
|
||||
import com.sun.xml.internal.ws.api.message.AttachmentSet;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.sun.xml.internal.ws.message.AttachmentSetImpl;
|
||||
|
||||
/**
|
||||
* Base representation an XML or SOAP message as stream.
|
||||
*
|
||||
*/
|
||||
abstract class StreamBasedMessage {
|
||||
/**
|
||||
* The properties of the message.
|
||||
*/
|
||||
public final Packet properties;
|
||||
|
||||
/**
|
||||
* The attachments of this message
|
||||
* (attachments live outside a message.)
|
||||
*/
|
||||
public final AttachmentSet attachments;
|
||||
|
||||
/**
|
||||
* Create a new message.
|
||||
*
|
||||
* @param properties
|
||||
* the properties of the message.
|
||||
*
|
||||
*/
|
||||
protected StreamBasedMessage(Packet properties) {
|
||||
this.properties = properties;
|
||||
this.attachments = new AttachmentSetImpl();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new message.
|
||||
*
|
||||
* @param properties
|
||||
* the properties of the message.
|
||||
*
|
||||
* @param attachments
|
||||
* the attachments of the message.
|
||||
*/
|
||||
protected StreamBasedMessage(Packet properties, AttachmentSet attachments) {
|
||||
this.properties = properties;
|
||||
this.attachments = attachments;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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.api.message.stream;
|
||||
|
||||
import com.sun.xml.internal.ws.api.message.AttachmentSet;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
|
||||
/**
|
||||
* Low level representation of an XML or SOAP message as an {@link XMLStreamReader}.
|
||||
*
|
||||
*/
|
||||
public class XMLStreamReaderMessage extends StreamBasedMessage {
|
||||
/**
|
||||
* The message represented as an {@link XMLStreamReader}.
|
||||
*/
|
||||
public final XMLStreamReader msg;
|
||||
|
||||
/**
|
||||
* Create a new message.
|
||||
*
|
||||
* @param properties
|
||||
* the properties of the message.
|
||||
*
|
||||
* @param msg
|
||||
* always a non-null unconsumed {@link XMLStreamReader} that
|
||||
* represents a request.
|
||||
*/
|
||||
public XMLStreamReaderMessage(Packet properties, XMLStreamReader msg) {
|
||||
super(properties);
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new message.
|
||||
*
|
||||
* @param properties
|
||||
* the properties of the message.
|
||||
*
|
||||
* @param attachments
|
||||
* the attachments of the message.
|
||||
*
|
||||
* @param msg
|
||||
* always a non-null unconsumed {@link XMLStreamReader} that
|
||||
* represents a request.
|
||||
*/
|
||||
public XMLStreamReaderMessage(Packet properties, AttachmentSet attachments, XMLStreamReader msg) {
|
||||
super(properties, attachments);
|
||||
this.msg = msg;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* 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.api.model;
|
||||
|
||||
import com.sun.xml.internal.bind.api.Bridge;
|
||||
|
||||
import javax.xml.ws.WebFault;
|
||||
import javax.xml.namespace.QName;
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
/**
|
||||
* This class provides abstractio to the the exception class
|
||||
* corresponding to the wsdl:fault, such as class MUST have
|
||||
* {@link WebFault} annotation defined on it.
|
||||
*
|
||||
* Also the exception class must have
|
||||
*
|
||||
* <code>public WrapperException()String message, FaultBean){}</code>
|
||||
*
|
||||
* and method
|
||||
*
|
||||
* <code>public FaultBean getFaultInfo();</code>
|
||||
*
|
||||
* @author Vivek Pandey
|
||||
*/
|
||||
public interface CheckedException {
|
||||
/**
|
||||
* Gets the root {@link SEIModel} that owns this model.
|
||||
*/
|
||||
SEIModel getOwner();
|
||||
|
||||
/**
|
||||
* Gets the parent {@link JavaMethod} to which this checked exception belongs.
|
||||
*/
|
||||
JavaMethod getParent();
|
||||
|
||||
/**
|
||||
* The returned exception class would be userdefined or WSDL exception class.
|
||||
*
|
||||
* @return
|
||||
* always non-null same object.
|
||||
*/
|
||||
Class getExceptionClass();
|
||||
|
||||
/**
|
||||
* The detail bean is serialized inside the detail entry in the SOAP message.
|
||||
* This must be known to the {@link javax.xml.bind.JAXBContext} inorder to get
|
||||
* marshalled/unmarshalled.
|
||||
*
|
||||
* @return the detail bean
|
||||
*/
|
||||
Class getDetailBean();
|
||||
|
||||
/**
|
||||
* Gives the {@link com.sun.xml.internal.bind.api.Bridge} associated with the detail
|
||||
* @deprecated Why do you need this?
|
||||
*/
|
||||
Bridge getBridge();
|
||||
|
||||
/**
|
||||
* Tells whether the exception class is a userdefined or a WSDL exception.
|
||||
* A WSDL exception class follows the pattern defined in JSR 224. According to that
|
||||
* a WSDL exception class must have:
|
||||
*
|
||||
* <code>public WrapperException()String message, FaultBean){}</code>
|
||||
*
|
||||
* and accessor method
|
||||
*
|
||||
* <code>public FaultBean getFaultInfo();</code>
|
||||
*/
|
||||
ExceptionType getExceptionType();
|
||||
|
||||
/**
|
||||
* Gives the wsdl:portType/wsdl:operation/wsdl:fault@message value - that is the wsdl:message
|
||||
* referenced by wsdl:fault
|
||||
*/
|
||||
String getMessageName();
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.api.model;
|
||||
/**
|
||||
* Type of java exception as defined by JAXWS 2.0 JSR 224.
|
||||
*
|
||||
* Tells whether the exception class is a userdefined or a WSDL exception.
|
||||
* A WSDL exception class follows the pattern defined in JSR 224. According to that
|
||||
* a WSDL exception class must have:
|
||||
*
|
||||
* <code>public WrapperException()String message, FaultBean){}</code>
|
||||
*
|
||||
* and accessor method
|
||||
*
|
||||
* <code>public FaultBean getFaultInfo();</code>
|
||||
*
|
||||
* @author Vivek Pandey
|
||||
*/
|
||||
public enum ExceptionType {
|
||||
WSDLException(0), UserDefined(1);
|
||||
|
||||
ExceptionType(int exceptionType){
|
||||
this.exceptionType = exceptionType;
|
||||
}
|
||||
|
||||
public int value() {
|
||||
return exceptionType;
|
||||
}
|
||||
private final int exceptionType;
|
||||
}
|
||||
141
jdkSrc/jdk8/com/sun/xml/internal/ws/api/model/JavaMethod.java
Normal file
141
jdkSrc/jdk8/com/sun/xml/internal/ws/api/model/JavaMethod.java
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* 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.api.model;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.api.model.soap.SOAPBinding;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import java.lang.reflect.Method;
|
||||
import javax.jws.WebService;
|
||||
|
||||
/**
|
||||
* Abstracts the annotated {@link Method} of a SEI.
|
||||
*
|
||||
* @author Vivek Pandey
|
||||
*/
|
||||
public interface JavaMethod {
|
||||
|
||||
/**
|
||||
* Gets the root {@link SEIModel} that owns this model.
|
||||
*/
|
||||
SEIModel getOwner();
|
||||
|
||||
/**
|
||||
* On the server side, it uses this for invocation of the web service
|
||||
*
|
||||
* <p>
|
||||
* {@literal @}{@link WebService}(endpointInterface="I")
|
||||
* class A { }
|
||||
*
|
||||
* In this case, it retuns A's method
|
||||
*
|
||||
* <p>
|
||||
* {@literal @}{@link WebService}(endpointInterface="I")
|
||||
* class A implements I { }
|
||||
* In this case, it returns A's method
|
||||
*
|
||||
* <p>
|
||||
* {@literal @}{@link WebService}
|
||||
* class A { }
|
||||
* In this case, it returns A's method
|
||||
*
|
||||
* @return Returns the java {@link Method}
|
||||
*/
|
||||
@NotNull Method getMethod();
|
||||
|
||||
|
||||
/**
|
||||
* This should be used if you want to access annotations on WebMethod
|
||||
* Returns the SEI method if there is one.
|
||||
*
|
||||
* <p>
|
||||
* {@literal @}{@link WebService}(endpointInterface="I")
|
||||
* class A { }
|
||||
* In this case, it retuns I's method
|
||||
*
|
||||
* <p>
|
||||
* {@literal @}{@link WebService}(endpointInterface="I")
|
||||
* class A implements I { }
|
||||
* In this case, it returns I's method
|
||||
*
|
||||
* <p>
|
||||
* {@literal @}{@link WebService}
|
||||
* class A { }
|
||||
* In this case, it returns A's method
|
||||
*
|
||||
* @return Returns the java {@link Method}
|
||||
*/
|
||||
@NotNull Method getSEIMethod();
|
||||
|
||||
/**
|
||||
* @return Returns the {@link MEP}.
|
||||
*/
|
||||
MEP getMEP();
|
||||
|
||||
/**
|
||||
* Binding object - a {@link SOAPBinding} isntance.
|
||||
*
|
||||
* @return the Binding object
|
||||
*/
|
||||
SOAPBinding getBinding();
|
||||
|
||||
/**
|
||||
* Gives the wsdl:operation@name value
|
||||
*/
|
||||
@NotNull String getOperationName();
|
||||
|
||||
|
||||
/**
|
||||
* Gives the request wsdl:message@name value
|
||||
*/
|
||||
@NotNull String getRequestMessageName();
|
||||
|
||||
/**
|
||||
* Gives the response wsdl:messageName value
|
||||
* @return null if its a oneway operation that is getMEP().isOneWay()==true.
|
||||
* @see com.sun.xml.internal.ws.api.model.MEP#isOneWay()
|
||||
*/
|
||||
@Nullable String getResponseMessageName();
|
||||
|
||||
/**
|
||||
* Gives soap:Body's first child's name for request message.
|
||||
*
|
||||
* @return
|
||||
* null if this operation doesn't have any request parameter bound to the body.
|
||||
*/
|
||||
@Nullable QName getRequestPayloadName();
|
||||
|
||||
/**
|
||||
* Gives soap:Body's first child's name for response message.
|
||||
*
|
||||
* @return
|
||||
* null if this operation doesn't have any response parameter bound to the body.
|
||||
*/
|
||||
@Nullable QName getResponsePayloadName();
|
||||
|
||||
}
|
||||
51
jdkSrc/jdk8/com/sun/xml/internal/ws/api/model/MEP.java
Normal file
51
jdkSrc/jdk8/com/sun/xml/internal/ws/api/model/MEP.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.api.model;
|
||||
|
||||
/**
|
||||
* Constants that represents four message exchange patterns.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public enum MEP {
|
||||
REQUEST_RESPONSE(false),
|
||||
ONE_WAY(false),
|
||||
ASYNC_POLL(true),
|
||||
ASYNC_CALLBACK(true);
|
||||
|
||||
/**
|
||||
* True for {@link #ASYNC_CALLBACK} and {@link #ASYNC_POLL}.
|
||||
*/
|
||||
public final boolean isAsync;
|
||||
|
||||
MEP(boolean async) {
|
||||
isAsync = async;
|
||||
}
|
||||
|
||||
public final boolean isOneWay() {
|
||||
return this==ONE_WAY;
|
||||
}
|
||||
}
|
||||
164
jdkSrc/jdk8/com/sun/xml/internal/ws/api/model/Parameter.java
Normal file
164
jdkSrc/jdk8/com/sun/xml/internal/ws/api/model/Parameter.java
Normal file
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* 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.api.model;
|
||||
|
||||
import com.sun.xml.internal.bind.api.Bridge;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.ws.Holder;
|
||||
import javax.jws.WebParam;
|
||||
import javax.jws.WebParam.Mode;
|
||||
|
||||
/**
|
||||
* Runtime Parameter that abstracts the annotated java parameter
|
||||
* <p/>
|
||||
* <p/>
|
||||
* A parameter may be bound to a header, a body, or an attachment.
|
||||
* Note that when it's bound to a body, it's bound to a body,
|
||||
* it binds to the whole payload.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* Sometimes multiple Java parameters are packed into the payload,
|
||||
* in which case the subclass {@link com.sun.xml.internal.ws.model.WrapperParameter} is used.
|
||||
*
|
||||
* @author Vivek Pandey
|
||||
*/
|
||||
public interface Parameter {
|
||||
/**
|
||||
* Gets the root {@link SEIModel} that owns this model.
|
||||
*/
|
||||
SEIModel getOwner();
|
||||
|
||||
/**
|
||||
* Gets the parent {@link JavaMethod} to which this parameter belongs.
|
||||
*/
|
||||
JavaMethod getParent();
|
||||
|
||||
/**
|
||||
* @return Returns the {@link QName} of the payload/infoset of a SOAP body or header.
|
||||
*/
|
||||
QName getName();
|
||||
|
||||
/**
|
||||
* Gives the {@link Bridge} associated with this Parameter
|
||||
* @deprecated
|
||||
*/
|
||||
Bridge getBridge();
|
||||
|
||||
/**
|
||||
* @return Returns the mode, such as IN, OUT or INOUT.
|
||||
*/
|
||||
Mode getMode();
|
||||
|
||||
/**
|
||||
* Position of a parameter in the method signature. It would be -1 if the parameter is a return.
|
||||
*
|
||||
* @return Returns the index.
|
||||
*/
|
||||
int getIndex();
|
||||
|
||||
/**
|
||||
* @return true if <tt>this instanceof {@link com.sun.xml.internal.ws.model.WrapperParameter}</tt>.
|
||||
*/
|
||||
boolean isWrapperStyle();
|
||||
|
||||
/**
|
||||
* Returns true if this parameter is bound to the return value from the {@link JavaMethod}.
|
||||
*
|
||||
* <p>
|
||||
* Just the convenience method for <tt>getIndex()==-1</tt>
|
||||
*/
|
||||
boolean isReturnValue();
|
||||
|
||||
/**
|
||||
* Returns the binding associated with the parameter. For IN parameter the binding will be
|
||||
* same as {@link #getInBinding()}, for OUT parameter the binding will be same as
|
||||
* {@link #getOutBinding()} and for INOUT parameter the binding will be same as calling
|
||||
* {@link #getInBinding()}
|
||||
*
|
||||
* @return the Binding for this Parameter. Returns {@link ParameterBinding#BODY} by default.
|
||||
*/
|
||||
ParameterBinding getBinding();
|
||||
|
||||
/**
|
||||
* Returns the {@link ParameterBinding} associated with the IN mode
|
||||
*
|
||||
* @return the binding
|
||||
*/
|
||||
ParameterBinding getInBinding();
|
||||
|
||||
/**
|
||||
* Returns the {@link ParameterBinding} associated with the OUT mode
|
||||
*
|
||||
* @return the binding
|
||||
*/
|
||||
ParameterBinding getOutBinding();
|
||||
|
||||
/**
|
||||
* @return true if the {@link Mode} associated with the parameter is {@link Mode#IN} and false otherwise.
|
||||
*/
|
||||
boolean isIN();
|
||||
|
||||
/**
|
||||
* @return true if the {@link Mode} associated with the parameter is {@link Mode#OUT} and false otherwise.
|
||||
*/
|
||||
boolean isOUT();
|
||||
|
||||
/**
|
||||
* @return true if the {@link Mode} associated with the parameter is {@link Mode#INOUT} and false otherwise.
|
||||
*/
|
||||
boolean isINOUT();
|
||||
|
||||
/**
|
||||
* If true, this parameter maps to the return value of a method invocation.
|
||||
*
|
||||
* <p>
|
||||
* {@link JavaMethod#getResponseParameters()} is guaranteed to have
|
||||
* at most one such {@link Parameter}. Note that there coule be none,
|
||||
* in which case the method returns <tt>void</tt>.
|
||||
*
|
||||
* <p>
|
||||
* Other response parameters are bound to {@link Holder}.
|
||||
*/
|
||||
boolean isResponse();
|
||||
|
||||
/**
|
||||
* Gets the holder value if applicable. To be called for inbound client side
|
||||
* message.
|
||||
*
|
||||
* @param obj
|
||||
* @return the holder value if applicable.
|
||||
*/
|
||||
Object getHolderValue(Object obj);
|
||||
|
||||
/**
|
||||
* Gives the wsdl:part@name value
|
||||
*
|
||||
* @return Value of {@link WebParam#partName()} annotation if present,
|
||||
* otherwise its the localname of the infoset associated with the parameter
|
||||
*/
|
||||
String getPartName();
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* 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.api.model;
|
||||
|
||||
/**
|
||||
* Denotes the binding of a parameter.
|
||||
*
|
||||
* <p>
|
||||
* This is somewhat like an enumeration (but it is <b>NOT</b> an enumeration.)
|
||||
*
|
||||
* <p>
|
||||
* The possible values are
|
||||
* BODY, HEADER, UNBOUND, and ATTACHMENT. BODY, HEADER, and UNBOUND
|
||||
* has a singleton semantics, but there are multiple ATTACHMENT instances
|
||||
* as it carries additional MIME type parameter.
|
||||
*
|
||||
* <p>
|
||||
* So don't use '==' for testing the equality.
|
||||
*/
|
||||
public final class ParameterBinding {
|
||||
/**
|
||||
* Singleton instance that represents 'BODY'
|
||||
*/
|
||||
public static final ParameterBinding BODY = new ParameterBinding(Kind.BODY,null);
|
||||
/**
|
||||
* Singleton instance that represents 'HEADER'
|
||||
*/
|
||||
public static final ParameterBinding HEADER = new ParameterBinding(Kind.HEADER,null);
|
||||
/**
|
||||
* Singleton instance that represents 'UNBOUND',
|
||||
* meaning the parameter doesn't have a representation in a SOAP message.
|
||||
*/
|
||||
public static final ParameterBinding UNBOUND = new ParameterBinding(Kind.UNBOUND,null);
|
||||
/**
|
||||
* Creates an instance that represents the attachment
|
||||
* with a given MIME type.
|
||||
*
|
||||
* <p>
|
||||
* TODO: shall we consider givint the singleton semantics by using
|
||||
* a cache? It's more elegant to do so, but
|
||||
* no where in JAX-WS RI two {@link ParameterBinding}s are compared today,
|
||||
*/
|
||||
public static ParameterBinding createAttachment(String mimeType) {
|
||||
return new ParameterBinding(Kind.ATTACHMENT,mimeType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents 4 kinds of binding.
|
||||
*/
|
||||
public static enum Kind {
|
||||
BODY, HEADER, UNBOUND, ATTACHMENT;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Represents the kind of {@link ParameterBinding}.
|
||||
* Always non-null.
|
||||
*/
|
||||
public final Kind kind;
|
||||
|
||||
/**
|
||||
* Only used with attachment binding.
|
||||
*/
|
||||
private String mimeType;
|
||||
|
||||
private ParameterBinding(Kind kind,String mimeType) {
|
||||
this.kind = kind;
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String toString() {
|
||||
return kind.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the MIME type associated with this binding.
|
||||
*
|
||||
* @throws IllegalStateException
|
||||
* if this binding doesn't represent an attachment.
|
||||
* IOW, if {@link #isAttachment()} returns false.
|
||||
* @return
|
||||
* Can be null, if the MIME type is not known.
|
||||
*/
|
||||
public String getMimeType() {
|
||||
if(!isAttachment())
|
||||
throw new IllegalStateException();
|
||||
return mimeType;
|
||||
}
|
||||
|
||||
public boolean isBody(){
|
||||
return this==BODY;
|
||||
}
|
||||
|
||||
public boolean isHeader(){
|
||||
return this==HEADER;
|
||||
}
|
||||
|
||||
public boolean isUnbound(){
|
||||
return this==UNBOUND;
|
||||
}
|
||||
|
||||
public boolean isAttachment(){
|
||||
return kind==Kind.ATTACHMENT;
|
||||
}
|
||||
}
|
||||
180
jdkSrc/jdk8/com/sun/xml/internal/ws/api/model/SEIModel.java
Normal file
180
jdkSrc/jdk8/com/sun/xml/internal/ws/api/model/SEIModel.java
Normal file
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
* 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.api.model;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.xml.internal.bind.api.Bridge;
|
||||
import com.sun.xml.internal.bind.api.JAXBRIContext;
|
||||
import com.sun.xml.internal.bind.api.TypeReference;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.util.Pool;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.ws.Dispatch;
|
||||
import javax.xml.ws.Provider;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Represents abstraction of SEI.
|
||||
*
|
||||
* <p>
|
||||
* This interface would be used to access which Java concepts correspond to
|
||||
* which WSDL concepts, such as which <code>wsdl:port</code> corresponds to
|
||||
* a SEI, or which <code>wsdl:operation</code> corresponds to {@link JavaMethod}.
|
||||
*
|
||||
* <P>
|
||||
* It also retains information about the databinding done for a SEI;
|
||||
* such as {@link JAXBRIContext} and {@link Bridge}.
|
||||
*
|
||||
* <p>
|
||||
* This model is constructed only when there is a Java SEI. Therefore it's
|
||||
* not available with {@link Dispatch} or {@link Provider}. Technologies that
|
||||
* need to work regardless of such surface API difference shall not be using
|
||||
* this model.
|
||||
*
|
||||
* @author Vivek Pandey
|
||||
*/
|
||||
public interface SEIModel {
|
||||
Pool.Marshaller getMarshallerPool();
|
||||
|
||||
/**
|
||||
* JAXBContext that will be used to marshall/unmarshall the java classes found in the SEI.
|
||||
*
|
||||
* @return the <code>{@link JAXBRIContext}</code>
|
||||
* @deprecated Why do you need this?
|
||||
*/
|
||||
JAXBContext getJAXBContext();
|
||||
|
||||
/**
|
||||
* Get the Bridge associated with the {@link TypeReference}
|
||||
*
|
||||
* @param type
|
||||
* @return the <code>{@link Bridge}</code> for the <code>type</code>
|
||||
*/
|
||||
// Bridge getBridge(TypeReference type);
|
||||
|
||||
/**
|
||||
* Its a known fault if the exception thrown by {@link Method} is annotated with the
|
||||
* {@link javax.xml.ws.WebFault#name()} thas equal to the name passed as parameter.
|
||||
*
|
||||
* @param name is the qualified name of fault detail element as specified by wsdl:fault@element value.
|
||||
* @param method is the Java {@link Method}
|
||||
* @return true if <code>name</code> is the name
|
||||
* of a known fault name for the <code>method</code>
|
||||
*/
|
||||
// boolean isKnownFault(QName name, Method method);
|
||||
|
||||
/**
|
||||
* Checks if the {@link JavaMethod} for the {@link Method} knowns the exception class.
|
||||
*
|
||||
* @param m {@link Method} to pickup the right {@link JavaMethod} model
|
||||
* @param ex exception class
|
||||
* @return true if <code>ex</code> is a Checked Exception
|
||||
* for <code>m</code>
|
||||
*/
|
||||
// boolean isCheckedException(Method m, Class ex);
|
||||
|
||||
/**
|
||||
* This method will be useful to get the {@link JavaMethod} corrrespondiong to
|
||||
* a {@link Method} - such as on the client side.
|
||||
*
|
||||
* @param method for which {@link JavaMethod} is asked for
|
||||
* @return the {@link JavaMethod} representing the <code>method</code>
|
||||
*/
|
||||
JavaMethod getJavaMethod(Method method);
|
||||
|
||||
/**
|
||||
* Gives a {@link JavaMethod} for a given {@link QName}. The {@link QName} will
|
||||
* be equivalent to the SOAP Body or Header block or can simply be the name of an
|
||||
* infoset that corresponds to the payload.
|
||||
* @param name
|
||||
* @return the <code>JavaMethod</code> associated with the
|
||||
* operation named name
|
||||
*/
|
||||
public JavaMethod getJavaMethod(QName name);
|
||||
|
||||
/**
|
||||
* Gives the JavaMethod associated with the wsdl operation
|
||||
* @param operationName QName of the wsdl operation
|
||||
* @return
|
||||
*/
|
||||
public JavaMethod getJavaMethodForWsdlOperation(QName operationName);
|
||||
|
||||
|
||||
/**
|
||||
* Gives all the {@link JavaMethod} for a wsdl:port for which this {@link SEIModel} is
|
||||
* created.
|
||||
*
|
||||
* @return a {@link Collection} of {@link JavaMethod}
|
||||
* associated with the {@link SEIModel}
|
||||
*/
|
||||
Collection<? extends JavaMethod> getJavaMethods();
|
||||
|
||||
/**
|
||||
* Location of the WSDL that defines the port associated with the {@link SEIModel}
|
||||
*
|
||||
* @return wsdl location uri - always non-null
|
||||
*/
|
||||
@NotNull String getWSDLLocation();
|
||||
|
||||
/**
|
||||
* wsdl:service qualified name for the port associated with the {@link SEIModel}
|
||||
*
|
||||
* @return wsdl:service@name value - always non-null
|
||||
*/
|
||||
@NotNull QName getServiceQName();
|
||||
|
||||
/**
|
||||
* Gets the {@link WSDLPort} that represents the port that this SEI binds to.
|
||||
*/
|
||||
@NotNull WSDLPort getPort();
|
||||
|
||||
/**
|
||||
* Value of the wsdl:port name associated with the {@link SEIModel}
|
||||
*
|
||||
* @return wsdl:service/wsdl:port@name value, always non-null
|
||||
*/
|
||||
@NotNull QName getPortName();
|
||||
|
||||
/**
|
||||
* Value of wsdl:portType bound to the port associated with the {@link SEIModel}
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@NotNull QName getPortTypeName();
|
||||
|
||||
/**
|
||||
* Gives the wsdl:binding@name value
|
||||
*/
|
||||
@NotNull QName getBoundPortTypeName();
|
||||
|
||||
/**
|
||||
* Namespace of the wsd;:port associated with the {@link SEIModel}
|
||||
*/
|
||||
@NotNull String getTargetNamespace();
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.api.model;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation;
|
||||
|
||||
/**
|
||||
* WSDLOperationMapping represents the mapping between a WSDL operation and a
|
||||
* JavaMethod. This is intended to be the output of resolving a Packet to the
|
||||
* targeting WSDL operation.
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public interface WSDLOperationMapping {
|
||||
|
||||
WSDLBoundOperation getWSDLBoundOperation();
|
||||
|
||||
JavaMethod getJavaMethod();
|
||||
|
||||
/**
|
||||
* WSDL1.1 allows operation overloading on the operation name; the operation name should
|
||||
* NOT be used as identifier of the operation.
|
||||
*/
|
||||
QName getOperationName();
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* 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.api.model.soap;
|
||||
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.model.JavaMethod;
|
||||
|
||||
import javax.jws.soap.SOAPBinding.Style;
|
||||
import javax.jws.soap.SOAPBinding.Use;
|
||||
import javax.jws.WebMethod;
|
||||
|
||||
/**
|
||||
* Models soap:binding in a WSDL document or a {@link javax.jws.soap.SOAPBinding} annotation. This
|
||||
* can be the return of {@link JavaMethod#getBinding()}.
|
||||
*
|
||||
* @author Vivek Pandey
|
||||
*/
|
||||
abstract public class SOAPBinding {
|
||||
protected Use use = Use.LITERAL;
|
||||
protected Style style = Style.DOCUMENT;
|
||||
protected SOAPVersion soapVersion = SOAPVersion.SOAP_11;
|
||||
protected String soapAction = "";
|
||||
|
||||
/**
|
||||
* Get {@link Use} such as <code>literal</code> or <code>encoded</code>.
|
||||
*/
|
||||
public Use getUse() {
|
||||
return use;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get {@link Style} - such as <code>document</code> or <code>rpc</code>.
|
||||
*/
|
||||
public Style getStyle() {
|
||||
return style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link SOAPVersion}
|
||||
*/
|
||||
public SOAPVersion getSOAPVersion() {
|
||||
return soapVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if its document/literal
|
||||
*/
|
||||
public boolean isDocLit() {
|
||||
return style == Style.DOCUMENT && use == Use.LITERAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this is a rpc/literal binding
|
||||
*/
|
||||
public boolean isRpcLit() {
|
||||
return style == Style.RPC && use == Use.LITERAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Value of <code>wsdl:binding/wsdl:operation/soap:operation@soapAction</code> attribute or
|
||||
* {@link WebMethod#action()} annotation.
|
||||
* <pre>
|
||||
* For example:
|
||||
* <wsdl:binding name="HelloBinding" type="tns:Hello">
|
||||
* <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
|
||||
* <wsdl:operation name="echoData">
|
||||
* <soap12:operation soapAction=""/>
|
||||
* ...
|
||||
* </pre>
|
||||
* It's always non-null. soap message serializer needs to generated SOAPAction HTTP header with
|
||||
* the return of this method enclosed in quotes("").
|
||||
*
|
||||
* @see com.sun.xml.internal.ws.api.message.Packet#soapAction
|
||||
*/
|
||||
public String getSOAPAction() {
|
||||
return soapAction;
|
||||
}
|
||||
}
|
||||
@@ -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.api.model.wsdl;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
/**
|
||||
* Abstracts wsdl:binding/wsdl:operation/wsdl:fault
|
||||
*
|
||||
* @author Vivek Pandey
|
||||
*/
|
||||
public interface WSDLBoundFault extends WSDLObject, WSDLExtensible {
|
||||
|
||||
/**
|
||||
* Gives the wsdl:binding/wsdl:operation/wsdl:fault@name value
|
||||
*/
|
||||
public
|
||||
@NotNull
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Gives the qualified name associated with the fault. the namespace URI of the bounded fault
|
||||
* will be the one derived from wsdl:portType namespace.
|
||||
*
|
||||
* Maybe null if this method is called before the model is completely build (frozen), if a binding fault has no
|
||||
* corresponding fault in abstractwsdl:portType/wsdl:operation then the namespace URI of the fault will be that of
|
||||
* the WSDBoundPortType.
|
||||
*/
|
||||
public @Nullable QName getQName();
|
||||
|
||||
/**
|
||||
* Gives the associated abstract fault from
|
||||
* wsdl:portType/wsdl:operation/wsdl:fault. It is only available after
|
||||
* the WSDL parsing is complete and the entire model is frozen.
|
||||
* <p/>
|
||||
* Maybe null if a binding fault has no corresponding fault in abstract
|
||||
* wsdl:portType/wsdl:operation
|
||||
*/
|
||||
public
|
||||
@Nullable
|
||||
WSDLFault getFault();
|
||||
|
||||
/**
|
||||
* Gives the owner {@link WSDLBoundOperation}
|
||||
*/
|
||||
@NotNull WSDLBoundOperation getBoundOperation();
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
* 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.api.model.wsdl;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.api.model.ParameterBinding;
|
||||
|
||||
import javax.jws.WebParam.Mode;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Abstracts wsdl:binding/wsdl:operation. It can be used to determine the parts and their binding.
|
||||
*
|
||||
* @author Vivek Pandey
|
||||
*/
|
||||
public interface WSDLBoundOperation extends WSDLObject, WSDLExtensible {
|
||||
/**
|
||||
* Short-cut for {@code getOperation().getName()}
|
||||
*/
|
||||
@NotNull QName getName();
|
||||
|
||||
/**
|
||||
* Gives soapbinding:operation@soapAction value. soapbinding:operation@soapAction is optional attribute.
|
||||
* If not present an empty String is returned as per BP 1.1 R2745.
|
||||
*/
|
||||
@NotNull String getSOAPAction();
|
||||
|
||||
/**
|
||||
* Gets the wsdl:portType/wsdl:operation model - {@link WSDLOperation},
|
||||
* associated with this binding operation.
|
||||
*
|
||||
* @return always same {@link WSDLOperation}
|
||||
*/
|
||||
@NotNull WSDLOperation getOperation();
|
||||
|
||||
/**
|
||||
* Gives the owner {@link WSDLBoundPortType}
|
||||
*/
|
||||
@NotNull WSDLBoundPortType getBoundPortType();
|
||||
|
||||
/**
|
||||
* Gets the soapbinding:binding/operation/wsaw:Anonymous. A default value of OPTIONAL is returned.
|
||||
*
|
||||
* @return Anonymous value of the operation
|
||||
*/
|
||||
ANONYMOUS getAnonymous();
|
||||
|
||||
enum ANONYMOUS { optional, required, prohibited }
|
||||
|
||||
/**
|
||||
* Gets {@link WSDLPart} for the given wsdl:input or wsdl:output part
|
||||
*
|
||||
* @return null if no part is found
|
||||
*/
|
||||
@Nullable WSDLPart getPart(@NotNull String partName, @NotNull Mode mode);
|
||||
|
||||
/**
|
||||
* Gets {@link ParameterBinding} for a given wsdl part in wsdl:input
|
||||
*
|
||||
* @param part Name of wsdl:part, must be non-null
|
||||
* @return null if the part is not found.
|
||||
*/
|
||||
public ParameterBinding getInputBinding(String part);
|
||||
|
||||
/**
|
||||
* Gets {@link ParameterBinding} for a given wsdl part in wsdl:output
|
||||
*
|
||||
* @param part Name of wsdl:part, must be non-null
|
||||
* @return null if the part is not found.
|
||||
*/
|
||||
public ParameterBinding getOutputBinding(String part);
|
||||
|
||||
/**
|
||||
* Gets {@link ParameterBinding} for a given wsdl part in wsdl:fault
|
||||
*
|
||||
* @param part Name of wsdl:part, must be non-null
|
||||
* @return null if the part is not found.
|
||||
*/
|
||||
public ParameterBinding getFaultBinding(String part);
|
||||
|
||||
/**
|
||||
* Gets the MIME type for a given wsdl part in wsdl:input
|
||||
*
|
||||
* @param part Name of wsdl:part, must be non-null
|
||||
* @return null if the part is not found.
|
||||
*/
|
||||
public String getMimeTypeForInputPart(String part);
|
||||
|
||||
/**
|
||||
* Gets the MIME type for a given wsdl part in wsdl:output
|
||||
*
|
||||
* @param part Name of wsdl:part, must be non-null
|
||||
* @return null if the part is not found.
|
||||
*/
|
||||
public String getMimeTypeForOutputPart(String part);
|
||||
|
||||
/**
|
||||
* Gets the MIME type for a given wsdl part in wsdl:fault
|
||||
*
|
||||
* @param part Name of wsdl:part, must be non-null
|
||||
* @return null if the part is not found.
|
||||
*/
|
||||
public String getMimeTypeForFaultPart(String part);
|
||||
|
||||
/**
|
||||
* Gets all inbound {@link WSDLPart} by its {@link WSDLPart#getName() name}.
|
||||
*/
|
||||
@NotNull Map<String,? extends WSDLPart> getInParts();
|
||||
|
||||
/**
|
||||
* Gets all outbound {@link WSDLPart} by its {@link WSDLPart#getName() name}.
|
||||
*/
|
||||
@NotNull Map<String,? extends WSDLPart> getOutParts();
|
||||
|
||||
/**
|
||||
* Gets all the {@link WSDLFault} bound to this operation.
|
||||
*/
|
||||
@NotNull Iterable<? extends WSDLBoundFault> getFaults();
|
||||
|
||||
/**
|
||||
* Map of wsdl:input part name and the binding as {@link ParameterBinding}
|
||||
*
|
||||
* @return empty Map if there is no parts
|
||||
*/
|
||||
public Map<String, ParameterBinding> getInputParts();
|
||||
|
||||
/**
|
||||
* Map of wsdl:output part name and the binding as {@link ParameterBinding}
|
||||
*
|
||||
* @return empty Map if there is no parts
|
||||
*/
|
||||
public Map<String, ParameterBinding> getOutputParts();
|
||||
|
||||
/**
|
||||
* Map of wsdl:fault part name and the binding as {@link ParameterBinding}
|
||||
*
|
||||
* @return empty Map if there is no parts
|
||||
*/
|
||||
public Map<String, ParameterBinding> getFaultParts();
|
||||
|
||||
/**
|
||||
* Gets the payload QName of the request message.
|
||||
*
|
||||
* <p>
|
||||
* It's possible for an operation to define no body part, in which case
|
||||
* this method returns null.
|
||||
*/
|
||||
@Nullable QName getRequestPayloadName();
|
||||
|
||||
/**
|
||||
* Gets the payload QName of the response message.
|
||||
*
|
||||
* <p>
|
||||
* It's possible for an operation to define no body part, in which case
|
||||
* this method returns null.
|
||||
*/
|
||||
@Nullable QName getResponsePayloadName();
|
||||
|
||||
/**
|
||||
* Gets the namespace of request payload.
|
||||
*/
|
||||
String getRequestNamespace();
|
||||
|
||||
/**
|
||||
* Gets the namespace of response payload.
|
||||
*/
|
||||
String getResponseNamespace();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* 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.api.model.wsdl;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.api.BindingID;
|
||||
import com.sun.xml.internal.ws.api.message.Message;
|
||||
import com.sun.xml.internal.ws.api.model.ParameterBinding;
|
||||
|
||||
import javax.jws.WebParam.Mode;
|
||||
import javax.jws.soap.SOAPBinding;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
/**
|
||||
* {@link WSDLPortType} bound with a specific binding.
|
||||
*
|
||||
* @author Vivek Pandey
|
||||
*/
|
||||
public interface WSDLBoundPortType extends WSDLFeaturedObject, WSDLExtensible {
|
||||
/**
|
||||
* Gets the name of the wsdl:binding@name attribute value as local name and wsdl:definitions@targetNamespace
|
||||
* as the namespace uri.
|
||||
*/
|
||||
QName getName();
|
||||
|
||||
/**
|
||||
* Gets the {@link WSDLModel} that owns this port type.
|
||||
*/
|
||||
@NotNull WSDLModel getOwner();
|
||||
|
||||
/**
|
||||
* Gets the {@link WSDLBoundOperation} for a given operation name
|
||||
*
|
||||
* @param operationName non-null operationName
|
||||
* @return null if a {@link WSDLBoundOperation} is not found
|
||||
*/
|
||||
public WSDLBoundOperation get(QName operationName);
|
||||
|
||||
/**
|
||||
* Gets the wsdl:binding@type value, same as {@link WSDLPortType#getName()}
|
||||
*/
|
||||
QName getPortTypeName();
|
||||
|
||||
/**
|
||||
* Gets the {@link WSDLPortType} associated with the wsdl:binding
|
||||
*/
|
||||
WSDLPortType getPortType();
|
||||
|
||||
/**
|
||||
* Gets the {@link WSDLBoundOperation}s
|
||||
*/
|
||||
Iterable<? extends WSDLBoundOperation> getBindingOperations();
|
||||
|
||||
/**
|
||||
* Is this a document style or RPC style?
|
||||
*
|
||||
* Since we only support literal and not encoding, this means
|
||||
* either doc/lit or rpc/lit.
|
||||
*/
|
||||
@NotNull SOAPBinding.Style getStyle();
|
||||
|
||||
/**
|
||||
* Returns the binding ID.
|
||||
* This would typically determined by the binding extension elements in wsdl:binding.
|
||||
*/
|
||||
BindingID getBindingId();
|
||||
|
||||
/**
|
||||
* Gets the bound operation in this port for a tag name. Here the operation would be the one whose
|
||||
* input part descriptor bound to soap:body is same as the tag name except for rpclit where the tag
|
||||
* name would be {@link WSDLBoundOperation#getName()}.
|
||||
*
|
||||
* <p>
|
||||
* If you have a {@link Message} and trying to figure out which operation it belongs to,
|
||||
* always use {@link Message#getOperation}, as that performs better.
|
||||
*
|
||||
* <p>
|
||||
* For example this can be used in the case when a message receipient can get the
|
||||
* {@link WSDLBoundOperation} from the payload tag name.
|
||||
*
|
||||
* <p>
|
||||
* namespaceUri and the local name both can be null to get the WSDLBoundOperation that has empty body -
|
||||
* there is no payload. According to BP 1.1 in a port there can be at MOST one operation with empty body.
|
||||
* Its an error to have namespace URI non-null but local name as null.
|
||||
*
|
||||
* @param namespaceUri namespace of the payload element.
|
||||
* @param localName local name of the payload
|
||||
* @throws NullPointerException if localName is null and namespaceUri is not.
|
||||
* @return
|
||||
* null if no operation with the given tag name is found.
|
||||
*/
|
||||
@Nullable WSDLBoundOperation getOperation(String namespaceUri, String localName);
|
||||
|
||||
/**
|
||||
* Gets the {@link ParameterBinding} for a given operation, part name and the direction - IN/OUT
|
||||
*
|
||||
* @param operation wsdl:operation@name value. Must be non-null.
|
||||
* @param part wsdl:part@name such as value of soap:header@part. Must be non-null.
|
||||
* @param mode {@link Mode#IN} or {@link Mode#OUT}. Must be non-null.
|
||||
* @return null if the binding could not be resolved for the part.
|
||||
*/
|
||||
ParameterBinding getBinding(QName operation, String part, Mode mode);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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.api.model.wsdl;
|
||||
|
||||
/**
|
||||
* Enumeration that tells a wsdl:part that can be defined either using a type
|
||||
* attribute or an element attribute.
|
||||
*
|
||||
* @author Vivek Pandey
|
||||
*/
|
||||
public enum WSDLDescriptorKind {
|
||||
/**
|
||||
* wsdl:part is defined using element attribute.
|
||||
*
|
||||
* <pre>
|
||||
* for exmaple,
|
||||
* <wsdl:part name="foo" element="ns1:FooElement">
|
||||
* </pre>
|
||||
*/
|
||||
ELEMENT(0),
|
||||
|
||||
/**
|
||||
* wsdl:part is defined using type attribute.
|
||||
*
|
||||
* <pre>
|
||||
* for exmaple,
|
||||
* <wsdl:part name="foo" element="ns1:FooType">
|
||||
* </pre>
|
||||
*/
|
||||
TYPE(1);
|
||||
|
||||
WSDLDescriptorKind(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private final int value;
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* 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.api.model.wsdl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.xml.sax.Locator;
|
||||
|
||||
/**
|
||||
* Interface that represents WSDL concepts that
|
||||
* can have extensions.
|
||||
*
|
||||
* @author Vivek Pandey
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public interface WSDLExtensible extends WSDLObject {
|
||||
/**
|
||||
* Gets all the {@link WSDLExtension}s
|
||||
* added through {@link #addExtension(WSDLExtension)}.
|
||||
*
|
||||
* @return
|
||||
* never null.
|
||||
*/
|
||||
Iterable<WSDLExtension> getExtensions();
|
||||
|
||||
/**
|
||||
* Gets all the extensions that is assignable to the given type.
|
||||
*
|
||||
* <p>
|
||||
* This allows clients to find specific extensions in a type-safe
|
||||
* and convenient way.
|
||||
*
|
||||
* @param type
|
||||
* The type of the extension to obtain. Must not be null.
|
||||
*
|
||||
* @return
|
||||
* Can be an empty fromjava.collection but never null.
|
||||
*/
|
||||
<T extends WSDLExtension> Iterable<T> getExtensions(Class<T> type);
|
||||
|
||||
/**
|
||||
* Gets the extension that is assignable to the given type.
|
||||
*
|
||||
* <p>
|
||||
* This is just a convenient version that does
|
||||
*
|
||||
* <pre>
|
||||
* Iterator itr = getExtensions(type);
|
||||
* if(itr.hasNext()) return itr.next();
|
||||
* else return null;
|
||||
* </pre>
|
||||
*
|
||||
* @return
|
||||
* null if the extension was not found.
|
||||
*/
|
||||
<T extends WSDLExtension> T getExtension(Class<T> type);
|
||||
|
||||
/**
|
||||
* Adds a new {@link WSDLExtension}
|
||||
* to this object.
|
||||
*
|
||||
* @param extension
|
||||
* must not be null.
|
||||
*/
|
||||
void addExtension(WSDLExtension extension);
|
||||
|
||||
/**
|
||||
* True if all required WSDL extensions on Port and Binding are understood
|
||||
* @return true if all wsdl required extensions on Port and Binding are understood
|
||||
*/
|
||||
public boolean areRequiredExtensionsUnderstood();
|
||||
|
||||
/**
|
||||
* Marks extension as not understood
|
||||
* @param extnEl QName of extension
|
||||
* @param locator Locator
|
||||
*/
|
||||
public void addNotUnderstoodExtension(QName extnEl, Locator locator);
|
||||
|
||||
/**
|
||||
* Lists extensions marked as not understood
|
||||
* @return List of not understood extensions
|
||||
*/
|
||||
public List<? extends WSDLExtension> getNotUnderstoodExtensions();
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.api.model.wsdl;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
/**
|
||||
* Represents a WSDL extensibility element or attribute.
|
||||
*
|
||||
* <p>
|
||||
* This interface can be implemented by the programs that build
|
||||
* on top of the JAX-WS RI, to hook additional information into
|
||||
* {@link WSDLModel}.
|
||||
*
|
||||
* @author Vivek Pandey
|
||||
*/
|
||||
public interface WSDLExtension {
|
||||
/**
|
||||
* Gets the qualified name of the WSDL extensibility element or attribute.
|
||||
*
|
||||
* @return
|
||||
* must not be null.
|
||||
*/
|
||||
public QName getName();
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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.api.model.wsdl;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
/**
|
||||
* Abstracts wsdl:portType/wsdl:operation/wsdl:fault
|
||||
*
|
||||
* @author Vivek Pandey
|
||||
*/
|
||||
public interface WSDLFault extends WSDLObject, WSDLExtensible {
|
||||
/**
|
||||
* Gives wsdl:fault@name value
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Gives the WSDLMessage corresponding to wsdl:fault@message
|
||||
* This method should not be called before the entire WSDLModel is built. Basically after the WSDLModel is built
|
||||
* all the references are resolve in a post processing phase. IOW, the WSDL extensions should
|
||||
* not call this method.
|
||||
*
|
||||
* @return Always returns null when called from inside WSDL extensions.
|
||||
*/
|
||||
WSDLMessage getMessage();
|
||||
|
||||
/**
|
||||
* Gives the owning {@link WSDLOperation}
|
||||
*/
|
||||
@NotNull
|
||||
WSDLOperation getOperation();
|
||||
|
||||
/**
|
||||
* Gives qualified name of the wsdl:fault 'name' attribute value.
|
||||
* <p/>
|
||||
*
|
||||
* The namespace uri is determined from the enclosing wsdl:operation.
|
||||
*/
|
||||
@NotNull
|
||||
QName getQName();
|
||||
|
||||
/**
|
||||
* Gives the Action Message Addressing Property value for
|
||||
* {@link WSDLFault} message.
|
||||
* <p/>
|
||||
* This method provides the correct value irrespective of
|
||||
* whether the Action is explicitly specified in the WSDL or
|
||||
* implicitly derived using the rules defined in WS-Addressing.
|
||||
*
|
||||
* @return Action
|
||||
*/
|
||||
String getAction();
|
||||
|
||||
/**
|
||||
* True if this is the default action
|
||||
* @return
|
||||
*/
|
||||
public boolean isDefaultAction();
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user