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

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

View File

@@ -0,0 +1,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;
}
}

View File

@@ -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 &lt;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;
}
}
}

View 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.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 &lt;ReplyTo> and &lt;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);
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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

View File

@@ -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;