I need to generate a custom wsdl from my java artifacts. I use cxf apis to generate service.
Let me describe the scenario in details,
I want to generate different WSDL from same set of java artifacts.The idea behind such requirement to is to provide license based operation/messages to the customers. We have set of java objects defined as messages and service interfaces/implementation. Using Cxf API (ServerFactoryBean) I generate Service/WSDL on demand( purely run time operation).
Just to make it clear, I am giving example scenario
public class InputBean {
private XYZ xyz;
private ABC abc;
private PQR pqr;
Where XYZ, ABC, PQR are some java objects and InputBean is used in my Service Implementation class.
The requirement is to have these fields conditionally based on license
if(XYZ Licensed){
Include XYZ in bean
}
if(PQR Licensed){
Include PQR in bean
}
if(XYZ and PQR licensed){
Inlcude XYZ and PQR
}
I know this is strange requirement, and not sure if I had explained my problem clearly.
I would have tried with inheritance(dynamic method dispatch), but I want random combinations.
Any help would be appreciated!
I have solved this issue by creating a template file(free marker template), with place holder for required classes. This will be substituted at run time with required class names, created java source files using free marker api and then created java classes by java compiler api. Also developed custom class loader to load the class at run time. All the operation will perform in background at runtime. I could not find a better solution for my requirement, but I am happy with this as it is giving perfect result as expected.