javax.jws.Oneway Java Examples

The following examples show how to use javax.jws.Oneway. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WrapperUtil.java    From cxf with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #2
Source File: WebServiceVisitor.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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);
        }
    }
}
 
Example #3
Source File: GreeterNoWsdl.java    From cxf with Apache License 2.0 5 votes vote down vote up
@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
);
 
Example #4
Source File: AnnotatedGreeterNoOverloadImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
@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");
}
 
Example #5
Source File: WrappedSink.java    From cxf with Apache License 2.0 5 votes vote down vote up
@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
);
 
Example #6
Source File: WebServiceVisitor.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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);
        }
    }
}
 
Example #7
Source File: WebServiceVisitor.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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);
        }
    }
}
 
Example #8
Source File: WebServiceVisitor.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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);
        }
    }
}
 
Example #9
Source File: WebServiceVisitor.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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);
        }
    }
}
 
Example #10
Source File: WebServiceVisitor.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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);
        }
    }
}
 
Example #11
Source File: WebServiceVisitor.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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);
        }
    }
}
 
Example #12
Source File: WebServiceVisitor.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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);
        }
    }
}
 
Example #13
Source File: WebServiceVisitor.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example #14
Source File: WebServiceVisitor.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example #15
Source File: SimpleDocLitBare.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Oneway
@WebMethod
void oneWay(@WebParam(name = "corrigan") String param);
 
Example #16
Source File: CatastrophicEventSink.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Oneway
@Action(input = "http://www.fire.com")
void fire(@WebParam(name = "fire") FireEvent ev);
 
Example #17
Source File: CatastrophicEventSink.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Oneway
@Action(input = "http://www.earthquake.com")
void earthquake(@WebParam(name = "earthquake") EarthquakeEvent ev);
 
Example #18
Source File: WebServiceVisitor.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example #19
Source File: JaxWsServiceConfiguration.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Override
public Boolean hasOutMessage(Method method) {
    method = getDeclaredMethod(method);
    return !method.isAnnotationPresent(Oneway.class);
}
 
Example #20
Source File: OperationNSTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@WebMethod(operationName = "Notify2", action = "")
@Oneway
void notify2(@WebParam(name = "Notify",
     targetNamespace = "http://docs.oasis-open.org/wsn/2004/"
         + "06/wsn-WS-BaseNotification-1.2-draft-01.xsd")
     Document notify);
 
Example #21
Source File: CodeGenTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Test
public void testHelloWorld() throws Exception {
    env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world.wsdl"));
    processor.setContext(env);
    processor.execute();

    assertNotNull(output);

    File org = new File(output, "org");
    assertTrue(org.exists());
    File apache = new File(org, "apache");
    assertTrue(apache.exists());
    File cxf = new File(apache, "cxf");
    assertTrue(cxf.exists());
    File w2j = new File(cxf, "w2j");
    assertTrue(w2j.exists());
    File helloworldsoaphttp = new File(w2j, "hello_world_soap_http");
    assertTrue(helloworldsoaphttp.exists());
    File types = new File(helloworldsoaphttp, "types");
    assertTrue(types.exists());
    File[] files = helloworldsoaphttp.listFiles();
    assertEquals(9, files.length);
    files = types.listFiles();
    assertEquals(17, files.length);

    Class<?> clz = classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.Greeter");
    assertTrue("class " + clz.getName() + " modifier is not public", Modifier
        .isPublic(clz.getModifiers()));
    assertTrue("class " + clz.getName() + " modifier is interface", Modifier.isInterface(clz
        .getModifiers()));

    WebService webServiceAnn = AnnotationUtil.getPrivClassAnnotation(clz, WebService.class);
    assertEquals("Greeter", webServiceAnn.name());

    Method method = clz.getMethod("sayHi", new Class[] {});
    WebMethod webMethodAnno = AnnotationUtil.getPrivMethodAnnotation(method, WebMethod.class);
    if (webMethodAnno.operationName() != null
        && !"".equals(webMethodAnno.operationName())) {
        assertEquals(method.getName() + "()" + " Annotation : WebMethod.operationName ", "sayHi",
                 webMethodAnno.operationName());
    }

    RequestWrapper requestWrapperAnn = AnnotationUtil.getPrivMethodAnnotation(method,
                                                                              RequestWrapper.class);

    assertEquals("org.apache.cxf.w2j.hello_world_soap_http.types.SayHi", requestWrapperAnn.className());

    ResponseWrapper resposneWrapperAnn = AnnotationUtil.getPrivMethodAnnotation(method,
                                                                                ResponseWrapper.class);

    assertEquals("sayHiResponse", resposneWrapperAnn.localName());

    WebResult webResultAnno = AnnotationUtil.getPrivMethodAnnotation(method, WebResult.class);

    assertEquals("responseType", webResultAnno.name());

    method = clz.getMethod("greetMe", new Class[] {String.class});
    assertEquals("String", method.getReturnType().getSimpleName());
    WebParam webParamAnn = AnnotationUtil.getWebParam(method, "requestType");
    //if is wrapped, tns should be empty
    assertEquals("http://cxf.apache.org/w2j/hello_world_soap_http/types", webParamAnn.targetNamespace());
    //assertEquals("", webParamAnn.targetNamespace());
    method = clz.getMethod("greetMeOneWay", new Class[] {String.class});
    Oneway oneWayAnn = AnnotationUtil.getPrivMethodAnnotation(method, Oneway.class);
    assertNotNull("OneWay Annotation is not generated", oneWayAnn);
    assertEquals("void", method.getReturnType().getSimpleName());

    method = clz.getMethod("greetMeSometime", new Class[] {String.class});
    assertEquals("String", method.getReturnType().getSimpleName());

    method = clz.getMethod("testDocLitFault", new Class[] {java.lang.String.class});
    assertEquals("void", method.getReturnType().getSimpleName());
    assertEquals("Exception class is not generated ", 2, method.getExceptionTypes().length);

    method = clz.getMethod("testDocLitBare", new Class[] {java.lang.String.class});
    webResultAnno = AnnotationUtil.getPrivMethodAnnotation(method, WebResult.class);
    assertEquals("out", webResultAnno.partName());
    SOAPBinding soapBindingAnno = AnnotationUtil.getPrivMethodAnnotation(method, SOAPBinding.class);
    assertNotNull(soapBindingAnno);
    assertEquals(SOAPBinding.ParameterStyle.BARE, soapBindingAnno.parameterStyle());
    assertEquals("BareDocumentResponse", method.getReturnType().getSimpleName());

}
 
