下面列出了怎么用javax.jws.Oneway的API类实例代码及写法,或者点击链接到github查看源代码。
public static boolean isWrapperClassExists(Method method) {
Wrapper requestWrapper = new RequestWrapper();
requestWrapper.setMethod(method);
try {
requestWrapper.getWrapperClass();
boolean isOneWay = method.isAnnotationPresent(Oneway.class);
if (!isOneWay) {
Wrapper responseWrapper = new ResponseWrapper();
responseWrapper.setMethod(method);
responseWrapper.getWrapperClass();
}
} catch (Exception e) {
return false;
}
return true;
}
protected void verifyImplAnnotations(TypeElement d) {
for (ExecutableElement method : ElementFilter.methodsIn(d.getEnclosedElements())) {
checkForInvalidImplAnnotation(method, WebMethod.class);
checkForInvalidImplAnnotation(method, Oneway.class);
checkForInvalidImplAnnotation(method, WebResult.class);
for (VariableElement param : method.getParameters()) {
checkForInvalidImplAnnotation(param, WebParam.class);
}
}
}
protected void verifyImplAnnotations(TypeElement d) {
for (ExecutableElement method : ElementFilter.methodsIn(d.getEnclosedElements())) {
checkForInvalidImplAnnotation(method, WebMethod.class);
checkForInvalidImplAnnotation(method, Oneway.class);
checkForInvalidImplAnnotation(method, WebResult.class);
for (VariableElement param : method.getParameters()) {
checkForInvalidImplAnnotation(param, WebParam.class);
}
}
}
protected void verifyImplAnnotations(TypeElement d) {
for (ExecutableElement method : ElementFilter.methodsIn(d.getEnclosedElements())) {
checkForInvalidImplAnnotation(method, WebMethod.class);
checkForInvalidImplAnnotation(method, Oneway.class);
checkForInvalidImplAnnotation(method, WebResult.class);
for (VariableElement param : method.getParameters()) {
checkForInvalidImplAnnotation(param, WebParam.class);
}
}
}
protected void verifyImplAnnotations(TypeElement d) {
for (ExecutableElement method : ElementFilter.methodsIn(d.getEnclosedElements())) {
checkForInvalidImplAnnotation(method, WebMethod.class);
checkForInvalidImplAnnotation(method, Oneway.class);
checkForInvalidImplAnnotation(method, WebResult.class);
for (VariableElement param : method.getParameters()) {
checkForInvalidImplAnnotation(param, WebParam.class);
}
}
}
protected void verifyImplAnnotations(TypeElement d) {
for (ExecutableElement method : ElementFilter.methodsIn(d.getEnclosedElements())) {
checkForInvalidImplAnnotation(method, WebMethod.class);
checkForInvalidImplAnnotation(method, Oneway.class);
checkForInvalidImplAnnotation(method, WebResult.class);
for (VariableElement param : method.getParameters()) {
checkForInvalidImplAnnotation(param, WebParam.class);
}
}
}
protected void verifyImplAnnotations(TypeElement d) {
for (ExecutableElement method : ElementFilter.methodsIn(d.getEnclosedElements())) {
checkForInvalidImplAnnotation(method, WebMethod.class);
checkForInvalidImplAnnotation(method, Oneway.class);
checkForInvalidImplAnnotation(method, WebResult.class);
for (VariableElement param : method.getParameters()) {
checkForInvalidImplAnnotation(param, WebParam.class);
}
}
}
protected void verifyImplAnnotations(TypeElement d) {
for (ExecutableElement method : ElementFilter.methodsIn(d.getEnclosedElements())) {
checkForInvalidImplAnnotation(method, WebMethod.class);
checkForInvalidImplAnnotation(method, Oneway.class);
checkForInvalidImplAnnotation(method, WebResult.class);
for (VariableElement param : method.getParameters()) {
checkForInvalidImplAnnotation(param, WebParam.class);
}
}
}
protected void verifyImplAnnotations(TypeElement d) {
for (ExecutableElement method : ElementFilter.methodsIn(d.getEnclosedElements())) {
checkForInvalidImplAnnotation(method, WebMethod.class);
checkForInvalidImplAnnotation(method, Oneway.class);
checkForInvalidImplAnnotation(method, WebResult.class);
for (VariableElement param : method.getParameters()) {
checkForInvalidImplAnnotation(param, WebParam.class);
}
}
}
@Oneway
@Action(input = EventingConstants.ACTION_NOTIFY_EVENT_WRAPPED_DELIVERY)
@WebMethod(operationName = EventingConstants.OPERATION_NOTIFY_EVENT)
void notifyEvent(
@WebParam(partName = EventingConstants.PARAMETER, name = EventingConstants.NOTIFY,
targetNamespace = EventingConstants.EVENTING_2011_03_NAMESPACE)
EventType parameter
);
@WebMethod
@RequestWrapper(className = "org.apache.hello_world_soap_http.types.GreetMeOneWay",
localName = "greetMeOneWay",
targetNamespace = "http://apache.org/hello_world_soap_http/types")
@Oneway
public void greetMeOneWay(String me) {
incrementInvocationCount("greetMeOneWay");
System.out.println("Hello there " + me);
System.out.println("That was OneWay to say hello");
}
@Oneway
@RequestWrapper(targetNamespace = "http://cxf.apache.org/greeter_control/types",
className = "org.apache.cxf.greeter_control.types.GreetMeOneWay",
localName = "greetMeOneWay")
@WebMethod(operationName = "greetMeOneWay")
void greetMeOneWay(
@WebParam(targetNamespace = "http://cxf.apache.org/greeter_control/types", name = "requestType")
java.lang.String requestType
);
protected boolean isLegalMethod(ExecutableElement method, TypeElement typeElement) {
WebMethod webMethod = method.getAnnotation(WebMethod.class);
//SEI cannot have methods with @WebMethod(exclude=true)
if (typeElement.getKind().equals(ElementKind.INTERFACE) && webMethod != null && webMethod.exclude())
builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_SEI_ANNOTATION_ELEMENT_EXCLUDE("exclude=true", typeElement.getQualifiedName(), method.toString()), method);
// With https://jax-ws.dev.java.net/issues/show_bug.cgi?id=577, hasWebMethods has no effect
if (hasWebMethods && webMethod == null) // backwards compatibility (for legacyWebMethod computation)
return true;
if ((webMethod != null) && webMethod.exclude()) {
return true;
}
/*
This check is not needed as Impl class is already checked that it is not abstract.
if (typeElement instanceof TypeElement && method.getModifiers().contains(Modifier.ABSTRACT)) { // use Kind.equals instead of instanceOf
builder.processError(method.getPosition(), WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_METHOD_IS_ABSTRACT(typeElement.getQualifiedName(), method.getSimpleName()));
return false;
}
*/
TypeMirror returnType = method.getReturnType();
if (!isLegalType(returnType)) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_RETURN_TYPE_CANNOT_IMPLEMENT_REMOTE(typeElement.getQualifiedName(),
method.getSimpleName(),
returnType), method);
}
boolean isOneWay = method.getAnnotation(Oneway.class) != null;
if (isOneWay && !isValidOneWayMethod(method, typeElement))
return false;
SOAPBinding soapBinding = method.getAnnotation(SOAPBinding.class);
if (soapBinding != null) {
if (soapBinding.style().equals(SOAPBinding.Style.RPC)) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_RPC_SOAPBINDING_NOT_ALLOWED_ON_METHOD(typeElement.getQualifiedName(), method.toString()), method);
}
}
int paramIndex = 0;
for (VariableElement parameter : method.getParameters()) {
if (!isLegalParameter(parameter, method, typeElement, paramIndex++))
return false;
}
if (!isDocLitWrapped() && soapStyle.equals(SOAPStyle.DOCUMENT)) {
VariableElement outParam = getOutParameter(method);
int inParams = getModeParameterCount(method, WebParam.Mode.IN);
int outParams = getModeParameterCount(method, WebParam.Mode.OUT);
if (inParams != 1) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_AND_NO_ONE_IN(typeElement.getQualifiedName(), method.toString()), method);
}
if (returnType.accept(NO_TYPE_VISITOR, null)) {
if (outParam == null && !isOneWay) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_NO_OUT(typeElement.getQualifiedName(), method.toString()), method);
}
if (outParams != 1) {
if (!isOneWay && outParams != 0)
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_NO_RETURN_AND_NO_OUT(typeElement.getQualifiedName(), method.toString()), method);
}
} else {
if (outParams > 0) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_RETURN_AND_OUT(typeElement.getQualifiedName(), method.toString()), outParam);
}
}
}
return true;
}
protected boolean isLegalMethod(ExecutableElement method, TypeElement typeElement) {
WebMethod webMethod = method.getAnnotation(WebMethod.class);
//SEI cannot have methods with @WebMethod(exclude=true)
if (typeElement.getKind().equals(ElementKind.INTERFACE) && webMethod != null && webMethod.exclude())
builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_SEI_ANNOTATION_ELEMENT_EXCLUDE("exclude=true", typeElement.getQualifiedName(), method.toString()), method);
// With https://jax-ws.dev.java.net/issues/show_bug.cgi?id=577, hasWebMethods has no effect
if (hasWebMethods && webMethod == null) // backwards compatibility (for legacyWebMethod computation)
return true;
if ((webMethod != null) && webMethod.exclude()) {
return true;
}
/*
This check is not needed as Impl class is already checked that it is not abstract.
if (typeElement instanceof TypeElement && method.getModifiers().contains(Modifier.ABSTRACT)) { // use Kind.equals instead of instanceOf
builder.processError(method.getPosition(), WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_METHOD_IS_ABSTRACT(typeElement.getQualifiedName(), method.getSimpleName()));
return false;
}
*/
TypeMirror returnType = method.getReturnType();
if (!isLegalType(returnType)) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_RETURN_TYPE_CANNOT_IMPLEMENT_REMOTE(typeElement.getQualifiedName(),
method.getSimpleName(),
returnType), method);
}
boolean isOneWay = method.getAnnotation(Oneway.class) != null;
if (isOneWay && !isValidOneWayMethod(method, typeElement))
return false;
SOAPBinding soapBinding = method.getAnnotation(SOAPBinding.class);
if (soapBinding != null) {
if (soapBinding.style().equals(SOAPBinding.Style.RPC)) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_RPC_SOAPBINDING_NOT_ALLOWED_ON_METHOD(typeElement.getQualifiedName(), method.toString()), method);
}
}
int paramIndex = 0;
for (VariableElement parameter : method.getParameters()) {
if (!isLegalParameter(parameter, method, typeElement, paramIndex++))
return false;
}
if (!isDocLitWrapped() && soapStyle.equals(SOAPStyle.DOCUMENT)) {
VariableElement outParam = getOutParameter(method);
int inParams = getModeParameterCount(method, WebParam.Mode.IN);
int outParams = getModeParameterCount(method, WebParam.Mode.OUT);
if (inParams != 1) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_AND_NO_ONE_IN(typeElement.getQualifiedName(), method.toString()), method);
}
if (returnType.accept(NO_TYPE_VISITOR, null)) {
if (outParam == null && !isOneWay) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_NO_OUT(typeElement.getQualifiedName(), method.toString()), method);
}
if (outParams != 1) {
if (!isOneWay && outParams != 0)
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_NO_RETURN_AND_NO_OUT(typeElement.getQualifiedName(), method.toString()), method);
}
} else {
if (outParams > 0) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_RETURN_AND_OUT(typeElement.getQualifiedName(), method.toString()), outParam);
}
}
}
return true;
}
protected boolean isLegalMethod(ExecutableElement method, TypeElement typeElement) {
WebMethod webMethod = method.getAnnotation(WebMethod.class);
//SEI cannot have methods with @WebMethod(exclude=true)
if (typeElement.getKind().equals(ElementKind.INTERFACE) && webMethod != null && webMethod.exclude())
builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_SEI_ANNOTATION_ELEMENT_EXCLUDE("exclude=true", typeElement.getQualifiedName(), method.toString()), method);
// With https://jax-ws.dev.java.net/issues/show_bug.cgi?id=577, hasWebMethods has no effect
if (hasWebMethods && webMethod == null) // backwards compatibility (for legacyWebMethod computation)
return true;
if ((webMethod != null) && webMethod.exclude()) {
return true;
}
/*
This check is not needed as Impl class is already checked that it is not abstract.
if (typeElement instanceof TypeElement && method.getModifiers().contains(Modifier.ABSTRACT)) { // use Kind.equals instead of instanceOf
builder.processError(method.getPosition(), WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_METHOD_IS_ABSTRACT(typeElement.getQualifiedName(), method.getSimpleName()));
return false;
}
*/
TypeMirror returnType = method.getReturnType();
if (!isLegalType(returnType)) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_RETURN_TYPE_CANNOT_IMPLEMENT_REMOTE(typeElement.getQualifiedName(),
method.getSimpleName(),
returnType), method);
}
boolean isOneWay = method.getAnnotation(Oneway.class) != null;
if (isOneWay && !isValidOneWayMethod(method, typeElement))
return false;
SOAPBinding soapBinding = method.getAnnotation(SOAPBinding.class);
if (soapBinding != null) {
if (soapBinding.style().equals(SOAPBinding.Style.RPC)) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_RPC_SOAPBINDING_NOT_ALLOWED_ON_METHOD(typeElement.getQualifiedName(), method.toString()), method);
}
}
int paramIndex = 0;
for (VariableElement parameter : method.getParameters()) {
if (!isLegalParameter(parameter, method, typeElement, paramIndex++))
return false;
}
if (!isDocLitWrapped() && soapStyle.equals(SOAPStyle.DOCUMENT)) {
VariableElement outParam = getOutParameter(method);
int inParams = getModeParameterCount(method, WebParam.Mode.IN);
int outParams = getModeParameterCount(method, WebParam.Mode.OUT);
if (inParams != 1) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_AND_NO_ONE_IN(typeElement.getQualifiedName(), method.toString()), method);
}
if (returnType.accept(NO_TYPE_VISITOR, null)) {
if (outParam == null && !isOneWay) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_NO_OUT(typeElement.getQualifiedName(), method.toString()), method);
}
if (outParams != 1) {
if (!isOneWay && outParams != 0)
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_NO_RETURN_AND_NO_OUT(typeElement.getQualifiedName(), method.toString()), method);
}
} else {
if (outParams > 0) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_RETURN_AND_OUT(typeElement.getQualifiedName(), method.toString()), outParam);
}
}
}
return true;
}
@WebMethod
@Oneway
public void send(@WebParam(name = "message")
String str) {
}
@WebMethod
@Oneway
public void send(@WebParam(name = "message")
String str, String to) {
}
@Oneway
public void setNamespace(@WebParam(mode=WebParam.Mode.INOUT) String name) {
}
@Oneway
public String getNamespace(){
return null;
}
@Oneway
public void getNamespace() throws Exception {
}
@Oneway()
@WebMethod
public String getName() {
return "name";
}
@Oneway()
@WebMethod(operationName="setAge")
public void setAge(@WebParam(name="age", mode=Mode.OUT) int age) {
int personAge = age;
}
@Oneway()
@WebMethod(operationName="setSurname")
public void setSurname(@WebParam(name="surname", mode=Mode.IN) String surname) {
String personSurname = surname;
}
@Oneway()
@WebMethod()
public void setName() throws Exception {
String name = "name";
}
/**
* Web service operation
*/
@WebMethod(operationName = "voidOperation")
@Oneway
public void voidOperation() {
}
protected boolean isLegalMethod(ExecutableElement method, TypeElement typeElement) {
WebMethod webMethod = method.getAnnotation(WebMethod.class);
//SEI cannot have methods with @WebMethod(exclude=true)
if (typeElement.getKind().equals(ElementKind.INTERFACE) && webMethod != null && webMethod.exclude())
builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_SEI_ANNOTATION_ELEMENT_EXCLUDE("exclude=true", typeElement.getQualifiedName(), method.toString()), method);
// With https://jax-ws.dev.java.net/issues/show_bug.cgi?id=577, hasWebMethods has no effect
if (hasWebMethods && webMethod == null) // backwards compatibility (for legacyWebMethod computation)
return true;
if ((webMethod != null) && webMethod.exclude()) {
return true;
}
/*
This check is not needed as Impl class is already checked that it is not abstract.
if (typeElement instanceof TypeElement && method.getModifiers().contains(Modifier.ABSTRACT)) { // use Kind.equals instead of instanceOf
builder.processError(method.getPosition(), WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_METHOD_IS_ABSTRACT(typeElement.getQualifiedName(), method.getSimpleName()));
return false;
}
*/
TypeMirror returnType = method.getReturnType();
if (!isLegalType(returnType)) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_RETURN_TYPE_CANNOT_IMPLEMENT_REMOTE(typeElement.getQualifiedName(),
method.getSimpleName(),
returnType), method);
}
boolean isOneWay = method.getAnnotation(Oneway.class) != null;
if (isOneWay && !isValidOneWayMethod(method, typeElement))
return false;
SOAPBinding soapBinding = method.getAnnotation(SOAPBinding.class);
if (soapBinding != null) {
if (soapBinding.style().equals(SOAPBinding.Style.RPC)) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_RPC_SOAPBINDING_NOT_ALLOWED_ON_METHOD(typeElement.getQualifiedName(), method.toString()), method);
}
}
int paramIndex = 0;
for (VariableElement parameter : method.getParameters()) {
if (!isLegalParameter(parameter, method, typeElement, paramIndex++))
return false;
}
if (!isDocLitWrapped() && soapStyle.equals(SOAPStyle.DOCUMENT)) {
VariableElement outParam = getOutParameter(method);
int inParams = getModeParameterCount(method, WebParam.Mode.IN);
int outParams = getModeParameterCount(method, WebParam.Mode.OUT);
if (inParams != 1) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_AND_NO_ONE_IN(typeElement.getQualifiedName(), method.toString()), method);
}
if (returnType.accept(NO_TYPE_VISITOR, null)) {
if (outParam == null && !isOneWay) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_NO_OUT(typeElement.getQualifiedName(), method.toString()), method);
}
if (outParams != 1) {
if (!isOneWay && outParams != 0)
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_NO_RETURN_AND_NO_OUT(typeElement.getQualifiedName(), method.toString()), method);
}
} else {
if (outParams > 0) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_RETURN_AND_OUT(typeElement.getQualifiedName(), method.toString()), outParam);
}
}
}
return true;
}
protected boolean isLegalMethod(ExecutableElement method, TypeElement typeElement) {
WebMethod webMethod = method.getAnnotation(WebMethod.class);
//SEI cannot have methods with @WebMethod(exclude=true)
if (typeElement.getKind().equals(ElementKind.INTERFACE) && webMethod != null && webMethod.exclude())
builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_SEI_ANNOTATION_ELEMENT_EXCLUDE("exclude=true", typeElement.getQualifiedName(), method.toString()), method);
// With https://jax-ws.dev.java.net/issues/show_bug.cgi?id=577, hasWebMethods has no effect
if (hasWebMethods && webMethod == null) // backwards compatibility (for legacyWebMethod computation)
return true;
if ((webMethod != null) && webMethod.exclude()) {
return true;
}
/*
This check is not needed as Impl class is already checked that it is not abstract.
if (typeElement instanceof TypeElement && method.getModifiers().contains(Modifier.ABSTRACT)) { // use Kind.equals instead of instanceOf
builder.processError(method.getPosition(), WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_METHOD_IS_ABSTRACT(typeElement.getQualifiedName(), method.getSimpleName()));
return false;
}
*/
TypeMirror returnType = method.getReturnType();
if (!isLegalType(returnType)) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_RETURN_TYPE_CANNOT_IMPLEMENT_REMOTE(typeElement.getQualifiedName(),
method.getSimpleName(),
returnType), method);
}
boolean isOneWay = method.getAnnotation(Oneway.class) != null;
if (isOneWay && !isValidOneWayMethod(method, typeElement))
return false;
SOAPBinding soapBinding = method.getAnnotation(SOAPBinding.class);
if (soapBinding != null) {
if (soapBinding.style().equals(SOAPBinding.Style.RPC)) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_RPC_SOAPBINDING_NOT_ALLOWED_ON_METHOD(typeElement.getQualifiedName(), method.toString()), method);
}
}
int paramIndex = 0;
for (VariableElement parameter : method.getParameters()) {
if (!isLegalParameter(parameter, method, typeElement, paramIndex++))
return false;
}
if (!isDocLitWrapped() && soapStyle.equals(SOAPStyle.DOCUMENT)) {
VariableElement outParam = getOutParameter(method);
int inParams = getModeParameterCount(method, WebParam.Mode.IN);
int outParams = getModeParameterCount(method, WebParam.Mode.OUT);
if (inParams != 1) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_AND_NO_ONE_IN(typeElement.getQualifiedName(), method.toString()), method);
}
if (returnType.accept(NO_TYPE_VISITOR, null)) {
if (outParam == null && !isOneWay) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_NO_OUT(typeElement.getQualifiedName(), method.toString()), method);
}
if (outParams != 1) {
if (!isOneWay && outParams != 0)
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_NO_RETURN_AND_NO_OUT(typeElement.getQualifiedName(), method.toString()), method);
}
} else {
if (outParams > 0) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_RETURN_AND_OUT(typeElement.getQualifiedName(), method.toString()), outParam);
}
}
}
return true;
}
protected boolean isLegalMethod(ExecutableElement method, TypeElement typeElement) {
WebMethod webMethod = method.getAnnotation(WebMethod.class);
//SEI cannot have methods with @WebMethod(exclude=true)
if (typeElement.getKind().equals(ElementKind.INTERFACE) && webMethod != null && webMethod.exclude())
builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_SEI_ANNOTATION_ELEMENT_EXCLUDE("exclude=true", typeElement.getQualifiedName(), method.toString()), method);
// With https://jax-ws.dev.java.net/issues/show_bug.cgi?id=577, hasWebMethods has no effect
if (hasWebMethods && webMethod == null) // backwards compatibility (for legacyWebMethod computation)
return true;
if ((webMethod != null) && webMethod.exclude()) {
return true;
}
/*
This check is not needed as Impl class is already checked that it is not abstract.
if (typeElement instanceof TypeElement && method.getModifiers().contains(Modifier.ABSTRACT)) { // use Kind.equals instead of instanceOf
builder.processError(method.getPosition(), WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_METHOD_IS_ABSTRACT(typeElement.getQualifiedName(), method.getSimpleName()));
return false;
}
*/
TypeMirror returnType = method.getReturnType();
if (!isLegalType(returnType)) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_RETURN_TYPE_CANNOT_IMPLEMENT_REMOTE(typeElement.getQualifiedName(),
method.getSimpleName(),
returnType), method);
}
boolean isOneWay = method.getAnnotation(Oneway.class) != null;
if (isOneWay && !isValidOneWayMethod(method, typeElement))
return false;
SOAPBinding soapBinding = method.getAnnotation(SOAPBinding.class);
if (soapBinding != null) {
if (soapBinding.style().equals(SOAPBinding.Style.RPC)) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_RPC_SOAPBINDING_NOT_ALLOWED_ON_METHOD(typeElement.getQualifiedName(), method.toString()), method);
}
}
int paramIndex = 0;
for (VariableElement parameter : method.getParameters()) {
if (!isLegalParameter(parameter, method, typeElement, paramIndex++))
return false;
}
if (!isDocLitWrapped() && soapStyle.equals(SOAPStyle.DOCUMENT)) {
VariableElement outParam = getOutParameter(method);
int inParams = getModeParameterCount(method, WebParam.Mode.IN);
int outParams = getModeParameterCount(method, WebParam.Mode.OUT);
if (inParams != 1) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_AND_NO_ONE_IN(typeElement.getQualifiedName(), method.toString()), method);
}
if (returnType.accept(NO_TYPE_VISITOR, null)) {
if (outParam == null && !isOneWay) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_NO_OUT(typeElement.getQualifiedName(), method.toString()), method);
}
if (outParams != 1) {
if (!isOneWay && outParams != 0)
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_NO_RETURN_AND_NO_OUT(typeElement.getQualifiedName(), method.toString()), method);
}
} else {
if (outParams > 0) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_RETURN_AND_OUT(typeElement.getQualifiedName(), method.toString()), outParam);
}
}
}
return true;
}
protected boolean isLegalMethod(ExecutableElement method, TypeElement typeElement) {
WebMethod webMethod = method.getAnnotation(WebMethod.class);
//SEI cannot have methods with @WebMethod(exclude=true)
if (typeElement.getKind().equals(ElementKind.INTERFACE) && webMethod != null && webMethod.exclude())
builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_SEI_ANNOTATION_ELEMENT_EXCLUDE("exclude=true", typeElement.getQualifiedName(), method.toString()), method);
// With https://jax-ws.dev.java.net/issues/show_bug.cgi?id=577, hasWebMethods has no effect
if (hasWebMethods && webMethod == null) // backwards compatibility (for legacyWebMethod computation)
return true;
if ((webMethod != null) && webMethod.exclude()) {
return true;
}
/*
This check is not needed as Impl class is already checked that it is not abstract.
if (typeElement instanceof TypeElement && method.getModifiers().contains(Modifier.ABSTRACT)) { // use Kind.equals instead of instanceOf
builder.processError(method.getPosition(), WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_METHOD_IS_ABSTRACT(typeElement.getQualifiedName(), method.getSimpleName()));
return false;
}
*/
TypeMirror returnType = method.getReturnType();
if (!isLegalType(returnType)) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_RETURN_TYPE_CANNOT_IMPLEMENT_REMOTE(typeElement.getQualifiedName(),
method.getSimpleName(),
returnType), method);
}
boolean isOneWay = method.getAnnotation(Oneway.class) != null;
if (isOneWay && !isValidOneWayMethod(method, typeElement))
return false;
SOAPBinding soapBinding = method.getAnnotation(SOAPBinding.class);
if (soapBinding != null) {
if (soapBinding.style().equals(SOAPBinding.Style.RPC)) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_RPC_SOAPBINDING_NOT_ALLOWED_ON_METHOD(typeElement.getQualifiedName(), method.toString()), method);
}
}
int paramIndex = 0;
for (VariableElement parameter : method.getParameters()) {
if (!isLegalParameter(parameter, method, typeElement, paramIndex++))
return false;
}
if (!isDocLitWrapped() && soapStyle.equals(SOAPStyle.DOCUMENT)) {
VariableElement outParam = getOutParameter(method);
int inParams = getModeParameterCount(method, WebParam.Mode.IN);
int outParams = getModeParameterCount(method, WebParam.Mode.OUT);
if (inParams != 1) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_AND_NO_ONE_IN(typeElement.getQualifiedName(), method.toString()), method);
}
if (returnType.accept(NO_TYPE_VISITOR, null)) {
if (outParam == null && !isOneWay) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_NO_OUT(typeElement.getQualifiedName(), method.toString()), method);
}
if (outParams != 1) {
if (!isOneWay && outParams != 0)
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_NO_RETURN_AND_NO_OUT(typeElement.getQualifiedName(), method.toString()), method);
}
} else {
if (outParams > 0) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_RETURN_AND_OUT(typeElement.getQualifiedName(), method.toString()), outParam);
}
}
}
return true;
}
protected boolean isLegalMethod(ExecutableElement method, TypeElement typeElement) {
WebMethod webMethod = method.getAnnotation(WebMethod.class);
//SEI cannot have methods with @WebMethod(exclude=true)
if (typeElement.getKind().equals(ElementKind.INTERFACE) && webMethod != null && webMethod.exclude())
builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_SEI_ANNOTATION_ELEMENT_EXCLUDE("exclude=true", typeElement.getQualifiedName(), method.toString()), method);
// With https://jax-ws.dev.java.net/issues/show_bug.cgi?id=577, hasWebMethods has no effect
if (hasWebMethods && webMethod == null) // backwards compatibility (for legacyWebMethod computation)
return true;
if ((webMethod != null) && webMethod.exclude()) {
return true;
}
/*
This check is not needed as Impl class is already checked that it is not abstract.
if (typeElement instanceof TypeElement && method.getModifiers().contains(Modifier.ABSTRACT)) { // use Kind.equals instead of instanceOf
builder.processError(method.getPosition(), WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_METHOD_IS_ABSTRACT(typeElement.getQualifiedName(), method.getSimpleName()));
return false;
}
*/
TypeMirror returnType = method.getReturnType();
if (!isLegalType(returnType)) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_RETURN_TYPE_CANNOT_IMPLEMENT_REMOTE(typeElement.getQualifiedName(),
method.getSimpleName(),
returnType), method);
}
boolean isOneWay = method.getAnnotation(Oneway.class) != null;
if (isOneWay && !isValidOneWayMethod(method, typeElement))
return false;
SOAPBinding soapBinding = method.getAnnotation(SOAPBinding.class);
if (soapBinding != null) {
if (soapBinding.style().equals(SOAPBinding.Style.RPC)) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_RPC_SOAPBINDING_NOT_ALLOWED_ON_METHOD(typeElement.getQualifiedName(), method.toString()), method);
}
}
int paramIndex = 0;
for (VariableElement parameter : method.getParameters()) {
if (!isLegalParameter(parameter, method, typeElement, paramIndex++))
return false;
}
if (!isDocLitWrapped() && soapStyle.equals(SOAPStyle.DOCUMENT)) {
VariableElement outParam = getOutParameter(method);
int inParams = getModeParameterCount(method, WebParam.Mode.IN);
int outParams = getModeParameterCount(method, WebParam.Mode.OUT);
if (inParams != 1) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_AND_NO_ONE_IN(typeElement.getQualifiedName(), method.toString()), method);
}
if (returnType.accept(NO_TYPE_VISITOR, null)) {
if (outParam == null && !isOneWay) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_NO_OUT(typeElement.getQualifiedName(), method.toString()), method);
}
if (outParams != 1) {
if (!isOneWay && outParams != 0)
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_NO_RETURN_AND_NO_OUT(typeElement.getQualifiedName(), method.toString()), method);
}
} else {
if (outParams > 0) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_RETURN_AND_OUT(typeElement.getQualifiedName(), method.toString()), outParam);
}
}
}
return true;
}