1 /* 2 * Copyright (c) 1997, 2013, 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 */ 25 26 package com.sun.xml.internal.ws.model; 27 28 import com.sun.xml.internal.bind.api.Bridge; 29 import com.sun.xml.internal.ws.api.model.CheckedException; 30 import com.sun.xml.internal.ws.api.model.ExceptionType; 31 import com.sun.xml.internal.ws.api.model.JavaMethod; 32 import com.sun.xml.internal.ws.addressing.WsaActionUtil; 33 import com.sun.xml.internal.ws.spi.db.XMLBridge; 34 import com.sun.xml.internal.ws.spi.db.TypeInfo; 35 36 /** 37 * CheckedException class. Holds the exception class - class that has public 38 * constructor 39 * 40 * <code>public WrapperException()String message, FaultBean){}</code> 41 * 42 * and method 43 * 44 * <code>public FaultBean getFaultInfo();</code> 45 * 46 * @author Vivek Pandey 47 */ 48 public final class CheckedExceptionImpl implements CheckedException { 49 private final Class exceptionClass; 50 private final TypeInfo detail; 51 private final ExceptionType exceptionType; 52 private final JavaMethodImpl javaMethod; 53 private String messageName; 54 private String faultAction = ""; 55 56 /** 57 * @param jm {@link JavaMethodImpl} that throws this exception 58 * @param exceptionClass 59 * Userdefined or WSDL exception class that extends 60 * java.lang.Exception. 61 * @param detail 62 * detail or exception bean's TypeReference 63 * @param exceptionType 64 * either ExceptionType.UserDefined or 65 */ 66 public CheckedExceptionImpl(JavaMethodImpl jm, Class exceptionClass, TypeInfo detail, ExceptionType exceptionType) { 67 this.detail = detail; 68 this.exceptionType = exceptionType; 69 this.exceptionClass = exceptionClass; 70 this.javaMethod = jm; 71 } 72 73 public AbstractSEIModelImpl getOwner() { 74 return javaMethod.owner; 75 } 76 77 public JavaMethod getParent() { 78 return javaMethod; 79 } 80 81 /** 82 * @return the <code>Class</clode> for this object 83 * 84 */ 85 public Class getExceptionClass() { 86 return exceptionClass; 87 } 88 89 public Class getDetailBean() { 90 return (Class) detail.type; 91 } 92 /** @deprecated */ 93 public Bridge getBridge() { 94 //TODO return getOwner().getBridge(detail); 95 return null; 96 } 97 98 public XMLBridge getBond() { 99 return getOwner().getXMLBridge(detail); 100 } 101 102 public TypeInfo getDetailType() { 103 return detail; 104 } 105 106 public ExceptionType getExceptionType() { 107 return exceptionType; 108 } 109 110 public String getMessageName() { 111 return messageName; 112 } 113 114 public void setMessageName(String messageName) { 115 this.messageName = messageName; 116 } 117 118 public String getFaultAction() { 119 return faultAction; 120 } 121 122 public void setFaultAction(String faultAction) { 123 this.faultAction = faultAction; 124 } 125 126 public String getDefaultFaultAction() { 127 return WsaActionUtil.getDefaultFaultAction(javaMethod,this); 128 } 129 130 131 }