Example #22
Source File: WebResultAnnotator.java    From cxf with Apache License 2.0 4 votes vote down vote up
public void annotate(JavaAnnotatable ja) {
    JavaMethod method = null;
    if (ja instanceof JavaMethod) {
        method = (JavaMethod) ja;
    } else {
        throw new RuntimeException("WebResult can only annotate JavaMethod");
    }

    if (method.isOneWay()) {
        JAnnotation oneWayAnnotation = new JAnnotation(Oneway.class);
        method.addAnnotation("Oneway", oneWayAnnotation);
        return;
    }

    if ("void".equals(method.getReturn().getType())) {
        return;
    }
    JAnnotation resultAnnotation = new JAnnotation(WebResult.class);
    String targetNamespace = method.getReturn().getTargetNamespace();
    String name = "return";

    if (method.getSoapStyle() == SOAPBinding.Style.DOCUMENT && !method.isWrapperStyle()) {
        name = method.getName() + "Response";
    }

    if (method.getSoapStyle() == SOAPBinding.Style.RPC) {
        name = method.getReturn().getName();
        targetNamespace = method.getInterface().getNamespace();

    }
    if (method.getSoapStyle() == SOAPBinding.Style.DOCUMENT) {
        if (method.getReturn().getQName() != null) {
            name = method.getReturn().getQName().getLocalPart();
        }
        targetNamespace = method.getReturn().getTargetNamespace();
    }


    resultAnnotation.addElement(new JAnnotationElement("name", name));
    if (null != targetNamespace) {
        resultAnnotation.addElement(new JAnnotationElement("targetNamespace", targetNamespace));
    }

    if (method.getSoapStyle() == SOAPBinding.Style.RPC
        || (method.getSoapStyle() == SOAPBinding.Style.DOCUMENT && !method.isWrapperStyle())) {
        resultAnnotation.addElement(new JAnnotationElement("partName",
                                                                  method.getReturn().getName()));
    }

    method.addAnnotation("WebResult", resultAnnotation);
    method.getInterface().addImport("javax.jws.WebResult");
}
 
Example #23
Source File: DocLitWrappedCodeFirstService.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Oneway
@WebMethod
void doOneWay();
 
Example #24
Source File: CatastrophicEventSink.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Action(input = "http://www.fire.com")
@Oneway
void fire(@WebParam(name = "fire") FireEvent ev);
 
Example #25
Source File: CatastrophicEventSink.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Action(input = "http://www.earthquake.com")
@Oneway
void earthquake(@WebParam(name = "earthquake") EarthquakeEvent ev);
 
Example #26
Source File: OnewayOperationExceptionsTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Oneway
public void getNamespace() throws Exception {
}
 
Example #27
Source File: WebServiceVisitor.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example #28
Source File: WebServiceVisitor.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example #29
Source File: AddNumbers.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@WebMethod
@Oneway
public void send(@WebParam(name = "message")
                 String str) {
}
 
Example #30
Source File: WebServiceVisitor.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
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;
}