Wed, 27 Apr 2016 01:27:09 +0800
Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/jaxws/
changeset: 657:d47a47f961ee
tag: jdk8u25-b17
1 /*
2 * Copyright (c) 1997, 2012, 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.tools.internal.ws.processor.modeler.annotation;
28 import com.sun.tools.internal.ws.processor.model.Model;
29 import com.sun.tools.internal.ws.processor.model.Operation;
30 import com.sun.tools.internal.ws.processor.model.Port;
31 import com.sun.tools.internal.ws.processor.model.Service;
32 import com.sun.tools.internal.ws.wsdl.document.soap.SOAPUse;
34 import javax.lang.model.element.ExecutableElement;
35 import javax.lang.model.element.Name;
36 import javax.lang.model.element.TypeElement;
37 import javax.lang.model.element.VariableElement;
38 import java.util.Collection;
39 import java.util.HashMap;
40 import java.util.Map;
43 /**
44 *
45 * @author dkohlert
46 */
47 public class AnnotationProcessorContext {
49 private Map<Name, SeiContext> seiContextMap = new HashMap<Name, SeiContext>();
50 private int round = 1;
51 private boolean modelCompleted = false;
53 public void addSeiContext(Name seiName, SeiContext seiContext) {
54 seiContextMap.put(seiName, seiContext);
55 }
57 public SeiContext getSeiContext(Name seiName) {
58 SeiContext context = seiContextMap.get(seiName);
59 if (context == null) {
60 context = new SeiContext();
61 addSeiContext(seiName, context);
62 }
63 return context;
64 }
66 public SeiContext getSeiContext(TypeElement d) {
67 return getSeiContext(d.getQualifiedName());
68 }
70 public Collection<SeiContext> getSeiContexts() {
71 return seiContextMap.values();
72 }
74 public int getRound() {
75 return round;
76 }
78 public void incrementRound() {
79 round++;
80 }
82 public static boolean isEncoded(Model model) {
83 if (model == null)
84 return false;
85 for (Service service : model.getServices()) {
86 for (Port port : service.getPorts()) {
87 for (Operation operation : port.getOperations()) {
88 if (operation.getUse() != null && operation.getUse().equals(SOAPUse.LITERAL))
89 return false;
90 }
91 }
92 }
93 return true;
94 }
96 public void setModelCompleted(boolean modelCompleted) {
97 this.modelCompleted = modelCompleted;
98 }
100 public boolean isModelCompleted() {
101 return modelCompleted;
102 }
104 public static class SeiContext {
106 private Map<String, WrapperInfo> reqOperationWrapperMap = new HashMap<String, WrapperInfo>();
107 private Map<String, WrapperInfo> resOperationWrapperMap = new HashMap<String, WrapperInfo>();
108 private Map<Name, FaultInfo> exceptionBeanMap = new HashMap<Name, FaultInfo>();
110 private Name seiImplName;
111 private boolean implementsSei;
112 private String namespaceUri;
114 public SeiContext() {};
116 /**
117 * @deprecated use empty constructor, seiName value is ignored
118 * @param seiName
119 */
120 public SeiContext(Name seiName) {};
122 public void setImplementsSei(boolean implementsSei) {
123 this.implementsSei = implementsSei;
124 }
126 public boolean getImplementsSei() {
127 return implementsSei;
128 }
130 public void setNamespaceUri(String namespaceUri) {
131 this.namespaceUri = namespaceUri;
132 }
134 public String getNamespaceUri() {
135 return namespaceUri;
136 }
138 public Name getSeiImplName() {
139 return seiImplName;
140 }
142 public void setSeiImplName(Name implName) {
143 seiImplName = implName;
144 }
146 public void setReqWrapperOperation(ExecutableElement method, WrapperInfo wrapperInfo) {
147 reqOperationWrapperMap.put(methodToString(method), wrapperInfo);
148 }
150 public WrapperInfo getReqOperationWrapper(ExecutableElement method) {
151 return reqOperationWrapperMap.get(methodToString(method));
152 }
154 public void setResWrapperOperation(ExecutableElement method, WrapperInfo wrapperInfo) {
155 resOperationWrapperMap.put(methodToString(method), wrapperInfo);
156 }
158 public WrapperInfo getResOperationWrapper(ExecutableElement method) {
159 return resOperationWrapperMap.get(methodToString(method));
160 }
162 public String methodToString(ExecutableElement method) {
163 StringBuilder buf = new StringBuilder(method.getSimpleName());
164 for (VariableElement param : method.getParameters())
165 buf.append(';').append(param.asType());
166 return buf.toString();
167 }
169 public void clearExceptionMap() {
170 exceptionBeanMap.clear();
171 }
173 public void addExceptionBeanEntry(Name exception, FaultInfo faultInfo, ModelBuilder builder) {
174 exceptionBeanMap.put(exception, faultInfo);
175 }
177 public FaultInfo getExceptionBeanName(Name exception) {
178 return exceptionBeanMap.get(exception);
179 }
180 }
181 }