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,534 @@
/*
* 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.model;
import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.bind.api.Bridge;
import com.sun.xml.internal.bind.api.JAXBRIContext;
import com.sun.xml.internal.bind.api.TypeReference;
import com.sun.xml.internal.ws.api.BindingID;
import com.sun.xml.internal.ws.api.WSBinding;
import com.sun.xml.internal.ws.api.databinding.Databinding;
import com.sun.xml.internal.ws.api.model.JavaMethod;
import com.sun.xml.internal.ws.api.model.ParameterBinding;
import com.sun.xml.internal.ws.api.model.SEIModel;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLModel;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPart;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundPortType;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation;
import com.sun.xml.internal.ws.encoding.soap.streaming.SOAPNamespaceConstants;
import com.sun.xml.internal.ws.resources.ModelerMessages;
import com.sun.xml.internal.ws.spi.db.BindingContext;
import com.sun.xml.internal.ws.spi.db.BindingContextFactory;
import com.sun.xml.internal.ws.spi.db.BindingInfo;
import com.sun.xml.internal.ws.spi.db.XMLBridge;
import com.sun.xml.internal.ws.spi.db.TypeInfo;
import com.sun.xml.internal.ws.util.Pool;
import com.sun.xml.internal.ws.developer.UsesJAXBContextFeature;
import com.sun.xml.internal.ws.developer.JAXBContextFactory;
import com.sun.xml.internal.ws.binding.WebServiceFeatureList;
import javax.jws.WebParam.Mode;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.namespace.QName;
import javax.xml.ws.WebServiceException;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* model of the web service. Used by the runtime marshall/unmarshall
* web service invocations
*
* @author JAXWS Development Team
*/
public abstract class AbstractSEIModelImpl implements SEIModel {
protected AbstractSEIModelImpl(WebServiceFeatureList features) {
this.features = features;
databindingInfo = new BindingInfo();
databindingInfo.setSEIModel(this);
}
void postProcess() {
// should be called only once.
if (jaxbContext != null) {
return;
}
populateMaps();
createJAXBContext();
}
/**
* Link {@link SEIModel} to {@link WSDLModel}.
* Merge it with {@link #postProcess()}.
*/
public void freeze(WSDLPort port) {
this.port = port;
for (JavaMethodImpl m : javaMethods) {
m.freeze(port);
putOp(m.getOperationQName(),m);
}
if (databinding != null) {
((com.sun.xml.internal.ws.db.DatabindingImpl)databinding).freeze(port);
}
}
/**
* Populate methodToJM and nameToJM maps.
*/
abstract protected void populateMaps();
@Override
public Pool.Marshaller getMarshallerPool() {
return marshallers;
}
/**
* @return the <code>JAXBRIContext</code>
* @deprecated
*/
@Override
public JAXBContext getJAXBContext() {
JAXBContext jc = bindingContext.getJAXBContext();
if (jc != null) {
return jc;
}
return jaxbContext;
}
public BindingContext getBindingContext() {
return bindingContext;
}
/**
* @return the known namespaces from JAXBRIContext
*/
public List<String> getKnownNamespaceURIs() {
return knownNamespaceURIs;
}
/**
* @return the <code>Bridge</code> for the <code>type</code>
* @deprecated use getBond
*/
public final Bridge getBridge(TypeReference type) {
Bridge b = bridgeMap.get(type);
assert b!=null; // we should have created Bridge for all TypeReferences known to this model
return b;
}
public final XMLBridge getXMLBridge(TypeInfo type) {
XMLBridge b = xmlBridgeMap.get(type);
assert b!=null; // we should have created Bridge for all TypeReferences known to this model
return b;
}
private void /*JAXBRIContext*/ createJAXBContext() {
final List<TypeInfo> types = getAllTypeInfos();
final List<Class> cls = new ArrayList<Class>(types.size() + additionalClasses.size());
cls.addAll(additionalClasses);
for (TypeInfo type : types) {
cls.add((Class) type.type);
}
try {
//jaxbContext = JAXBRIContext.newInstance(cls, types, targetNamespace, false);
// Need to avoid doPriv block once JAXB is fixed. Afterwards, use the above
bindingContext = AccessController.doPrivileged(new PrivilegedExceptionAction<BindingContext>() {
public BindingContext run() throws Exception {
if(LOGGER.isLoggable(Level.FINEST)) {
LOGGER.log(Level.FINEST, "Creating JAXBContext with classes={0} and types={1}", new Object[]{cls, types});
}
UsesJAXBContextFeature f = features.get(UsesJAXBContextFeature.class);
com.oracle.webservices.internal.api.databinding.DatabindingModeFeature dmf =
features.get(com.oracle.webservices.internal.api.databinding.DatabindingModeFeature.class);
JAXBContextFactory factory = f!=null ? f.getFactory() : null;
if(factory==null) factory=JAXBContextFactory.DEFAULT;
// return factory.createJAXBContext(AbstractSEIModelImpl.this,cls,types);
databindingInfo.properties().put(JAXBContextFactory.class.getName(), factory);
if (dmf != null) {
if (LOGGER.isLoggable(Level.FINE))
LOGGER.log(Level.FINE, "DatabindingModeFeature in SEI specifies mode: {0}", dmf.getMode());
databindingInfo.setDatabindingMode(dmf
.getMode());
}
if (f!=null) databindingInfo.setDatabindingMode(BindingContextFactory.DefaultDatabindingMode);
databindingInfo.setClassLoader(classLoader);
databindingInfo.contentClasses().addAll(cls);
databindingInfo.typeInfos().addAll(types);
databindingInfo.properties().put("c14nSupport", Boolean.FALSE);
databindingInfo.setDefaultNamespace(AbstractSEIModelImpl.this.getDefaultSchemaNamespace());
BindingContext bc = BindingContextFactory.create(databindingInfo);
if (LOGGER.isLoggable(Level.FINE))
LOGGER.log(Level.FINE,
"Created binding context: "
+ bc.getClass().getName());
// System.out.println("---------------------- databinding " + bc);
return bc;
}
});
// createBridgeMap(types);
createBondMap(types);
} catch (PrivilegedActionException e) {
throw new WebServiceException(ModelerMessages.UNABLE_TO_CREATE_JAXB_CONTEXT(), e);
}
knownNamespaceURIs = new ArrayList<String>();
for (String namespace : bindingContext.getKnownNamespaceURIs()) {
if (namespace.length() > 0) {
if (!namespace.equals(SOAPNamespaceConstants.XSD) && !namespace.equals(SOAPNamespaceConstants.XMLNS))
knownNamespaceURIs.add(namespace);
}
}
marshallers = new Pool.Marshaller(jaxbContext);
//return getJAXBContext();
}
/**
* @return returns non-null list of TypeReference
*/
private List<TypeInfo> getAllTypeInfos() {
List<TypeInfo> types = new ArrayList<TypeInfo>();
Collection<JavaMethodImpl> methods = methodToJM.values();
for (JavaMethodImpl m : methods) {
m.fillTypes(types);
}
return types;
}
private void createBridgeMap(List<TypeReference> types) {
for (TypeReference type : types) {
Bridge bridge = jaxbContext.createBridge(type);
bridgeMap.put(type, bridge);
}
}
private void createBondMap(List<TypeInfo> types) {
for (TypeInfo type : types) {
XMLBridge binding = bindingContext.createBridge(type);
xmlBridgeMap.put(type, binding);
}
}
/**
* @return true if <code>name</code> is the name
* of a known fault name for the <code>Method method</code>
*/
public boolean isKnownFault(QName name, Method method) {
JavaMethodImpl m = getJavaMethod(method);
for (CheckedExceptionImpl ce : m.getCheckedExceptions()) {
if (ce.getDetailType().tagName.equals(name))
return true;
}
return false;
}
/**
* @return true if <code>ex</code> is a Checked Exception
* for <code>Method m</code>
*/
public boolean isCheckedException(Method m, Class ex) {
JavaMethodImpl jm = getJavaMethod(m);
for (CheckedExceptionImpl ce : jm.getCheckedExceptions()) {
if (ce.getExceptionClass().equals(ex))
return true;
}
return false;
}
/**
* @return the <code>JavaMethod</code> representing the <code>method</code>
*/
public JavaMethodImpl getJavaMethod(Method method) {
return methodToJM.get(method);
}
/**
* @return the <code>JavaMethod</code> associated with the
* operation named name
*/
public JavaMethodImpl getJavaMethod(QName name) {
return nameToJM.get(name);
}
public JavaMethod getJavaMethodForWsdlOperation(QName operationName) {
return wsdlOpToJM.get(operationName);
}
/**
* @return the <code>QName</code> associated with the
* JavaMethod jm.
*
* @deprecated
* Use {@link JavaMethod#getOperationName()}.
*/
public QName getQNameForJM(JavaMethodImpl jm) {
for (QName key : nameToJM.keySet()) {
JavaMethodImpl jmethod = nameToJM.get(key);
if (jmethod.getOperationName().equals(jm.getOperationName())){
return key;
}
}
return null;
}
/**
* @return a <code>Collection</code> of <code>JavaMethods</code>
* associated with this <code>RuntimeModel</code>
*/
public final Collection<JavaMethodImpl> getJavaMethods() {
return Collections.unmodifiableList(javaMethods);
}
void addJavaMethod(JavaMethodImpl jm) {
if (jm != null)
javaMethods.add(jm);
}
/**
* Applies binding related information to the RpcLitPayload. The payload map is populated correctly
* @return
* Returns attachment parameters if/any.
*/
private List<ParameterImpl> applyRpcLitParamBinding(JavaMethodImpl method, WrapperParameter wrapperParameter, WSDLBoundPortType boundPortType, Mode mode) {
QName opName = new QName(boundPortType.getPortTypeName().getNamespaceURI(), method.getOperationName());
WSDLBoundOperation bo = boundPortType.get(opName);
Map<Integer, ParameterImpl> bodyParams = new HashMap<Integer, ParameterImpl>();
List<ParameterImpl> unboundParams = new ArrayList<ParameterImpl>();
List<ParameterImpl> attachParams = new ArrayList<ParameterImpl>();
for(ParameterImpl param : wrapperParameter.wrapperChildren){
String partName = param.getPartName();
if(partName == null)
continue;
ParameterBinding paramBinding = boundPortType.getBinding(opName,
partName, mode);
if(paramBinding != null){
if(mode == Mode.IN)
param.setInBinding(paramBinding);
else if(mode == Mode.OUT || mode == Mode.INOUT)
param.setOutBinding(paramBinding);
if(paramBinding.isUnbound()){
unboundParams.add(param);
} else if(paramBinding.isAttachment()){
attachParams.add(param);
}else if(paramBinding.isBody()){
if(bo != null){
WSDLPart p = bo.getPart(param.getPartName(), mode);
if(p != null)
bodyParams.put(p.getIndex(), param);
else
bodyParams.put(bodyParams.size(), param);
}else{
bodyParams.put(bodyParams.size(), param);
}
}
}
}
wrapperParameter.clear();
for(int i = 0; i < bodyParams.size();i++){
ParameterImpl p = bodyParams.get(i);
wrapperParameter.addWrapperChild(p);
}
//add unbounded parts
for(ParameterImpl p:unboundParams){
wrapperParameter.addWrapperChild(p);
}
return attachParams;
}
void put(QName name, JavaMethodImpl jm) {
nameToJM.put(name, jm);
}
void put(Method method, JavaMethodImpl jm) {
methodToJM.put(method, jm);
}
void putOp(QName opName, JavaMethodImpl jm) {
wsdlOpToJM.put(opName, jm);
}
public String getWSDLLocation() {
return wsdlLocation;
}
void setWSDLLocation(String location) {
wsdlLocation = location;
}
public QName getServiceQName() {
return serviceName;
}
public WSDLPort getPort() {
return port;
}
public QName getPortName() {
return portName;
}
public QName getPortTypeName() {
return portTypeName;
}
void setServiceQName(QName name) {
serviceName = name;
}
void setPortName(QName name) {
portName = name;
}
void setPortTypeName(QName name) {
portTypeName = name;
}
/**
* This is the targetNamespace for the WSDL containing the PortType
* definition
*/
void setTargetNamespace(String namespace) {
targetNamespace = namespace;
}
/**
* This is the targetNamespace for the WSDL containing the PortType
* definition
*/
public String getTargetNamespace() {
return targetNamespace;
}
String getDefaultSchemaNamespace() {
String defaultNamespace = getTargetNamespace();
if (defaultSchemaNamespaceSuffix == null) return defaultNamespace;
if (!defaultNamespace.endsWith("/")) {
defaultNamespace += "/";
}
return (defaultNamespace + defaultSchemaNamespaceSuffix);
}
@NotNull
public QName getBoundPortTypeName() {
assert portName != null;
return new QName(portName.getNamespaceURI(), portName.getLocalPart()+"Binding");
}
/**
* Adds additional classes obtained from {@link XmlSeeAlso} annotation. In starting
* from wsdl case these classes would most likely be JAXB ObjectFactory that references other classes.
*/
public void addAdditionalClasses(Class... additionalClasses) {
for(Class cls : additionalClasses)
this.additionalClasses.add(cls);
}
public Databinding getDatabinding() {
return databinding;
}
public void setDatabinding(Databinding wsRuntime) {
this.databinding = wsRuntime;
}
public WSBinding getWSBinding() {
return wsBinding;
}
public Class getContractClass() {
return contractClass;
}
public Class getEndpointClass() {
return endpointClass;
}
private List<Class> additionalClasses = new ArrayList<Class>();
private Pool.Marshaller marshallers;
/**
* @deprecated
*/
protected JAXBRIContext jaxbContext;
protected BindingContext bindingContext;
private String wsdlLocation;
private QName serviceName;
private QName portName;
private QName portTypeName;
private Map<Method,JavaMethodImpl> methodToJM = new HashMap<Method, JavaMethodImpl>();
/**
* Payload QName to the method that handles it.
*/
private Map<QName,JavaMethodImpl> nameToJM = new HashMap<QName, JavaMethodImpl>();
/**
* Wsdl Operation QName to the method that handles it.
*/
private Map<QName, JavaMethodImpl> wsdlOpToJM = new HashMap<QName, JavaMethodImpl>();
private List<JavaMethodImpl> javaMethods = new ArrayList<JavaMethodImpl>();
private final Map<TypeReference, Bridge> bridgeMap = new HashMap<TypeReference, Bridge>();
private final Map<TypeInfo, XMLBridge> xmlBridgeMap = new HashMap<TypeInfo, XMLBridge>();
protected final QName emptyBodyName = new QName("");
private String targetNamespace = "";
private List<String> knownNamespaceURIs = null;
private WSDLPort port;
private final WebServiceFeatureList features;
private Databinding databinding;
BindingID bindingId;
protected Class contractClass;
protected Class endpointClass;
protected ClassLoader classLoader = null;
protected WSBinding wsBinding;
protected BindingInfo databindingInfo;
protected String defaultSchemaNamespaceSuffix;
private static final Logger LOGGER = Logger.getLogger(AbstractSEIModelImpl.class.getName());
}

View File

