operationdescriptionimpl.java
来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 1,476 行 · 第 1/5 页
JAVA
1,476 行
return methodComposite;
}
private boolean isWrappedParameters() {
return getSoapBindingParameterStyle() == javax.jws.soap.SOAPBinding.ParameterStyle.WRAPPED;
}
private ParameterDescription[] createParameterDescriptions() {
ArrayList<ParameterDescription> buildParameterList = new ArrayList<ParameterDescription>();
if (!isDBC()) {
Class[] parameters = seiMethod.getParameterTypes();
Type[] paramaterTypes = seiMethod.getGenericParameterTypes();
Annotation[][] annotations = seiMethod.getParameterAnnotations();
for (int i = 0; i < parameters.length; i++) {
ParameterDescription paramDesc = new ParameterDescriptionImpl(i, parameters[i],
paramaterTypes[i],
annotations[i], this);
buildParameterList.add(paramDesc);
}
} else {
ParameterDescriptionComposite pdc = null;
Iterator<ParameterDescriptionComposite> iter =
methodComposite.getParameterDescriptionCompositeList().iterator();
for (int i = 0; i < methodComposite.getParameterDescriptionCompositeList().size(); i++)
{
ParameterDescription paramDesc =
new ParameterDescriptionImpl(i,
methodComposite.getParameterDescriptionComposite(
i),
this);
buildParameterList.add(paramDesc);
}
}
return buildParameterList.toArray(new ParameterDescription[buildParameterList.size()]);
}
private FaultDescription[] createFaultDescriptions() {
ArrayList<FaultDescription> buildFaultList = new ArrayList<FaultDescription>();
if (!isDBC()) {
// get exceptions this method "throws"
Class[] webFaultClasses = seiMethod.getExceptionTypes();
for (Class wfClass : webFaultClasses) {
// according to JAXWS 3.7, the @WebFault annotation is only used for customizations,
// so we'll add all declared exceptions
WebFault wfanno = null;
for (Annotation anno : wfClass.getAnnotations()) {
if (anno.annotationType() == WebFault.class) {
wfanno = (WebFault)anno;
}
}
buildFaultList.add(new FaultDescriptionImpl(wfClass, wfanno, this));
}
} else {
// TODO do I care about methodComposite like the paramDescription does?
//Call FaultDescriptionImpl for all non-generic exceptions...Need to check a
// a couple of things
// 1. If this is a generic exception, ignore it
// 2. If this is not a generic exception, then find it in the DBC Map
// If not found in map, then throw not found exception
//3. Pass the validated WebFault dbc and possibly the classImpl dbc to FaultDescription
//4. Possibly set AxisOperation.setFaultMessages array...or something like that
String[] webFaultClassNames = methodComposite.getExceptions();
HashMap<String, DescriptionBuilderComposite> dbcMap =
getEndpointInterfaceDescriptionImpl().getEndpointDescriptionImpl()
.getServiceDescriptionImpl().getDBCMap();
if (webFaultClassNames != null) {
for (String wfClassName : webFaultClassNames) {
// Try to find this exception class in the dbc list. If we can't find it
// then just assume that its a generic exception.
DescriptionBuilderComposite faultDBC = dbcMap.get(wfClassName);
if (faultDBC != null) {
// JAXWS 3.7 does not require @WebFault annotation
// We found a valid exception composite thats annotated
buildFaultList.add(new FaultDescriptionImpl(faultDBC, this));
}
}
}
}
return buildFaultList.toArray(new FaultDescription[0]);
}
// =====================================
// ANNOTATION: WebMethod
// =====================================
public WebMethod getAnnoWebMethod() {
return webMethodAnnotation;
}
static QName determineOperationQName(Method javaMethod) {
return new QName(determineOperationName(javaMethod));
}
//TODO: For now, we are overriding the above method only because it is static, these should
//be combined at some point
public static QName determineOperationQName(MethodDescriptionComposite mdc) {
return new QName(determineOperationName(mdc));
}
//TODO: Deprecate this after we use only DBC objects
private static String determineOperationName(Method javaMethod) {
String operationName = null;
if (javaMethod == null) {
return null;
}
WebMethod wmAnnotation = javaMethod.getAnnotation(WebMethod.class);
// Per JSR-181 MR Sec 4.2 "Annotation: javax.jws.WebMethod" pg 17,
// if @WebMethod specifies and operation name, use that. Otherwise
// default is the Java method name
if (wmAnnotation != null && !DescriptionUtils.isEmpty(wmAnnotation.operationName())) {
operationName = wmAnnotation.operationName();
} else {
operationName = javaMethod.getName();
}
return operationName;
}
//TODO: For now, we are overriding the above method only because it is static, these should
//be combined at some point
private static String determineOperationName(MethodDescriptionComposite mdc) {
String operationName = null;
if (mdc == null) {
return null;
}
WebMethod wmAnnotation = mdc.getWebMethodAnnot();
if (wmAnnotation != null && !DescriptionUtils.isEmpty(wmAnnotation.operationName())) {
operationName = wmAnnotation.operationName();
} else {
operationName = mdc.getMethodName();
}
return operationName;
}
public String getOperationName() {
// REVIEW: WSDL/Anno merge
return getAnnoWebMethodOperationName();
}
public String getAnnoWebMethodOperationName() {
if (webMethodOperationName == null) {
if (!isDBC() && seiMethod != null) {
webMethodOperationName = determineOperationName(seiMethod);
} else if (methodComposite != null) {
webMethodOperationName = determineOperationName(methodComposite);
}
}
return webMethodOperationName;
}
/* (non-Javadoc)
* @see org.apache.axis2.jaxws.description.OperationDescription#getSyncOperation()
*/
public OperationDescription getSyncOperation() {
if (syncOperationDescription != null) {
// No need to do anything; the sync operation has already been set and will be
// returned below
} else if (!isJAXWSAsyncClientMethod()) {
// The current OpDesc is not an async operation. Cache it, then return it below.
syncOperationDescription = this;
} else {
// We haven't found a sync opdesc for this operation yet, so try again. See the
// comments in the interface declaration for this method on why this might occur.
OperationDescription opDesc = null;
String webMethodAnnoName = getOperationName();
String javaMethodName = getJavaMethodName();
if (webMethodAnnoName != null && webMethodAnnoName.length() > 0 &&
webMethodAnnoName != javaMethodName) {
EndpointInterfaceDescription eid = getEndpointInterfaceDescription();
if (eid != null) {
//searching for opDesc of sync operation.
OperationDescription[] ods = null;
ods = eid.getOperationForJavaMethod(webMethodAnnoName);
if (ods != null) {
for (OperationDescription od : ods) {
if (od.getJavaMethodName().equals(webMethodAnnoName)
&& !od.isJAXWSAsyncClientMethod()) {
opDesc = od;
break;
}
}
}
}
}
// Note that opDesc might still be null
syncOperationDescription = opDesc;
}
return syncOperationDescription;
}
public String getAction() {
// REVIEW: WSDL/Anno merge
return getAnnoWebMethodAction();
}
public String getAnnoWebMethodAction() {
if (webMethodAction == null) {
if (getAnnoWebMethod() != null &&
!DescriptionUtils.isEmpty(getAnnoWebMethod().action())) {
webMethodAction = getAnnoWebMethod().action();
} else {
webMethodAction = WebMethod_Action_DEFAULT;
}
}
return webMethodAction;
}
public boolean isExcluded() {
// REVIEW: WSDL/Annotation merge
return getAnnoWebMethodExclude();
}
public boolean getAnnoWebMethodExclude() {
if (webMethodExclude == null) {
// TODO: Validation: if this attribute specified, no other elements allowed per JSR-181 MR Sec 4.2, pg 17
// TODO: Validation: This element is not allowed on endpoint interfaces
// Unlike the elements with a String value, if the annotation is present, exclude will always
// return a usable value since it will default to FALSE if the element is not present.
if (getAnnoWebMethod() != null) {
webMethodExclude = new Boolean(getAnnoWebMethod().exclude());
} else {
webMethodExclude = WebMethod_Exclude_DEFAULT;
}
}
return webMethodExclude.booleanValue();
}
// ==========================================
// ANNOTATION: RequestWrapper
// ==========================================
public RequestWrapper getAnnoRequestWrapper() {
if (requestWrapperAnnotation == null) {
if (!isDBC() && seiMethod != null) {
requestWrapperAnnotation = seiMethod.getAnnotation(RequestWrapper.class);
} else if (isDBC() && methodComposite != null) {
requestWrapperAnnotation = methodComposite.getRequestWrapperAnnot();
} else {
if (log.isDebugEnabled()) {
log.debug("Unable to get RequestWrapper annotation");
}
}
}
return requestWrapperAnnotation;
}
public String getRequestWrapperLocalName() {
// REVIEW: WSDL/Anno merge
return getAnnoRequestWrapperLocalName();
}
/**
* For wrapped parameter style (based on the annotation and the WSDL), returns the wrapper
* value. For non-wrapped (i.e. bare) parameter style, returns null.
*
* @return
*/
public String getAnnoRequestWrapperLocalName() {
if (!isWrappedParameters()) {
// A wrapper is only meaningful for wrapped parameters
return null;
}
if (requestWrapperLocalName == null) {
if (getAnnoRequestWrapper() != null
&& !DescriptionUtils.isEmpty(getAnnoRequestWrapper().localName())) {
requestWrapperLocalName = getAnnoRequestWrapper().localName();
} else {
// The default value of localName is the value of operationQName as
// defined in the WebMethod annotation. [JAX-WS Sec. 7.3, p. 80]
requestWrapperLocalName = getAnnoWebMethodOperationName();
}
}
return requestWrapperLocalName;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?