ohair@286: /* alanb@368: * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. ohair@286: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ohair@286: * ohair@286: * This code is free software; you can redistribute it and/or modify it ohair@286: * under the terms of the GNU General Public License version 2 only, as ohair@286: * published by the Free Software Foundation. Oracle designates this ohair@286: * particular file as subject to the "Classpath" exception as provided ohair@286: * by Oracle in the LICENSE file that accompanied this code. ohair@286: * ohair@286: * This code is distributed in the hope that it will be useful, but WITHOUT ohair@286: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ohair@286: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ohair@286: * version 2 for more details (a copy is included in the LICENSE file that ohair@286: * accompanied this code). ohair@286: * ohair@286: * You should have received a copy of the GNU General Public License version ohair@286: * 2 along with this work; if not, write to the Free Software Foundation, ohair@286: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ohair@286: * ohair@286: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@286: * or visit www.oracle.com if you need additional information or have any ohair@286: * questions. ohair@286: */ ohair@286: ohair@286: package com.sun.xml.internal.ws.binding; ohair@286: ohair@286: import com.sun.istack.internal.NotNull; ohair@286: import com.sun.istack.internal.Nullable; ohair@286: import com.sun.xml.internal.ws.api.BindingID; alanb@368: import com.sun.xml.internal.ws.api.FeatureListValidator; alanb@368: import com.sun.xml.internal.ws.api.FeatureListValidatorAnnotation; ohair@286: import com.sun.xml.internal.ws.api.ImpliesWebServiceFeature; ohair@286: import com.sun.xml.internal.ws.api.SOAPVersion; ohair@286: import com.sun.xml.internal.ws.api.WSBinding; ohair@286: import com.sun.xml.internal.ws.api.WSFeatureList; ohair@286: import com.sun.xml.internal.ws.api.FeatureConstructor; ohair@286: import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort; ohair@286: import com.sun.xml.internal.ws.api.model.wsdl.WSDLFeaturedObject; ohair@286: import com.sun.xml.internal.ws.model.RuntimeModelerException; ohair@286: import com.sun.xml.internal.ws.resources.ModelerMessages; ohair@286: import com.sun.xml.internal.bind.util.Which; ohair@286: ohair@286: import javax.xml.ws.RespectBinding; ohair@286: import javax.xml.ws.RespectBindingFeature; ohair@286: import javax.xml.ws.WebServiceException; ohair@286: import javax.xml.ws.WebServiceFeature; ohair@286: import javax.xml.ws.soap.Addressing; ohair@286: import javax.xml.ws.soap.AddressingFeature; ohair@286: import javax.xml.ws.soap.MTOM; ohair@286: import javax.xml.ws.soap.MTOMFeature; ohair@286: import javax.xml.ws.spi.WebServiceFeatureAnnotation; ohair@286: alanb@368: import com.oracle.webservices.internal.api.EnvelopeStyleFeature; ohair@286: ohair@286: import java.lang.annotation.Annotation; ohair@286: import java.lang.reflect.InvocationTargetException; ohair@286: import java.lang.reflect.Method; ohair@286: import java.lang.reflect.Constructor; ohair@286: import java.util.*; ohair@286: import java.util.logging.Logger; ohair@286: ohair@286: /** ohair@286: * Represents a list of {@link WebServiceFeature}s that has bunch of utility ohair@286: * methods pertaining to web service features. ohair@286: * ohair@286: * @author Rama Pulavarthi ohair@286: */ ohair@286: public final class WebServiceFeatureList extends AbstractMap, WebServiceFeature> implements WSFeatureList { ohair@286: public static WebServiceFeatureList toList(Iterable features) { ohair@286: if (features instanceof WebServiceFeatureList) ohair@286: return (WebServiceFeatureList) features; ohair@286: WebServiceFeatureList w = new WebServiceFeatureList(); ohair@286: if (features != null) ohair@286: w.addAll(features); ohair@286: return w; ohair@286: } ohair@286: ohair@286: private Map, WebServiceFeature> wsfeatures = new HashMap, WebServiceFeature>(); alanb@368: private boolean isValidating = false; ohair@286: ohair@286: public WebServiceFeatureList() { ohair@286: } ohair@286: ohair@286: /** ohair@286: * Delegate to this parent if non-null. ohair@286: */ ohair@286: private @Nullable ohair@286: WSDLFeaturedObject parent; ohair@286: ohair@286: public WebServiceFeatureList(@NotNull WebServiceFeature... features) { ohair@286: if (features != null) { ohair@286: for (WebServiceFeature f : features) { alanb@368: addNoValidate(f); alanb@368: } alanb@368: } alanb@368: } alanb@368: alanb@368: public void validate() { alanb@368: if (!isValidating) { alanb@368: isValidating = true; alanb@368: alanb@368: // validation alanb@368: for (WebServiceFeature ff : this) { alanb@368: validate(ff); alanb@368: } alanb@368: } alanb@368: } alanb@368: alanb@368: private void validate(WebServiceFeature feature) { alanb@368: // run validation alanb@368: FeatureListValidatorAnnotation fva = feature.getClass().getAnnotation(FeatureListValidatorAnnotation.class); alanb@368: if (fva != null) { alanb@368: Class beanClass = fva.bean(); alanb@368: try { alanb@368: FeatureListValidator validator = beanClass.newInstance(); alanb@368: validator.validate(this); alanb@368: } catch (InstantiationException e) { alanb@368: throw new WebServiceException(e); alanb@368: } catch (IllegalAccessException e) { alanb@368: throw new WebServiceException(e); ohair@286: } ohair@286: } ohair@286: } ohair@286: ohair@286: public WebServiceFeatureList(WebServiceFeatureList features) { ohair@286: if (features != null) { ohair@286: wsfeatures.putAll(features.wsfeatures); ohair@286: parent = features.parent; alanb@368: isValidating = features.isValidating; ohair@286: } ohair@286: } ohair@286: ohair@286: /** ohair@286: * Creates a list by reading featuers from the annotation on a class. ohair@286: */ ohair@286: public WebServiceFeatureList(@NotNull Class endpointClass) { ohair@286: parseAnnotations(endpointClass); ohair@286: } ohair@286: ohair@286: /** ohair@286: * Adds the corresponding features to the list for feature annotations(i.e ohair@286: * which have {@link WebServiceFeatureAnnotation} meta annotation) ohair@286: * ohair@286: * @param annIt collection of annotations(that can have non-feature annotations) ohair@286: */ ohair@286: public void parseAnnotations(Iterable annIt) { ohair@286: for(Annotation ann : annIt) { ohair@286: WebServiceFeature feature = getFeature(ann); ohair@286: if (feature != null) { ohair@286: add(feature); ohair@286: } ohair@286: } ohair@286: } ohair@286: ohair@286: /** ohair@286: * Returns a corresponding feature for a feature annotation(i.e which has ohair@286: * {@link WebServiceFeatureAnnotation} meta annotation) ohair@286: * ohair@286: * @return corresponding feature for the annotation ohair@286: * null, if the annotation is nota feature annotation ohair@286: */ ohair@286: public static WebServiceFeature getFeature(Annotation a) { ohair@286: WebServiceFeature ftr = null; ohair@286: if (!(a.annotationType().isAnnotationPresent(WebServiceFeatureAnnotation.class))) { ohair@286: ftr = null; ohair@286: } else if (a instanceof Addressing) { ohair@286: Addressing addAnn = (Addressing) a; ohair@286: try { ohair@286: ftr = new AddressingFeature(addAnn.enabled(), addAnn.required(),addAnn.responses()); ohair@286: } catch(NoSuchMethodError e) { ohair@286: //throw error. We can't default to Responses.ALL as we dont know if the user has not used 2.2 annotation with responses. ohair@286: throw new RuntimeModelerException(ModelerMessages.RUNTIME_MODELER_ADDRESSING_RESPONSES_NOSUCHMETHOD(toJar(Which.which(Addressing.class)))); ohair@286: } ohair@286: } else if (a instanceof MTOM) { ohair@286: MTOM mtomAnn = (MTOM) a; ohair@286: ftr = new MTOMFeature(mtomAnn.enabled(), mtomAnn.threshold()); ohair@286: } else if (a instanceof RespectBinding) { ohair@286: RespectBinding rbAnn = (RespectBinding) a; ohair@286: ftr = new RespectBindingFeature(rbAnn.enabled()); ohair@286: } else { ohair@286: ftr = getWebServiceFeatureBean(a); ohair@286: } ohair@286: return ftr; ohair@286: } ohair@286: ohair@286: /** ohair@286: * ohair@286: * @param endpointClass web service impl class ohair@286: */ ohair@286: public void parseAnnotations(Class endpointClass) { ohair@286: for (Annotation a : endpointClass.getAnnotations()) { ohair@286: WebServiceFeature ftr = getFeature(a); ohair@286: if (ftr != null) { ohair@286: if (ftr instanceof MTOMFeature) { ohair@286: // check conflict with @BindingType ohair@286: BindingID bindingID = BindingID.parse(endpointClass); ohair@286: MTOMFeature bindingMtomSetting = bindingID.createBuiltinFeatureList().get(MTOMFeature.class); ohair@286: if (bindingMtomSetting != null && bindingMtomSetting.isEnabled() ^ ftr.isEnabled()) { ohair@286: throw new RuntimeModelerException( ohair@286: ModelerMessages.RUNTIME_MODELER_MTOM_CONFLICT(bindingID, ftr.isEnabled())); ohair@286: } ohair@286: } ohair@286: add(ftr); ohair@286: } ohair@286: } ohair@286: } ohair@286: ohair@286: /** ohair@286: * Given the URL String inside jar, returns the URL to the jar itself. ohair@286: */ ohair@286: private static String toJar(String url) { ohair@286: if(!url.startsWith("jar:")) ohair@286: return url; ohair@286: url = url.substring(4); // cut off jar: ohair@286: return url.substring(0,url.lastIndexOf('!')); // cut off everything after '!' ohair@286: } ohair@286: ohair@286: private static WebServiceFeature getWebServiceFeatureBean(Annotation a) { ohair@286: WebServiceFeatureAnnotation wsfa = a.annotationType().getAnnotation(WebServiceFeatureAnnotation.class); ohair@286: Class beanClass = wsfa.bean(); ohair@286: WebServiceFeature bean; ohair@286: ohair@286: Constructor ftrCtr = null; ohair@286: String[] paramNames = null; ohair@286: for (Constructor con : beanClass.getConstructors()) { ohair@286: FeatureConstructor ftrCtrAnn = (FeatureConstructor) con.getAnnotation(FeatureConstructor.class); ohair@286: if (ftrCtrAnn != null) { ohair@286: if (ftrCtr == null) { ohair@286: ftrCtr = con; ohair@286: paramNames = ftrCtrAnn.value(); ohair@286: } else { ohair@286: throw new WebServiceException( ohair@286: ModelerMessages.RUNTIME_MODELER_WSFEATURE_MORETHANONE_FTRCONSTRUCTOR(a, beanClass)); ohair@286: } ohair@286: } ohair@286: } ohair@286: if (ftrCtr == null) { ohair@286: bean = getWebServiceFeatureBeanViaBuilder(a, beanClass); ohair@286: if (bean != null) { ohair@286: return bean; ohair@286: } else { ohair@286: throw new WebServiceException( ohair@286: ModelerMessages.RUNTIME_MODELER_WSFEATURE_NO_FTRCONSTRUCTOR(a, beanClass)); ohair@286: } ohair@286: } ohair@286: if (ftrCtr.getParameterTypes().length != paramNames.length) { ohair@286: throw new WebServiceException( ohair@286: ModelerMessages.RUNTIME_MODELER_WSFEATURE_ILLEGAL_FTRCONSTRUCTOR(a, beanClass)); ohair@286: } ohair@286: ohair@286: try { ohair@286: Object[] params = new Object[paramNames.length]; ohair@286: for (int i = 0; i < paramNames.length; i++) { ohair@286: Method m = a.annotationType().getDeclaredMethod(paramNames[i]); ohair@286: params[i] = m.invoke(a); ohair@286: } ohair@286: bean = (WebServiceFeature) ftrCtr.newInstance(params); ohair@286: } catch (Exception e) { ohair@286: throw new WebServiceException(e); ohair@286: } ohair@286: return bean; ohair@286: } ohair@286: ohair@286: private static WebServiceFeature getWebServiceFeatureBeanViaBuilder( ohair@286: final Annotation annotation, ohair@286: final Class beanClass) ohair@286: { ohair@286: try { ohair@286: final Method featureBuilderMethod = beanClass.getDeclaredMethod("builder"); ohair@286: final Object builder = featureBuilderMethod.invoke(beanClass); ohair@286: final Method buildMethod = builder.getClass().getDeclaredMethod("build"); ohair@286: ohair@286: for (Method builderMethod : builder.getClass().getDeclaredMethods()) { ohair@286: if (!builderMethod.equals(buildMethod)) { ohair@286: final String methodName = builderMethod.getName(); ohair@286: final Method annotationMethod = annotation.annotationType().getDeclaredMethod(methodName); ohair@286: final Object annotationFieldValue = annotationMethod.invoke(annotation); ohair@286: final Object[] arg = { annotationFieldValue }; alanb@368: if (skipDuringOrgJvnetWsToComOracleWebservicesPackageMove(builderMethod, annotationFieldValue)) { alanb@368: continue; alanb@368: } ohair@286: builderMethod.invoke(builder, arg); ohair@286: } ohair@286: } ohair@286: ohair@286: final Object result = buildMethod.invoke(builder); ohair@286: if (result instanceof WebServiceFeature) { ohair@286: return (WebServiceFeature) result; ohair@286: } else { ohair@286: throw new WebServiceException("Not a WebServiceFeature: " + result); ohair@286: } ohair@286: } catch (final NoSuchMethodException e) { ohair@286: return null; ohair@286: } catch (final IllegalAccessException e) { ohair@286: throw new WebServiceException(e); ohair@286: } catch (final InvocationTargetException e) { ohair@286: throw new WebServiceException(e); ohair@286: } ohair@286: } ohair@286: alanb@368: // TODO this will be removed after package move is complete. alanb@368: private static boolean skipDuringOrgJvnetWsToComOracleWebservicesPackageMove( alanb@368: final Method builderMethod, alanb@368: final Object annotationFieldValue) alanb@368: { alanb@368: final Class annotationFieldValueClass = annotationFieldValue.getClass(); alanb@368: if (! annotationFieldValueClass.isEnum()) { alanb@368: return false; alanb@368: } alanb@368: final Class[] builderMethodParameterTypes = builderMethod.getParameterTypes(); alanb@368: if (builderMethodParameterTypes.length != 1) { alanb@368: throw new WebServiceException("expected only 1 parameter"); alanb@368: } alanb@368: final String builderParameterTypeName = builderMethodParameterTypes[0].getName(); alanb@368: if (! builderParameterTypeName.startsWith("com.oracle.webservices.internal.test.features_annotations_enums.apinew") && alanb@368: ! builderParameterTypeName.startsWith("com.oracle.webservices.internal.api")) { alanb@368: return false; alanb@368: } alanb@368: return false; alanb@368: } alanb@368: ohair@286: public Iterator iterator() { ohair@286: if (parent != null) ohair@286: return new MergedFeatures(parent.getFeatures()); ohair@286: return wsfeatures.values().iterator(); ohair@286: } ohair@286: ohair@286: public @NotNull ohair@286: WebServiceFeature[] toArray() { ohair@286: if (parent != null) ohair@286: return new MergedFeatures(parent.getFeatures()).toArray(); ohair@286: return wsfeatures.values().toArray(new WebServiceFeature[] {}); ohair@286: } ohair@286: ohair@286: public boolean isEnabled(@NotNull Class feature) { ohair@286: WebServiceFeature ftr = get(feature); ohair@286: return ftr != null && ftr.isEnabled(); ohair@286: } ohair@286: ohair@286: public boolean contains(@NotNull Class feature) { ohair@286: WebServiceFeature ftr = get(feature); ohair@286: return ftr != null; ohair@286: } ohair@286: ohair@286: public @Nullable ohair@286: F get(@NotNull Class featureType) { ohair@286: WebServiceFeature f = featureType.cast(wsfeatures.get(featureType)); ohair@286: if (f == null && parent != null) { ohair@286: return parent.getFeatures().get(featureType); ohair@286: } ohair@286: return (F) f; ohair@286: } ohair@286: ohair@286: /** ohair@286: * Adds a feature to the list if it's not already added. ohair@286: */ ohair@286: public void add(@NotNull WebServiceFeature f) { alanb@368: if(addNoValidate(f) && isValidating) alanb@368: validate(f); alanb@368: } alanb@368: alanb@368: private boolean addNoValidate(@NotNull WebServiceFeature f) { ohair@286: if (!wsfeatures.containsKey(f.getClass())) { ohair@286: wsfeatures.put(f.getClass(), f); ohair@286: ohair@286: if (f instanceof ImpliesWebServiceFeature) ohair@286: ((ImpliesWebServiceFeature) f).implyFeatures(this); alanb@368: alanb@368: return true; ohair@286: } alanb@368: alanb@368: return false; ohair@286: } ohair@286: ohair@286: /** ohair@286: * Adds features to the list if it's not already added. ohair@286: */ ohair@286: public void addAll(@NotNull Iterable list) { ohair@286: for (WebServiceFeature f : list) ohair@286: add(f); ohair@286: } ohair@286: ohair@286: /** ohair@286: * Sets MTOM feature, overriding any existing feature. This is necessary for compatibility ohair@286: * with the existing {@link SOAPBinding.setMTOMEnabled}. ohair@286: * @param b if MTOM will be enabled ohair@286: */ ohair@286: void setMTOMEnabled(boolean b) { ohair@286: wsfeatures.put(MTOMFeature.class, new MTOMFeature(b)); ohair@286: } ohair@286: ohair@286: public boolean equals(Object other) { ohair@286: if (!(other instanceof WebServiceFeatureList)) ohair@286: return false; ohair@286: ohair@286: WebServiceFeatureList w = (WebServiceFeatureList) other; ohair@286: return wsfeatures.equals(w.wsfeatures) && (parent == w.parent); ohair@286: } ohair@286: ohair@286: public String toString() { ohair@286: return wsfeatures.toString(); ohair@286: } ohair@286: ohair@286: /** ohair@286: * Merges the extra features that are not already set on binding. ohair@286: * i.e, if a feature is set already on binding through some other API ohair@286: * the corresponding wsdlFeature is not set. ohair@286: * ohair@286: * @param features Web Service features that need to be merged with already configured features. ohair@286: * @param reportConflicts If true, checks if the feature setting in WSDL (wsdl extension or ohair@286: * policy configuration) conflicts with feature setting in Deployed Service and ohair@286: * logs warning if there are any conflicts. ohair@286: */ ohair@286: public void mergeFeatures(@NotNull Iterable features, boolean reportConflicts) { ohair@286: for (WebServiceFeature wsdlFtr : features) { ohair@286: if (get(wsdlFtr.getClass()) == null) { ohair@286: add(wsdlFtr); ohair@286: } else if (reportConflicts) { ohair@286: if (isEnabled(wsdlFtr.getClass()) != wsdlFtr.isEnabled()) { ohair@286: LOGGER.warning(ModelerMessages.RUNTIME_MODELER_FEATURE_CONFLICT( ohair@286: get(wsdlFtr.getClass()), wsdlFtr)); ohair@286: } ohair@286: } ohair@286: } ohair@286: } ohair@286: ohair@286: public void mergeFeatures(WebServiceFeature[] features, boolean reportConflicts) { ohair@286: for (WebServiceFeature wsdlFtr : features) { ohair@286: if (get(wsdlFtr.getClass()) == null) { ohair@286: add(wsdlFtr); ohair@286: } else if (reportConflicts) { ohair@286: if (isEnabled(wsdlFtr.getClass()) != wsdlFtr.isEnabled()) { ohair@286: LOGGER.warning(ModelerMessages.RUNTIME_MODELER_FEATURE_CONFLICT( ohair@286: get(wsdlFtr.getClass()), wsdlFtr)); ohair@286: } ohair@286: } ohair@286: } ohair@286: } ohair@286: ohair@286: /** mkos@408: * Extracts features from {@link WSDLPort#getFeatures()}. Extra features ohair@286: * that are not already set on binding. i.e, if a feature is set already on mkos@408: * binding through some other API the corresponding wsdlFeature is not set. ohair@286: * ohair@286: * @param wsdlPort ohair@286: * WSDLPort model ohair@286: * @param honorWsdlRequired ohair@286: * If this is true add WSDL Feature only if wsd:Required=true In ohair@286: * SEI case, it should be false In Provider case, it should be ohair@286: * true ohair@286: * @param reportConflicts ohair@286: * If true, checks if the feature setting in WSDL (wsdl extension mkos@408: * or policy configuration) conflicts with feature setting in ohair@286: * Deployed Service and logs warning if there are any conflicts. ohair@286: */ ohair@286: public void mergeFeatures(@NotNull WSDLPort wsdlPort, ohair@286: boolean honorWsdlRequired, boolean reportConflicts) { ohair@286: if (honorWsdlRequired && !isEnabled(RespectBindingFeature.class)) ohair@286: return; ohair@286: if (!honorWsdlRequired) { ohair@286: addAll(wsdlPort.getFeatures()); ohair@286: return; ohair@286: } ohair@286: // Add only if isRequired returns true, when honorWsdlRequired is true ohair@286: for (WebServiceFeature wsdlFtr : wsdlPort.getFeatures()) { ohair@286: if (get(wsdlFtr.getClass()) == null) { ohair@286: try { ohair@286: // if it is a WSDL Extension , it will have required ohair@286: // attribute ohair@286: Method m = (wsdlFtr.getClass().getMethod("isRequired")); ohair@286: try { ohair@286: boolean required = (Boolean) m.invoke(wsdlFtr); ohair@286: if (required) ohair@286: add(wsdlFtr); ohair@286: } catch (IllegalAccessException e) { ohair@286: throw new WebServiceException(e); ohair@286: } catch (InvocationTargetException e) { ohair@286: throw new WebServiceException(e); ohair@286: } ohair@286: } catch (NoSuchMethodException e) { ohair@286: // this wsdlFtr is not an WSDL extension, just add it ohair@286: add(wsdlFtr); ohair@286: } ohair@286: } else if (reportConflicts) { ohair@286: if (isEnabled(wsdlFtr.getClass()) != wsdlFtr.isEnabled()) { ohair@286: LOGGER.warning(ModelerMessages.RUNTIME_MODELER_FEATURE_CONFLICT( ohair@286: get(wsdlFtr.getClass()), wsdlFtr)); ohair@286: } ohair@286: ohair@286: } ohair@286: } ohair@286: } ohair@286: ohair@286: /** ohair@286: * Set the parent features. Basically the parent feature list will be ohair@286: * overriden by this feature list. ohair@286: */ ohair@286: public void setParentFeaturedObject(@NotNull WSDLFeaturedObject parent) { ohair@286: this.parent = parent; ohair@286: } ohair@286: ohair@286: public static @Nullable F getFeature(@NotNull WebServiceFeature[] features, ohair@286: @NotNull Class featureType) { ohair@286: for (WebServiceFeature f : features) { ohair@286: if (f.getClass() == featureType) ohair@286: return (F) f; ohair@286: } ohair@286: return null; ohair@286: } ohair@286: ohair@286: /** ohair@286: * A Union of this WebServiceFeatureList and the parent. ohair@286: */ ohair@286: private final class MergedFeatures implements Iterator { ohair@286: private final Stack features = new Stack(); ohair@286: ohair@286: public MergedFeatures(@NotNull WSFeatureList parent) { ohair@286: ohair@286: for (WebServiceFeature f : wsfeatures.values()) { ohair@286: features.push(f); ohair@286: } ohair@286: ohair@286: for (WebServiceFeature f : parent) { ohair@286: if (!wsfeatures.containsKey(f.getClass())) { ohair@286: features.push(f); ohair@286: } ohair@286: } ohair@286: } ohair@286: ohair@286: public boolean hasNext() { ohair@286: return !features.empty(); ohair@286: } ohair@286: ohair@286: public WebServiceFeature next() { ohair@286: if (!features.empty()) { ohair@286: return features.pop(); ohair@286: } ohair@286: throw new NoSuchElementException(); ohair@286: } ohair@286: ohair@286: public void remove() { ohair@286: if (!features.empty()) { ohair@286: features.pop(); ohair@286: } ohair@286: } ohair@286: ohair@286: public WebServiceFeature[] toArray() { ohair@286: return features.toArray(new WebServiceFeature[] {}); ohair@286: } ohair@286: } ohair@286: ohair@286: private static final Logger LOGGER = Logger.getLogger(WebServiceFeatureList.class.getName()); ohair@286: ohair@286: @Override ohair@286: public Set, WebServiceFeature>> entrySet() { ohair@286: return wsfeatures.entrySet(); ohair@286: } ohair@286: ohair@286: @Override ohair@286: public WebServiceFeature put(Class key, WebServiceFeature value) { ohair@286: return wsfeatures.put(key, value); ohair@286: } ohair@286: ohair@286: static public SOAPVersion getSoapVersion(WSFeatureList features) { alanb@368: { alanb@368: EnvelopeStyleFeature env = features.get(EnvelopeStyleFeature.class); alanb@368: if (env != null) { alanb@368: return SOAPVersion.from(env); alanb@368: } alanb@368: } alanb@368: com.oracle.webservices.internal.api.EnvelopeStyleFeature env = features.get(com.oracle.webservices.internal.api.EnvelopeStyleFeature.class); ohair@286: return env != null ? SOAPVersion.from(env) : null; ohair@286: } ohair@286: ohair@286: static public boolean isFeatureEnabled(Class type, WebServiceFeature[] features) { ohair@286: WebServiceFeature ftr = getFeature(features, type); ohair@286: return ftr != null && ftr.isEnabled(); ohair@286: } ohair@286: ohair@286: static public WebServiceFeature[] toFeatureArray(WSBinding binding) { ohair@286: //TODO scchen convert BindingID to WebServiceFeature[] ohair@286: if(!binding.isFeatureEnabled(EnvelopeStyleFeature.class)) { ohair@286: WebServiceFeature[] f = { binding.getSOAPVersion().toFeature() }; ohair@286: binding.getFeatures().mergeFeatures(f, false); ohair@286: } ohair@286: return binding.getFeatures().toArray(); ohair@286: } ohair@286: }