@openapi-generator-plus/java-cxf-cdi-server-generator
Version:
An OpenAPI Generator Plus template for a Java API server using CXF and CDI
35 lines (34 loc) • 1.6 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.hooks = void 0;
const java_jaxrs_generator_common_1 = require("@openapi-generator-plus/java-jaxrs-generator-common");
const pom_1 = require("./pom");
const apiTest_1 = require("./apiTest");
/**
* Declares a CDI-injected dependency field, annotated with `@Inject`. Callers embed this
* behind their own single-tab indent (see `java-jaxrs-generator-common`'s single-line
* default), so the field's own line bakes in that same indent after the annotation's
* newline.
*/
function inject(params, ctx) {
var _a;
const access = (_a = params.access) !== null && _a !== void 0 ? _a : 'private';
return `@${(0, java_jaxrs_generator_common_1.javax)(ctx.root.useJakarta)}.inject.Inject\n\t${access} ${params.interface} ${params.name};`;
}
/** The `@Dependent` annotation shared by the API implementation, API service implementation and invoker classes. */
function dependentAnnotation(ctx) {
return `@${(0, java_jaxrs_generator_common_1.javax)(ctx.root.useJakarta)}.enterprise.context.Dependent`;
}
/**
* This generator's overrides of the DI, class-annotation and whole-file hooks from
* `java-jaxrs-generator-common` and `java-jaxrs-server-generator`, wiring the generated
* classes into CDI.
*/
exports.hooks = {
inject,
apiImplClassAnnotations: (_group, ctx) => dependentAnnotation(ctx),
apiServiceImplClassAnnotations: (_group, ctx) => dependentAnnotation(ctx),
invokerClassAnnotations: (ctx) => dependentAnnotation(ctx),
pom: pom_1.pom,
apiTest: apiTest_1.apiTest,
};