@@ -0,0 +1,468 @@
/*
* 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.model;
import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.bind.v2.model.annotation.AnnotationReader;
import com.sun.xml.internal.bind.v2.model.nav.Navigator;
import com.sun.xml.internal.ws.spi.db.BindingHelper;
import com.sun.xml.internal.ws.util.StringUtils;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.ws.WebServiceException;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.*;
import java.util.logging.Logger;
/**
* Finds request/response wrapper and exception bean memebers.
*
* <p>
* It uses JAXB's {@link AnnotationReader}, {@link Navigator} so that
* tools can use this with annotation processing, and the runtime can use this with
* reflection.
*
* @author Jitendra Kotamraju
*/
public abstract class AbstractWrapperBeanGenerator<T,C,M,A extends Comparable> {
private static final Logger LOGGER = Logger.getLogger(AbstractWrapperBeanGenerator.class.getName());
private static final String RETURN = "return";
private static final String EMTPY_NAMESPACE_ID = "";
private static final Class[] jaxbAnns = new Class[] {
XmlAttachmentRef.class, XmlMimeType.class, XmlJavaTypeAdapter.class,
XmlList.class, XmlElement.class
};
private static final Set<String> skipProperties = new HashSet<String>();
static{
skipProperties.add("getCause");
skipProperties.add("getLocalizedMessage");
skipProperties.add("getClass");
skipProperties.add("getStackTrace");
skipProperties.add("getSuppressed"); // JDK 7 adds this
}
private final AnnotationReader<T,C,?,M> annReader;
private final Navigator<T,C,?,M> nav;
private final BeanMemberFactory<T,A> factory;
protected AbstractWrapperBeanGenerator(AnnotationReader<T,C,?,M> annReader,
Navigator<T,C,?,M> nav, BeanMemberFactory<T,A> factory) {
this.annReader = annReader;
this.nav = nav;
this.factory = factory;
}
public static interface BeanMemberFactory<T,A> {
A createWrapperBeanMember(T paramType, String paramName, List<Annotation> jaxbAnnotations);
}
// Collects the JAXB annotations on a method
private List<Annotation> collectJAXBAnnotations(M method) {
List<Annotation> jaxbAnnotation = new ArrayList<Annotation>();
for(Class jaxbClass : jaxbAnns) {
Annotation ann = annReader.getMethodAnnotation(jaxbClass, method, null);
if (ann != null) {
jaxbAnnotation.add(ann);
}
}
return jaxbAnnotation;
}
// Collects the JAXB annotations on a parameter
private List<Annotation> collectJAXBAnnotations(M method, int paramIndex) {
List<Annotation> jaxbAnnotation = new ArrayList<Annotation>();
for(Class jaxbClass : jaxbAnns) {
Annotation ann = annReader.getMethodParameterAnnotation(jaxbClass, method, paramIndex, null);
if (ann != null) {
jaxbAnnotation.add(ann);
}
}
return jaxbAnnotation;
}
protected abstract T getSafeType(T type);
/**
* Returns Holder's value type.
*
* @return null if it not a Holder, otherwise return Holder's value type
*/
protected abstract T getHolderValueType(T type);
protected abstract boolean isVoidType(T type);
/**
* Computes request bean members for a method. Collects all IN and INOUT
* parameters as request bean fields. In this process, if a parameter
* has any known JAXB annotations they are collected as well.
* Special processing for @XmlElement annotation is done.
*
* @param method SEI method for which request bean members are computed
* @return List of request bean members
*/
public List<A> collectRequestBeanMembers(M method) {
List<A> requestMembers = new ArrayList<A>();
int paramIndex = -1;
for (T param : nav.getMethodParameters(method)) {
paramIndex++;
WebParam webParam = annReader.getMethodParameterAnnotation(WebParam.class, method, paramIndex, null);
if (webParam != null && (webParam.header() || webParam.mode().equals(WebParam.Mode.OUT))) {
continue;
}
T holderType = getHolderValueType(param);
// if (holderType != null && webParam != null && webParam.mode().equals(WebParam.Mode.IN)) {
// // Should we flag an error - holder cannot be IN part ??
// continue;
// }
T paramType = (holderType != null) ? holderType : getSafeType(param);
String paramName = (webParam != null && webParam.name().length() > 0)
? webParam.name() : "arg"+paramIndex;
String paramNamespace = (webParam != null && webParam.targetNamespace().length() > 0)
? webParam.targetNamespace() : EMTPY_NAMESPACE_ID;
// Collect JAXB annotations on a parameter
List<Annotation> jaxbAnnotation = collectJAXBAnnotations(method, paramIndex);
// If a parameter contains @XmlElement, process it.
processXmlElement(jaxbAnnotation, paramName, paramNamespace, paramType);
A member = factory.createWrapperBeanMember(paramType,
getPropertyName(paramName), jaxbAnnotation);
requestMembers.add(member);
}
return requestMembers;
}
/**
* Computes response bean members for a method. Collects all OUT and INOUT
* parameters as response bean fields. In this process, if a parameter
* has any known JAXB annotations they are collected as well.
* Special processing for @XmlElement annotation is done.
*
* @param method SEI method for which response bean members are computed
* @return List of response bean members
*/
public List<A> collectResponseBeanMembers(M method) {
List<A> responseMembers = new ArrayList<A>();
// return that need to be part response wrapper bean
String responseElementName = RETURN;
String responseNamespace = EMTPY_NAMESPACE_ID;
boolean isResultHeader = false;
WebResult webResult = annReader.getMethodAnnotation(WebResult.class, method ,null);
if (webResult != null) {
if (webResult.name().length() > 0) {
responseElementName = webResult.name();
}
if (webResult.targetNamespace().length() > 0) {
responseNamespace = webResult.targetNamespace();
}
isResultHeader = webResult.header();
}
T returnType = getSafeType(nav.getReturnType(method));
if (!isVoidType(returnType) && !isResultHeader) {
List<Annotation> jaxbRespAnnotations = collectJAXBAnnotations(method);
processXmlElement(jaxbRespAnnotations, responseElementName, responseNamespace, returnType);
responseMembers.add(factory.createWrapperBeanMember(returnType, getPropertyName(responseElementName), jaxbRespAnnotations));
}
// Now parameters that need to be part response wrapper bean
int paramIndex = -1;
for (T param : nav.getMethodParameters(method)) {
paramIndex++;
T paramType = getHolderValueType(param);
WebParam webParam = annReader.getMethodParameterAnnotation(WebParam.class, method, paramIndex, null);
if (paramType == null || (webParam != null && webParam.header())) {
continue; // not a holder or a header - so don't add it
}
String paramName = (webParam != null && webParam.name().length() > 0)
? webParam.name() : "arg"+paramIndex;
String paramNamespace = (webParam != null && webParam.targetNamespace().length() > 0)
? webParam.targetNamespace() : EMTPY_NAMESPACE_ID;
List<Annotation> jaxbAnnotation = collectJAXBAnnotations(method, paramIndex);
processXmlElement(jaxbAnnotation, paramName, paramNamespace, paramType);
A member = factory.createWrapperBeanMember(paramType,
getPropertyName(paramName), jaxbAnnotation);
responseMembers.add(member);
}
return responseMembers;
}
private void processXmlElement(List<Annotation> jaxb, String elemName, String elemNS, T type) {
XmlElement elemAnn = null;
for (Annotation a : jaxb) {
if (a.annotationType() == XmlElement.class) {
elemAnn = (XmlElement) a;
jaxb.remove(a);
break;
}
}
String name = (elemAnn != null && !elemAnn.name().equals("##default"))
? elemAnn.name() : elemName;
String ns = (elemAnn != null && !elemAnn.namespace().equals("##default"))
? elemAnn.namespace() : elemNS;
boolean nillable = nav.isArray(type)
|| (elemAnn != null && elemAnn.nillable());
boolean required = elemAnn != null && elemAnn.required();
XmlElementHandler handler = new XmlElementHandler(name, ns, nillable, required);
XmlElement elem = (XmlElement) Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class<?>[]{XmlElement.class}, handler);
jaxb.add(elem);
}
private static class XmlElementHandler implements InvocationHandler {
private String name;
private String namespace;
private boolean nillable;
private boolean required;
XmlElementHandler(String name, String namespace, boolean nillable,
boolean required) {
this.name = name;
this.namespace = namespace;
this.nillable = nillable;
this.required = required;
}
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
String methodName = method.getName();
if (methodName.equals("name")) {
return name;
} else if (methodName.equals("namespace")) {
return namespace;
} else if (methodName.equals("nillable")) {
return nillable;
} else if (methodName.equals("required")) {
return required;
} else {
throw new WebServiceException("Not handling "+methodName);
}
}
}
/**
* Computes and sorts exception bean members for a given exception as per
* the 3.7 section of the spec. It takes all getter properties in the
* exception and its superclasses(except getCause, getLocalizedMessage,
* getStackTrace, getClass). The returned collection is sorted based
* on the property names.
*
* <p>
* But if the exception has @XmlType its values are honored. Only the
* propOrder properties are considered. The returned collection is sorted
* as per the given propOrder.
*
* @param exception
* @return list of properties in the correct order for an exception bean
*/
public Collection<A> collectExceptionBeanMembers(C exception) {
return collectExceptionBeanMembers(exception, true);
}
/**
* Computes and sorts exception bean members for a given exception as per
* the 3.7 section of the spec. It takes all getter properties in the
* exception and its superclasses(except getCause, getLocalizedMessage,
* getStackTrace, getClass). The returned collection is sorted based
* on the property names.
*
* <p>
* But if the exception has @XmlType its values are honored. Only the
* propOrder properties are considered. The returned collection is sorted
* as per the given propOrder.
*
* @param exception
* @param decapitalize if true, all the property names are decapitalized
*
* @return list of properties in the correct order for an exception bean
*/
public Collection<A> collectExceptionBeanMembers(C exception, boolean decapitalize ) {
TreeMap<String, A> fields = new TreeMap<String, A>();
getExceptionProperties(exception, fields, decapitalize);
// Consider only the @XmlType(propOrder) properties
XmlType xmlType = annReader.getClassAnnotation(XmlType.class, exception, null);
if (xmlType != null) {
String[] propOrder = xmlType.propOrder();
// If not the default order of properties, use that propOrder
if (propOrder.length > 0 && propOrder[0].length() != 0) {
List<A> list = new ArrayList<A>();
for(String prop : propOrder) {
A a = fields.get(prop);
if (a != null) {
list.add(a);
} else {
throw new WebServiceException("Exception "+exception+
" has @XmlType and its propOrder contains unknown property "+prop);
}
}
return list;
}
}
return fields.values();
}
private void getExceptionProperties(C exception, TreeMap<String, A> fields, boolean decapitalize) {
C sc = nav.getSuperClass(exception);
if (sc != null) {
getExceptionProperties(sc, fields, decapitalize);
}
Collection<? extends M> methods = nav.getDeclaredMethods(exception);
for (M method : methods) {
// 2.1.x is doing the following: no final static, transient, non-public
// transient cannot used as modifier for method, so not doing it now
if (!nav.isPublicMethod(method)
|| (nav.isStaticMethod(method) && nav.isFinalMethod(method))) {
continue;
}
if (!nav.isPublicMethod(method)) {
continue;
}
String name = nav.getMethodName(method);
if (!(name.startsWith("get") || name.startsWith("is")) || skipProperties.contains(name) ||
name.equals("get") || name.equals("is")) {
// Don't bother with invalid propertyNames.
continue;
}
T returnType = getSafeType(nav.getReturnType(method));
if (nav.getMethodParameters(method).length == 0) {
String fieldName = name.startsWith("get") ? name.substring(3) : name.substring(2);
if (decapitalize) fieldName = StringUtils.decapitalize(fieldName);
fields.put(fieldName, factory.createWrapperBeanMember(returnType, fieldName, Collections.<Annotation>emptyList()));
}
}
}
/**
* Gets the property name by mangling using JAX-WS rules
* @param name to be mangled
* @return property name
*/
private static String getPropertyName(String name) {
String propertyName = BindingHelper.mangleNameToVariableName(name);
//We wont have to do this if JAXBRIContext.mangleNameToVariableName() takes
//care of mangling java identifiers
return getJavaReservedVarialbeName(propertyName);
}
//TODO MOVE Names.java to runtime (instead of doing the following)
/*
* See if its a java keyword name, if so then mangle the name
*/
private static @NotNull String getJavaReservedVarialbeName(@NotNull String name) {
String reservedName = reservedWords.get(name);
return reservedName == null ? name : reservedName;
}
private static final Map<String, String> reservedWords;
static {
reservedWords = new HashMap<String, String>();
reservedWords.put("abstract", "_abstract");
reservedWords.put("assert", "_assert");
reservedWords.put("boolean", "_boolean");
reservedWords.put("break", "_break");
reservedWords.put("byte", "_byte");
reservedWords.put("case", "_case");
reservedWords.put("catch", "_catch");
reservedWords.put("char", "_char");
reservedWords.put("class", "_class");
reservedWords.put("const", "_const");
reservedWords.put("continue", "_continue");
reservedWords.put("default", "_default");
reservedWords.put("do", "_do");
reservedWords.put("double", "_double");
reservedWords.put("else", "_else");
reservedWords.put("extends", "_extends");
reservedWords.put("false", "_false");
reservedWords.put("final", "_final");
reservedWords.put("finally", "_finally");
reservedWords.put("float", "_float");
reservedWords.put("for", "_for");
reservedWords.put("goto", "_goto");
reservedWords.put("if", "_if");
reservedWords.put("implements", "_implements");
reservedWords.put("import", "_import");
reservedWords.put("instanceof", "_instanceof");
reservedWords.put("int", "_int");
reservedWords.put("interface", "_interface");
reservedWords.put("long", "_long");
reservedWords.put("native", "_native");
reservedWords.put("new", "_new");
reservedWords.put("null", "_null");
reservedWords.put("package", "_package");
reservedWords.put("private", "_private");
reservedWords.put("protected", "_protected");
reservedWords.put("public", "_public");
reservedWords.put("return", "_return");
reservedWords.put("short", "_short");
reservedWords.put("static", "_static");
reservedWords.put("strictfp", "_strictfp");
reservedWords.put("super", "_super");
reservedWords.put("switch", "_switch");
reservedWords.put("synchronized", "_synchronized");
reservedWords.put("this", "_this");
reservedWords.put("throw", "_throw");
reservedWords.put("throws", "_throws");
reservedWords.put("transient", "_transient");
reservedWords.put("true", "_true");
reservedWords.put("try", "_try");
reservedWords.put("void", "_void");
reservedWords.put("volatile", "_volatile");
reservedWords.put("while", "_while");
reservedWords.put("enum", "_enum");
}
}

View File

@@ -0,0 +1,131 @@
/*
* 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.model;
import com.sun.xml.internal.bind.api.Bridge;
import com.sun.xml.internal.ws.api.model.CheckedException;
import com.sun.xml.internal.ws.api.model.ExceptionType;
import com.sun.xml.internal.ws.api.model.JavaMethod;
import com.sun.xml.internal.ws.addressing.WsaActionUtil;
import com.sun.xml.internal.ws.spi.db.XMLBridge;
import com.sun.xml.internal.ws.spi.db.TypeInfo;
/**
* CheckedException class. Holds the exception class - class that has public
* constructor
*
* <code>public WrapperException()String message, FaultBean){}</code>
*
* and method
*
* <code>public FaultBean getFaultInfo();</code>
*
* @author Vivek Pandey
*/
public final class CheckedExceptionImpl implements CheckedException {
private final Class exceptionClass;
private final TypeInfo detail;
private final ExceptionType exceptionType;
private final JavaMethodImpl javaMethod;
private String messageName;
private String faultAction = "";
/**
* @param jm {@link JavaMethodImpl} that throws this exception
* @param exceptionClass
* Userdefined or WSDL exception class that extends
* java.lang.Exception.
* @param detail
* detail or exception bean's TypeReference
* @param exceptionType
* either ExceptionType.UserDefined or
*/
public CheckedExceptionImpl(JavaMethodImpl jm, Class exceptionClass, TypeInfo detail, ExceptionType exceptionType) {
this.detail = detail;
this.exceptionType = exceptionType;
this.exceptionClass = exceptionClass;
this.javaMethod = jm;
}
public AbstractSEIModelImpl getOwner() {
return javaMethod.owner;
}
public JavaMethod getParent() {
return javaMethod;
}
/**
* @return the <code>Class</clode> for this object
*
*/
public Class getExceptionClass() {
return exceptionClass;
}
public Class getDetailBean() {
return (Class) detail.type;
}
/** @deprecated */
public Bridge getBridge() {
//TODO return getOwner().getBridge(detail);
return null;
}
public XMLBridge getBond() {
return getOwner().getXMLBridge(detail);
}
public TypeInfo getDetailType() {
return detail;
}
public ExceptionType getExceptionType() {
return exceptionType;
}
public String getMessageName() {
return messageName;
}
public void setMessageName(String messageName) {
this.messageName = messageName;
}
public String getFaultAction() {
return faultAction;
}
public void setFaultAction(String faultAction) {
this.faultAction = faultAction;
}
public String getDefaultFaultAction() {
return WsaActionUtil.getDefaultFaultAction(javaMethod,this);
}
}

View File

