325N/A/*
325N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
325N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
325N/A *
325N/A * This code is free software; you can redistribute it and/or modify it
325N/A * under the terms of the GNU General Public License version 2 only, as
325N/A * published by the Free Software Foundation. Oracle designates this
325N/A * particular file as subject to the "Classpath" exception as provided
325N/A * by Oracle in the LICENSE file that accompanied this code.
325N/A *
325N/A * This code is distributed in the hope that it will be useful, but WITHOUT
325N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
325N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
325N/A * version 2 for more details (a copy is included in the LICENSE file that
325N/A * accompanied this code).
325N/A *
325N/A * You should have received a copy of the GNU General Public License version
325N/A * 2 along with this work; if not, write to the Free Software Foundation,
325N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
325N/A *
325N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
325N/A * or visit www.oracle.com if you need additional information or have any
325N/A * questions.
325N/A */
325N/A
325N/Apackage com.sun.tools.internal.ws.processor.modeler.annotation;
325N/A
325N/Aimport com.sun.mirror.declaration.MethodDeclaration;
325N/Aimport com.sun.mirror.declaration.ParameterDeclaration;
325N/Aimport com.sun.mirror.declaration.TypeDeclaration;
325N/Aimport com.sun.tools.internal.ws.processor.model.Model;
325N/Aimport com.sun.tools.internal.ws.processor.model.Operation;
325N/Aimport com.sun.tools.internal.ws.processor.model.Port;
325N/Aimport com.sun.tools.internal.ws.processor.model.Service;
325N/Aimport com.sun.tools.internal.ws.wsdl.document.soap.SOAPUse;
325N/A
325N/Aimport java.util.Collection;
325N/Aimport java.util.HashMap;
325N/Aimport java.util.Map;
325N/A
325N/A
325N/A/**
325N/A *
325N/A * @author dkohlert
325N/A */
325N/Apublic class AnnotationProcessorContext {
325N/A
325N/A private Map<String, SEIContext> seiContextMap;
325N/A private int round = 1;
325N/A private boolean modelCompleted = false;
325N/A
325N/A /** Creates a new instance of AnnotationProcessorContext */
325N/A public AnnotationProcessorContext() {
325N/A seiContextMap = new HashMap<String, SEIContext>();
325N/A }
325N/A
325N/A public void addSEIContext(String seiName, SEIContext seiContext) {
325N/A seiContextMap.put(seiName, seiContext);
325N/A }
325N/A
325N/A public SEIContext getSEIContext(String seiName) {
325N/A SEIContext context = seiContextMap.get(seiName);
325N/A if (context == null) {
325N/A context = new SEIContext(seiName);
325N/A addSEIContext(seiName, context);
325N/A }
325N/A return context;
325N/A }
325N/A
325N/A public SEIContext getSEIContext(TypeDeclaration d) {
325N/A SEIContext context = getSEIContext(d.getQualifiedName());
325N/A return context;
325N/A }
325N/A
325N/A public Collection<SEIContext> getSEIContexts() {
325N/A return seiContextMap.values();
325N/A }
325N/A
325N/A public int getRound() {
325N/A return round;
325N/A }
325N/A
325N/A public void incrementRound() {
325N/A round++;
325N/A }
325N/A
325N/A public static boolean isEncoded(Model model) {
325N/A if (model == null)
325N/A return false;
325N/A for (Service service : model.getServices()) {
325N/A for (Port port : service.getPorts()) {
325N/A for (Operation operation : port.getOperations()) {
325N/A if (operation.getUse() != null && operation.getUse().equals(SOAPUse.LITERAL))
325N/A return false;
325N/A }
325N/A }
325N/A }
325N/A return true;
325N/A }
325N/A
325N/A public void setModelCompleted(boolean modelCompleted) {
325N/A this.modelCompleted = modelCompleted;
325N/A }
325N/A
325N/A public boolean isModelCompleted() {
325N/A return modelCompleted;
325N/A }
325N/A
325N/A public static class SEIContext {
325N/A private Map<String, WrapperInfo> reqOperationWrapperMap;
325N/A private Map<String, WrapperInfo> resOperationWrapperMap;
325N/A private Map<String, FaultInfo> exceptionBeanMap;
325N/A
325N/A private String seiName;
325N/A private String seiImplName;
325N/A private boolean implementsSEI = false;
325N/A private String namespaceURI = null;
325N/A
325N/A public SEIContext(String seiName) {
325N/A reqOperationWrapperMap = new HashMap<String, WrapperInfo>();
325N/A resOperationWrapperMap = new HashMap<String, WrapperInfo>();
325N/A exceptionBeanMap = new HashMap<String,FaultInfo>();
325N/A this.seiName = seiName;
325N/A }
325N/A
325N/A public void setImplementsSEI(boolean implementsSEI) {
325N/A this.implementsSEI = implementsSEI;
325N/A }
325N/A
325N/A public boolean getImplementsSEI() {
325N/A return implementsSEI;
325N/A }
325N/A
325N/A public void setNamespaceURI(String namespaceURI) {
325N/A this.namespaceURI = namespaceURI;
325N/A }
325N/A
325N/A public String getNamespaceURI() {
325N/A return namespaceURI;
325N/A }
325N/A
325N/A public String getSEIImplName() {
325N/A return seiImplName;
325N/A }
325N/A
325N/A public void setSEIImplName(String implName) {
325N/A seiImplName = implName;
325N/A }
325N/A
325N/A public void setReqWrapperOperation(MethodDeclaration method, WrapperInfo wrapperInfo) {
325N/A reqOperationWrapperMap.put(methodToString(method), wrapperInfo);
325N/A }
325N/A
325N/A public WrapperInfo getReqOperationWrapper(MethodDeclaration method) {
325N/A return reqOperationWrapperMap.get(methodToString(method));
325N/A }
325N/A
325N/A public void setResWrapperOperation(MethodDeclaration method, WrapperInfo wrapperInfo) {
325N/A resOperationWrapperMap.put(methodToString(method), wrapperInfo);
325N/A }
325N/A
325N/A public WrapperInfo getResOperationWrapper(MethodDeclaration method) {
325N/A return resOperationWrapperMap.get(methodToString(method));
325N/A }
325N/A
325N/A public String methodToString(MethodDeclaration method) {
325N/A StringBuffer buf = new StringBuffer(method.getSimpleName());
325N/A for (ParameterDeclaration param : method.getParameters())
325N/A buf.append(";"+param.getType().toString());
325N/A return buf.toString();
325N/A }
325N/A
325N/A public void clearExceptionMap() {
325N/A exceptionBeanMap.clear();
325N/A }
325N/A
325N/A public void addExceptionBeanEntry(String exception, FaultInfo faultInfo, ModelBuilder builder) {
325N/A exceptionBeanMap.put(exception,faultInfo);
325N/A }
325N/A
325N/A public FaultInfo getExceptionBeanName(String exception) {
325N/A return exceptionBeanMap.get(exception);
325N/A }
325N/A }
325N/A}