jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/model/RuntimeModeler.java
changeset 27837 86d4f46e622a
parent 25871 b80b84e87032
child 42124 640a383428fb
equal deleted inserted replaced
27581:9fffb959eb41 27837:86d4f46e622a
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    47 import com.sun.xml.internal.ws.spi.db.BindingContext;
    47 import com.sun.xml.internal.ws.spi.db.BindingContext;
    48 import com.sun.xml.internal.ws.spi.db.TypeInfo;
    48 import com.sun.xml.internal.ws.spi.db.TypeInfo;
    49 import com.sun.xml.internal.ws.spi.db.WrapperComposite;
    49 import com.sun.xml.internal.ws.spi.db.WrapperComposite;
    50 
    50 
    51 import static com.sun.xml.internal.ws.binding.WebServiceFeatureList.getSoapVersion;
    51 import static com.sun.xml.internal.ws.binding.WebServiceFeatureList.getSoapVersion;
       
    52 import static com.sun.xml.internal.ws.model.Utils.REFLECTION_NAVIGATOR;
    52 
    53 
    53 import javax.jws.*;
    54 import javax.jws.*;
    54 import javax.jws.WebParam.Mode;
    55 import javax.jws.WebParam.Mode;
    55 import javax.jws.soap.SOAPBinding;
    56 import javax.jws.soap.SOAPBinding;
    56 import javax.jws.soap.SOAPBinding.Style;
    57 import javax.jws.soap.SOAPBinding.Style;
   379         if (o!= null && o instanceof Boolean) decapitalizeExceptionBeanProperties = (Boolean) o;
   380         if (o!= null && o instanceof Boolean) decapitalizeExceptionBeanProperties = (Boolean) o;
   380         ClassLoader loader =  (classLoader == null) ? Thread.currentThread().getContextClassLoader() : classLoader;
   381         ClassLoader loader =  (classLoader == null) ? Thread.currentThread().getContextClassLoader() : classLoader;
   381         try {
   382         try {
   382             return loader.loadClass(className);
   383             return loader.loadClass(className);
   383         } catch (ClassNotFoundException e) {
   384         } catch (ClassNotFoundException e) {
       
   385             if (noWrapperGen()) return exception;
   384             logger.fine("Dynamically creating exception bean Class " + className);
   386             logger.fine("Dynamically creating exception bean Class " + className);
   385             return WrapperBeanGenerator.createExceptionBean(className, exception, targetNamespace, name, namespace, loader, decapitalizeExceptionBeanProperties);
   387             return WrapperBeanGenerator.createExceptionBean(className, exception, targetNamespace, name, namespace, loader, decapitalizeExceptionBeanProperties);
   386         }
   388         }
   387     }
   389     }
   388 
   390 
   883 
   885 
   884             boolean isHolder = HOLDER_CLASS.isAssignableFrom(clazzType);
   886             boolean isHolder = HOLDER_CLASS.isAssignableFrom(clazzType);
   885             //set the actual type argument of Holder in the TypeReference
   887             //set the actual type argument of Holder in the TypeReference
   886             if (isHolder) {
   888             if (isHolder) {
   887                 if(clazzType==Holder.class){
   889                 if(clazzType==Holder.class){
   888                     clazzType = (Class) Utils.REFLECTION_NAVIGATOR.erasure(((ParameterizedType)genericParameterTypes[pos]).getActualTypeArguments()[0]);
   890                     clazzType = erasure(((ParameterizedType)genericParameterTypes[pos]).getActualTypeArguments()[0]);
   889                 }
   891                 }
   890             }
   892             }
   891             Mode paramMode = isHolder ? Mode.INOUT : Mode.IN;
   893             Mode paramMode = isHolder ? Mode.INOUT : Mode.IN;
   892             WebParam webParam = null;
   894             WebParam webParam = null;
   893             xmlElem = null;
   895             xmlElem = null;
  1098 
  1100 
  1099             boolean isHolder = HOLDER_CLASS.isAssignableFrom(clazzType);
  1101             boolean isHolder = HOLDER_CLASS.isAssignableFrom(clazzType);
  1100             //set the actual type argument of Holder in the TypeReference
  1102             //set the actual type argument of Holder in the TypeReference
  1101             if (isHolder) {
  1103             if (isHolder) {
  1102                 if (clazzType==Holder.class)
  1104                 if (clazzType==Holder.class)
  1103                     clazzType = (Class) Utils.REFLECTION_NAVIGATOR.erasure(((ParameterizedType)genericParameterTypes[pos]).getActualTypeArguments()[0]);
  1105                     clazzType = erasure(((ParameterizedType)genericParameterTypes[pos]).getActualTypeArguments()[0]);
  1104             }
  1106             }
  1105             Mode paramMode = isHolder ? Mode.INOUT : Mode.IN;
  1107             Mode paramMode = isHolder ? Mode.INOUT : Mode.IN;
  1106             for (Annotation annotation : pannotations[pos]) {
  1108             for (Annotation annotation : pannotations[pos]) {
  1107                 if (annotation.annotationType() == javax.jws.WebParam.class) {
  1109                 if (annotation.annotationType() == javax.jws.WebParam.class) {
  1108                     javax.jws.WebParam webParam = (javax.jws.WebParam) annotation;
  1110                     javax.jws.WebParam webParam = (javax.jws.WebParam) annotation;
  1208             //Exclude RuntimeException, RemoteException and Error etc
  1210             //Exclude RuntimeException, RemoteException and Error etc
  1209             if (!EXCEPTION_CLASS.isAssignableFrom(exception))
  1211             if (!EXCEPTION_CLASS.isAssignableFrom(exception))
  1210                 continue;
  1212                 continue;
  1211             if (RUNTIME_EXCEPTION_CLASS.isAssignableFrom(exception) || REMOTE_EXCEPTION_CLASS.isAssignableFrom(exception))
  1213             if (RUNTIME_EXCEPTION_CLASS.isAssignableFrom(exception) || REMOTE_EXCEPTION_CLASS.isAssignableFrom(exception))
  1212                 continue;
  1214                 continue;
  1213 
  1215             if (getAnnotation(exception, javax.xml.bind.annotation.XmlTransient.class) != null)
       
  1216                 continue;
  1214             Class exceptionBean;
  1217             Class exceptionBean;
  1215             Annotation[] anns;
  1218             Annotation[] anns;
  1216             WebFault webFault = getAnnotation(exception, WebFault.class);
  1219             WebFault webFault = getAnnotation(exception, WebFault.class);
  1217             Method faultInfoMethod = getWSDLExceptionFaultInfo(exception);
  1220             Method faultInfoMethod = getWSDLExceptionFaultInfo(exception);
  1218             ExceptionType exceptionType = ExceptionType.WSDLException;
  1221             ExceptionType exceptionType = ExceptionType.WSDLException;
  1244             QName faultName = new QName(namespace, name);
  1247             QName faultName = new QName(namespace, name);
  1245             TypeInfo typeRef = new TypeInfo(faultName, exceptionBean, anns);
  1248             TypeInfo typeRef = new TypeInfo(faultName, exceptionBean, anns);
  1246             CheckedExceptionImpl checkedException =
  1249             CheckedExceptionImpl checkedException =
  1247                 new CheckedExceptionImpl(javaMethod, exception, typeRef, exceptionType);
  1250                 new CheckedExceptionImpl(javaMethod, exception, typeRef, exceptionType);
  1248             checkedException.setMessageName(messageName);
  1251             checkedException.setMessageName(messageName);
       
  1252             checkedException.setFaultInfoGetter(faultInfoMethod);
  1249             for(FaultAction fa: faultActions) {
  1253             for(FaultAction fa: faultActions) {
  1250                 if(fa.className().equals(exception) && !fa.value().equals("")) {
  1254                 if(fa.className().equals(exception) && !fa.value().equals("")) {
  1251                     checkedException.setFaultAction(fa.value());
  1255                     checkedException.setFaultAction(fa.value());
  1252                     break;
  1256                     break;
  1253                 }
  1257                 }
  1344 
  1348 
  1345             boolean isHolder = HOLDER_CLASS.isAssignableFrom(clazzType);
  1349             boolean isHolder = HOLDER_CLASS.isAssignableFrom(clazzType);
  1346             //set the actual type argument of Holder in the TypeReference
  1350             //set the actual type argument of Holder in the TypeReference
  1347             if (isHolder) {
  1351             if (isHolder) {
  1348                 if (clazzType==Holder.class)
  1352                 if (clazzType==Holder.class)
  1349                     clazzType = (Class) Utils.REFLECTION_NAVIGATOR.erasure(((ParameterizedType)genericParameterTypes[pos]).getActualTypeArguments()[0]);
  1353                     clazzType = erasure(((ParameterizedType)genericParameterTypes[pos]).getActualTypeArguments()[0]);
  1350             }
  1354             }
  1351 
  1355 
  1352             Mode paramMode = isHolder ? Mode.INOUT : Mode.IN;
  1356             Mode paramMode = isHolder ? Mode.INOUT : Mode.IN;
  1353             for (Annotation annotation : pannotations[pos]) {
  1357             for (Annotation annotation : pannotations[pos]) {
  1354                 if (annotation.annotationType() == javax.jws.WebParam.class) {
  1358                 if (annotation.annotationType() == javax.jws.WebParam.class) {
  1432     }
  1436     }
  1433 
  1437 
  1434     private Class getAsyncReturnType(Method method, Class returnType) {
  1438     private Class getAsyncReturnType(Method method, Class returnType) {
  1435         if(Response.class.isAssignableFrom(returnType)){
  1439         if(Response.class.isAssignableFrom(returnType)){
  1436             Type ret = method.getGenericReturnType();
  1440             Type ret = method.getGenericReturnType();
  1437             return (Class) Utils.REFLECTION_NAVIGATOR.erasure(((ParameterizedType)ret).getActualTypeArguments()[0]);
  1441             return erasure(((ParameterizedType)ret).getActualTypeArguments()[0]);
  1438         }else{
  1442         }else{
  1439             Type[] types = method.getGenericParameterTypes();
  1443             Type[] types = method.getGenericParameterTypes();
  1440             Class[] params = method.getParameterTypes();
  1444             Class[] params = method.getParameterTypes();
  1441             int i = 0;
  1445             int i = 0;
  1442             for(Class cls : params){
  1446             for(Class cls : params){
  1443                 if(AsyncHandler.class.isAssignableFrom(cls)){
  1447                 if(AsyncHandler.class.isAssignableFrom(cls)){
  1444                     return (Class) Utils.REFLECTION_NAVIGATOR.erasure(((ParameterizedType)types[i]).getActualTypeArguments()[0]);
  1448                     return erasure(((ParameterizedType)types[i]).getActualTypeArguments()[0]);
  1445                 }
  1449                 }
  1446                 i++;
  1450                 i++;
  1447             }
  1451             }
  1448         }
  1452         }
  1449         return returnType;
  1453         return returnType;
  1731         }
  1735         }
  1732 
  1736 
  1733         return new QName(ns, localPart);
  1737         return new QName(ns, localPart);
  1734     }
  1738     }
  1735 
  1739 
  1736 
  1740     static public Class erasure(Type type) {
       
  1741         return (Class)REFLECTION_NAVIGATOR.erasure(type);
       
  1742     }
  1737 }
  1743 }