@@ -0,0 +1,549 @@
/*
* 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.model;
import com.oracle.xmlns.internal.webservices.jaxws_databinding.JavaMethod;
import com.oracle.xmlns.internal.webservices.jaxws_databinding.JavaParam;
import com.oracle.xmlns.internal.webservices.jaxws_databinding.JavaWsdlMappingType;
import com.oracle.xmlns.internal.webservices.jaxws_databinding.ObjectFactory;
import com.sun.xml.internal.bind.api.JAXBRIContext;
import com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil;
import com.sun.xml.internal.ws.util.xml.XmlUtil;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.util.JAXBResult;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import java.io.*;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.*;
import static com.oracle.xmlns.internal.webservices.jaxws_databinding.ExistingAnnotationsType.MERGE;
/**
* Metadata Reader able to read from either class annotations or external metadata files or combine both,
* depending on configuration provided in xml file itself.
*
* @author shih-chang.chen@oracle.com, miroslav.kos@oracle.com
*/
public class ExternalMetadataReader extends ReflectAnnotationReader {
private static final String NAMESPACE_WEBLOGIC_WSEE_DATABINDING = "http://xmlns.oracle.com/weblogic/weblogic-wsee-databinding";
private static final String NAMESPACE_JAXWS_RI_EXTERNAL_METADATA = "http://xmlns.oracle.com/webservices/jaxws-databinding";
/**
* map of readers for defined java types
*/
private Map<String, JavaWsdlMappingType> readers = new HashMap<String, JavaWsdlMappingType>();
public ExternalMetadataReader(Collection<File> files, Collection<String> resourcePaths, ClassLoader classLoader,
boolean xsdValidation, boolean disableXmlSecurity) {
if (files != null) {
for (File file : files) {
try {
String namespace = Util.documentRootNamespace(newSource(file), disableXmlSecurity);
JavaWsdlMappingType externalMapping = parseMetadata(xsdValidation, newSource(file), namespace, disableXmlSecurity);
readers.put(externalMapping.getJavaTypeName(), externalMapping);
} catch (Exception e) {
throw new RuntimeModelerException("runtime.modeler.external.metadata.unable.to.read", file.getAbsolutePath());
}
}
}
if (resourcePaths != null) {
for (String resourcePath : resourcePaths) {
try {
String namespace = Util.documentRootNamespace(newSource(resourcePath, classLoader), disableXmlSecurity);
JavaWsdlMappingType externalMapping = parseMetadata(xsdValidation, newSource(resourcePath, classLoader), namespace, disableXmlSecurity);
readers.put(externalMapping.getJavaTypeName(), externalMapping);
} catch (Exception e) {
throw new RuntimeModelerException("runtime.modeler.external.metadata.unable.to.read", resourcePath);
}
}
}
}
private StreamSource newSource(String resourcePath, ClassLoader classLoader) {
InputStream is = classLoader.getResourceAsStream(resourcePath);
return new StreamSource(is);
}
private JavaWsdlMappingType parseMetadata(boolean xsdValidation, StreamSource source, String namespace, boolean disableXmlSecurity) throws JAXBException, IOException, TransformerException {
if (NAMESPACE_WEBLOGIC_WSEE_DATABINDING.equals(namespace)) {
return Util.transformAndRead(source, disableXmlSecurity);
} if (NAMESPACE_JAXWS_RI_EXTERNAL_METADATA.equals(namespace)) {
return Util.read(source, xsdValidation, disableXmlSecurity);
} else {
throw new RuntimeModelerException("runtime.modeler.external.metadata.unsupported.schema", namespace, Arrays.asList(NAMESPACE_WEBLOGIC_WSEE_DATABINDING, NAMESPACE_JAXWS_RI_EXTERNAL_METADATA).toString());
}
}
private StreamSource newSource(File file) {
try {
return new StreamSource(new FileInputStream(file));
} catch (FileNotFoundException e) {
throw new RuntimeModelerException("runtime.modeler.external.metadata.unable.to.read", file.getAbsolutePath());
}
}
public <A extends Annotation> A getAnnotation(Class<A> annType, Class<?> cls) {
JavaWsdlMappingType r = reader(cls);
return r == null ? super.getAnnotation(annType, cls) : Util.annotation(r, annType);
}
private JavaWsdlMappingType reader(Class<?> cls) {
return readers.get(cls.getName());
}
Annotation[] getAnnotations(List<Object> objects) {
ArrayList<Annotation> list = new ArrayList<Annotation>();
for (Object a : objects) {
if (Annotation.class.isInstance(a)) {
list.add(Annotation.class.cast(a));
}
}
return list.toArray(new Annotation[list.size()]);
}
public Annotation[] getAnnotations(final Class<?> c) {
Merger<Annotation[]> merger = new Merger<Annotation[]>(reader(c)) {
Annotation[] reflection() {
return ExternalMetadataReader.super.getAnnotations(c);
}
Annotation[] external() {
return getAnnotations(reader.getClassAnnotation());
}
};
return merger.merge();
}
public Annotation[] getAnnotations(final Method m) {
Merger<Annotation[]> merger = new Merger<Annotation[]>(reader(m.getDeclaringClass())) {
Annotation[] reflection() {
return ExternalMetadataReader.super.getAnnotations(m);
}
Annotation[] external() {
JavaMethod jm = getJavaMethod(m, reader);
return (jm == null) ? new Annotation[0] : getAnnotations(jm.getMethodAnnotation());
}
};
return merger.merge();
}
@SuppressWarnings("unchecked")
public <A extends Annotation> A getAnnotation(final Class<A> annType, final Method m) {
Merger<Annotation> merger = new Merger<Annotation>(reader(m.getDeclaringClass())) {
Annotation reflection() {
return ExternalMetadataReader.super.getAnnotation(annType, m);
}
Annotation external() {
JavaMethod jm = getJavaMethod(m, reader);
return Util.annotation(jm, annType);
}
};
return (A) merger.merge();
}
public Annotation[][] getParameterAnnotations(final Method m) {
Merger<Annotation[][]> merger = new Merger<Annotation[][]>(reader(m.getDeclaringClass())) {
Annotation[][] reflection() {
return ExternalMetadataReader.super.getParameterAnnotations(m);
}
Annotation[][] external() {
JavaMethod jm = getJavaMethod(m, reader);
Annotation[][] a = m.getParameterAnnotations();
for (int i = 0; i < m.getParameterTypes().length; i++) {
if (jm == null) continue;
JavaParam jp = jm.getJavaParams().getJavaParam().get(i);
a[i] = getAnnotations(jp.getParamAnnotation());
}
return a;
}
};
return merger.merge();
}
public void getProperties(final Map<String, Object> prop, final Class<?> cls) {
JavaWsdlMappingType r = reader(cls);
// no external reader or it requires annotations merging ...
if (r == null || MERGE.equals(r.getExistingAnnotations())) {
super.getProperties(prop, cls);
}
}
public void getProperties(final Map<String, Object> prop, final Method m) {
JavaWsdlMappingType r = reader(m.getDeclaringClass());
// no external reader or it requires annotations merging ...
if (r == null || MERGE.equals(r.getExistingAnnotations())) {
super.getProperties(prop, m);
}
if (r != null) {
JavaMethod jm = getJavaMethod(m, r);
Element[] e = Util.annotation(jm);
prop.put("eclipselink-oxm-xml.xml-element", findXmlElement(e));
}
}
public void getProperties(final Map<String, Object> prop, final Method m, int pos) {
JavaWsdlMappingType r = reader(m.getDeclaringClass());
// no external reader or it requires annotations merging ...
if (r == null || MERGE.equals(r.getExistingAnnotations())) {
super.getProperties(prop, m, pos);
}
if (r != null) {
JavaMethod jm = getJavaMethod(m, r);
if (jm == null) return;
JavaParam jp = jm.getJavaParams().getJavaParam().get(pos);
Element[] e = Util.annotation(jp);
prop.put("eclipselink-oxm-xml.xml-element", findXmlElement(e));
}
}
JavaMethod getJavaMethod(Method method, JavaWsdlMappingType r) {
JavaWsdlMappingType.JavaMethods javaMethods = r.getJavaMethods();
if (javaMethods == null) {
return null;
}
List<JavaMethod> sameName = new ArrayList<JavaMethod>();
for (JavaMethod jm : javaMethods.getJavaMethod()) {
if (method.getName().equals(jm.getName())) {
sameName.add(jm);
}
}
if (sameName.isEmpty()) {
return null;
} else {
if (sameName.size() == 1) {
return sameName.get(0);
} else {
Class<?>[] argCls = method.getParameterTypes();
for (JavaMethod jm : sameName) {
JavaMethod.JavaParams params = jm.getJavaParams();
if (params != null && params.getJavaParam() != null && params.getJavaParam().size() == argCls.length) {
int count = 0;
for (int i = 0; i < argCls.length; i++) {
JavaParam jp = params.getJavaParam().get(i);
if (argCls[i].getName().equals(jp.getJavaType())) {
count++;
}
}
if (count == argCls.length) {
return jm;
}
}
}
}
}
return null;
}
Element findXmlElement(Element[] xa) {
if (xa == null) return null;
for (Element e : xa) {
if (e.getLocalName().equals("java-type")) return e;
if (e.getLocalName().equals("xml-element")) return e;
}
return null;
}
/**
* Helper class to merge two different arrays of annotation objects. It merges annotations based on attribute
* <code>existing-annotations</code> in external customization file.
* <p/>
* We suppose that in the result array there wouldn't be two annotations of same type:
* annotation.annotationType().getName(); if there are found such annotations the one from reflection is
* considered overriden and is thrown away.
* <p/>
* The helper can work either with one and two dimensional array, but it can be used for two single Annotation
* objects;
*/
static abstract class Merger<T> {
JavaWsdlMappingType reader;
Merger(JavaWsdlMappingType r) {
this.reader = r;
}
abstract T reflection();
abstract T external();
@SuppressWarnings("unchecked")
T merge() {
T reflection = reflection();
if (reader == null) {
return reflection;
}
T external = external();
if (!MERGE.equals(reader.getExistingAnnotations())) {
return external;
}
if (reflection instanceof Annotation) {
return (T) doMerge((Annotation) reflection, (Annotation) external);
} else if (reflection instanceof Annotation[][]) {
return (T) doMerge((Annotation[][]) reflection, (Annotation[][]) external);
} else {
return (T) doMerge((Annotation[]) reflection, (Annotation[]) external);
}
}
private Annotation doMerge(Annotation reflection, Annotation external) {
return external != null ? external : reflection;
}
private Annotation[][] doMerge(Annotation[][] reflection, Annotation[][] external) {
for (int i = 0; i < reflection.length; i++) {
reflection[i] = doMerge(reflection[i], external.length > i ? external[i] : null);
}
return reflection;
}
private Annotation[] doMerge(Annotation[] annotations, Annotation[] externalAnnotations) {
HashMap<String, Annotation> mergeMap = new HashMap<String, Annotation>();
if (annotations != null) {
for (Annotation reflectionAnnotation : annotations) {
mergeMap.put(reflectionAnnotation.annotationType().getName(), reflectionAnnotation);
}
}
// overriding happens here, based on annotationType().getName() ...
if (externalAnnotations != null) {
for (Annotation externalAnnotation : externalAnnotations) {
mergeMap.put(externalAnnotation.annotationType().getName(), externalAnnotation);
}
}
Collection<Annotation> values = mergeMap.values();
int size = values.size();
return size == 0 ? null : values.toArray(new Annotation[size]);
}
}
static class Util {
//private static final String DATABINDING_XSD = "com/sun/xml/internal/ws/model/jaxws-databinding.xsd";
private static final String DATABINDING_XSD = "jaxws-databinding.xsd";
//private static final String TRANSLATE_NAMESPACES_XSL = "/com/sun/xml/internal/ws/model/jaxws-databinding-translate-namespaces.xml";
private static final String TRANSLATE_NAMESPACES_XSL = "jaxws-databinding-translate-namespaces.xml";
static Schema schema;
static JAXBContext jaxbContext;
static {
SchemaFactory sf = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
try {
URL xsdUrl = getResource();
if (xsdUrl != null) {
schema = sf.newSchema(xsdUrl);
}
} catch (SAXException e1) {
// e1.printStackTrace();
}
jaxbContext = createJaxbContext(false);
}
private static URL getResource() {
ClassLoader classLoader = Util.class.getClassLoader();
return classLoader != null ? classLoader.getResource(DATABINDING_XSD) : ClassLoader.getSystemResource(DATABINDING_XSD);
}
private static JAXBContext createJaxbContext(boolean disableXmlSecurity) {
Class[] cls = {ObjectFactory.class};
try {
if (disableXmlSecurity) {
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(JAXBRIContext.DISABLE_XML_SECURITY, disableXmlSecurity);
return JAXBContext.newInstance(cls, properties);
} else {
return JAXBContext.newInstance(cls);
}
} catch (JAXBException e) {
e.printStackTrace();
return null;
}
}
@SuppressWarnings("unchecked")
public static JavaWsdlMappingType read(Source src, boolean xsdValidation, boolean disableXmlSecurity) throws IOException, JAXBException {
JAXBContext ctx = jaxbContext(disableXmlSecurity);
try {
Unmarshaller um = ctx.createUnmarshaller();
if (xsdValidation) {
if (schema == null) {
//TODO 0 warning for schema == null
}
um.setSchema(schema);
}
Object o = um.unmarshal(src);
return getJavaWsdlMapping(o);
} catch (JAXBException e) {
// throw new
// WebServiceException(WsDatabindingMessages.mappingFileCannotRead
// (src.getSystemId()), e);
URL url = new URL(src.getSystemId());
Source s = new StreamSource(url.openStream());
Unmarshaller um = ctx.createUnmarshaller();
if (xsdValidation) {
if (schema == null) {
//TODO 0 warning for schema == null
}
um.setSchema(schema);
}
Object o = um.unmarshal(s);
return getJavaWsdlMapping(o);
}
}
private static JAXBContext jaxbContext(boolean disableXmlSecurity) {
// as it is supposed to have security enabled in most cases, we create and don't cache
// "insecure" JAXBContext - these should be corner cases
return disableXmlSecurity ? createJaxbContext(true) : jaxbContext;
}
public static JavaWsdlMappingType transformAndRead(Source src, boolean disableXmlSecurity) throws TransformerException, JAXBException {
Source xsl = new StreamSource(Util.class.getResourceAsStream(TRANSLATE_NAMESPACES_XSL));
JAXBResult result = new JAXBResult(jaxbContext(disableXmlSecurity));
TransformerFactory tf = XmlUtil.newTransformerFactory(!disableXmlSecurity);
Transformer transformer = tf.newTemplates(xsl).newTransformer();
transformer.transform(src, result);
return getJavaWsdlMapping(result.getResult());
}
static JavaWsdlMappingType getJavaWsdlMapping(Object o) {
Object val = (o instanceof JAXBElement) ? ((JAXBElement) o).getValue() : o;
if (val instanceof JavaWsdlMappingType) return (JavaWsdlMappingType) val;
// else if (val instanceof JavaWsdlMappings)
// for (JavaWsdlMappingType m: ((JavaWsdlMappings) val).getJavaWsdlMapping())
// if (seiName.equals(m.javaTypeName)) return m;
return null;
}
static <T> T findInstanceOf(Class<T> type, List<Object> objects) {
for (Object o : objects) {
if (type.isInstance(o)) {
return type.cast(o);
}
}
return null;
}
static public <T> T annotation(JavaWsdlMappingType jwse, Class<T> anntype) {
if (jwse == null || jwse.getClassAnnotation() == null) {
return null;
}
return findInstanceOf(anntype, jwse.getClassAnnotation());
}
static public <T> T annotation(JavaMethod jm, Class<T> anntype) {
if (jm == null || jm.getMethodAnnotation() == null) {
return null;
}
return findInstanceOf(anntype, jm.getMethodAnnotation());
}
static public <T> T annotation(JavaParam jp, Class<T> anntype) {
if (jp == null || jp.getParamAnnotation() == null) {
return null;
}
return findInstanceOf(anntype, jp.getParamAnnotation());
}
static public Element[] annotation(JavaMethod jm) {
if (jm == null || jm.getMethodAnnotation() == null) {
return null;
}
return findElements(jm.getMethodAnnotation());
}
static public Element[] annotation(JavaParam jp) {
if (jp == null || jp.getParamAnnotation() == null) {
return null;
}
return findElements(jp.getParamAnnotation());
}
private static Element[] findElements(List<Object> objects) {
List<Element> elems = new ArrayList<Element>();
for (Object o : objects) {
if (o instanceof Element) {
elems.add((Element) o);
}
}
return elems.toArray(new Element[elems.size()]);
}
static String documentRootNamespace(Source src, boolean disableXmlSecurity) throws XMLStreamException {
XMLInputFactory factory;
factory = XmlUtil.newXMLInputFactory(!disableXmlSecurity);
XMLStreamReader streamReader = factory.createXMLStreamReader(src);
XMLStreamReaderUtil.nextElementContent(streamReader);
String namespaceURI = streamReader.getName().getNamespaceURI();
XMLStreamReaderUtil.close(streamReader);
return namespaceURI;
}
}
}

View File

@@ -0,0 +1,122 @@
/*
* 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.model;
import java.lang.reflect.*;
/**
* Creates vm signature string from Type
*
* TypeSignature: Z | C | B | S | I | F | J | D | FieldTypeSignature
* FieldTypeSignature: ClassTypeSignature | [ TypeSignature | TypeVar
* ClassTypeSignature: L Id ( / Id )* TypeArgs? ( . Id TypeArgs? )* ;
* TypeArgs: < TypeArg+ >
* TypeArg: * | ( + | - )? FieldTypeSignature
* TypeVar: T Id ;
*
* @author Jitendra Kotamraju
*/
final class FieldSignature {
static String vms(Type t) {
if (t instanceof Class && ((Class)t).isPrimitive()) {
Class c = (Class)t;
if (c == Integer.TYPE) {
return "I";
} else if (c == Void.TYPE) {
return "V";
} else if (c == Boolean.TYPE) {
return "Z";
} else if (c == Byte.TYPE) {
return "B";
} else if (c == Character.TYPE) {
return "C";
} else if (c == Short.TYPE) {
return "S";
} else if (c == Double.TYPE) {
return "D";
} else if (c == Float.TYPE) {
return "F";
} else if (c == Long.TYPE) {
return "J";
}
} else if (t instanceof Class && ((Class)t).isArray()) {
return "["+vms(((Class)t).getComponentType());
} else if (t instanceof Class || t instanceof ParameterizedType) {
return "L"+fqcn(t)+";";
} else if (t instanceof GenericArrayType) {
return "["+vms(((GenericArrayType)t).getGenericComponentType());
} else if (t instanceof TypeVariable) {
// While creating wrapper bean fields, it doesn't create with TypeVariables
// Otherwise, the type variable need to be declared in the wrapper bean class
// return "T"+((TypeVariable)t).getName()+";";
return "Ljava/lang/Object;";
} else if (t instanceof WildcardType) {
WildcardType w = (WildcardType)t;
if (w.getLowerBounds().length > 0) {
return "-"+vms(w.getLowerBounds()[0]);
} else if (w.getUpperBounds().length > 0) {
Type wt = w.getUpperBounds()[0];
if (wt.equals(Object.class)) {
return "*";
} else {
return "+"+vms(wt);
}
}
}
throw new IllegalArgumentException("Illegal vms arg " + t);
}
private static String fqcn(Type t) {
if (t instanceof Class) {
Class c = (Class)t;
if (c.getDeclaringClass() == null) {
return c.getName().replace('.', '/');
} else {
return fqcn(c.getDeclaringClass())+"$"+c.getSimpleName();
}
} else if (t instanceof ParameterizedType) {
ParameterizedType p = (ParameterizedType)t;
if (p.getOwnerType() == null) {
return fqcn(p.getRawType())+args(p);
} else {
assert p.getRawType() instanceof Class;
return fqcn(p.getOwnerType())+"."+
((Class)p.getRawType()).getSimpleName()+args(p);
}
}
throw new IllegalArgumentException("Illegal fqcn arg = "+t);
}
private static String args(ParameterizedType p) {
StringBuilder sig = new StringBuilder("<");
for(Type t : p.getActualTypeArguments()) {
sig.append(vms(t));
}
return sig.append(">").toString();
}
}

