Search in sources :

Example 1 with ClientContextHolder

use of org.ballerinalang.code.generator.model.ClientContextHolder in project ballerina by ballerina-lang.

the class ClientGeneratorPlugin method process.

@Override
public void process(ServiceNode serviceNode, List<AnnotationAttachmentNode> annotations) {
    CodeGenerator codegen = new CodeGenerator();
    PrintStream err = System.err;
    AnnotationAttachmentNode config = GeneratorUtils.getAnnotationFromList("ClientConfig", GeneratorConstants.SWAGGER_PKG_ALIAS, annotations);
    // Generate client only if requested by providing the client config annotation
    if (isClientGenerationEnabled(config)) {
        try {
            ClientContextHolder context = ClientContextHolder.buildContext(serviceNode, endpoints);
            codegen.writeGeneratedSource(GeneratorConstants.GenType.CLIENT, context, getOutputFilePath(serviceNode));
        } catch (CodeGeneratorException e) {
            err.println("Client code was not generated: " + e.getMessage());
        }
    }
}
Also used : PrintStream(java.io.PrintStream) CodeGeneratorException(org.ballerinalang.code.generator.exception.CodeGeneratorException) CodeGenerator(org.ballerinalang.code.generator.CodeGenerator) ClientContextHolder(org.ballerinalang.code.generator.model.ClientContextHolder) AnnotationAttachmentNode(org.ballerinalang.model.tree.AnnotationAttachmentNode)

Aggregations

PrintStream (java.io.PrintStream)1 CodeGenerator (org.ballerinalang.code.generator.CodeGenerator)1 CodeGeneratorException (org.ballerinalang.code.generator.exception.CodeGeneratorException)1 ClientContextHolder (org.ballerinalang.code.generator.model.ClientContextHolder)1 AnnotationAttachmentNode (org.ballerinalang.model.tree.AnnotationAttachmentNode)1