Skip to content

Commit

Permalink
use new generator and have one class by producer to fix namespace issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dufoli authored and olivier dufour committed Nov 22, 2019
1 parent dac0894 commit 8e3eab4
Showing 1 changed file with 16 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.quarkus.arc.Unremovable;
import io.quarkus.arc.deployment.BeanArchiveIndexBuildItem;
import io.quarkus.arc.deployment.GeneratedBeanBuildItem;
import io.quarkus.arc.deployment.GeneratedBeanGizmoAdaptor;
import io.quarkus.arc.deployment.UnremovableBeanBuildItem;
import io.quarkus.arc.processor.DotNames;
import io.quarkus.cxf.runtime.AbstractCxfWebServiceProducer;
Expand Down Expand Up @@ -167,44 +168,36 @@ private String getMappingPath(String path) {
@BuildStep
public void createBeans(
BuildProducer<UnremovableBeanBuildItem> unremovableBeans,
BuildProducer<GeneratedBeanBuildItem> generatedBean,
BuildProducer<GeneratedBeanBuildItem> generatedBeans,
List<WebServiceBuildItem> webServices) throws Exception {

ClassOutput classOutput = new ClassOutput() {
@Override
public void write(String name, byte[] data) {
generatedBean.produce(new GeneratedBeanBuildItem(name, data));
}
};

ClassCreator classCreator = ClassCreator.builder().classOutput(classOutput)
.className("CxfWebServiceProducer")
.superClass(AbstractCxfWebServiceProducer.class)
.build();
classCreator.addAnnotation(ApplicationScoped.class);

for (WebServiceBuildItem webService : webServices) {
ClassOutput classOutput = new GeneratedBeanGizmoAdaptor(generatedBeans);
String webServiceName = webService.getWebServiceClass();
ClassCreator classCreator = ClassCreator.builder().classOutput(classOutput)
.className(webServiceName + "Producer")
.superClass(AbstractCxfWebServiceProducer.class)
.build();
classCreator.addAnnotation(ApplicationScoped.class);

unremovableBeans.produce(new UnremovableBeanBuildItem(
new UnremovableBeanBuildItem.BeanClassNameExclusion(webService.getWebServiceClass())));
new UnremovableBeanBuildItem.BeanClassNameExclusion(webServiceName)));

MethodCreator namedWebServiceMethodCreator = classCreator.getMethodCreator(
"createWebService_" + HashUtil.sha1(webService.getWebServiceClass()),
webService.getWebServiceClass());
"createWebService_" + HashUtil.sha1(webServiceName),
webServiceName);
namedWebServiceMethodCreator.addAnnotation(ApplicationScoped.class);
namedWebServiceMethodCreator.addAnnotation(Unremovable.class);
namedWebServiceMethodCreator.addAnnotation(Produces.class);
namedWebServiceMethodCreator.addAnnotation(AnnotationInstance.create(DotNames.NAMED, null,
new AnnotationValue[] { AnnotationValue.createStringValue("value", webService.getWebServiceClass()) }));
new AnnotationValue[] { AnnotationValue.createStringValue("value", webServiceName) }));

//ResultHandle namedDataSourceNameRH = namedWebServiceMethodCreator.load(webService.getWebServiceClass());
ResultHandle namedWebService = namedWebServiceMethodCreator
.newInstance(MethodDescriptor.ofConstructor(webService.getWebServiceClass()));
.newInstance(MethodDescriptor.ofConstructor(webServiceName));

namedWebServiceMethodCreator.returnValue(namedWebService);
classCreator.close();
}

classCreator.close();

}

}

0 comments on commit 8e3eab4

Please sign in to comment.