View File

@@ -0,0 +1,108 @@
/*
* Copyright (c) 2008, 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.model;
import javax.xml.ws.WebServiceException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* A {@link ClassLoader} used to "inject" wrapper and exception bean classes
* into the VM.
*
* @author Jitendra kotamraju
*/
final class Injector {
private static final Logger LOGGER = Logger.getLogger(Injector.class.getName());
private static final Method defineClass;
private static final Method resolveClass;
private static final Method getPackage;
private static final Method definePackage;
static {
try {
defineClass = ClassLoader.class.getDeclaredMethod("defineClass",String.class,byte[].class,Integer.TYPE,Integer.TYPE);
resolveClass = ClassLoader.class.getDeclaredMethod("resolveClass",Class.class);
getPackage = ClassLoader.class.getDeclaredMethod("getPackage", String.class);
definePackage = ClassLoader.class.getDeclaredMethod("definePackage",
String.class, String.class, String.class, String.class,
String.class, String.class, String.class, URL.class);
} catch (NoSuchMethodException e) {
// impossible
throw new NoSuchMethodError(e.getMessage());
}
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
// TODO: check security implication
// do these setAccessible allow anyone to call these methods freely?s
defineClass.setAccessible(true);
resolveClass.setAccessible(true);
getPackage.setAccessible(true);
definePackage.setAccessible(true);
return null;
}
});
}
static synchronized Class inject(ClassLoader cl, String className, byte[] image) {
// To avoid race conditions let us check if the classloader
// already contains the class
try {
return cl.loadClass(className);
} catch (ClassNotFoundException e) {
// nothing to do
}
try {
int packIndex = className.lastIndexOf('.');
if (packIndex != -1) {
String pkgname = className.substring(0, packIndex);
// Check if package already loaded.
Package pkg = (Package)getPackage.invoke(cl, pkgname);
if (pkg == null) {
definePackage.invoke(cl, pkgname, null, null, null, null, null, null, null);
}
}
Class c = (Class)defineClass.invoke(cl,className.replace('/','.'),image,0,image.length);
resolveClass.invoke(cl, c);
return c;
} catch (IllegalAccessException e) {
LOGGER.log(Level.FINE,"Unable to inject "+className,e);
throw new WebServiceException(e);
} catch (InvocationTargetException e) {
LOGGER.log(Level.FINE,"Unable to inject "+className,e);
throw new WebServiceException(e);
}
}
}

View File

@@ -0,0 +1,416 @@
/*
* 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.model;
import com.sun.xml.internal.bind.api.TypeReference;
import com.sun.xml.internal.ws.api.databinding.MetadataReader;
import com.sun.xml.internal.ws.api.model.JavaMethod;
import com.sun.xml.internal.ws.api.model.MEP;
import com.sun.xml.internal.ws.api.model.SEIModel;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLFault;
import com.sun.xml.internal.ws.api.model.soap.SOAPBinding;
import com.sun.xml.internal.ws.model.soap.SOAPBindingImpl;
import com.sun.xml.internal.ws.spi.db.TypeInfo;
import com.sun.xml.internal.ws.wsdl.ActionBasedOperationSignature;
import com.sun.istack.internal.Nullable;
import javax.xml.namespace.QName;
import javax.xml.ws.Action;
import javax.xml.ws.WebServiceException;
import javax.jws.WebMethod;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Logger;
/**
* Build this runtime model using java SEI and annotations
*
* @author Vivek Pandey
*/
public final class JavaMethodImpl implements JavaMethod {
private String inputAction = "";
private String outputAction = "";
private final List<CheckedExceptionImpl> exceptions = new ArrayList<CheckedExceptionImpl>();
private final Method method;
/*package*/ final List<ParameterImpl> requestParams = new ArrayList<ParameterImpl>();
/*package*/ final List<ParameterImpl> responseParams = new ArrayList<ParameterImpl>();
private final List<ParameterImpl> unmReqParams = Collections.unmodifiableList(requestParams);
private final List<ParameterImpl> unmResParams = Collections.unmodifiableList(responseParams);
private SOAPBinding binding;
private MEP mep;
private QName operationName;
private WSDLBoundOperation wsdlOperation;
/*package*/ final AbstractSEIModelImpl owner;
private final Method seiMethod;
private QName requestPayloadName;
private String soapAction;
/**
* @param owner
* @param method : Implementation class method
* @param seiMethod : corresponding SEI Method.
* Is there is no SEI, it should be Implementation class method
*/
public JavaMethodImpl(AbstractSEIModelImpl owner, Method method, Method seiMethod, MetadataReader metadataReader) {
this.owner = owner;
this.method = method;
this.seiMethod = seiMethod;
setWsaActions(metadataReader);
}
private void setWsaActions(MetadataReader metadataReader) {
Action action = (metadataReader != null)? metadataReader.getAnnotation(Action.class, seiMethod):seiMethod.getAnnotation(Action.class);
if(action != null) {
inputAction = action.input();
outputAction = action.output();
}
//@Action(input) =="", get it from @WebMethod(action)
WebMethod webMethod = (metadataReader != null)? metadataReader.getAnnotation(WebMethod.class, seiMethod):seiMethod.getAnnotation(WebMethod.class);
soapAction = "";
if (webMethod != null )
soapAction = webMethod.action();
if(!soapAction.equals("")) {
//non-empty soapAction
if(inputAction.equals(""))
// set input action to non-empty soapAction
inputAction = soapAction;
else if(!inputAction.equals(soapAction)){
//both are explicitly set via annotations, make sure @Action == @WebMethod.action
//http://java.net/jira/browse/JAX_WS-1108
//throw new WebServiceException("@Action and @WebMethod(action=\"\" does not match on operation "+ method.getName());
}
}
}
public ActionBasedOperationSignature getOperationSignature() {
QName qname = getRequestPayloadName();
if (qname == null) qname = new QName("", "");
return new ActionBasedOperationSignature(getInputAction(), qname);
}
public SEIModel getOwner() {
return owner;
}
/**
* @see JavaMethod
*
* @return Returns the method.
*/
public Method getMethod() {
return method;
}
/**
* @see JavaMethod
*
* @return Returns the SEI method where annotations are present
*/
public Method getSEIMethod() {
return seiMethod;
}
/**
* @return Returns the mep.
*/
public MEP getMEP() {
return mep;
}
/**
* @param mep
* The mep to set.
*/
void setMEP(MEP mep) {
this.mep = mep;
}
/**
* @return the Binding object
*/
public SOAPBinding getBinding() {
if (binding == null)
return new SOAPBindingImpl();
return binding;
}
/**
* @param binding
*/
void setBinding(SOAPBinding binding) {
this.binding = binding;
}
/**
* Returns the {@link WSDLBoundOperation} Operation associated with {@link JavaMethodImpl}
* operation.
* @deprecated
* @return the WSDLBoundOperation for this JavaMethod
*/
public WSDLBoundOperation getOperation() {
// assert wsdlOperation != null;
return wsdlOperation;
}
public void setOperationQName(QName name) {
this.operationName = name;
}
public QName getOperationQName() {
return (wsdlOperation != null)? wsdlOperation.getName(): operationName;
}
public String getSOAPAction() {
return (wsdlOperation != null)? wsdlOperation.getSOAPAction(): soapAction;
}
public String getOperationName() {
return operationName.getLocalPart();
}
public String getRequestMessageName() {
return getOperationName();
}
public String getResponseMessageName() {
if(mep.isOneWay())
return null;
return getOperationName()+"Response";
}
public void setRequestPayloadName(QName n) {
requestPayloadName = n;
}
/**
* @return soap:Body's first child name for request message.
*/
public @Nullable QName getRequestPayloadName() {
return (wsdlOperation != null)? wsdlOperation.getRequestPayloadName(): requestPayloadName;
}
/**
* @return soap:Body's first child name for response message.
*/
public @Nullable QName getResponsePayloadName() {
return (mep == MEP.ONE_WAY) ? null : wsdlOperation.getResponsePayloadName();
}
/**
* @return returns unmodifiable list of request parameters
*/
public List<ParameterImpl> getRequestParameters() {
return unmReqParams;
}
/**
* @return returns unmodifiable list of response parameters
*/
public List<ParameterImpl> getResponseParameters() {
return unmResParams;
}
void addParameter(ParameterImpl p) {
if (p.isIN() || p.isINOUT()) {
assert !requestParams.contains(p);
requestParams.add(p);
}
if (p.isOUT() || p.isINOUT()) {
// this check is only for out parameters
assert !responseParams.contains(p);
responseParams.add(p);
}
}
void addRequestParameter(ParameterImpl p){
if (p.isIN() || p.isINOUT()) {
requestParams.add(p);
}
}
void addResponseParameter(ParameterImpl p){
if (p.isOUT() || p.isINOUT()) {
responseParams.add(p);
}
}
/**
* @return Returns number of java method parameters - that will be all the
* IN, INOUT and OUT holders
*
* @deprecated no longer use in the new architecture
*/
public int getInputParametersCount() {
int count = 0;
for (ParameterImpl param : requestParams) {
if (param.isWrapperStyle()) {
count += ((WrapperParameter) param).getWrapperChildren().size();
} else {
count++;
}
}
for (ParameterImpl param : responseParams) {
if (param.isWrapperStyle()) {
for (ParameterImpl wc : ((WrapperParameter) param).getWrapperChildren()) {
if (!wc.isResponse() && wc.isOUT()) {
count++;
}
}
} else if (!param.isResponse() && param.isOUT()) {
count++;
}
}
return count;
}
/**
* @param ce
*/
void addException(CheckedExceptionImpl ce) {
if (!exceptions.contains(ce))
exceptions.add(ce);
}
/**
* @param exceptionClass
* @return CheckedException corresponding to the exceptionClass. Returns
* null if not found.
*/
public CheckedExceptionImpl getCheckedException(Class exceptionClass) {
for (CheckedExceptionImpl ce : exceptions) {
if (ce.getExceptionClass()==exceptionClass)
return ce;
}
return null;
}
/**
* @return a list of checked Exceptions thrown by this method
*/
public List<CheckedExceptionImpl> getCheckedExceptions(){
return Collections.unmodifiableList(exceptions);
}
public String getInputAction() {
// return (wsdlOperation != null)? wsdlOperation.getOperation().getInput().getAction(): inputAction;
return inputAction;
}
public String getOutputAction() {
// return (wsdlOperation != null)? wsdlOperation.getOperation().getOutput().getAction(): outputAction;
return outputAction;
}
/**
* @deprecated
* @param detailType
* @return Gets the CheckedException corresponding to detailType. Returns
* null if no CheckedExcpetion with the detailType found.
*/
public CheckedExceptionImpl getCheckedException(TypeReference detailType) {
for (CheckedExceptionImpl ce : exceptions) {
TypeInfo actual = ce.getDetailType();
if (actual.tagName.equals(detailType.tagName) && actual.type==detailType.type) {
return ce;
}
}
return null;
}
/**
* Returns if the java method is async
* @return if this is an Asynch
*/
public boolean isAsync(){
return mep.isAsync;
}
/*package*/ void freeze(WSDLPort portType) {
this.wsdlOperation = portType.getBinding().get(new QName(portType.getBinding().getPortType().getName().getNamespaceURI(),getOperationName()));
// TODO: replace this with proper error handling
if(wsdlOperation ==null)
throw new WebServiceException("Method "+seiMethod.getName()+" is exposed as WebMethod, but there is no corresponding wsdl operation with name "+operationName+" in the wsdl:portType" + portType.getBinding().getPortType().getName());
//so far, the inputAction, outputAction and fault actions are set from the @Action and @FaultAction
//set the values from WSDLModel, if such annotations are not present or defaulted
if(inputAction.equals("")) {
inputAction = wsdlOperation.getOperation().getInput().getAction();
} else if(!inputAction.equals(wsdlOperation.getOperation().getInput().getAction()))
//TODO input action might be from @Action or WebMethod(action)
LOGGER.warning("Input Action on WSDL operation "+wsdlOperation.getName().getLocalPart() + " and @Action on its associated Web Method " + seiMethod.getName() +" did not match and will cause problems in dispatching the requests");
if (!mep.isOneWay()) {
if (outputAction.equals(""))
outputAction = wsdlOperation.getOperation().getOutput().getAction();
for (CheckedExceptionImpl ce : exceptions) {
if (ce.getFaultAction().equals("")) {
QName detailQName = ce.getDetailType().tagName;
WSDLFault wsdlfault = wsdlOperation.getOperation().getFault(detailQName);
if(wsdlfault == null) {
// mismatch between wsdl model and SEI model, log a warning and use SEI model for Action determination
LOGGER.warning("Mismatch between Java model and WSDL model found, For wsdl operation " +
wsdlOperation.getName() + ",There is no matching wsdl fault with detail QName " +
ce.getDetailType().tagName);
ce.setFaultAction(ce.getDefaultFaultAction());
} else {
ce.setFaultAction(wsdlfault.getAction());
}
}
}
}
}
final void fillTypes(List<TypeInfo> types) {
fillTypes(requestParams, types);
fillTypes(responseParams, types);
for (CheckedExceptionImpl ce : exceptions) {
types.add(ce.getDetailType());
}
}
private void fillTypes(List<ParameterImpl> params, List<TypeInfo> types) {
for (ParameterImpl p : params) {
p.fillTypes(types);
}
}
private static final Logger LOGGER = Logger.getLogger(com.sun.xml.internal.ws.model.JavaMethodImpl.class.getName());
}

View File

@@ -0,0 +1,260 @@
/*
* 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.model;
import com.sun.xml.internal.bind.api.Bridge;
import com.sun.xml.internal.bind.api.TypeReference;
import com.sun.xml.internal.ws.api.model.JavaMethod;
import com.sun.xml.internal.ws.api.model.Parameter;
import com.sun.xml.internal.ws.api.model.ParameterBinding;
import com.sun.xml.internal.ws.spi.db.RepeatedElementBridge;
import com.sun.xml.internal.ws.spi.db.WrapperComposite;
import com.sun.xml.internal.ws.spi.db.XMLBridge;
import com.sun.xml.internal.ws.spi.db.TypeInfo;
import javax.jws.WebParam.Mode;
import javax.xml.namespace.QName;
import javax.xml.ws.Holder;
import java.util.List;
/**
* runtime Parameter that abstracts the annotated java parameter
*
* <p>
* A parameter may be bound to a header, a body, or an attachment.
* Note that when it's bound to a body, it's bound to a body,
* it binds to the whole payload.
*
* <p>
* Sometimes multiple Java parameters are packed into the payload,
* in which case the subclass {@link WrapperParameter} is used.
*
* @author Vivek Pandey
*/
public class ParameterImpl implements Parameter {
private ParameterBinding binding;
private ParameterBinding outBinding;
private String partName;
private final int index;
private final Mode mode;
/** @deprecated */
private TypeReference typeReference;
private TypeInfo typeInfo;
private QName name;
private final JavaMethodImpl parent;
WrapperParameter wrapper;
TypeInfo itemTypeInfo;
public ParameterImpl(JavaMethodImpl parent, TypeInfo type, Mode mode, int index) {
assert type != null;
this.typeInfo = type;
this.name = type.tagName;
this.mode = mode;
this.index = index;
this.parent = parent;
}
public AbstractSEIModelImpl getOwner() {
return parent.owner;
}
public JavaMethod getParent() {
return parent;
}
/**
* @return Returns the name.
*/
public QName getName() {
return name;
}
public XMLBridge getXMLBridge() {
return getOwner().getXMLBridge(typeInfo);
}
public XMLBridge getInlinedRepeatedElementBridge() {
TypeInfo itemType = getItemType();
if (itemType != null) {
XMLBridge xb = getOwner().getXMLBridge(itemType);
if (xb != null) return new RepeatedElementBridge(typeInfo, xb);
}
return null;
}
public TypeInfo getItemType() {
if (itemTypeInfo != null) return itemTypeInfo;
//RpcLit cannot inline repeated element in wrapper
if (parent.getBinding().isRpcLit() || wrapper == null) return null;
//InlinedRepeatedElementBridge is only used for dynamic wrapper (no wrapper class)
if (!WrapperComposite.class.equals(wrapper.getTypeInfo().type)) return null;
if (!getBinding().isBody()) return null;
itemTypeInfo = typeInfo.getItemType();
return itemTypeInfo;
}
/** @deprecated */
public Bridge getBridge() {
return getOwner().getBridge(typeReference);
}
/** @deprecated */
protected Bridge getBridge(TypeReference typeRef) {
return getOwner().getBridge(typeRef);
}
/**
* TODO: once the model gets JAXBContext, shouldn't {@link Bridge}s
* be made available from model objects?
* @deprecated use getTypeInfo
* @return Returns the TypeReference associated with this Parameter
*/
public TypeReference getTypeReference() {
return typeReference;
}
public TypeInfo getTypeInfo() {
return typeInfo;
}
/**
* Sometimes we need to overwrite the typeReferenc, such as during patching for rpclit
* @see AbstractSEIModelImpl#applyRpcLitParamBinding(JavaMethodImpl, WrapperParameter, WSDLBoundPortType, WebParam.Mode)
* @deprecated
*/
void setTypeReference(TypeReference type){
typeReference = type;
name = type.tagName;
}
public Mode getMode() {
return mode;
}
public int getIndex() {
return index;
}
/**
* @return true if <tt>this instanceof {@link WrapperParameter}</tt>.
*/
public boolean isWrapperStyle() {
return false;
}
public boolean isReturnValue() {
return index==-1;
}
/**
* @return the Binding for this Parameter
*/
public ParameterBinding getBinding() {
if(binding == null)
return ParameterBinding.BODY;
return binding;
}
/**
* @param binding
*/
public void setBinding(ParameterBinding binding) {
this.binding = binding;
}
public void setInBinding(ParameterBinding binding){
this.binding = binding;
}
public void setOutBinding(ParameterBinding binding){
this.outBinding = binding;
}
public ParameterBinding getInBinding(){
return binding;
}
public ParameterBinding getOutBinding(){
if(outBinding == null)
return binding;
return outBinding;
}
public boolean isIN() {
return mode==Mode.IN;
}
public boolean isOUT() {
return mode==Mode.OUT;
}
public boolean isINOUT() {
return mode==Mode.INOUT;
}
/**
* If true, this parameter maps to the return value of a method invocation.
*
* <p>
* {@link JavaMethodImpl#getResponseParameters()} is guaranteed to have
* at most one such {@link ParameterImpl}. Note that there coule be none,
* in which case the method returns <tt>void</tt>.
*/
public boolean isResponse() {
return index == -1;
}
/**
* Gets the holder value if applicable. To be called for inbound client side
* message.
*
* @param obj
* @return the holder value if applicable.
*/
public Object getHolderValue(Object obj) {
if (obj != null && obj instanceof Holder)
return ((Holder) obj).value;
return obj;
}
public String getPartName() {
if(partName == null)
return name.getLocalPart();
return partName;
}
public void setPartName(String partName) {
this.partName = partName;
}
void fillTypes(List<TypeInfo> types) {
TypeInfo itemType = getItemType();
types.add((itemType != null) ? itemType : getTypeInfo());
}
}

