feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
404
jdkSrc/jdk8/com/sun/xml/internal/ws/binding/BindingImpl.java
Normal file
404
jdkSrc/jdk8/com/sun/xml/internal/ws/binding/BindingImpl.java
Normal file
@@ -0,0 +1,404 @@
|
||||
/*
|
||||
* 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.binding;
|
||||
|
||||
import com.oracle.webservices.internal.api.message.MessageContextFactory;
|
||||
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.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.pipe.Codec;
|
||||
import com.sun.xml.internal.ws.client.HandlerConfiguration;
|
||||
import com.sun.xml.internal.ws.developer.MemberSubmissionAddressingFeature;
|
||||
import com.sun.xml.internal.ws.developer.BindingTypeFeature;
|
||||
|
||||
import javax.activation.CommandInfo;
|
||||
import javax.activation.CommandMap;
|
||||
import javax.activation.MailcapCommandMap;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.ws.Service;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import javax.xml.ws.soap.AddressingFeature;
|
||||
import javax.xml.ws.handler.Handler;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* Instances are created by the service, which then
|
||||
* sets the handler chain on the binding impl.
|
||||
*
|
||||
* <p>
|
||||
* This class is made abstract as we don't see a situation when
|
||||
* a BindingImpl has much meaning without binding id.
|
||||
* IOW, for a specific binding there will be a class
|
||||
* extending BindingImpl, for example SOAPBindingImpl.
|
||||
*
|
||||
* <p>
|
||||
* The spi Binding interface extends Binding.
|
||||
*
|
||||
* @author WS Development Team
|
||||
*/
|
||||
public abstract class BindingImpl implements WSBinding {
|
||||
|
||||
protected static final WebServiceFeature[] EMPTY_FEATURES = new WebServiceFeature[0];
|
||||
|
||||
//This is reset when ever Binding.setHandlerChain() or SOAPBinding.setRoles() is called.
|
||||
private HandlerConfiguration handlerConfig;
|
||||
private final Set<QName> addedHeaders = new HashSet<QName>();
|
||||
private final Set<QName> knownHeaders = new HashSet<QName>();
|
||||
private final Set<QName> unmodKnownHeaders = Collections.unmodifiableSet(knownHeaders);
|
||||
private final BindingID bindingId;
|
||||
// Features that are set(enabled/disabled) on the binding
|
||||
protected final WebServiceFeatureList features;
|
||||
// Features that are set(enabled/disabled) on the binding or an operation
|
||||
protected final Map<QName, WebServiceFeatureList> operationFeatures = new HashMap<QName, WebServiceFeatureList>();
|
||||
// Features that are set(enabled/disabled) on the binding, an operation or an input message
|
||||
protected final Map<QName, WebServiceFeatureList> inputMessageFeatures = new HashMap<QName, WebServiceFeatureList>();
|
||||
// Features that are set(enabled/disabled) on the binding, an operation or an output message
|
||||
protected final Map<QName, WebServiceFeatureList> outputMessageFeatures = new HashMap<QName, WebServiceFeatureList>();
|
||||
// Features that are set(enabled/disabled) on the binding, an operation or a fault message
|
||||
protected final Map<MessageKey, WebServiceFeatureList> faultMessageFeatures = new HashMap<MessageKey, WebServiceFeatureList>();
|
||||
|
||||
protected javax.xml.ws.Service.Mode serviceMode = javax.xml.ws.Service.Mode.PAYLOAD;
|
||||
|
||||
protected MessageContextFactory messageContextFactory;
|
||||
|
||||
protected BindingImpl(BindingID bindingId, WebServiceFeature ... features) {
|
||||
this.bindingId = bindingId;
|
||||
handlerConfig = new HandlerConfiguration(Collections.<String>emptySet(), Collections.<Handler>emptyList());
|
||||
if (handlerConfig.getHandlerKnownHeaders() != null)
|
||||
knownHeaders.addAll(handlerConfig.getHandlerKnownHeaders());
|
||||
this.features = new WebServiceFeatureList(features);
|
||||
this.features.validate();
|
||||
}
|
||||
|
||||
public
|
||||
@NotNull
|
||||
List<Handler> getHandlerChain() {
|
||||
return handlerConfig.getHandlerChain();
|
||||
}
|
||||
|
||||
public HandlerConfiguration getHandlerConfig() {
|
||||
return handlerConfig;
|
||||
}
|
||||
|
||||
protected void setHandlerConfig(HandlerConfiguration handlerConfig) {
|
||||
this.handlerConfig = handlerConfig;
|
||||
knownHeaders.clear();
|
||||
knownHeaders.addAll(addedHeaders);
|
||||
if (handlerConfig != null && handlerConfig.getHandlerKnownHeaders() != null)
|
||||
knownHeaders.addAll(handlerConfig.getHandlerKnownHeaders());
|
||||
}
|
||||
|
||||
public void setMode(@NotNull Service.Mode mode) {
|
||||
this.serviceMode = mode;
|
||||
}
|
||||
|
||||
public Set<QName> getKnownHeaders() {
|
||||
return unmodKnownHeaders;
|
||||
}
|
||||
|
||||
public boolean addKnownHeader(QName headerQName) {
|
||||
addedHeaders.add(headerQName);
|
||||
return knownHeaders.add(headerQName);
|
||||
}
|
||||
|
||||
public
|
||||
@NotNull
|
||||
BindingID getBindingId() {
|
||||
return bindingId;
|
||||
}
|
||||
|
||||
public final SOAPVersion getSOAPVersion() {
|
||||
return bindingId.getSOAPVersion();
|
||||
}
|
||||
|
||||
public AddressingVersion getAddressingVersion() {
|
||||
AddressingVersion addressingVersion;
|
||||
if (features.isEnabled(AddressingFeature.class))
|
||||
addressingVersion = AddressingVersion.W3C;
|
||||
else if (features.isEnabled(MemberSubmissionAddressingFeature.class))
|
||||
addressingVersion = AddressingVersion.MEMBER;
|
||||
else
|
||||
addressingVersion = null;
|
||||
return addressingVersion;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public final Codec createCodec() {
|
||||
|
||||
// initialization from here should cover most of cases;
|
||||
// if not, it would be necessary to call
|
||||
// BindingImpl.initializeJavaActivationHandlers()
|
||||
// explicitly by programmer
|
||||
initializeJavaActivationHandlers();
|
||||
|
||||
return bindingId.createEncoder(this);
|
||||
}
|
||||
|
||||
public static void initializeJavaActivationHandlers() {
|
||||
// DataHandler.writeTo() may search for DCH. So adding some default ones.
|
||||
try {
|
||||
CommandMap map = CommandMap.getDefaultCommandMap();
|
||||
if (map instanceof MailcapCommandMap) {
|
||||
MailcapCommandMap mailMap = (MailcapCommandMap) map;
|
||||
|
||||
// registering our DCH since javamail's DCH doesn't handle
|
||||
if (!cmdMapInitialized(mailMap)) {
|
||||
mailMap.addMailcap("text/xml;;x-java-content-handler=com.sun.xml.internal.ws.encoding.XmlDataContentHandler");
|
||||
mailMap.addMailcap("application/xml;;x-java-content-handler=com.sun.xml.internal.ws.encoding.XmlDataContentHandler");
|
||||
mailMap.addMailcap("image/*;;x-java-content-handler=com.sun.xml.internal.ws.encoding.ImageDataContentHandler");
|
||||
mailMap.addMailcap("text/plain;;x-java-content-handler=com.sun.xml.internal.ws.encoding.StringDataContentHandler");
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
// ignore the exception.
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean cmdMapInitialized(MailcapCommandMap mailMap) {
|
||||
CommandInfo[] commands = mailMap.getAllCommands("text/xml");
|
||||
if (commands == null || commands.length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// SAAJ RI implements it's own DataHandlers which can be used for JAX-WS too;
|
||||
// see com.sun.xml.internal.messaging.saaj.soap.AttachmentPartImpl#initializeJavaActivationHandlers
|
||||
// so if found any of SAAJ or our own handler registered, we are ok; anyway using SAAJ directly here
|
||||
// is not good idea since we don't want standalone JAX-WS to depend on specific SAAJ impl.
|
||||
// This is also reason for duplication of Handler's code by JAX-WS
|
||||
String saajClassName = "com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler";
|
||||
String jaxwsClassName = "com.sun.xml.internal.ws.encoding.XmlDataContentHandler";
|
||||
for (CommandInfo command : commands) {
|
||||
String commandClass = command.getCommandClass();
|
||||
if (saajClassName.equals(commandClass) ||
|
||||
jaxwsClassName.equals(commandClass)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static BindingImpl create(@NotNull BindingID bindingId) {
|
||||
if (bindingId.equals(BindingID.XML_HTTP))
|
||||
return new HTTPBindingImpl();
|
||||
else
|
||||
return new SOAPBindingImpl(bindingId);
|
||||
}
|
||||
|
||||
public static BindingImpl create(@NotNull BindingID bindingId, WebServiceFeature[] features) {
|
||||
// Override the BindingID from the features
|
||||
for(WebServiceFeature feature : features) {
|
||||
if (feature instanceof BindingTypeFeature) {
|
||||
BindingTypeFeature f = (BindingTypeFeature)feature;
|
||||
bindingId = BindingID.parse(f.getBindingId());
|
||||
}
|
||||
}
|
||||
if (bindingId.equals(BindingID.XML_HTTP))
|
||||
return new HTTPBindingImpl(features);
|
||||
else
|
||||
return new SOAPBindingImpl(bindingId, features);
|
||||
}
|
||||
|
||||
public static WSBinding getDefaultBinding() {
|
||||
return new SOAPBindingImpl(BindingID.SOAP11_HTTP);
|
||||
}
|
||||
|
||||
public String getBindingID() {
|
||||
return bindingId.toString();
|
||||
}
|
||||
|
||||
public @Nullable <F extends WebServiceFeature> F getFeature(@NotNull Class<F> featureType){
|
||||
return features.get(featureType);
|
||||
}
|
||||
|
||||
public @Nullable <F extends WebServiceFeature> F getOperationFeature(@NotNull Class<F> featureType,
|
||||
@NotNull final QName operationName) {
|
||||
final WebServiceFeatureList operationFeatureList = this.operationFeatures.get(operationName);
|
||||
return FeatureListUtil.mergeFeature(featureType, operationFeatureList, features);
|
||||
}
|
||||
|
||||
public boolean isFeatureEnabled(@NotNull Class<? extends WebServiceFeature> feature){
|
||||
return features.isEnabled(feature);
|
||||
}
|
||||
|
||||
public boolean isOperationFeatureEnabled(@NotNull Class<? extends WebServiceFeature> featureType,
|
||||
@NotNull final QName operationName) {
|
||||
final WebServiceFeatureList operationFeatureList = this.operationFeatures.get(operationName);
|
||||
return FeatureListUtil.isFeatureEnabled(featureType, operationFeatureList, features);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public WebServiceFeatureList getFeatures() {
|
||||
//TODO scchen convert BindingID to WebServiceFeature[]
|
||||
if(!isFeatureEnabled(com.oracle.webservices.internal.api.EnvelopeStyleFeature.class)) {
|
||||
WebServiceFeature[] f = { getSOAPVersion().toFeature() };
|
||||
features.mergeFeatures(f, false);
|
||||
}
|
||||
return features;
|
||||
}
|
||||
|
||||
public @NotNull WebServiceFeatureList getOperationFeatures(@NotNull final QName operationName) {
|
||||
final WebServiceFeatureList operationFeatureList = this.operationFeatures.get(operationName);
|
||||
return FeatureListUtil.mergeList(operationFeatureList, features);
|
||||
}
|
||||
|
||||
public @NotNull WebServiceFeatureList getInputMessageFeatures(@NotNull final QName operationName) {
|
||||
final WebServiceFeatureList operationFeatureList = this.operationFeatures.get(operationName);
|
||||
final WebServiceFeatureList messageFeatureList = this.inputMessageFeatures.get(operationName);
|
||||
return FeatureListUtil.mergeList(operationFeatureList, messageFeatureList, features);
|
||||
|
||||
}
|
||||
|
||||
public @NotNull WebServiceFeatureList getOutputMessageFeatures(@NotNull final QName operationName) {
|
||||
final WebServiceFeatureList operationFeatureList = this.operationFeatures.get(operationName);
|
||||
final WebServiceFeatureList messageFeatureList = this.outputMessageFeatures.get(operationName);
|
||||
return FeatureListUtil.mergeList(operationFeatureList, messageFeatureList, features);
|
||||
}
|
||||
|
||||
public @NotNull WebServiceFeatureList getFaultMessageFeatures(@NotNull final QName operationName,
|
||||
@NotNull final QName messageName) {
|
||||
final WebServiceFeatureList operationFeatureList = this.operationFeatures.get(operationName);
|
||||
final WebServiceFeatureList messageFeatureList = this.faultMessageFeatures.get(
|
||||
new MessageKey(operationName, messageName));
|
||||
return FeatureListUtil.mergeList(operationFeatureList, messageFeatureList, features);
|
||||
}
|
||||
|
||||
public void setOperationFeatures(@NotNull final QName operationName, WebServiceFeature... newFeatures) {
|
||||
if (newFeatures != null) {
|
||||
WebServiceFeatureList featureList = operationFeatures.get(operationName);
|
||||
if (featureList == null) {
|
||||
featureList = new WebServiceFeatureList();
|
||||
}
|
||||
for (WebServiceFeature f : newFeatures) {
|
||||
featureList.add(f);
|
||||
}
|
||||
operationFeatures.put(operationName, featureList);
|
||||
}
|
||||
}
|
||||
|
||||
public void setInputMessageFeatures(@NotNull final QName operationName, WebServiceFeature... newFeatures) {
|
||||
if (newFeatures != null) {
|
||||
WebServiceFeatureList featureList = inputMessageFeatures.get(operationName);
|
||||
if (featureList == null) {
|
||||
featureList = new WebServiceFeatureList();
|
||||
}
|
||||
for (WebServiceFeature f : newFeatures) {
|
||||
featureList.add(f);
|
||||
}
|
||||
inputMessageFeatures.put(operationName, featureList);
|
||||
}
|
||||
}
|
||||
|
||||
public void setOutputMessageFeatures(@NotNull final QName operationName, WebServiceFeature... newFeatures) {
|
||||
if (newFeatures != null) {
|
||||
WebServiceFeatureList featureList = outputMessageFeatures.get(operationName);
|
||||
if (featureList == null) {
|
||||
featureList = new WebServiceFeatureList();
|
||||
}
|
||||
for (WebServiceFeature f : newFeatures) {
|
||||
featureList.add(f);
|
||||
}
|
||||
outputMessageFeatures.put(operationName, featureList);
|
||||
}
|
||||
}
|
||||
|
||||
public void setFaultMessageFeatures(@NotNull final QName operationName, @NotNull final QName messageName, WebServiceFeature... newFeatures) {
|
||||
if (newFeatures != null) {
|
||||
final MessageKey key = new MessageKey(operationName, messageName);
|
||||
WebServiceFeatureList featureList = faultMessageFeatures.get(key);
|
||||
if (featureList == null) {
|
||||
featureList = new WebServiceFeatureList();
|
||||
}
|
||||
for (WebServiceFeature f : newFeatures) {
|
||||
featureList.add(f);
|
||||
}
|
||||
faultMessageFeatures.put(key, featureList);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized @NotNull com.oracle.webservices.internal.api.message.MessageContextFactory getMessageContextFactory () {
|
||||
if (messageContextFactory == null) {
|
||||
messageContextFactory = MessageContextFactory.createFactory(getFeatures().toArray());
|
||||
}
|
||||
return messageContextFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Experimental: Identify messages based on the name of the message and the
|
||||
* operation that uses this message.
|
||||
*/
|
||||
protected static class MessageKey {
|
||||
|
||||
final private QName operationName;
|
||||
final private QName messageName;
|
||||
|
||||
public MessageKey(final QName operationName, final QName messageName) {
|
||||
this.operationName = operationName;
|
||||
this.messageName = messageName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int hashFirst = this.operationName != null ? this.operationName.hashCode() : 0;
|
||||
final int hashSecond = this.messageName != null ? this.messageName.hashCode() : 0;
|
||||
|
||||
return (hashFirst + hashSecond) * hashSecond + hashFirst;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final MessageKey other = (MessageKey) obj;
|
||||
if (this.operationName != other.operationName && (this.operationName == null || !this.operationName.equals(other.operationName))) {
|
||||
return false;
|
||||
}
|
||||
if (this.messageName != other.messageName && (this.messageName == null || !this.messageName.equals(other.messageName))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "(" + this.operationName + ", " + this.messageName + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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.binding;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
/**
|
||||
* Experimental: Utility methods that operate on WebServiceFeatureLists.
|
||||
*
|
||||
* @author WS Development Team
|
||||
*/
|
||||
public class FeatureListUtil {
|
||||
|
||||
/**
|
||||
* Merge all features into one list. Returns an empty list if no lists were
|
||||
* passed as parameter.
|
||||
*
|
||||
* @param lists The WebServiceFeatureLists.
|
||||
* @return A new WebServiceFeatureList that contains all features.
|
||||
*/
|
||||
public static @NotNull WebServiceFeatureList mergeList(WebServiceFeatureList... lists) {
|
||||
final WebServiceFeatureList result = new WebServiceFeatureList();
|
||||
for (WebServiceFeatureList list : lists) {
|
||||
result.addAll(list);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static @Nullable <F extends WebServiceFeature> F mergeFeature(final @NotNull Class<F> featureType,
|
||||
@Nullable WebServiceFeatureList list1, @Nullable WebServiceFeatureList list2)
|
||||
throws WebServiceException {
|
||||
final F feature1 = list1 != null ? list1.get(featureType) : null;
|
||||
final F feature2 = list2 != null ? list2.get(featureType) : null;
|
||||
if (feature1 == null) {
|
||||
return feature2;
|
||||
}
|
||||
else if (feature2 == null) {
|
||||
return feature1;
|
||||
}
|
||||
else {
|
||||
if (feature1.equals(feature2)) {
|
||||
return feature1;
|
||||
}
|
||||
else {
|
||||
// TODO exception text
|
||||
throw new WebServiceException(feature1 + ", " + feature2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isFeatureEnabled(@NotNull Class<? extends WebServiceFeature> featureType,
|
||||
@Nullable WebServiceFeatureList list1, @Nullable WebServiceFeatureList list2)
|
||||
throws WebServiceException {
|
||||
final WebServiceFeature mergedFeature = mergeFeature(featureType, list1, list2);
|
||||
return (mergedFeature != null) && mergedFeature.isEnabled();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.binding;
|
||||
|
||||
import com.sun.xml.internal.ws.api.BindingID;
|
||||
import com.sun.xml.internal.ws.client.HandlerConfiguration;
|
||||
import com.sun.xml.internal.ws.resources.ClientMessages;
|
||||
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import javax.xml.ws.handler.Handler;
|
||||
import javax.xml.ws.handler.LogicalHandler;
|
||||
import javax.xml.ws.http.HTTPBinding;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author WS Development Team
|
||||
*/
|
||||
public class HTTPBindingImpl extends BindingImpl implements HTTPBinding {
|
||||
|
||||
/**
|
||||
* Use {@link BindingImpl#create(BindingID)} to create this.
|
||||
*/
|
||||
HTTPBindingImpl() {
|
||||
this(EMPTY_FEATURES);
|
||||
}
|
||||
|
||||
HTTPBindingImpl(WebServiceFeature ... features) {
|
||||
super(BindingID.XML_HTTP, features);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method separates the logical and protocol handlers and
|
||||
* sets the HandlerConfiguration.
|
||||
* Only logical handlers are allowed with HTTPBinding.
|
||||
* Setting SOAPHandlers throws WebServiceException
|
||||
*/
|
||||
public void setHandlerChain(List<Handler> chain) {
|
||||
for (Handler handler : chain) {
|
||||
if (!(handler instanceof LogicalHandler)) {
|
||||
throw new WebServiceException(ClientMessages.NON_LOGICAL_HANDLER_SET(handler.getClass()));
|
||||
}
|
||||
}
|
||||
setHandlerConfig(new HandlerConfiguration(Collections.<String>emptySet(), chain));
|
||||
}
|
||||
}
|
||||
169
jdkSrc/jdk8/com/sun/xml/internal/ws/binding/SOAPBindingImpl.java
Normal file
169
jdkSrc/jdk8/com/sun/xml/internal/ws/binding/SOAPBindingImpl.java
Normal file
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* 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.binding;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.xml.internal.ws.api.BindingID;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.client.HandlerConfiguration;
|
||||
import com.sun.xml.internal.ws.encoding.soap.streaming.SOAP12NamespaceConstants;
|
||||
import com.sun.xml.internal.ws.resources.ClientMessages;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.MessageFactory;
|
||||
import javax.xml.soap.SOAPFactory;
|
||||
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import javax.xml.ws.handler.Handler;
|
||||
import javax.xml.ws.soap.MTOMFeature;
|
||||
import javax.xml.ws.soap.SOAPBinding;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author WS Development Team
|
||||
*/
|
||||
public final class SOAPBindingImpl extends BindingImpl implements SOAPBinding {
|
||||
|
||||
public static final String X_SOAP12HTTP_BINDING =
|
||||
"http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/";
|
||||
|
||||
private static final String ROLE_NONE = SOAP12NamespaceConstants.ROLE_NONE;
|
||||
//protected boolean enableMtom;
|
||||
protected final SOAPVersion soapVersion;
|
||||
|
||||
private Set<QName> portKnownHeaders = Collections.emptySet();
|
||||
private Set<QName> bindingUnderstoodHeaders = new HashSet<QName>();
|
||||
|
||||
/**
|
||||
* Use {@link BindingImpl#create(BindingID)} to create this.
|
||||
*
|
||||
* @param bindingId SOAP binding ID
|
||||
*/
|
||||
SOAPBindingImpl(BindingID bindingId) {
|
||||
this(bindingId,EMPTY_FEATURES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use {@link BindingImpl#create(BindingID)} to create this.
|
||||
*
|
||||
* @param bindingId binding id
|
||||
* @param features
|
||||
* These features have a precedence over
|
||||
* {@link BindingID#createBuiltinFeatureList() the implicit features}
|
||||
* associated with the {@link BindingID}.
|
||||
*/
|
||||
SOAPBindingImpl(BindingID bindingId, WebServiceFeature... features) {
|
||||
super(bindingId, features);
|
||||
this.soapVersion = bindingId.getSOAPVersion();
|
||||
//populates with required roles and updates handlerConfig
|
||||
setRoles(new HashSet<String>());
|
||||
//Is this still required? comment out for now
|
||||
//setupSystemHandlerDelegate(serviceName);
|
||||
|
||||
this.features.addAll(bindingId.createBuiltinFeatureList());
|
||||
}
|
||||
|
||||
/**
|
||||
* This method should be called if the binding has SOAPSEIModel
|
||||
* The Headers understood by the Port are set, so that they can be used for MU
|
||||
* processing.
|
||||
*
|
||||
* @param headers SOAP header names
|
||||
*/
|
||||
public void setPortKnownHeaders(@NotNull Set<QName> headers) {
|
||||
this.portKnownHeaders = headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO A feature should be created to configure processing of MU headers.
|
||||
* @param header
|
||||
* @return
|
||||
*/
|
||||
public boolean understandsHeader(QName header) {
|
||||
return serviceMode == javax.xml.ws.Service.Mode.MESSAGE
|
||||
|| portKnownHeaders.contains(header)
|
||||
|| bindingUnderstoodHeaders.contains(header);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the handlers on the binding and then sorts the handlers in to logical and protocol handlers.
|
||||
* Creates a new HandlerConfiguration object and sets it on the BindingImpl. Also parses Headers understood by
|
||||
* Protocol Handlers and sets the HandlerConfiguration.
|
||||
*/
|
||||
public void setHandlerChain(List<Handler> chain) {
|
||||
setHandlerConfig(new HandlerConfiguration(getHandlerConfig().getRoles(), chain));
|
||||
}
|
||||
|
||||
protected void addRequiredRoles(Set<String> roles) {
|
||||
roles.addAll(soapVersion.requiredRoles);
|
||||
}
|
||||
|
||||
public Set<String> getRoles() {
|
||||
return getHandlerConfig().getRoles();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the next and other roles in case this has
|
||||
* been called by a user without them.
|
||||
* Creates a new HandlerConfiguration object and sets it on the BindingImpl.
|
||||
*/
|
||||
public void setRoles(Set<String> roles) {
|
||||
if (roles == null) {
|
||||
roles = new HashSet<String>();
|
||||
}
|
||||
if (roles.contains(ROLE_NONE)) {
|
||||
throw new WebServiceException(ClientMessages.INVALID_SOAP_ROLE_NONE());
|
||||
}
|
||||
addRequiredRoles(roles);
|
||||
setHandlerConfig(new HandlerConfiguration(roles, getHandlerConfig()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used typically by the runtime to enable/disable Mtom optimization
|
||||
*/
|
||||
public boolean isMTOMEnabled() {
|
||||
return isFeatureEnabled(MTOMFeature.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Client application can override if the MTOM optimization should be enabled
|
||||
*/
|
||||
public void setMTOMEnabled(boolean b) {
|
||||
features.setMTOMEnabled(b);
|
||||
}
|
||||
|
||||
public SOAPFactory getSOAPFactory() {
|
||||
return soapVersion.getSOAPFactory();
|
||||
}
|
||||
|
||||
public MessageFactory getMessageFactory() {
|
||||
return soapVersion.getMessageFactory();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,589 @@
|
||||
/*
|
||||
* 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.binding;
|
||||
|
||||
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.FeatureListValidator;
|
||||
import com.sun.xml.internal.ws.api.FeatureListValidatorAnnotation;
|
||||
import com.sun.xml.internal.ws.api.ImpliesWebServiceFeature;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.WSFeatureList;
|
||||
import com.sun.xml.internal.ws.api.FeatureConstructor;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLFeaturedObject;
|
||||
import com.sun.xml.internal.ws.model.RuntimeModelerException;
|
||||
import com.sun.xml.internal.ws.resources.ModelerMessages;
|
||||
import com.sun.xml.internal.bind.util.Which;
|
||||
|
||||
import javax.xml.ws.RespectBinding;
|
||||
import javax.xml.ws.RespectBindingFeature;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import javax.xml.ws.soap.Addressing;
|
||||
import javax.xml.ws.soap.AddressingFeature;
|
||||
import javax.xml.ws.soap.MTOM;
|
||||
import javax.xml.ws.soap.MTOMFeature;
|
||||
import javax.xml.ws.spi.WebServiceFeatureAnnotation;
|
||||
|
||||
import com.oracle.webservices.internal.api.EnvelopeStyleFeature;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Represents a list of {@link WebServiceFeature}s that has bunch of utility
|
||||
* methods pertaining to web service features.
|
||||
*
|
||||
* @author Rama Pulavarthi
|
||||
*/
|
||||
public final class WebServiceFeatureList extends AbstractMap<Class<? extends WebServiceFeature>, WebServiceFeature> implements WSFeatureList {
|
||||
public static WebServiceFeatureList toList(Iterable<WebServiceFeature> features) {
|
||||
if (features instanceof WebServiceFeatureList)
|
||||
return (WebServiceFeatureList) features;
|
||||
WebServiceFeatureList w = new WebServiceFeatureList();
|
||||
if (features != null)
|
||||
w.addAll(features);
|
||||
return w;
|
||||
}
|
||||
|
||||
private Map<Class<? extends WebServiceFeature>, WebServiceFeature> wsfeatures = new HashMap<Class<? extends WebServiceFeature>, WebServiceFeature>();
|
||||
private boolean isValidating = false;
|
||||
|
||||
public WebServiceFeatureList() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegate to this parent if non-null.
|
||||
*/
|
||||
private @Nullable
|
||||
WSDLFeaturedObject parent;
|
||||
|
||||
public WebServiceFeatureList(@NotNull WebServiceFeature... features) {
|
||||
if (features != null) {
|
||||
for (WebServiceFeature f : features) {
|
||||
addNoValidate(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void validate() {
|
||||
if (!isValidating) {
|
||||
isValidating = true;
|
||||
|
||||
// validation
|
||||
for (WebServiceFeature ff : this) {
|
||||
validate(ff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void validate(WebServiceFeature feature) {
|
||||
// run validation
|
||||
FeatureListValidatorAnnotation fva = feature.getClass().getAnnotation(FeatureListValidatorAnnotation.class);
|
||||
if (fva != null) {
|
||||
Class<? extends FeatureListValidator> beanClass = fva.bean();
|
||||
try {
|
||||
FeatureListValidator validator = beanClass.newInstance();
|
||||
validator.validate(this);
|
||||
} catch (InstantiationException e) {
|
||||
throw new WebServiceException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new WebServiceException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public WebServiceFeatureList(WebServiceFeatureList features) {
|
||||
if (features != null) {
|
||||
wsfeatures.putAll(features.wsfeatures);
|
||||
parent = features.parent;
|
||||
isValidating = features.isValidating;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a list by reading featuers from the annotation on a class.
|
||||
*/
|
||||
public WebServiceFeatureList(@NotNull Class<?> endpointClass) {
|
||||
parseAnnotations(endpointClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the corresponding features to the list for feature annotations(i.e
|
||||
* which have {@link WebServiceFeatureAnnotation} meta annotation)
|
||||
*
|
||||
* @param annIt collection of annotations(that can have non-feature annotations)
|
||||
*/
|
||||
public void parseAnnotations(Iterable<Annotation> annIt) {
|
||||
for(Annotation ann : annIt) {
|
||||
WebServiceFeature feature = getFeature(ann);
|
||||
if (feature != null) {
|
||||
add(feature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a corresponding feature for a feature annotation(i.e which has
|
||||
* {@link WebServiceFeatureAnnotation} meta annotation)
|
||||
*
|
||||
* @return corresponding feature for the annotation
|
||||
* null, if the annotation is nota feature annotation
|
||||
*/
|
||||
public static WebServiceFeature getFeature(Annotation a) {
|
||||
WebServiceFeature ftr = null;
|
||||
if (!(a.annotationType().isAnnotationPresent(WebServiceFeatureAnnotation.class))) {
|
||||
ftr = null;
|
||||
} else if (a instanceof Addressing) {
|
||||
Addressing addAnn = (Addressing) a;
|
||||
try {
|
||||
ftr = new AddressingFeature(addAnn.enabled(), addAnn.required(),addAnn.responses());
|
||||
} catch(NoSuchMethodError e) {
|
||||
//throw error. We can't default to Responses.ALL as we dont know if the user has not used 2.2 annotation with responses.
|
||||
throw new RuntimeModelerException(ModelerMessages.RUNTIME_MODELER_ADDRESSING_RESPONSES_NOSUCHMETHOD(toJar(Which.which(Addressing.class))));
|
||||
}
|
||||
} else if (a instanceof MTOM) {
|
||||
MTOM mtomAnn = (MTOM) a;
|
||||
ftr = new MTOMFeature(mtomAnn.enabled(), mtomAnn.threshold());
|
||||
} else if (a instanceof RespectBinding) {
|
||||
RespectBinding rbAnn = (RespectBinding) a;
|
||||
ftr = new RespectBindingFeature(rbAnn.enabled());
|
||||
} else {
|
||||
ftr = getWebServiceFeatureBean(a);
|
||||
}
|
||||
return ftr;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param endpointClass web service impl class
|
||||
*/
|
||||
public void parseAnnotations(Class<?> endpointClass) {
|
||||
for (Annotation a : endpointClass.getAnnotations()) {
|
||||
WebServiceFeature ftr = getFeature(a);
|
||||
if (ftr != null) {
|
||||
if (ftr instanceof MTOMFeature) {
|
||||
// check conflict with @BindingType
|
||||
BindingID bindingID = BindingID.parse(endpointClass);
|
||||
MTOMFeature bindingMtomSetting = bindingID.createBuiltinFeatureList().get(MTOMFeature.class);
|
||||
if (bindingMtomSetting != null && bindingMtomSetting.isEnabled() ^ ftr.isEnabled()) {
|
||||
throw new RuntimeModelerException(
|
||||
ModelerMessages.RUNTIME_MODELER_MTOM_CONFLICT(bindingID, ftr.isEnabled()));
|
||||
}
|
||||
}
|
||||
add(ftr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the URL String inside jar, returns the URL to the jar itself.
|
||||
*/
|
||||
private static String toJar(String url) {
|
||||
if(!url.startsWith("jar:"))
|
||||
return url;
|
||||
url = url.substring(4); // cut off jar:
|
||||
return url.substring(0,url.lastIndexOf('!')); // cut off everything after '!'
|
||||
}
|
||||
|
||||
private static WebServiceFeature getWebServiceFeatureBean(Annotation a) {
|
||||
WebServiceFeatureAnnotation wsfa = a.annotationType().getAnnotation(WebServiceFeatureAnnotation.class);
|
||||
Class<? extends WebServiceFeature> beanClass = wsfa.bean();
|
||||
WebServiceFeature bean;
|
||||
|
||||
Constructor ftrCtr = null;
|
||||
String[] paramNames = null;
|
||||
for (Constructor con : beanClass.getConstructors()) {
|
||||
FeatureConstructor ftrCtrAnn = (FeatureConstructor) con.getAnnotation(FeatureConstructor.class);
|
||||
if (ftrCtrAnn != null) {
|
||||
if (ftrCtr == null) {
|
||||
ftrCtr = con;
|
||||
paramNames = ftrCtrAnn.value();
|
||||
} else {
|
||||
throw new WebServiceException(
|
||||
ModelerMessages.RUNTIME_MODELER_WSFEATURE_MORETHANONE_FTRCONSTRUCTOR(a, beanClass));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ftrCtr == null) {
|
||||
bean = getWebServiceFeatureBeanViaBuilder(a, beanClass);
|
||||
if (bean != null) {
|
||||
return bean;
|
||||
} else {
|
||||
throw new WebServiceException(
|
||||
ModelerMessages.RUNTIME_MODELER_WSFEATURE_NO_FTRCONSTRUCTOR(a, beanClass));
|
||||
}
|
||||
}
|
||||
if (ftrCtr.getParameterTypes().length != paramNames.length) {
|
||||
throw new WebServiceException(
|
||||
ModelerMessages.RUNTIME_MODELER_WSFEATURE_ILLEGAL_FTRCONSTRUCTOR(a, beanClass));
|
||||
}
|
||||
|
||||
try {
|
||||
Object[] params = new Object[paramNames.length];
|
||||
for (int i = 0; i < paramNames.length; i++) {
|
||||
Method m = a.annotationType().getDeclaredMethod(paramNames[i]);
|
||||
params[i] = m.invoke(a);
|
||||
}
|
||||
bean = (WebServiceFeature) ftrCtr.newInstance(params);
|
||||
} catch (Exception e) {
|
||||
throw new WebServiceException(e);
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
private static WebServiceFeature getWebServiceFeatureBeanViaBuilder(
|
||||
final Annotation annotation,
|
||||
final Class<? extends WebServiceFeature> beanClass)
|
||||
{
|
||||
try {
|
||||
final Method featureBuilderMethod = beanClass.getDeclaredMethod("builder");
|
||||
final Object builder = featureBuilderMethod.invoke(beanClass);
|
||||
final Method buildMethod = builder.getClass().getDeclaredMethod("build");
|
||||
|
||||
for (Method builderMethod : builder.getClass().getDeclaredMethods()) {
|
||||
if (!builderMethod.equals(buildMethod)) {
|
||||
final String methodName = builderMethod.getName();
|
||||
final Method annotationMethod = annotation.annotationType().getDeclaredMethod(methodName);
|
||||
final Object annotationFieldValue = annotationMethod.invoke(annotation);
|
||||
final Object[] arg = { annotationFieldValue };
|
||||
if (skipDuringOrgJvnetWsToComOracleWebservicesPackageMove(builderMethod, annotationFieldValue)) {
|
||||
continue;
|
||||
}
|
||||
builderMethod.invoke(builder, arg);
|
||||
}
|
||||
}
|
||||
|
||||
final Object result = buildMethod.invoke(builder);
|
||||
if (result instanceof WebServiceFeature) {
|
||||
return (WebServiceFeature) result;
|
||||
} else {
|
||||
throw new WebServiceException("Not a WebServiceFeature: " + result);
|
||||
}
|
||||
} catch (final NoSuchMethodException e) {
|
||||
return null;
|
||||
} catch (final IllegalAccessException e) {
|
||||
throw new WebServiceException(e);
|
||||
} catch (final InvocationTargetException e) {
|
||||
throw new WebServiceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO this will be removed after package move is complete.
|
||||
private static boolean skipDuringOrgJvnetWsToComOracleWebservicesPackageMove(
|
||||
final Method builderMethod,
|
||||
final Object annotationFieldValue)
|
||||
{
|
||||
final Class<?> annotationFieldValueClass = annotationFieldValue.getClass();
|
||||
if (! annotationFieldValueClass.isEnum()) {
|
||||
return false;
|
||||
}
|
||||
final Class<?>[] builderMethodParameterTypes = builderMethod.getParameterTypes();
|
||||
if (builderMethodParameterTypes.length != 1) {
|
||||
throw new WebServiceException("expected only 1 parameter");
|
||||
}
|
||||
final String builderParameterTypeName = builderMethodParameterTypes[0].getName();
|
||||
if (! builderParameterTypeName.startsWith("com.oracle.webservices.internal.test.features_annotations_enums.apinew") &&
|
||||
! builderParameterTypeName.startsWith("com.oracle.webservices.internal.api")) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Iterator<WebServiceFeature> iterator() {
|
||||
if (parent != null)
|
||||
return new MergedFeatures(parent.getFeatures());
|
||||
return wsfeatures.values().iterator();
|
||||
}
|
||||
|
||||
public @NotNull
|
||||
WebServiceFeature[] toArray() {
|
||||
if (parent != null)
|
||||
return new MergedFeatures(parent.getFeatures()).toArray();
|
||||
return wsfeatures.values().toArray(new WebServiceFeature[] {});
|
||||
}
|
||||
|
||||
public boolean isEnabled(@NotNull Class<? extends WebServiceFeature> feature) {
|
||||
WebServiceFeature ftr = get(feature);
|
||||
return ftr != null && ftr.isEnabled();
|
||||
}
|
||||
|
||||
public boolean contains(@NotNull Class<? extends WebServiceFeature> feature) {
|
||||
WebServiceFeature ftr = get(feature);
|
||||
return ftr != null;
|
||||
}
|
||||
|
||||
public @Nullable
|
||||
<F extends WebServiceFeature> F get(@NotNull Class<F> featureType) {
|
||||
WebServiceFeature f = featureType.cast(wsfeatures.get(featureType));
|
||||
if (f == null && parent != null) {
|
||||
return parent.getFeatures().get(featureType);
|
||||
}
|
||||
return (F) f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a feature to the list if it's not already added.
|
||||
*/
|
||||
public void add(@NotNull WebServiceFeature f) {
|
||||
if(addNoValidate(f) && isValidating)
|
||||
validate(f);
|
||||
}
|
||||
|
||||
private boolean addNoValidate(@NotNull WebServiceFeature f) {
|
||||
if (!wsfeatures.containsKey(f.getClass())) {
|
||||
wsfeatures.put(f.getClass(), f);
|
||||
|
||||
if (f instanceof ImpliesWebServiceFeature)
|
||||
((ImpliesWebServiceFeature) f).implyFeatures(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds features to the list if it's not already added.
|
||||
*/
|
||||
public void addAll(@NotNull Iterable<WebServiceFeature> list) {
|
||||
for (WebServiceFeature f : list)
|
||||
add(f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets MTOM feature, overriding any existing feature. This is necessary for compatibility
|
||||
* with the existing {@link SOAPBinding.setMTOMEnabled}.
|
||||
* @param b if MTOM will be enabled
|
||||
*/
|
||||
void setMTOMEnabled(boolean b) {
|
||||
wsfeatures.put(MTOMFeature.class, new MTOMFeature(b));
|
||||
}
|
||||
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof WebServiceFeatureList))
|
||||
return false;
|
||||
|
||||
WebServiceFeatureList w = (WebServiceFeatureList) other;
|
||||
return wsfeatures.equals(w.wsfeatures) && (parent == w.parent);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return wsfeatures.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public void mergeFeatures(@NotNull Iterable<WebServiceFeature> features, boolean reportConflicts) {
|
||||
for (WebServiceFeature wsdlFtr : features) {
|
||||
if (get(wsdlFtr.getClass()) == null) {
|
||||
add(wsdlFtr);
|
||||
} else if (reportConflicts) {
|
||||
if (isEnabled(wsdlFtr.getClass()) != wsdlFtr.isEnabled()) {
|
||||
LOGGER.warning(ModelerMessages.RUNTIME_MODELER_FEATURE_CONFLICT(
|
||||
get(wsdlFtr.getClass()), wsdlFtr));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void mergeFeatures(WebServiceFeature[] features, boolean reportConflicts) {
|
||||
for (WebServiceFeature wsdlFtr : features) {
|
||||
if (get(wsdlFtr.getClass()) == null) {
|
||||
add(wsdlFtr);
|
||||
} else if (reportConflicts) {
|
||||
if (isEnabled(wsdlFtr.getClass()) != wsdlFtr.isEnabled()) {
|
||||
LOGGER.warning(ModelerMessages.RUNTIME_MODELER_FEATURE_CONFLICT(
|
||||
get(wsdlFtr.getClass()), wsdlFtr));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts features from {@link WSDLPort#getFeatures()}. 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 wsdlPort
|
||||
* WSDLPort model
|
||||
* @param honorWsdlRequired
|
||||
* If this is true add WSDL Feature only if wsd:Required=true In
|
||||
* SEI case, it should be false In Provider case, it should be
|
||||
* true
|
||||
* @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.
|
||||
*/
|
||||
public void mergeFeatures(@NotNull WSDLPort wsdlPort,
|
||||
boolean honorWsdlRequired, boolean reportConflicts) {
|
||||
if (honorWsdlRequired && !isEnabled(RespectBindingFeature.class))
|
||||
return;
|
||||
if (!honorWsdlRequired) {
|
||||
addAll(wsdlPort.getFeatures());
|
||||
return;
|
||||
}
|
||||
// Add only if isRequired returns true, when honorWsdlRequired is true
|
||||
for (WebServiceFeature wsdlFtr : wsdlPort.getFeatures()) {
|
||||
if (get(wsdlFtr.getClass()) == null) {
|
||||
try {
|
||||
// if it is a WSDL Extension , it will have required
|
||||
// attribute
|
||||
Method m = (wsdlFtr.getClass().getMethod("isRequired"));
|
||||
try {
|
||||
boolean required = (Boolean) m.invoke(wsdlFtr);
|
||||
if (required)
|
||||
add(wsdlFtr);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new WebServiceException(e);
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new WebServiceException(e);
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
// this wsdlFtr is not an WSDL extension, just add it
|
||||
add(wsdlFtr);
|
||||
}
|
||||
} else if (reportConflicts) {
|
||||
if (isEnabled(wsdlFtr.getClass()) != wsdlFtr.isEnabled()) {
|
||||
LOGGER.warning(ModelerMessages.RUNTIME_MODELER_FEATURE_CONFLICT(
|
||||
get(wsdlFtr.getClass()), wsdlFtr));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the parent features. Basically the parent feature list will be
|
||||
* overriden by this feature list.
|
||||
*/
|
||||
public void setParentFeaturedObject(@NotNull WSDLFeaturedObject parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public static @Nullable <F extends WebServiceFeature> F getFeature(@NotNull WebServiceFeature[] features,
|
||||
@NotNull Class<F> featureType) {
|
||||
for (WebServiceFeature f : features) {
|
||||
if (f.getClass() == featureType)
|
||||
return (F) f;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Union of this WebServiceFeatureList and the parent.
|
||||
*/
|
||||
private final class MergedFeatures implements Iterator<WebServiceFeature> {
|
||||
private final Stack<WebServiceFeature> features = new Stack<WebServiceFeature>();
|
||||
|
||||
public MergedFeatures(@NotNull WSFeatureList parent) {
|
||||
|
||||
for (WebServiceFeature f : wsfeatures.values()) {
|
||||
features.push(f);
|
||||
}
|
||||
|
||||
for (WebServiceFeature f : parent) {
|
||||
if (!wsfeatures.containsKey(f.getClass())) {
|
||||
features.push(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasNext() {
|
||||
return !features.empty();
|
||||
}
|
||||
|
||||
public WebServiceFeature next() {
|
||||
if (!features.empty()) {
|
||||
return features.pop();
|
||||
}
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
if (!features.empty()) {
|
||||
features.pop();
|
||||
}
|
||||
}
|
||||
|
||||
public WebServiceFeature[] toArray() {
|
||||
return features.toArray(new WebServiceFeature[] {});
|
||||
}
|
||||
}
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(WebServiceFeatureList.class.getName());
|
||||
|
||||
@Override
|
||||
public Set<java.util.Map.Entry<Class<? extends WebServiceFeature>, WebServiceFeature>> entrySet() {
|
||||
return wsfeatures.entrySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebServiceFeature put(Class<? extends WebServiceFeature> key, WebServiceFeature value) {
|
||||
return wsfeatures.put(key, value);
|
||||
}
|
||||
|
||||
static public SOAPVersion getSoapVersion(WSFeatureList features) {
|
||||
{
|
||||
EnvelopeStyleFeature env = features.get(EnvelopeStyleFeature.class);
|
||||
if (env != null) {
|
||||
return SOAPVersion.from(env);
|
||||
}
|
||||
}
|
||||
com.oracle.webservices.internal.api.EnvelopeStyleFeature env = features.get(com.oracle.webservices.internal.api.EnvelopeStyleFeature.class);
|
||||
return env != null ? SOAPVersion.from(env) : null;
|
||||
}
|
||||
|
||||
static public boolean isFeatureEnabled(Class<? extends WebServiceFeature> type, WebServiceFeature[] features) {
|
||||
WebServiceFeature ftr = getFeature(features, type);
|
||||
return ftr != null && ftr.isEnabled();
|
||||
}
|
||||
|
||||
static public WebServiceFeature[] toFeatureArray(WSBinding binding) {
|
||||
//TODO scchen convert BindingID to WebServiceFeature[]
|
||||
if(!binding.isFeatureEnabled(EnvelopeStyleFeature.class)) {
|
||||
WebServiceFeature[] f = { binding.getSOAPVersion().toFeature() };
|
||||
binding.getFeatures().mergeFeatures(f, false);
|
||||
}
|
||||
return binding.getFeatures().toArray();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user