Search in sources :

Example 1 with WebServiceEntryPoint

use of org.eclipse.scout.rt.server.jaxws.provider.annotation.WebServiceEntryPoint in project scout.rt by eclipse.

the class JaxWsAnnotationProcessor method generateEntryPoints.

/**
 * Generates an <em>entry point port type</em> for all declared {@link WebServiceEntryPoint} annotations.
 */
protected void generateEntryPoints(final RoundEnvironment roundEnv) {
    // Collect endpoint interfaces.
    final Set<String> endpointInterfaceNames = collectEndpointInterfaceNames(roundEnv);
    // Collect 'entryPointDefinitions' to generate entry point port types.
    for (final Element _element : roundEnv.getElementsAnnotatedWith(WebServiceEntryPoint.class)) {
        final TypeElement _entryPointDefinition = (TypeElement) _element;
        String endpointInterfaceName = null;
        try {
            final AnnotationMirror _entryPointAnnotationMirror = AnnotationUtil.findAnnotationMirror(WebServiceEntryPoint.class.getName(), _entryPointDefinition);
            // Resolve and validate the endpoint interface.
            final TypeElement _endpointInterface = AnnotationUtil.getTypeElement(_entryPointAnnotationMirror, "endpointInterface", processingEnv.getElementUtils(), processingEnv.getTypeUtils());
            Assertions.assertNotNull(_endpointInterface, "Failed to resolve endpoint interface [entryPointDefinition={}]", _entryPointDefinition.getQualifiedName().toString());
            endpointInterfaceName = _endpointInterface.getQualifiedName().toString();
            Assertions.assertNotNull(_endpointInterface.getAnnotation(WebService.class), "Invalid endpoint interface. Must be annoated with {} annotation [entryPointDefinition={}, endpointInterface={}]", WebService.class.getSimpleName(), _entryPointDefinition.getQualifiedName().toString(), endpointInterfaceName);
            // Mark endpoint interface as processed.
            endpointInterfaceNames.remove(endpointInterfaceName);
            final EntryPointDefinition entryPointDefinition = new EntryPointDefinition((TypeElement) _entryPointDefinition, _endpointInterface, processingEnv);
            if (entryPointDefinition.isIgnore()) {
                m_logger.info("Ignore entry point definition for endpoint interface '{}' [entryPoint={}, wsdl:portType={}, wsdl:service={}, wsdl:port={}]", endpointInterfaceName, entryPointDefinition.getEntryPointQualifiedName(), entryPointDefinition.getPortTypeName(), entryPointDefinition.getServiceName(), entryPointDefinition.getPortName());
            } else {
                m_logger.info("Generate entry point for endpoint interface '{}' [entryPoint={}, wsdl:portType={}, wsdl:service={}, wsdl:port={}]", endpointInterfaceName, entryPointDefinition.getEntryPointQualifiedName(), entryPointDefinition.getPortTypeName(), entryPointDefinition.getServiceName(), entryPointDefinition.getPortName());
                generateEntryPoint(entryPointDefinition, roundEnv);
            }
        } catch (final Exception e) {
            m_logger.error("Failed to generate entry point for endpoint interface '{}' [entryPointDefinition={}]", endpointInterfaceName, _entryPointDefinition.getQualifiedName().toString(), e);
        }
    }
    // Log endpoint interfaces for which no entry point was generated.
    for (final String endpointInterfaceName : endpointInterfaceNames) {
        m_logger.info("Skipped entry point generation for endpoint interface '{}' because not configured with {} annotation.", endpointInterfaceName, WebServiceEntryPoint.class.getSimpleName());
    }
}
Also used : AnnotationMirror(javax.lang.model.element.AnnotationMirror) EntryPointDefinition(org.eclipse.scout.jaxws.apt.internal.EntryPointDefinition) WebService(javax.jws.WebService) TypeElement(javax.lang.model.element.TypeElement) TypeElement(javax.lang.model.element.TypeElement) Element(javax.lang.model.element.Element) VariableElement(javax.lang.model.element.VariableElement) ExecutableElement(javax.lang.model.element.ExecutableElement) WebServiceEntryPoint(org.eclipse.scout.rt.server.jaxws.provider.annotation.WebServiceEntryPoint) JClassAlreadyExistsException(com.sun.codemodel.JClassAlreadyExistsException) IOException(java.io.IOException)

Aggregations

JClassAlreadyExistsException (com.sun.codemodel.JClassAlreadyExistsException)1 IOException (java.io.IOException)1 WebService (javax.jws.WebService)1 AnnotationMirror (javax.lang.model.element.AnnotationMirror)1 Element (javax.lang.model.element.Element)1 ExecutableElement (javax.lang.model.element.ExecutableElement)1 TypeElement (javax.lang.model.element.TypeElement)1 VariableElement (javax.lang.model.element.VariableElement)1 EntryPointDefinition (org.eclipse.scout.jaxws.apt.internal.EntryPointDefinition)1 WebServiceEntryPoint (org.eclipse.scout.rt.server.jaxws.provider.annotation.WebServiceEntryPoint)1