View File

@@ -0,0 +1,84 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.model;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Map;
import com.sun.xml.internal.ws.api.databinding.MetadataReader;
/**
* ReflectAnnotationReader
*
* @author shih-chang.chen@oracle.com
*/
public class ReflectAnnotationReader implements MetadataReader {
//getAnnotationOnImpl SEIorIMpl
public Annotation[] getAnnotations(Method m) {
return m.getAnnotations();
}
public Annotation[][] getParameterAnnotations(final Method method) {
return AccessController.doPrivileged(new PrivilegedAction<Annotation[][]>() {
public Annotation[][] run() {
return method.getParameterAnnotations();
}
});
}
public <A extends Annotation> A getAnnotation(final Class<A> annType, final Method m) {
return AccessController.doPrivileged(new PrivilegedAction<A>() {
public A run() {
return m.getAnnotation(annType);
}
});
}
public <A extends Annotation> A getAnnotation(final Class<A> annType, final Class<?> cls) {
return AccessController.doPrivileged(new PrivilegedAction<A>() {
public A run() {
return cls.getAnnotation(annType);
}
});
}
public Annotation[] getAnnotations(final Class<?> cls) {
return AccessController.doPrivileged(new PrivilegedAction<Annotation[]>() {
public Annotation[] run() {
return cls.getAnnotations();
}
});
}
public void getProperties(final Map<String, Object> prop, final Class<?> cls){}
public void getProperties(final Map<String, Object> prop, final Method method){}
public void getProperties(final Map<String, Object> prop, final Method method, int pos){}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,56 @@
/*
* 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.model;
import com.sun.istack.internal.localization.Localizable;
import com.sun.xml.internal.ws.util.exception.JAXWSExceptionBase;
/**
* RuntimeModelerException represents an exception that occurred while
* serializing a Java value as XML.
*
* @see JAXWSExceptionBase
*
* @author WS Development Team
*/
public class RuntimeModelerException extends JAXWSExceptionBase {
public RuntimeModelerException(String key, Object... args) {
super(key, args);
}
public RuntimeModelerException(Throwable throwable) {
super(throwable);
}
public RuntimeModelerException(Localizable arg) {
super("nestedModelerError", arg);
}
public String getDefaultResourceBundleName() {
return "com.sun.xml.internal.ws.resources.modeler";
}
}

View File

@@ -0,0 +1,101 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.model;
import com.sun.xml.internal.ws.api.model.ParameterBinding;
import com.sun.xml.internal.ws.binding.WebServiceFeatureList;
import javax.jws.WebParam.Mode;
import javax.xml.namespace.QName;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
/**
* Creates SOAP specific RuntimeModel
*
* @author Vivek Pandey
*/
public class SOAPSEIModel extends AbstractSEIModelImpl {
public SOAPSEIModel(WebServiceFeatureList features) {
super(features);
}
@Override
protected void populateMaps() {
int emptyBodyCount = 0;
for(JavaMethodImpl jm : getJavaMethods()){
put(jm.getMethod(), jm);
boolean bodyFound = false;
for(ParameterImpl p:jm.getRequestParameters()){
ParameterBinding binding = p.getBinding();
if(binding.isBody()){
put(p.getName(), jm);
bodyFound = true;
}
}
if(!bodyFound){
put(emptyBodyName, jm);
// System.out.println("added empty body for: "+jm.getMethod().getName());
emptyBodyCount++;
}
}
if(emptyBodyCount > 1){
//TODO throw exception
// System.out.println("Error: Unqiue signature violation - more than 1 empty body!");
}
}
public Set<QName> getKnownHeaders() {
Set<QName> headers = new HashSet<QName>();
for (JavaMethodImpl method : getJavaMethods()) {
// fill in request headers
Iterator<ParameterImpl> params = method.getRequestParameters().iterator();
fillHeaders(params, headers, Mode.IN);
// fill in response headers
params = method.getResponseParameters().iterator();
fillHeaders(params, headers, Mode.OUT);
}
return headers;
}
/**
* @param params
* @param headers
*/
private void fillHeaders(Iterator<ParameterImpl> params, Set<QName> headers, Mode mode) {
while (params.hasNext()) {
ParameterImpl param = params.next();
ParameterBinding binding = (mode == Mode.IN)?param.getInBinding():param.getOutBinding();
QName name = param.getName();
if (binding.isHeader() && !headers.contains(name)) {
headers.add(name);
}
}
}
}

View File

@@ -0,0 +1,94 @@
/*
* Copyright (c) 2013, 2014, 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.model;
import com.sun.xml.internal.bind.v2.model.nav.Navigator;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Utils class.
*
* WARNING: If you are doing any changes don't forget to change other Utils classes in different packages.
*
* Has *package private* access to avoid inappropriate usage.
*/
final class Utils {
private static final Logger LOGGER = Logger.getLogger(Utils.class.getName());
/**
* static ReflectionNavigator field to avoid usage of reflection every time we use it.
*/
static final Navigator<Type, Class, Field, Method> REFLECTION_NAVIGATOR;
static { // we statically initializing REFLECTION_NAVIGATOR property
try {
final Class refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
// requires accessClassInPackage privilege
final Method getInstance = AccessController.doPrivileged(
new PrivilegedAction<Method>() {
@Override
public Method run() {
try {
Method getInstance = refNav.getDeclaredMethod("getInstance");
getInstance.setAccessible(true);
return getInstance;
} catch (NoSuchMethodException e) {
throw new IllegalStateException("ReflectionNavigator.getInstance can't be found");
}
}
}
);
//noinspection unchecked
REFLECTION_NAVIGATOR = (Navigator<Type, Class, Field, Method>) getInstance.invoke(null);
} catch (ClassNotFoundException e) {
throw new IllegalStateException("Can't find ReflectionNavigator class");
} catch (InvocationTargetException e) {
throw new IllegalStateException("ReflectionNavigator.getInstance throws the exception");
} catch (IllegalAccessException e) {
throw new IllegalStateException("ReflectionNavigator.getInstance method is inaccessible");
} catch (SecurityException e) {
LOGGER.log(Level.FINE, "Unable to access ReflectionNavigator.getInstance", e);
throw e;
}
}
/**
* private constructor to avoid util class instantiating
*/
private Utils() {
}
}

View File

@@ -0,0 +1,402 @@
/*
* 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.model;
import com.sun.xml.internal.ws.model.AbstractWrapperBeanGenerator.BeanMemberFactory;
import com.sun.xml.internal.bind.v2.model.annotation.AnnotationReader;
import com.sun.xml.internal.bind.v2.model.annotation.RuntimeInlineAnnotationReader;
import com.sun.xml.internal.bind.v2.model.nav.Navigator;
import com.sun.xml.internal.ws.org.objectweb.asm.*;
import static com.sun.xml.internal.ws.org.objectweb.asm.Opcodes.*;
import com.sun.xml.internal.ws.org.objectweb.asm.Type;
import javax.xml.bind.annotation.XmlAttachmentRef;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlList;
import javax.xml.bind.annotation.XmlMimeType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.namespace.QName;
import javax.xml.ws.Holder;
import javax.xml.ws.WebServiceException;
import java.lang.annotation.Annotation;
import java.lang.reflect.*;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Runtime Wrapper and exception bean generator implementation.
* It uses ASM to generate request, response and exception beans.
*
* @author Jitendra Kotamraju
*/
public class WrapperBeanGenerator {
private static final Logger LOGGER = Logger.getLogger(WrapperBeanGenerator.class.getName());
private static final FieldFactory FIELD_FACTORY = new FieldFactory();
private static final AbstractWrapperBeanGenerator RUNTIME_GENERATOR =
new RuntimeWrapperBeanGenerator(new RuntimeInlineAnnotationReader(),
(Navigator<java.lang.reflect.Type, Class, ?, Method>) Utils.REFLECTION_NAVIGATOR, FIELD_FACTORY);
private static final class RuntimeWrapperBeanGenerator extends AbstractWrapperBeanGenerator<java.lang.reflect.Type, Class, java.lang.reflect.Method, Field> {
protected RuntimeWrapperBeanGenerator(AnnotationReader<java.lang.reflect.Type, Class, ?, Method> annReader, Navigator<java.lang.reflect.Type, Class, ?, Method> nav, BeanMemberFactory<java.lang.reflect.Type, Field> beanMemberFactory) {
super(annReader, nav, beanMemberFactory);
}
@Override
protected java.lang.reflect.Type getSafeType(java.lang.reflect.Type type) {
return type;
}
@Override
protected java.lang.reflect.Type getHolderValueType(java.lang.reflect.Type paramType) {
if (paramType instanceof ParameterizedType) {
ParameterizedType p = (ParameterizedType)paramType;
if (p.getRawType().equals(Holder.class)) {
return p.getActualTypeArguments()[0];
}
}
return null;
}
@Override
protected boolean isVoidType(java.lang.reflect.Type type) {
return type == Void.TYPE;
}
}
private static final class FieldFactory implements BeanMemberFactory<java.lang.reflect.Type, Field> {
@Override
public Field createWrapperBeanMember(java.lang.reflect.Type paramType,
String paramName, List<Annotation> jaxb) {
return new Field(paramName, paramType, getASMType(paramType), jaxb);
}
}
// Creates class's bytes
private static byte[] createBeanImage(String className,
String rootName, String rootNS,
String typeName, String typeNS,
Collection<Field> fields) throws Exception {
ClassWriter cw = new ClassWriter(0);
//org.objectweb.asm.util.TraceClassVisitor cw = new org.objectweb.asm.util.TraceClassVisitor(actual, new java.io.PrintWriter(System.out));
cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, replaceDotWithSlash(className), null, "java/lang/Object", null);
AnnotationVisitor root = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlRootElement;", true);
root.visit("name", rootName);
root.visit("namespace", rootNS);
root.visitEnd();
AnnotationVisitor type = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlType;", true);
type.visit("name", typeName);
type.visit("namespace", typeNS);
if (fields.size() > 1) {
AnnotationVisitor propVisitor = type.visitArray("propOrder");
for(Field field : fields) {
propVisitor.visit("propOrder", field.fieldName);
}
propVisitor.visitEnd();
}
type.visitEnd();
for(Field field : fields) {
FieldVisitor fv = cw.visitField(ACC_PUBLIC, field.fieldName, field.asmType.getDescriptor(), field.getSignature(), null);
for(Annotation ann : field.jaxbAnnotations) {
if (ann instanceof XmlMimeType) {
AnnotationVisitor mime = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlMimeType;", true);
mime.visit("value", ((XmlMimeType)ann).value());
mime.visitEnd();
} else if (ann instanceof XmlJavaTypeAdapter) {
AnnotationVisitor ada = fv.visitAnnotation("Ljavax/xml/bind/annotation/adapters/XmlJavaTypeAdapter;", true);
ada.visit("value", getASMType(((XmlJavaTypeAdapter)ann).value()));
// XmlJavaTypeAdapter.type() is for package only. No need to copy.
// ada.visit("type", ((XmlJavaTypeAdapter)ann).type());
ada.visitEnd();
} else if (ann instanceof XmlAttachmentRef) {
AnnotationVisitor att = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlAttachmentRef;", true);
att.visitEnd();
} else if (ann instanceof XmlList) {
AnnotationVisitor list = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlList;", true);
list.visitEnd();
} else if (ann instanceof XmlElement) {
AnnotationVisitor elem = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlElement;", true);
XmlElement xmlElem = (XmlElement)ann;
elem.visit("name", xmlElem.name());
elem.visit("namespace", xmlElem.namespace());
if (xmlElem.nillable()) {
elem.visit("nillable", true);
}
if (xmlElem.required()) {
elem.visit("required", true);
}
elem.visitEnd();
} else {
throw new WebServiceException("Unknown JAXB annotation " + ann);
}
}
fv.visitEnd();
}
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
mv.visitInsn(RETURN);
mv.visitMaxs(1, 1);
mv.visitEnd();
cw.visitEnd();
if (LOGGER.isLoggable(Level.FINE)) {
// Class's @XmlRootElement
StringBuilder sb = new StringBuilder();
sb.append("\n");
sb.append("@XmlRootElement(name=").append(rootName)
.append(", namespace=").append(rootNS).append(")");
// Class's @XmlType
sb.append("\n");
sb.append("@XmlType(name=").append(typeName)
.append(", namespace=").append(typeNS);
if (fields.size() > 1) {
sb.append(", propOrder={");
for(Field field : fields) {
sb.append(" ");
sb.append(field.fieldName);
}
sb.append(" }");
}
sb.append(")");
// class declaration
sb.append("\n");
sb.append("public class ").append(className).append(" {");
// fields declaration
for(Field field : fields) {
sb.append("\n");
// Field's other JAXB annotations
for(Annotation ann : field.jaxbAnnotations) {
sb.append("\n ");
if (ann instanceof XmlMimeType) {
sb.append("@XmlMimeType(value=").append(((XmlMimeType)ann).value()).append(")");
} else if (ann instanceof XmlJavaTypeAdapter) {
sb.append("@XmlJavaTypeAdapter(value=").append(getASMType(((XmlJavaTypeAdapter)ann).value())).append(")");
} else if (ann instanceof XmlAttachmentRef) {
sb.append("@XmlAttachmentRef");
} else if (ann instanceof XmlList) {
sb.append("@XmlList");
} else if (ann instanceof XmlElement) {
XmlElement xmlElem = (XmlElement)ann;
sb.append("\n ");
sb.append("@XmlElement(name=").append(xmlElem.name())
.append(", namespace=").append(xmlElem.namespace());
if (xmlElem.nillable()) {
sb.append(", nillable=true");
}
if (xmlElem.required()) {
sb.append(", required=true");
}
sb.append(")");
} else {
throw new WebServiceException("Unknown JAXB annotation " + ann);
}
}
// Field declaration
sb.append("\n ");
sb.append("public ");
if (field.getSignature() == null) {
sb.append(field.asmType.getDescriptor());
} else {
sb.append(field.getSignature());
}
sb.append(" ");
sb.append(field.fieldName);
}
sb.append("\n\n}");
LOGGER.fine(sb.toString());
}
return cw.toByteArray();
}
private static String replaceDotWithSlash(String name) {
return name.replace('.', '/');
}
static Class createRequestWrapperBean(String className, Method method, QName reqElemName, ClassLoader cl) {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "Request Wrapper Class : {0}", className);
}
List<Field> requestMembers = RUNTIME_GENERATOR.collectRequestBeanMembers(
method);
byte[] image;
try {
image = createBeanImage(className, reqElemName.getLocalPart(), reqElemName.getNamespaceURI(),
reqElemName.getLocalPart(), reqElemName.getNamespaceURI(),
requestMembers);
} catch(Exception e) {
throw new WebServiceException(e);
}
// write(image, className);
return Injector.inject(cl, className, image);
}
static Class createResponseWrapperBean(String className, Method method, QName resElemName, ClassLoader cl) {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "Response Wrapper Class : {0}", className);
}
List<Field> responseMembers = RUNTIME_GENERATOR.collectResponseBeanMembers(method);
byte[] image;
try {
image = createBeanImage(className, resElemName.getLocalPart(), resElemName.getNamespaceURI(),
resElemName.getLocalPart(), resElemName.getNamespaceURI(),
responseMembers);
} catch(Exception e) {
throw new WebServiceException(e);
}
// write(image, className);
return Injector.inject(cl, className, image);
}
private static Type getASMType(java.lang.reflect.Type t) {
assert t!=null;
if (t instanceof Class) {
return Type.getType((Class)t);
}
if (t instanceof ParameterizedType) {
ParameterizedType pt = (ParameterizedType)t;
if (pt.getRawType() instanceof Class) {
return Type.getType((Class)pt.getRawType());
}
}
if (t instanceof GenericArrayType) {
return Type.getType(FieldSignature.vms(t));
}
if (t instanceof WildcardType) {
return Type.getType(FieldSignature.vms(t));
}
if (t instanceof TypeVariable) {
TypeVariable tv = (TypeVariable)t;
if (tv.getBounds()[0] instanceof Class) {
return Type.getType((Class)tv.getBounds()[0]);
}
}
throw new IllegalArgumentException("Not creating ASM Type for type = "+t);
}
static Class createExceptionBean(String className, Class exception, String typeNS, String elemName, String elemNS, ClassLoader cl) {
return createExceptionBean(className, exception, typeNS, elemName, elemNS, cl, true);
}
static Class createExceptionBean(String className, Class exception, String typeNS, String elemName, String elemNS, ClassLoader cl, boolean decapitalizeExceptionBeanProperties) {
Collection<Field> fields = RUNTIME_GENERATOR.collectExceptionBeanMembers(exception, decapitalizeExceptionBeanProperties);
byte[] image;
try {
image = createBeanImage(className, elemName, elemNS,
exception.getSimpleName(), typeNS,
fields);
} catch(Exception e) {
throw new WebServiceException(e);
}
return Injector.inject(cl, className, image);
}
/**
* Note: this class has a natural ordering that is inconsistent with equals.
*/
private static class Field implements Comparable<Field> {
private final java.lang.reflect.Type reflectType;
private final Type asmType;
private final String fieldName;
private final List<Annotation> jaxbAnnotations;
Field(String paramName, java.lang.reflect.Type paramType, Type asmType,
List<Annotation> jaxbAnnotations) {
this.reflectType = paramType;
this.asmType = asmType;
this.fieldName = paramName;
this.jaxbAnnotations = jaxbAnnotations;
}
String getSignature() {
if (reflectType instanceof Class) {
return null;
}
if (reflectType instanceof TypeVariable) {
return null;
}
return FieldSignature.vms(reflectType);
}
@Override
public int compareTo(Field o) {
return fieldName.compareTo(o.fieldName);
}
}
static void write(byte[] b, String className) {
className = className.substring(className.lastIndexOf(".")+1);
try {
java.io.FileOutputStream fo = new java.io.FileOutputStream(className + ".class");
fo.write(b);
fo.flush();
fo.close();
} catch (java.io.IOException e) {
LOGGER.log(Level.INFO, "Error Writing class", e);
}
}
}

