Tue, 06 Mar 2012 16:09:35 -0800
7150322: Stop using drop source bundles in jaxws
Reviewed-by: darcy, ohrstrom
1 /*
2 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
26 package com.sun.xml.internal.ws.wsdl;
28 import com.sun.istack.internal.Nullable;
29 import com.sun.xml.internal.ws.api.WSBinding;
30 import com.sun.xml.internal.ws.api.model.JavaMethod;
31 import com.sun.xml.internal.ws.api.model.SEIModel;
32 import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
33 import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation;
34 import com.sun.xml.internal.ws.api.message.Packet;
35 import com.sun.xml.internal.ws.model.AbstractSEIModelImpl;
36 import com.sun.xml.internal.ws.model.JavaMethodImpl;
38 import javax.xml.namespace.QName;
39 import java.util.HashMap;
40 import java.util.Map;
42 /**
43 * An {@link WSDLOperationFinder} that uses SOAPAction as the key for dispatching.
44 * <p/>
45 * A map of all SOAPAction on the port and the corresponding WSDL operation QName
46 * is initialized in the constructor. The SOAPAction from the
47 * request {@link com.sun.xml.internal.ws.api.message.Packet} is used as the key to identify the associated wsdl operation.
48 *
49 * @author Jitendra Kotamraju
50 */
51 final class SOAPActionBasedOperationFinder extends WSDLOperationFinder {
52 private final Map<String, QName> methodHandlers;
54 public SOAPActionBasedOperationFinder(WSDLPort wsdlModel, WSBinding binding, @Nullable SEIModel seiModel) {
55 super(wsdlModel,binding,seiModel);
56 methodHandlers = new HashMap<String, QName>();
58 // Find if any SOAPAction repeat for operations
59 Map<String, Integer> unique = new HashMap<String, Integer>();
60 if (seiModel != null) {
61 for (JavaMethodImpl m : ((AbstractSEIModelImpl) seiModel).getJavaMethods()) {
62 String soapAction = m.getSOAPAction();
63 Integer count = unique.get(soapAction);
64 if (count == null) {
65 unique.put(soapAction, 1);
66 } else {
67 unique.put(soapAction, ++count);
68 }
69 }
71 for (JavaMethodImpl m : ((AbstractSEIModelImpl) seiModel).getJavaMethods()) {
72 String soapAction = m.getSOAPAction();
73 // Set up method handlers only for unique SOAPAction values so
74 // that dispatching happens consistently for a method
75 if (unique.get(soapAction) == 1) {
76 methodHandlers.put('"' + soapAction + '"', m.getOperationQName());
77 }
78 }
79 } else {
80 for(WSDLBoundOperation wsdlOp: wsdlModel.getBinding().getBindingOperations()) {
81 methodHandlers.put(wsdlOp.getSOAPAction(),wsdlOp.getName());
82 }
83 }
85 }
87 public QName getWSDLOperationQName(Packet request) {
88 return request.soapAction == null ? null : methodHandlers.get(request.soapAction);
89 }
90 }