jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/model/RuntimeModeler.java
changeset 42124 640a383428fb
parent 27837 86d4f46e622a
child 42398 a05b6a285169
equal deleted inserted replaced
42002:3ee4e7827413 42124:640a383428fb
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2016, 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
    64 import java.lang.annotation.Annotation;
    64 import java.lang.annotation.Annotation;
    65 import java.lang.reflect.Method;
    65 import java.lang.reflect.Method;
    66 import java.lang.reflect.Modifier;
    66 import java.lang.reflect.Modifier;
    67 import java.lang.reflect.ParameterizedType;
    67 import java.lang.reflect.ParameterizedType;
    68 import java.lang.reflect.Type;
    68 import java.lang.reflect.Type;
    69 import java.rmi.RemoteException;
       
    70 import java.security.AccessController;
    69 import java.security.AccessController;
    71 import java.util.HashSet;
    70 import java.util.HashSet;
    72 import java.util.Map;
    71 import java.util.Map;
    73 import java.util.Set;
    72 import java.util.Set;
    74 import java.util.StringTokenizer;
    73 import java.util.StringTokenizer;
   113     public static final String RETURN               = "return";
   112     public static final String RETURN               = "return";
   114     public static final String BEAN                 = "Bean";
   113     public static final String BEAN                 = "Bean";
   115     public static final String SERVICE              = "Service";
   114     public static final String SERVICE              = "Service";
   116     public static final String PORT                 = "Port";
   115     public static final String PORT                 = "Port";
   117     public static final Class HOLDER_CLASS = Holder.class;
   116     public static final Class HOLDER_CLASS = Holder.class;
   118     public static final Class<RemoteException> REMOTE_EXCEPTION_CLASS = RemoteException.class;
   117     public static final String REMOTE_EXCEPTION_CLASS = "java.rmi.RemoteException";
   119     public static final Class<RuntimeException> RUNTIME_EXCEPTION_CLASS = RuntimeException.class;
   118     public static final Class<RuntimeException> RUNTIME_EXCEPTION_CLASS = RuntimeException.class;
   120     public static final Class<Exception> EXCEPTION_CLASS = Exception.class;
   119     public static final Class<Exception> EXCEPTION_CLASS = Exception.class;
   121     public static final String DecapitalizeExceptionBeanProperties = "com.sun.xml.internal.ws.api.model.DecapitalizeExceptionBeanProperties";
   120     public static final String DecapitalizeExceptionBeanProperties = "com.sun.xml.internal.ws.api.model.DecapitalizeExceptionBeanProperties";
   122     public static final String SuppressDocLitWrapperGeneration = "com.sun.xml.internal.ws.api.model.SuppressDocLitWrapperGeneration";
   121     public static final String SuppressDocLitWrapperGeneration = "com.sun.xml.internal.ws.api.model.SuppressDocLitWrapperGeneration";
   123     public static final String DocWrappeeNamespapceQualified = "com.sun.xml.internal.ws.api.model.DocWrappeeNamespapceQualified";
   122     public static final String DocWrappeeNamespapceQualified = "com.sun.xml.internal.ws.api.model.DocWrappeeNamespapceQualified";
   584      * @param exception
   583      * @param exception
   585      * @return
   584      * @return
   586      */
   585      */
   587     private boolean isServiceException(Class<?> exception) {
   586     private boolean isServiceException(Class<?> exception) {
   588         return EXCEPTION_CLASS.isAssignableFrom(exception) &&
   587         return EXCEPTION_CLASS.isAssignableFrom(exception) &&
   589                 !(RUNTIME_EXCEPTION_CLASS.isAssignableFrom(exception) || REMOTE_EXCEPTION_CLASS.isAssignableFrom(exception));
   588                 !(RUNTIME_EXCEPTION_CLASS.isAssignableFrom(exception) || isRemoteException(exception));
   590     }
   589     }
   591 
   590 
   592     /**
   591     /**
   593      * creates the runtime model for a method on the <code>portClass</code>
   592      * creates the runtime model for a method on the <code>portClass</code>
   594      * @param method the method to model
   593      * @param method the method to model
  1167                 if(!param.isOUT()){
  1166                 if(!param.isOUT()){
  1168                     WSDLPart p = getPart(new QName(targetNamespace,operationName), partName, Mode.IN);
  1167                     WSDLPart p = getPart(new QName(targetNamespace,operationName), partName, Mode.IN);
  1169                     if(p == null)
  1168                     if(p == null)
  1170                         reqRpcParams.put(reqRpcParams.size()+10000, param);
  1169                         reqRpcParams.put(reqRpcParams.size()+10000, param);
  1171                     else
  1170                     else
  1172                         reqRpcParams.put(p.getIndex(), param);
  1171                         reqRpcParams.put(param.getIndex(), param);
  1173                 }
  1172                 }
  1174 
  1173 
  1175                 if(!param.isIN()){
  1174                 if(!param.isIN()){
  1176                     if (isOneway) {
  1175                     if (isOneway) {
  1177                             throw new RuntimeModelerException("runtime.modeler.oneway.operation.no.out.parameters",
  1176                             throw new RuntimeModelerException("runtime.modeler.oneway.operation.no.out.parameters",
  1179                     }
  1178                     }
  1180                     WSDLPart p = getPart(new QName(targetNamespace,operationName), partName, Mode.OUT);
  1179                     WSDLPart p = getPart(new QName(targetNamespace,operationName), partName, Mode.OUT);
  1181                     if(p == null)
  1180                     if(p == null)
  1182                         resRpcParams.put(resRpcParams.size()+10000, param);
  1181                         resRpcParams.put(resRpcParams.size()+10000, param);
  1183                     else
  1182                     else
  1184                         resRpcParams.put(p.getIndex(), param);
  1183                         resRpcParams.put(param.getIndex(), param);
  1185                 }
  1184                 }
  1186             }else{
  1185             }else{
  1187                 javaMethod.addParameter(param);
  1186                 javaMethod.addParameter(param);
  1188             }
  1187             }
  1189         }
  1188         }
  1208         for (Class<?> exception : method.getExceptionTypes()) {
  1207         for (Class<?> exception : method.getExceptionTypes()) {
  1209 
  1208 
  1210             //Exclude RuntimeException, RemoteException and Error etc
  1209             //Exclude RuntimeException, RemoteException and Error etc
  1211             if (!EXCEPTION_CLASS.isAssignableFrom(exception))
  1210             if (!EXCEPTION_CLASS.isAssignableFrom(exception))
  1212                 continue;
  1211                 continue;
  1213             if (RUNTIME_EXCEPTION_CLASS.isAssignableFrom(exception) || REMOTE_EXCEPTION_CLASS.isAssignableFrom(exception))
  1212             if (RUNTIME_EXCEPTION_CLASS.isAssignableFrom(exception) || isRemoteException(exception))
  1214                 continue;
  1213                 continue;
  1215             if (getAnnotation(exception, javax.xml.bind.annotation.XmlTransient.class) != null)
  1214             if (getAnnotation(exception, javax.xml.bind.annotation.XmlTransient.class) != null)
  1216                 continue;
  1215                 continue;
  1217             Class exceptionBean;
  1216             Class exceptionBean;
  1218             Annotation[] anns;
  1217             Annotation[] anns;
  1644                 return bo.getPart(partName, mode);
  1643                 return bo.getPart(partName, mode);
  1645         }
  1644         }
  1646         return null;
  1645         return null;
  1647     }
  1646     }
  1648 
  1647 
       
  1648     /*
       
  1649      * Returns true if an exception is a java.rmi.RemoteException or its subtype.
       
  1650      *
       
  1651      * @param exception
       
  1652      * @return true if an exception is a java.rmi.RemoteException or its subtype,
       
  1653      *      false otherwise
       
  1654      */
       
  1655     private boolean isRemoteException(Class<?> exception) {
       
  1656         Class<?> c = exception;
       
  1657         while (c != null && !REMOTE_EXCEPTION_CLASS.equals(c.getName())) {
       
  1658             c = c.getSuperclass();
       
  1659         }
       
  1660         return c != null;
       
  1661     }
       
  1662 
  1649     private static Boolean getBooleanSystemProperty(final String prop) {
  1663     private static Boolean getBooleanSystemProperty(final String prop) {
  1650         return AccessController.doPrivileged(
  1664         return AccessController.doPrivileged(
  1651             new java.security.PrivilegedAction<Boolean>() {
  1665             new java.security.PrivilegedAction<Boolean>() {
  1652                 public Boolean run() {
  1666                 public Boolean run() {
  1653                     String value = System.getProperty(prop);
  1667                     String value = System.getProperty(prop);