View File

@@ -0,0 +1,111 @@
/*
* 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.model;
import com.sun.xml.internal.ws.api.model.JavaMethod;
import com.sun.xml.internal.ws.api.model.ParameterBinding;
import com.sun.xml.internal.ws.spi.db.TypeInfo;
import com.sun.xml.internal.ws.spi.db.WrapperComposite;
import javax.jws.WebParam.Mode;
import java.util.ArrayList;
import java.util.List;
/**
* {@link ParameterImpl} that represents a wrapper,
* which is a parameter that consists of multiple nested {@link ParameterImpl}s
* within, which together form a body part.
*
* <p>
* Java method parameters represented by nested {@link ParameterImpl}s will be
* packed into a "wrapper bean" and it becomes the {@link ParameterImpl} for the
* body.
*
* <p>
* This parameter is only used for the {@link ParameterBinding#BODY} binding.
* Other parameters that bind to other parts (such as headers or unbound)
* will show up directly under {@link JavaMethod}.
*
* @author Vivek Pandey
*/
public class WrapperParameter extends ParameterImpl {
protected final List<ParameterImpl> wrapperChildren = new ArrayList<ParameterImpl>();
// TODO: wrapper parameter doesn't use 'typeRef' --- it only uses tag name.
public WrapperParameter(JavaMethodImpl parent, TypeInfo typeRef, Mode mode, int index) {
super(parent, typeRef, mode, index);
//chen workaround for document-literal wrapper - new feature on eclipselink API requested
typeRef.properties().put(WrapperParameter.class.getName(), this);
}
/**
*
* @deprecated
* Why are you calling a method that always return true?
*/
@Override
public boolean isWrapperStyle() {
return true;
}
/**
* @return Returns the wrapperChildren.
*/
public List<ParameterImpl> getWrapperChildren() {
return wrapperChildren;
}
/**
* Adds a new child parameter.
*
* @param wrapperChild
*/
public void addWrapperChild(ParameterImpl wrapperChild) {
wrapperChildren.add(wrapperChild);
wrapperChild.wrapper = this;
// must bind to body. see class javadoc
assert wrapperChild.getBinding()== ParameterBinding.BODY;
}
public void clear(){
wrapperChildren.clear();
}
@Override
void fillTypes(List<TypeInfo> types) {
super.fillTypes(types);
if(WrapperComposite.class.equals(getTypeInfo().type)) {
for (ParameterImpl p : wrapperChildren) p.fillTypes(types);
}
// if(getParent().getBinding().isRpcLit()) {
// // for rpc/lit, we need to individually marshal/unmarshal wrapped values,
// // so their TypeReference needs to be collected
//// assert getTypeReference().type==CompositeStructure.class;
// for (ParameterImpl p : wrapperChildren)
// p.fillTypes(types);
// }
}
}

View File

@@ -0,0 +1,71 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.model.soap;
import com.sun.xml.internal.ws.api.model.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import com.sun.xml.internal.ws.api.SOAPVersion;
/**
* A wsdl:opeartion binding object that represents soap:binding. This can be
* the return of {@link com.sun.xml.internal.ws.api.model.JavaMethod#getBinding()}.
* <p/>
* the default values are always document/literal and SoapVersion is SOAP 1.1.
*
* @author Vivek Pandey
*/
public class SOAPBindingImpl extends SOAPBinding {
public SOAPBindingImpl() {
}
public SOAPBindingImpl(SOAPBinding sb) {
this.use = sb.getUse();
this.style = sb.getStyle();
this.soapVersion = sb.getSOAPVersion();
this.soapAction = sb.getSOAPAction();
}
/**
* @param style The style to set.
*/
public void setStyle(Style style) {
this.style = style;
}
/**
* @param version
*/
public void setSOAPVersion(SOAPVersion version) {
this.soapVersion = version;
}
/**
* @param soapAction The soapAction to set.
*/
public void setSOAPAction(String soapAction) {
this.soapAction = soapAction;
}
}

View File

@@ -0,0 +1,140 @@
/*
* 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.model.wsdl;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLExtensible;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLExtension;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLObject;
import com.sun.xml.internal.ws.resources.UtilMessages;
import com.sun.istack.internal.NotNull;
import javax.xml.stream.XMLStreamReader;
import javax.xml.namespace.QName;
import javax.xml.ws.WebServiceException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.xml.sax.Locator;
/**
* All the WSDL 1.1 elements that are extensible should subclass from this abstract implementation of
* {@link WSDLExtensible} interface.
*
* @author Vivek Pandey
* @author Kohsuke Kawaguchi
*/
abstract class AbstractExtensibleImpl extends AbstractObjectImpl implements WSDLExtensible {
protected final Set<WSDLExtension> extensions = new HashSet<WSDLExtension>();
// this captures any wsdl extensions that are not understood by WSDLExtensionParsers
// and have wsdl:required=true
protected List<UnknownWSDLExtension> notUnderstoodExtensions =
new ArrayList<UnknownWSDLExtension>();
protected AbstractExtensibleImpl(XMLStreamReader xsr) {
super(xsr);
}
protected AbstractExtensibleImpl(String systemId, int lineNumber) {
super(systemId, lineNumber);
}
public final Iterable<WSDLExtension> getExtensions() {
return extensions;
}
public final <T extends WSDLExtension> Iterable<T> getExtensions(Class<T> type) {
// TODO: this is a rather stupid implementation
List<T> r = new ArrayList<T>(extensions.size());
for (WSDLExtension e : extensions) {
if(type.isInstance(e))
r.add(type.cast(e));
}
return r;
}
public <T extends WSDLExtension> T getExtension(Class<T> type) {
for (WSDLExtension e : extensions) {
if(type.isInstance(e))
return type.cast(e);
}
return null;
}
public void addExtension(WSDLExtension ex) {
if(ex==null)
// I don't trust plugins. So let's always check it, instead of making this an assertion
throw new IllegalArgumentException();
extensions.add(ex);
}
public List<? extends UnknownWSDLExtension> getNotUnderstoodExtensions() {
return notUnderstoodExtensions;
}
/**
* This can be used if a WSDL extension element that has wsdl:required=true
* is not understood
* @param extnEl
* @param locator
*/
public void addNotUnderstoodExtension(QName extnEl, Locator locator) {
notUnderstoodExtensions.add(new UnknownWSDLExtension(extnEl, locator));
}
protected static class UnknownWSDLExtension implements WSDLExtension, WSDLObject {
private final QName extnEl;
private final Locator locator;
public UnknownWSDLExtension(QName extnEl, Locator locator) {
this.extnEl = extnEl;
this.locator = locator;
}
public QName getName() {
return extnEl;
}
@NotNull public Locator getLocation() {
return locator;
}
public String toString(){
return extnEl + " "+ UtilMessages.UTIL_LOCATION( locator.getLineNumber(), locator.getSystemId());
}
}
/**
* This method should be called after freezing the WSDLModel
* @return true if all wsdl required extensions on Port and Binding are understood
*/
public boolean areRequiredExtensionsUnderstood() {
if (notUnderstoodExtensions.size() != 0) {
StringBuilder buf = new StringBuilder("Unknown WSDL extensibility elements:");
for (UnknownWSDLExtension extn : notUnderstoodExtensions)
buf.append('\n').append(extn.toString());
throw new WebServiceException(buf.toString());
}
return true;
}
}

View File

@@ -0,0 +1,78 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.model.wsdl;import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLFeaturedObject;
import com.sun.xml.internal.ws.binding.WebServiceFeatureList;
import javax.xml.stream.XMLStreamReader;
import javax.xml.ws.WebServiceFeature;
/**
* @author Kohsuke Kawaguchi
*/
abstract class AbstractFeaturedObjectImpl extends AbstractExtensibleImpl implements WSDLFeaturedObject {
protected WebServiceFeatureList features;
protected AbstractFeaturedObjectImpl(XMLStreamReader xsr) {
super(xsr);
}
protected AbstractFeaturedObjectImpl(String systemId, int lineNumber) {
super(systemId, lineNumber);
}
public final void addFeature(WebServiceFeature feature) {
if (features == null)
features = new WebServiceFeatureList();
features.add(feature);
}
public @NotNull WebServiceFeatureList getFeatures() {
if(features == null)
return new WebServiceFeatureList();
return features;
}
public final WebServiceFeature getFeature(String id) {
if (features != null) {
for (WebServiceFeature f : features) {
if (f.getID().equals(id))
return f;
}
}
return null;
}
@Nullable
public <F extends WebServiceFeature> F getFeature(@NotNull Class<F> featureType) {
if(features==null)
return null;
else
return features.get(featureType);
}
}

View File

@@ -0,0 +1,62 @@
/*
* 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.model.wsdl;
import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLObject;
import org.xml.sax.Locator;
import org.xml.sax.helpers.LocatorImpl;
import javax.xml.stream.Location;
import javax.xml.stream.XMLStreamReader;
/**
* @author Kohsuke Kawaguchi
*/
abstract class AbstractObjectImpl implements WSDLObject {
// source location information
private final int lineNumber;
private final String systemId;
/*package*/ AbstractObjectImpl(XMLStreamReader xsr) {
Location loc = xsr.getLocation();
this.lineNumber = loc.getLineNumber();
this.systemId = loc.getSystemId();
}
/*package*/ AbstractObjectImpl(String systemId, int lineNumber) {
this.systemId = systemId;
this.lineNumber = lineNumber;
}
public final @NotNull Locator getLocation() {
LocatorImpl loc = new LocatorImpl();
loc.setSystemId(systemId);
loc.setLineNumber(lineNumber);
return loc;
}
}

View File

@@ -0,0 +1,85 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.model.wsdl;
import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLBoundFault;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLBoundOperation;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLFault;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLOperation;
import javax.xml.stream.XMLStreamReader;
import javax.xml.namespace.QName;
/**
* @author Vivek Pandey
*/
public class WSDLBoundFaultImpl extends AbstractExtensibleImpl implements EditableWSDLBoundFault {
private final String name;
private EditableWSDLFault fault;
private EditableWSDLBoundOperation owner;
public WSDLBoundFaultImpl(XMLStreamReader xsr, String name, EditableWSDLBoundOperation owner) {
super(xsr);
this.name = name;
this.owner = owner;
}
public
@NotNull
String getName() {
return name;
}
public QName getQName() {
if(owner.getOperation() != null){
return new QName(owner.getOperation().getName().getNamespaceURI(), name);
}
return null;
}
public EditableWSDLFault getFault() {
return fault;
}
@NotNull
public EditableWSDLBoundOperation getBoundOperation() {
return owner;
}
public void freeze(EditableWSDLBoundOperation root) {
assert root != null;
EditableWSDLOperation op = root.getOperation();
if (op != null) {
for (EditableWSDLFault f : op.getFaults()) {
if (f.getName().equals(name)) {
this.fault = f;
break;
}
}
}
}
}

View File

