servicedescriptionimpl.java
来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 1,278 行 · 第 1/5 页
JAVA
1,278 行
}
//TODO: hmmm, will we ever actually validate an interface directly...don't think so
if (!composite.isInterface()) {
// TODO: Validate on the class that this.classModifiers Array does not contain the strings
// FINAL or ABSTRACT, but does contain PUBLIC
// TODO: Validate on the class that a public constructor exists
// TODO: Validate on the class that a finalize() method does not exist
if (!DescriptionUtils.isEmpty(composite.getWebServiceAnnot().wsdlLocation())) {
if (composite.getWsdlDefinition() == null && composite.getWsdlURL() == null) {
// TODO: RAS/NLS
throw ExceptionFactory.makeWebServiceException(
"Validation error: cannot find WSDL Definition specified by this WebService annotation. Implementation class: "
+ composite.getClassName() + "; WSDL location: " +
composite.getWebServiceAnnot().wsdlLocation());
}
}
// setWebServiceAnnotDefaults(true=impl); Must happen before we start checking annot
if (!DescriptionUtils.isEmpty(composite.getWebServiceAnnot().endpointInterface())) {
DescriptionBuilderComposite seic =
dbcMap.get(composite.getWebServiceAnnot().endpointInterface());
//Verify that we can find the SEI in the composite list
if (seic == null) {
// TODO: RAS/NLS
throw ExceptionFactory.makeWebServiceException(
"Validation error: cannot find SEI specified by the WebService.endpointInterface. Implementaiton class: "
+ composite.getClassName() + "; EndpointInterface: " +
composite.getWebServiceAnnot().endpointInterface());
}
// Verify that the only class annotations are WebService and HandlerChain
// (per JSR181 Sec. 3.1). Note that this applies to JSR-181 annotations; the restriction
// does not apply to JSR-224 annotations such as BindingType
if (composite.getSoapBindingAnnot() != null
|| composite.getWebFaultAnnot() != null
|| composite.getWebServiceClientAnnot() != null
|| composite.getWebServiceContextAnnot() != null
|| !composite.getAllWebServiceRefAnnots().isEmpty()
) {
// TODO: RAS/NLS
throw ExceptionFactory.makeWebServiceException(
"Validation error: invalid annotations specified when WebService annotation specifies an endpoint interface. Implemntation class: "
+ composite.getClassName());
}
//Verify that WebService annotation does not contain a name attribute
//(per JSR181 Sec. 3.1)
if (!DescriptionUtils.isEmpty(composite.getWebServiceAnnot().name())) {
// TODO: RAS/NLS
throw ExceptionFactory.makeWebServiceException(
"Validation error: WebService.name must not be specified when the bean specifies an endpoint interface. Implentation class: "
+ composite.getClassName() + "; WebService.name: " +
composite.getWebServiceAnnot().name());
}
validateSEI(seic);
//Verify that that this implementation class implements all methods in the interface
validateImplementation(seic);
//Verify that this impl. class does not contain any @WebMethod annotations
if (webMethodAnnotationsExist()) {
// TODO: RAS/NLS
throw ExceptionFactory.makeWebServiceException(
"Validation error: WebMethod annotations cannot exist on implentation when WebService.endpointInterface is set. Implementation class: " +
composite.getClassName());
}
} else { //this is an implicit SEI (i.e. impl w/out endpointInterface
checkImplicitSEIAgainstWSDL();
// TODO: Call ValidateWebMethodAnnots()
// - this method will check that all methods are public - ???
//
}
} else { //this is an interface...we should not be processing interfaces here
// TODO: RAS/NLS
throw ExceptionFactory.makeWebServiceException(
"Validation error: Improper usage: cannot invoke this method with an interface. Implementation class: "
+ composite.getClassName());
}
// Verify that the SOAPBinding annotations are supported.
//REVIEW: The assumption here is that SOAPBinding annotation can be place on an impl. class
// (implicit SEI) or a WebServiceProvider
if (composite.getSoapBindingAnnot() != null) {
if (composite.getSoapBindingAnnot().use() == javax.jws.soap.SOAPBinding.Use.ENCODED) {
throw ExceptionFactory.makeWebServiceException("Validation error: Unsupported SOAPBinding annotation value. The ENCODED setting is not supported for SOAPBinding.Use. Implementation class: "
+composite.getClassName());
}
}
//TODO: don't think this is necessary
checkMethodsAgainstWSDL();
}
}
/**
* Validate there is an invoke method on the composite.
*
* @return
*/
private boolean validateInvokeMethod() {
boolean validInvokeMethod = false;
List<MethodDescriptionComposite> invokeMethodList =
composite.getMethodDescriptionComposite("invoke");
if (invokeMethodList != null && !invokeMethodList.isEmpty()) {
validInvokeMethod = true;
}
return validInvokeMethod;
}
/**
* Validate that, if using PAYLOAD mode, then interfaces list cannot contain SOAPMessage or
* DataSource
*
* @return
*/
private void validateProviderInterfaces() {
// Default for ServiceMode is 'PAYLOAD'. So, if it is specified (explicitly or
// implicitly) then verify that we are not implementing improper interfaces)
if ((composite.getServiceModeAnnot() == null)
|| composite.getServiceModeAnnot().value() == javax.xml.ws.Service.Mode.PAYLOAD) {
Iterator<String> iter = composite.getInterfacesList().iterator();
while (iter.hasNext()) {
String interfaceString = iter.next();
if (interfaceString.equals(MDQConstants.PROVIDER_SOAP)
|| interfaceString.equals(MDQConstants.PROVIDER_DATASOURCE)) {
throw ExceptionFactory
.makeWebServiceException(
"Validation error: SOAPMessage and DataSource objects cannot be used when ServiceMode specifies PAYLOAD. Implementation class: "
+ composite.getClassName());
}
}
} else {
// We are in MESSAGE mode
// Conformance: JAXWS Spec.- Sec. 4.3 (javax.activation.DataSource)
// REVIEW: Should the provider interface validation be moved to post-construction validation,
// since it seems that the logic to understand the default values for binding type
// (see comment below) should be left to the creation of the Description objects.
String bindingType = null;
if (composite.getBindingTypeAnnot() != null) {
bindingType = composite.getBindingTypeAnnot().value();
}
Iterator<String> iter = composite.getInterfacesList().iterator();
while (iter.hasNext()) {
String interfaceString = iter.next();
if (interfaceString.equals(MDQConstants.PROVIDER_SOAP)) {
// Make sure BindingType is SOAP/HTTP with SOAPMessage
// object, Default for Binding Type is SOAP/HTTP
if (!DescriptionUtils.isEmpty(bindingType)
&& !bindingType
.equals(SOAPBinding.SOAP11HTTP_BINDING)
&& !bindingType
.equals(SOAPBinding.SOAP11HTTP_MTOM_BINDING)
&& !bindingType
.equals(SOAPBinding.SOAP12HTTP_BINDING)
&& !bindingType
.equals(SOAPBinding.SOAP12HTTP_MTOM_BINDING))
throw ExceptionFactory
.makeWebServiceException(
"Validation error: SOAPMessage objects cannot be used with HTTP binding type. Implementation class: "
+ composite.getClassName());
} else if (interfaceString
.equals(MDQConstants.PROVIDER_DATASOURCE)) {
// Make sure BindingType is XML/HTTP with DataSource object
if (DescriptionUtils.isEmpty(bindingType)
|| !bindingType
.equals(javax.xml.ws.http.HTTPBinding.HTTP_BINDING))
throw ExceptionFactory
.makeWebServiceException(
"Validation error: DataSource objects must be used with HTTP binding type. Implementation class: "
+ composite.getClassName());
}
}
}
}
/**
* Validate there is a default no-argument constructor on the composite.
*
* @return
*/
private boolean validateDefaultConstructor() {
boolean validDefaultCtor = false;
List<MethodDescriptionComposite> constructorList =
composite.getMethodDescriptionComposite("<init>");
if (constructorList != null && !constructorList.isEmpty()) {
// There are public constructors; make sure there is one that takes no arguments.
for (MethodDescriptionComposite checkCtor : constructorList) {
List<ParameterDescriptionComposite> paramList =
checkCtor.getParameterDescriptionCompositeList();
if (paramList == null || paramList.isEmpty()) {
validDefaultCtor = true;
break;
}
}
}
return validDefaultCtor;
}
private void validateImplementation(DescriptionBuilderComposite seic) {
/*
* Verify that an impl class implements all the methods of the SEI. We
* have to verify this because an impl class is not required to actually use
* the 'implements' clause. So, if it doesn't, the Java compiler won't
* catch it. Don't need to worry about chaining because only one EndpointInterface
* can be specified, and the SEI cannot specify an EndpointInterface, so the Java
* compiler will take care of everything else.
*/
HashMap<String, MethodDescriptionComposite> compositeHashMap =
new HashMap<String, MethodDescriptionComposite>();
Iterator<MethodDescriptionComposite> compIterator =
composite.getMethodDescriptionsList().iterator();
while (compIterator.hasNext()) {
MethodDescriptionComposite mdc = compIterator.next();
compositeHashMap.put(mdc.getMethodName(), mdc);
}
// Add methods declared in the implementation's superclass
addSuperClassMethods(compositeHashMap, composite);
HashMap<String, MethodDescriptionComposite> seiMethodHashMap =
new HashMap<String, MethodDescriptionComposite>();
Iterator<MethodDescriptionComposite> seiMethodIterator =
seic.getMethodDescriptionsList().iterator();
while (seiMethodIterator.hasNext()) {
MethodDescriptionComposite mdc = seiMethodIterator.next();
seiMethodHashMap.put(mdc.getMethodName(), mdc);
}
// Add any methods declared in superinterfaces of the SEI
addSuperClassMethods(seiMethodHashMap, seic);
// Make sure all the methods in the SEI (including any inherited from superinterfaces) are
// implemented by the bean (including inherited methods on the bean).
Iterator<MethodDescriptionComposite> verifySEIIterator =
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?