@@ -0,0 +1,430 @@
/*
* 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.model.wsdl;
import com.sun.istack.internal.Nullable;
import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.ws.api.model.ParameterBinding;
import com.sun.xml.internal.ws.api.model.wsdl.*;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLBoundFault;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLBoundOperation;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLBoundPortType;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLMessage;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLModel;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLOperation;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLPart;
import com.sun.xml.internal.ws.model.RuntimeModeler;
import javax.jws.WebParam.Mode;
import javax.jws.soap.SOAPBinding.Style;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
import java.util.*;
/**
* Implementation of {@link WSDLBoundOperation}
*
* @author Vivek Pandey
*/
public final class WSDLBoundOperationImpl extends AbstractExtensibleImpl implements EditableWSDLBoundOperation {
private final QName name;
// map of wsdl:part to the binding
private final Map<String, ParameterBinding> inputParts;
private final Map<String, ParameterBinding> outputParts;
private final Map<String, ParameterBinding> faultParts;
private final Map<String, String> inputMimeTypes;
private final Map<String, String> outputMimeTypes;
private final Map<String, String> faultMimeTypes;
private boolean explicitInputSOAPBodyParts = false;
private boolean explicitOutputSOAPBodyParts = false;
private boolean explicitFaultSOAPBodyParts = false;
private Boolean emptyInputBody;
private Boolean emptyOutputBody;
private Boolean emptyFaultBody;
private final Map<String, EditableWSDLPart> inParts;
private final Map<String, EditableWSDLPart> outParts;
private final List<EditableWSDLBoundFault> wsdlBoundFaults;
private EditableWSDLOperation operation;
private String soapAction;
private ANONYMOUS anonymous;
private final EditableWSDLBoundPortType owner;
/**
*
* @param name wsdl:operation name qualified value
*/
public WSDLBoundOperationImpl(XMLStreamReader xsr, EditableWSDLBoundPortType owner, QName name) {
super(xsr);
this.name = name;
inputParts = new HashMap<String, ParameterBinding>();
outputParts = new HashMap<String, ParameterBinding>();
faultParts = new HashMap<String, ParameterBinding>();
inputMimeTypes = new HashMap<String, String>();
outputMimeTypes = new HashMap<String, String>();
faultMimeTypes = new HashMap<String, String>();
inParts = new HashMap<String, EditableWSDLPart>();
outParts = new HashMap<String, EditableWSDLPart>();
wsdlBoundFaults = new ArrayList<EditableWSDLBoundFault>();
this.owner = owner;
}
@Override
public QName getName(){
return name;
}
@Override
public String getSOAPAction() {
return soapAction;
}
public void setSoapAction(String soapAction) {
this.soapAction = soapAction!=null?soapAction:"";
}
@Override
public EditableWSDLPart getPart(String partName, Mode mode) {
if(mode==Mode.IN){
return inParts.get(partName);
}else if(mode==Mode.OUT){
return outParts.get(partName);
}
return null;
}
public void addPart(EditableWSDLPart part, Mode mode){
if(mode==Mode.IN)
inParts.put(part.getName(), part);
else if(mode==Mode.OUT)
outParts.put(part.getName(), part);
}
/**
* Map of wsdl:input part name and the binding as {@link ParameterBinding}
*
* @return empty Map if there is no parts
*/
public Map<String, ParameterBinding> getInputParts() {
return inputParts;
}
/**
* Map of wsdl:output part name and the binding as {@link ParameterBinding}
*
* @return empty Map if there is no parts
*/
public Map<String, ParameterBinding> getOutputParts() {
return outputParts;
}
/**
* Map of wsdl:fault part name and the binding as {@link ParameterBinding}
*
* @return empty Map if there is no parts
*/
public Map<String, ParameterBinding> getFaultParts() {
return faultParts;
}
// TODO: what's the difference between this and inputParts/outputParts?
@Override
public Map<String, ? extends EditableWSDLPart> getInParts() {
return Collections.<String, EditableWSDLPart>unmodifiableMap(inParts);
}
@Override
public Map<String, ? extends EditableWSDLPart> getOutParts() {
return Collections.<String, EditableWSDLPart>unmodifiableMap(outParts);
}
@NotNull
@Override
public List<? extends EditableWSDLBoundFault> getFaults() {
return wsdlBoundFaults;
}
public void addFault(@NotNull EditableWSDLBoundFault fault){
wsdlBoundFaults.add(fault);
}
/**
* Gets {@link ParameterBinding} for a given wsdl part in wsdl:input
*
* @param part Name of wsdl:part, must be non-null
* @return null if the part is not found.
*/
public ParameterBinding getInputBinding(String part){
if(emptyInputBody == null){
if(inputParts.get(" ") != null)
emptyInputBody = true;
else
emptyInputBody = false;
}
ParameterBinding block = inputParts.get(part);
if(block == null){
if(explicitInputSOAPBodyParts || emptyInputBody)
return ParameterBinding.UNBOUND;
return ParameterBinding.BODY;
}
return block;
}
/**
* Gets {@link ParameterBinding} for a given wsdl part in wsdl:output
*
* @param part Name of wsdl:part, must be non-null
* @return null if the part is not found.
*/
public ParameterBinding getOutputBinding(String part){
if(emptyOutputBody == null){
if(outputParts.get(" ") != null)
emptyOutputBody = true;
else
emptyOutputBody = false;
}
ParameterBinding block = outputParts.get(part);
if(block == null){
if(explicitOutputSOAPBodyParts || emptyOutputBody)
return ParameterBinding.UNBOUND;
return ParameterBinding.BODY;
}
return block;
}
/**
* Gets {@link ParameterBinding} for a given wsdl part in wsdl:fault
*
* @param part Name of wsdl:part, must be non-null
* @return null if the part is not found.
*/
public ParameterBinding getFaultBinding(String part){
if(emptyFaultBody == null){
if(faultParts.get(" ") != null)
emptyFaultBody = true;
else
emptyFaultBody = false;
}
ParameterBinding block = faultParts.get(part);
if(block == null){
if(explicitFaultSOAPBodyParts || emptyFaultBody)
return ParameterBinding.UNBOUND;
return ParameterBinding.BODY;
}
return block;
}
/**
* Gets the MIME type for a given wsdl part in wsdl:input
*
* @param part Name of wsdl:part, must be non-null
* @return null if the part is not found.
*/
public String getMimeTypeForInputPart(String part){
return inputMimeTypes.get(part);
}
/**
* Gets the MIME type for a given wsdl part in wsdl:output
*
* @param part Name of wsdl:part, must be non-null
* @return null if the part is not found.
*/
public String getMimeTypeForOutputPart(String part){
return outputMimeTypes.get(part);
}
/**
* Gets the MIME type for a given wsdl part in wsdl:fault
*
* @param part Name of wsdl:part, must be non-null
* @return null if the part is not found.
*/
public String getMimeTypeForFaultPart(String part){
return faultMimeTypes.get(part);
}
@Override
public EditableWSDLOperation getOperation() {
return operation;
}
@Override
public EditableWSDLBoundPortType getBoundPortType() {
return owner;
}
public void setInputExplicitBodyParts(boolean b) {
explicitInputSOAPBodyParts = b;
}
public void setOutputExplicitBodyParts(boolean b) {
explicitOutputSOAPBodyParts = b;
}
public void setFaultExplicitBodyParts(boolean b) {
explicitFaultSOAPBodyParts = b;
}
private Style style = Style.DOCUMENT;
public void setStyle(Style style){
this.style = style;
}
@Override
public @Nullable QName getRequestPayloadName() {
if (emptyRequestPayload)
return null;
if (requestPayloadName != null)
return requestPayloadName;
if(style.equals(Style.RPC)){
String ns = getRequestNamespace() != null ? getRequestNamespace() : name.getNamespaceURI();
requestPayloadName = new QName(ns, name.getLocalPart());
return requestPayloadName;
}else{
QName inMsgName = operation.getInput().getMessage().getName();
EditableWSDLMessage message = messages.get(inMsgName);
for(EditableWSDLPart part:message.parts()){
ParameterBinding binding = getInputBinding(part.getName());
if(binding.isBody()){
requestPayloadName = part.getDescriptor().name();
return requestPayloadName;
}
}
//Its empty payload
emptyRequestPayload = true;
}
//empty body
return null;
}
@Override
public @Nullable QName getResponsePayloadName() {
if (emptyResponsePayload)
return null;
if (responsePayloadName != null)
return responsePayloadName;
if(style.equals(Style.RPC)){
String ns = getResponseNamespace() != null ? getResponseNamespace() : name.getNamespaceURI();
responsePayloadName = new QName(ns, name.getLocalPart()+"Response");
return responsePayloadName;
}else{
QName outMsgName = operation.getOutput().getMessage().getName();
EditableWSDLMessage message = messages.get(outMsgName);
for(EditableWSDLPart part:message.parts()){
ParameterBinding binding = getOutputBinding(part.getName());
if(binding.isBody()){
responsePayloadName = part.getDescriptor().name();
return responsePayloadName;
}
}
//Its empty payload
emptyResponsePayload = true;
}
//empty body
return null;
}
private String reqNamespace;
private String respNamespace;
/**
* For rpclit gives namespace value on soapbinding:body@namespace
*
* @return non-null for rpclit and null for doclit
* @see RuntimeModeler#processRpcMethod(JavaMethodImpl, String, String, Method)
*/
@Override
public String getRequestNamespace(){
return (reqNamespace != null)?reqNamespace:name.getNamespaceURI();
}
public void setRequestNamespace(String ns){
reqNamespace = ns;
}
/**
* For rpclit gives namespace value on soapbinding:body@namespace
*
* @return non-null for rpclit and null for doclit
* @see RuntimeModeler#processRpcMethod(JavaMethodImpl, String, String, Method)
*/
@Override
public String getResponseNamespace(){
return (respNamespace!=null)?respNamespace:name.getNamespaceURI();
}
public void setResponseNamespace(String ns){
respNamespace = ns;
}
EditableWSDLBoundPortType getOwner(){
return owner;
}
private QName requestPayloadName;
private QName responsePayloadName;
private boolean emptyRequestPayload;
private boolean emptyResponsePayload;
private Map<QName, ? extends EditableWSDLMessage> messages;
public void freeze(EditableWSDLModel parent) {
messages = parent.getMessages();
operation = owner.getPortType().get(name.getLocalPart());
for(EditableWSDLBoundFault bf : wsdlBoundFaults){
bf.freeze(this);
}
}
public void setAnonymous(ANONYMOUS anonymous) {
this.anonymous = anonymous;
}
/**
* @inheritDoc
*/
@Override
public ANONYMOUS getAnonymous() {
return anonymous;
}
}

View File

@@ -0,0 +1,212 @@
/*
* 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.model.wsdl;
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.api.model.ParameterBinding;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundPortType;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLBoundOperation;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLBoundPortType;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLModel;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLPortType;
import com.sun.xml.internal.ws.resources.ClientMessages;
import com.sun.xml.internal.ws.util.QNameMap;
import com.sun.xml.internal.ws.util.exception.LocatableWebServiceException;
import javax.jws.WebParam.Mode;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
import javax.xml.ws.soap.MTOMFeature;
/**
* Implementation of {@link WSDLBoundPortType}
*
* @author Vivek Pandey
*/
public final class WSDLBoundPortTypeImpl extends AbstractFeaturedObjectImpl implements EditableWSDLBoundPortType {
private final QName name;
private final QName portTypeName;
private EditableWSDLPortType portType;
private BindingID bindingId;
private final @NotNull EditableWSDLModel owner;
private final QNameMap<EditableWSDLBoundOperation> bindingOperations = new QNameMap<EditableWSDLBoundOperation>();
/**
* Operations keyed by the payload tag name.
*/
private QNameMap<EditableWSDLBoundOperation> payloadMap;
/**
* {@link #payloadMap} doesn't allow null key, so we store the value for it here.
*/
private EditableWSDLBoundOperation emptyPayloadOperation;
public WSDLBoundPortTypeImpl(XMLStreamReader xsr,@NotNull EditableWSDLModel owner, QName name, QName portTypeName) {
super(xsr);
this.owner = owner;
this.name = name;
this.portTypeName = portTypeName;
owner.addBinding(this);
}
public QName getName() {
return name;
}
public @NotNull EditableWSDLModel getOwner() {
return owner;
}
public EditableWSDLBoundOperation get(QName operationName) {
return bindingOperations.get(operationName);
}
/**
* Populates the Map that holds operation name as key and {@link WSDLBoundOperation} as the value.
*
* @param opName Must be non-null
* @param ptOp Must be non-null
* @throws NullPointerException if either opName or ptOp is null
*/
public void put(QName opName, EditableWSDLBoundOperation ptOp) {
bindingOperations.put(opName,ptOp);
}
public QName getPortTypeName() {
return portTypeName;
}
public EditableWSDLPortType getPortType() {
return portType;
}
public Iterable<EditableWSDLBoundOperation> getBindingOperations() {
return bindingOperations.values();
}
public BindingID getBindingId() {
//Should the default be SOAP1.1/HTTP binding? For now lets keep it for
//JBI bug 6509800
return (bindingId==null)?BindingID.SOAP11_HTTP:bindingId;
}
public void setBindingId(BindingID bindingId) {
this.bindingId = bindingId;
}
/**
* sets whether the {@link WSDLBoundPortType} is rpc or lit
*/
private Style style = Style.DOCUMENT;
public void setStyle(Style style){
this.style = style;
}
public SOAPBinding.Style getStyle() {
return style;
}
public boolean isRpcLit(){
return Style.RPC==style;
}
public boolean isDoclit(){
return Style.DOCUMENT==style;
}
/**
* Gets the {@link ParameterBinding} for a given operation, part name and the direction - IN/OUT
*
* @param operation wsdl:operation@name value. Must be non-null.
* @param part wsdl:part@name such as value of soap:header@part. Must be non-null.
* @param mode {@link Mode#IN} or {@link Mode#OUT}. Must be non-null.
* @return null if the binding could not be resolved for the part.
*/
public ParameterBinding getBinding(QName operation, String part, Mode mode) {
EditableWSDLBoundOperation op = get(operation);
if (op == null) {
//TODO throw exception
return null;
}
if ((Mode.IN == mode) || (Mode.INOUT == mode))
return op.getInputBinding(part);
else
return op.getOutputBinding(part);
}
public EditableWSDLBoundOperation getOperation(String namespaceUri, String localName) {
if(namespaceUri==null && localName == null)
return emptyPayloadOperation;
else{
return payloadMap.get((namespaceUri==null)?"":namespaceUri,localName);
}
}
public void freeze() {
portType = owner.getPortType(portTypeName);
if(portType == null){
throw new LocatableWebServiceException(
ClientMessages.UNDEFINED_PORT_TYPE(portTypeName), getLocation());
}
portType.freeze();
for (EditableWSDLBoundOperation op : bindingOperations.values()) {
op.freeze(owner);
}
freezePayloadMap();
owner.finalizeRpcLitBinding(this);
}
private void freezePayloadMap() {
if(style== Style.RPC) {
payloadMap = new QNameMap<EditableWSDLBoundOperation>();
for(EditableWSDLBoundOperation op : bindingOperations.values()){
payloadMap.put(op.getRequestPayloadName(), op);
}
} else {
payloadMap = new QNameMap<EditableWSDLBoundOperation>();
// For doclit The tag will be the operation that has the same input part descriptor value
for(EditableWSDLBoundOperation op : bindingOperations.values()){
QName name = op.getRequestPayloadName();
if(name == null){
//empty payload
emptyPayloadOperation = op;
continue;
}
payloadMap.put(name, op);
}
}
}
}

View File

@@ -0,0 +1,62 @@
/*
* 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.model.wsdl;
import com.sun.xml.internal.ws.api.model.SEIModel;
import javax.xml.namespace.QName;
/**
* Replacement for {@link WSDLPortProperties} for when elements from the WSDL are known,
* but the full WSDL is not available.
*
*/
public final class WSDLDirectProperties extends WSDLProperties {
private final QName serviceName;
private final QName portName;
public WSDLDirectProperties(QName serviceName, QName portName) {
this(serviceName, portName, null);
}
public WSDLDirectProperties(QName serviceName, QName portName, SEIModel seiModel) {
super(seiModel);
this.serviceName = serviceName;
this.portName = portName;
}
public QName getWSDLService() {
return serviceName;
}
public QName getWSDLPort() {
return portName;
}
public QName getWSDLPortType() {
return null;
}
}

View File

@@ -0,0 +1,93 @@
/*
* 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.model.wsdl;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLFault;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLMessage;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLModel;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLOperation;
import com.sun.istack.internal.NotNull;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
/**
* @author Vivek Pandey
*/
public final class WSDLFaultImpl extends AbstractExtensibleImpl implements EditableWSDLFault {
private final String name;
private final QName messageName;
private EditableWSDLMessage message;
private EditableWSDLOperation operation;
private String action = "";
private boolean defaultAction = true;
public WSDLFaultImpl(XMLStreamReader xsr, String name, QName messageName, EditableWSDLOperation operation) {
super(xsr);
this.name = name;
this.messageName = messageName;
this.operation = operation;
}
public String getName() {
return name;
}
public EditableWSDLMessage getMessage() {
return message;
}
@NotNull
public EditableWSDLOperation getOperation() {
return operation;
}
@NotNull
public QName getQName() {
return new QName(operation.getName().getNamespaceURI(), name);
}
@NotNull
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public boolean isDefaultAction() {
return defaultAction;
}
public void setDefaultAction(boolean defaultAction) {
this.defaultAction = defaultAction;
}
public void freeze(EditableWSDLModel root){
message = root.getMessage(messageName);
}
}

View File

@@ -0,0 +1,94 @@
/*
* 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.model.wsdl;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLInput;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLMessage;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLModel;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLOperation;
import com.sun.istack.internal.NotNull;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
/**
* @author Vivek Pandey
*/
public final class WSDLInputImpl extends AbstractExtensibleImpl implements EditableWSDLInput {
private String name;
private QName messageName;
private EditableWSDLOperation operation;
private EditableWSDLMessage message;
private String action;
private boolean defaultAction = true;
public WSDLInputImpl(XMLStreamReader xsr,String name, QName messageName, EditableWSDLOperation operation) {
super(xsr);
this.name = name;
this.messageName = messageName;
this.operation = operation;
}
public String getName() {
if(name != null)
return name;
return (operation.isOneWay())?operation.getName().getLocalPart():operation.getName().getLocalPart()+"Request";
}
public EditableWSDLMessage getMessage() {
return message;
}
public String getAction() {
return action;
}
@NotNull
public EditableWSDLOperation getOperation() {
return operation;
}
public QName getQName() {
return new QName(operation.getName().getNamespaceURI(), getName());
}
public void setAction(String action) {
this.action = action;
}
public boolean isDefaultAction() {
return defaultAction;
}
public void setDefaultAction(boolean defaultAction) {
this.defaultAction = defaultAction;
}
public void freeze(EditableWSDLModel parent) {
message = parent.getMessage(messageName);
}
}

View File

@@ -0,0 +1,64 @@
/*
* 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.model.wsdl;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLMessage;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLPart;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
import java.util.ArrayList;
/**
* Provides abstraction for wsdl:message
* @author Vivek Pandey
*/
public final class WSDLMessageImpl extends AbstractExtensibleImpl implements EditableWSDLMessage {
private final QName name;
private final ArrayList<EditableWSDLPart> parts;
/**
* @param name wsdl:message name attribute value
*/
public WSDLMessageImpl(XMLStreamReader xsr,QName name) {
super(xsr);
this.name = name;
this.parts = new ArrayList<EditableWSDLPart>();
}
public QName getName() {
return name;
}
public void add(EditableWSDLPart part){
parts.add(part);
}
public Iterable<EditableWSDLPart> parts(){
return parts;
}
}

View File

@@ -0,0 +1,233 @@
/*
* 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.model.wsdl;
import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.ws.api.model.ParameterBinding;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLMessage;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLModel;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLOperation;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPortType;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLBoundOperation;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLBoundPortType;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLMessage;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLModel;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLPart;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLPort;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLPortType;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLService;
import com.sun.xml.internal.ws.policy.PolicyMap;
import javax.jws.WebParam.Mode;
import javax.xml.namespace.QName;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* Implementation of {@link WSDLModel}
*
* @author Vivek Pandey
*/
public final class WSDLModelImpl extends AbstractExtensibleImpl implements EditableWSDLModel {
private final Map<QName, EditableWSDLMessage> messages = new HashMap<QName, EditableWSDLMessage>();
private final Map<QName, EditableWSDLPortType> portTypes = new HashMap<QName, EditableWSDLPortType>();
private final Map<QName, EditableWSDLBoundPortType> bindings = new HashMap<QName, EditableWSDLBoundPortType>();
private final Map<QName, EditableWSDLService> services = new LinkedHashMap<QName, EditableWSDLService>();
private PolicyMap policyMap;
private final Map<QName, EditableWSDLBoundPortType> unmBindings
= Collections.<QName, EditableWSDLBoundPortType>unmodifiableMap(bindings);
public WSDLModelImpl(@NotNull String systemId) {
super(systemId,-1);
}
/**
* To create {@link WSDLModelImpl} from WSDL that doesn't have a system ID.
*/
public WSDLModelImpl() {
super(null,-1);
}
public void addMessage(EditableWSDLMessage msg){
messages.put(msg.getName(), msg);
}
public EditableWSDLMessage getMessage(QName name){
return messages.get(name);
}
public void addPortType(EditableWSDLPortType pt){
portTypes.put(pt.getName(), pt);
}
public EditableWSDLPortType getPortType(QName name){
return portTypes.get(name);
}
public void addBinding(EditableWSDLBoundPortType boundPortType){
assert !bindings.containsValue(boundPortType);
bindings.put(boundPortType.getName(), boundPortType);
}
public EditableWSDLBoundPortType getBinding(QName name){
return bindings.get(name);
}
public void addService(EditableWSDLService svc){
services.put(svc.getName(), svc);
}
public EditableWSDLService getService(QName name){
return services.get(name);
}
public Map<QName, EditableWSDLMessage> getMessages() {
return messages;
}
public @NotNull Map<QName, EditableWSDLPortType> getPortTypes() {
return portTypes;
}
public @NotNull Map<QName, ? extends EditableWSDLBoundPortType> getBindings() {
return unmBindings;
}
public @NotNull Map<QName, EditableWSDLService> getServices(){
return services;
}
/**
* Returns the first service QName from insertion order
*/
public QName getFirstServiceName(){
if(services.isEmpty())
return null;
return services.values().iterator().next().getName();
}
/**
*
* @param serviceName non-null service QName
* @param portName non-null port QName
* @return
* WSDLBoundOperation on success otherwise null. throws NPE if any of the parameters null
*/
public EditableWSDLBoundPortType getBinding(QName serviceName, QName portName){
EditableWSDLService service = services.get(serviceName);
if(service != null){
EditableWSDLPort port = service.get(portName);
if(port != null)
return port.getBinding();
}
return null;
}
public void finalizeRpcLitBinding(EditableWSDLBoundPortType boundPortType){
assert(boundPortType != null);
QName portTypeName = boundPortType.getPortTypeName();
if(portTypeName == null)
return;
WSDLPortType pt = portTypes.get(portTypeName);
if(pt == null)
return;
for (EditableWSDLBoundOperation bop : boundPortType.getBindingOperations()) {
WSDLOperation pto = pt.get(bop.getName().getLocalPart());
WSDLMessage inMsgName = pto.getInput().getMessage();
if(inMsgName == null)
continue;
EditableWSDLMessage inMsg = messages.get(inMsgName.getName());
int bodyindex = 0;
if(inMsg != null){
for(EditableWSDLPart part:inMsg.parts()){
String name = part.getName();
ParameterBinding pb = bop.getInputBinding(name);
if(pb.isBody()){
part.setIndex(bodyindex++);
part.setBinding(pb);
bop.addPart(part, Mode.IN);
}
}
}
bodyindex=0;
if(pto.isOneWay())
continue;
WSDLMessage outMsgName = pto.getOutput().getMessage();
if(outMsgName == null)
continue;
EditableWSDLMessage outMsg = messages.get(outMsgName.getName());
if(outMsg!= null){
for(EditableWSDLPart part:outMsg.parts()){
String name = part.getName();
ParameterBinding pb = bop.getOutputBinding(name);
if(pb.isBody()){
part.setIndex(bodyindex++);
part.setBinding(pb);
bop.addPart(part, Mode.OUT);
}
}
}
}
}
/**
* Gives the PolicyMap associated with the WSDLModel
*
* @return PolicyMap
*/
public PolicyMap getPolicyMap() {
return policyMap;
}
/**
* Set PolicyMap for the WSDLModel.
* @param policyMap
*/
public void setPolicyMap(PolicyMap policyMap) {
this.policyMap = policyMap;
}
/**
* Invoked at the end of the model construction to fix up references, etc.
*/
public void freeze() {
for (EditableWSDLService service : services.values()) {
service.freeze(this);
}
for (EditableWSDLBoundPortType bp : bindings.values()) {
bp.freeze();
}
// Enforce freeze all the portTypes referenced by this endpoints, see Bug8966673 for detail
for (EditableWSDLPortType pt : portTypes.values()) {
pt.freeze();
}
}
}

View File

@@ -0,0 +1,139 @@
/*
* 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.model.wsdl;
import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLOperation;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLFault;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLInput;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLMessage;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLModel;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLOperation;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLOutput;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLPart;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLPortType;
import com.sun.xml.internal.ws.util.QNameMap;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
import java.util.ArrayList;
import java.util.List;
/**
* Implementaiton of {@link WSDLOperation}
*
* @author Vivek Pandey
*/
public final class WSDLOperationImpl extends AbstractExtensibleImpl implements EditableWSDLOperation {
private final QName name;
private String parameterOrder;
private EditableWSDLInput input;
private EditableWSDLOutput output;
private final List<EditableWSDLFault> faults;
private final QNameMap<EditableWSDLFault> faultMap;
protected Iterable<EditableWSDLMessage> messages;
private final EditableWSDLPortType owner;
public WSDLOperationImpl(XMLStreamReader xsr, EditableWSDLPortType owner, QName name) {
super(xsr);
this.name = name;
this.faults = new ArrayList<EditableWSDLFault>();
this.faultMap = new QNameMap<EditableWSDLFault>();
this.owner = owner;
}
public QName getName() {
return name;
}
public String getParameterOrder() {
return parameterOrder;
}
public void setParameterOrder(String parameterOrder) {
this.parameterOrder = parameterOrder;
}
public EditableWSDLInput getInput() {
return input;
}
public void setInput(EditableWSDLInput input) {
this.input = input;
}
public EditableWSDLOutput getOutput() {
return output;
}
public boolean isOneWay() {
return output == null;
}
public void setOutput(EditableWSDLOutput output) {
this.output = output;
}
public Iterable<EditableWSDLFault> getFaults() {
return faults;
}
public EditableWSDLFault getFault(QName faultDetailName) {
EditableWSDLFault fault = faultMap.get(faultDetailName);
if(fault != null)
return fault;
for(EditableWSDLFault fi : faults){
assert fi.getMessage().parts().iterator().hasNext();
EditableWSDLPart part = fi.getMessage().parts().iterator().next();
if(part.getDescriptor().name().equals(faultDetailName)){
faultMap.put(faultDetailName, fi);
return fi;
}
}
return null;
}
@NotNull
public QName getPortTypeName() {
return owner.getName();
}
public void addFault(EditableWSDLFault fault) {
faults.add(fault);
}
public void freeze(EditableWSDLModel root) {
assert input != null;
input.freeze(root);
if(output != null)
output.freeze(root);
for(EditableWSDLFault fault : faults){
fault.freeze(root);
}
}
}

View File

@@ -0,0 +1,92 @@
/*
* 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.model.wsdl;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLMessage;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLModel;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLOperation;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLOutput;
import com.sun.istack.internal.NotNull;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
/**
* @author Vivek Pandey
*/
public final class WSDLOutputImpl extends AbstractExtensibleImpl implements EditableWSDLOutput {
private String name;
private QName messageName;
private EditableWSDLOperation operation;
private EditableWSDLMessage message;
private String action;
private boolean defaultAction = true;
public WSDLOutputImpl(XMLStreamReader xsr,String name, QName messageName, EditableWSDLOperation operation) {
super(xsr);
this.name = name;
this.messageName = messageName;
this.operation = operation;
}
public String getName() {
return (name == null)?operation.getName().getLocalPart()+"Response":name;
}
public EditableWSDLMessage getMessage() {
return message;
}
public String getAction() {
return action;
}
public boolean isDefaultAction() {
return defaultAction;
}
public void setDefaultAction(boolean defaultAction) {
this.defaultAction = defaultAction;
}
@NotNull
public EditableWSDLOperation getOperation() {
return operation;
}
@NotNull
public QName getQName() {
return new QName(operation.getName().getNamespaceURI(), getName());
}
public void setAction(String action) {
this.action = action;
}
public void freeze(EditableWSDLModel root) {
message = root.getMessage(messageName);
}
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.model.wsdl;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLDescriptorKind;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPartDescriptor;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
/**
* @author Vivek Pandey
*/
public final class WSDLPartDescriptorImpl extends AbstractObjectImpl implements WSDLPartDescriptor {
private QName name;
private WSDLDescriptorKind type;
public WSDLPartDescriptorImpl(XMLStreamReader xsr,QName name, WSDLDescriptorKind kind) {
super(xsr);
this.name = name;
this.type = kind;
}
public QName name() {
return name;
}
public WSDLDescriptorKind type() {
return type;
}
}

View File

@@ -0,0 +1,79 @@
/*
* 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.model.wsdl;
import com.sun.xml.internal.ws.api.model.ParameterBinding;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPart;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPartDescriptor;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLPart;
import javax.xml.stream.XMLStreamReader;
/**
* Implementation of {@link WSDLPart}
*
* @author Vivek Pandey
*/
public final class WSDLPartImpl extends AbstractObjectImpl implements EditableWSDLPart {
private final String name;
private ParameterBinding binding;
private int index;
private final WSDLPartDescriptor descriptor;
public WSDLPartImpl(XMLStreamReader xsr, String partName, int index, WSDLPartDescriptor descriptor) {
super(xsr);
this.name = partName;
this.binding = ParameterBinding.UNBOUND;
this.index = index;
this.descriptor = descriptor;
}
public String getName() {
return name;
}
public ParameterBinding getBinding() {
return binding;
}
public void setBinding(ParameterBinding binding) {
this.binding = binding;
}
public int getIndex() {
return index;
}
//need to set the index in case of rpclit to reorder the body parts
public void setIndex(int index){
this.index = index;
}
public WSDLPartDescriptor getDescriptor() {
return descriptor;
}
}

View File

@@ -0,0 +1,125 @@
/*
* 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.model.wsdl;
import java.util.List;
import com.sun.xml.internal.ws.api.EndpointAddress;
import com.sun.xml.internal.ws.api.SOAPVersion;
import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLBoundPortType;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLModel;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLPort;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLService;
import com.sun.xml.internal.ws.resources.ClientMessages;
import com.sun.xml.internal.ws.util.exception.LocatableWebServiceException;
import com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser;
import com.sun.xml.internal.ws.binding.WebServiceFeatureList;
import com.sun.istack.internal.Nullable;
import com.sun.istack.internal.NotNull;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
/**
* Implementation of {@link WSDLPort}
*
* @author Vivek Pandey
*/
public final class WSDLPortImpl extends AbstractFeaturedObjectImpl implements EditableWSDLPort {
private final QName name;
private EndpointAddress address;
private final QName bindingName;
private final EditableWSDLService owner;
private WSEndpointReference epr;
/**
* To be set after the WSDL parsing is complete.
*/
private EditableWSDLBoundPortType boundPortType;
public WSDLPortImpl(XMLStreamReader xsr, EditableWSDLService owner, QName name, QName binding) {
super(xsr);
this.owner = owner;
this.name = name;
this.bindingName = binding;
}
public QName getName() {
return name;
}
public QName getBindingName() {
return bindingName;
}
public EndpointAddress getAddress() {
return address;
}
public EditableWSDLService getOwner() {
return owner;
}
/**
* Only meant for {@link RuntimeWSDLParser} to call.
*/
public void setAddress(EndpointAddress address) {
assert address!=null;
this.address = address;
}
/**
* Only meant for {@link RuntimeWSDLParser} to call.
*/
public void setEPR(@NotNull WSEndpointReference epr) {
assert epr!=null;
this.addExtension(epr);
this.epr = epr;
}
public @Nullable WSEndpointReference getEPR() {
return epr;
}
public EditableWSDLBoundPortType getBinding() {
return boundPortType;
}
@SuppressWarnings("unchecked")
public void freeze(EditableWSDLModel root) {
boundPortType = root.getBinding(bindingName);
if(boundPortType==null) {
throw new LocatableWebServiceException(
ClientMessages.UNDEFINED_BINDING(bindingName), getLocation());
}
if(features == null)
features = new WebServiceFeatureList();
features.setParentFeaturedObject(boundPortType);
notUnderstoodExtensions.addAll((List<UnknownWSDLExtension>)boundPortType.getNotUnderstoodExtensions());
}
}

View File

@@ -0,0 +1,66 @@
/*
* 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.model.wsdl;
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;
import com.sun.xml.internal.ws.api.model.SEIModel;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
import javax.xml.namespace.QName;
import javax.xml.ws.handler.MessageContext;
/**
* Properties exposed from {@link WSDLPort} for {@link MessageContext}.
* Donot add this satellite if {@link WSDLPort} is null.
*
* @author Jitendra Kotamraju
*/
public final class WSDLPortProperties extends WSDLProperties {
private final @NotNull WSDLPort port;
public WSDLPortProperties(@NotNull WSDLPort port) {
this(port, null);
}
public WSDLPortProperties(@NotNull WSDLPort port, @Nullable SEIModel seiModel) {
super(seiModel);
this.port = port;
}
public QName getWSDLService() {
return port.getOwner().getName();
}
public QName getWSDLPort() {
return port.getName();
}
public QName getWSDLPortType() {
return port.getBinding().getPortTypeName();
}
}

View File

@@ -0,0 +1,88 @@
/*
* 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.model.wsdl;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLOperation;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPortType;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLModel;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLOperation;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLPortType;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
import java.util.Hashtable;
import java.util.Map;
/**
* Provides implementation of {@link WSDLPortType}
*
* @author Vivek Pandey
*/
public final class WSDLPortTypeImpl extends AbstractExtensibleImpl implements EditableWSDLPortType {
private QName name;
private final Map<String, EditableWSDLOperation> portTypeOperations;
private EditableWSDLModel owner;
public WSDLPortTypeImpl(XMLStreamReader xsr, EditableWSDLModel owner, QName name) {
super(xsr);
this.name = name;
this.owner = owner;
portTypeOperations = new Hashtable<String, EditableWSDLOperation>();
}
public QName getName() {
return name;
}
public EditableWSDLOperation get(String operationName) {
return portTypeOperations.get(operationName);
}
public Iterable<EditableWSDLOperation> getOperations() {
return portTypeOperations.values();
}
/**
* Populates the Map that holds operation name as key and {@link WSDLOperation} as the value.
* @param opName Must be non-null
* @param ptOp Must be non-null
* @throws NullPointerException if either opName or ptOp is null
*/
public void put(String opName, EditableWSDLOperation ptOp){
portTypeOperations.put(opName, ptOp);
}
EditableWSDLModel getOwner(){
return owner;
}
public void freeze() {
for(EditableWSDLOperation op : portTypeOperations.values()){
op.freeze(owner);
}
}
}

View File

@@ -0,0 +1,77 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.model.wsdl;
import com.oracle.webservices.internal.api.message.BasePropertySet;
import com.sun.istack.internal.Nullable;
import com.sun.xml.internal.ws.api.model.SEIModel;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
import javax.xml.namespace.QName;
import javax.xml.ws.handler.MessageContext;
import org.xml.sax.InputSource;
/**
* Properties exposed from {@link WSDLPort} for {@link MessageContext}.
* Donot add this satellite if {@link WSDLPort} is null.
*
* @author Jitendra Kotamraju
*/
public abstract class WSDLProperties extends BasePropertySet {
private static final PropertyMap model;
static {
model = parse(WSDLProperties.class);
}
private final @Nullable SEIModel seiModel;
protected WSDLProperties(@Nullable SEIModel seiModel) {
this.seiModel = seiModel;
}
@Property(MessageContext.WSDL_SERVICE)
public abstract QName getWSDLService();
@Property(MessageContext.WSDL_PORT)
public abstract QName getWSDLPort();
@Property(MessageContext.WSDL_INTERFACE)
public abstract QName getWSDLPortType();
@Property(MessageContext.WSDL_DESCRIPTION)
public InputSource getWSDLDescription() {
return seiModel != null ? new InputSource(seiModel.getWSDLLocation()) : null;
}
@Override
protected PropertyMap getPropertyMap() {
return model;
}
}

View File

@@ -0,0 +1,115 @@
/*
* 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.model.wsdl;
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLService;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLModel;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLPort;
import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLService;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* Implementation of {@link WSDLService}
*
* @author Vivek Pandey
*/
public final class WSDLServiceImpl extends AbstractExtensibleImpl implements EditableWSDLService {
private final QName name;
private final Map<QName, EditableWSDLPort> ports;
private final EditableWSDLModel parent;
public WSDLServiceImpl(XMLStreamReader xsr, EditableWSDLModel parent, QName name) {
super(xsr);
this.parent = parent;
this.name = name;
ports = new LinkedHashMap<QName, EditableWSDLPort>();
}
public @NotNull
EditableWSDLModel getParent() {
return parent;
}
public QName getName() {
return name;
}
public EditableWSDLPort get(QName portName) {
return ports.get(portName);
}
public EditableWSDLPort getFirstPort() {
if(ports.isEmpty())
return null;
else
return ports.values().iterator().next();
}
public Iterable<EditableWSDLPort> getPorts(){
return ports.values();
}
/**
* gets the first port in this service which matches the portType
*/
public @Nullable
EditableWSDLPort getMatchingPort(QName portTypeName){
for(EditableWSDLPort port : getPorts()){
QName ptName = port.getBinding().getPortTypeName();
assert (ptName != null);
if(ptName.equals(portTypeName))
return port;
}
return null;
}
/**
* Populates the Map that holds port name as key and {@link WSDLPort} as the value.
*
* @param portName Must be non-null
* @param port Must be non-null
* @throws NullPointerException if either opName or ptOp is null
*/
public void put(QName portName, EditableWSDLPort port) {
if (portName == null || port == null)
throw new NullPointerException();
ports.put(portName, port);
}
public void freeze(EditableWSDLModel root) {
for (EditableWSDLPort port : ports.values()) {
port.freeze(root);
}
}
}