use of org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.mapper.InterfaceMapper in project cxf by apache.
the class PortTypeProcessor method getInterface.
public static JavaInterface getInterface(ToolContext context, ServiceInfo serviceInfo, InterfaceInfo interfaceInfo) throws ToolException {
JavaInterface intf = interfaceInfo.getProperty("JavaInterface", JavaInterface.class);
if (intf == null) {
intf = new InterfaceMapper(context).map(interfaceInfo);
JAXWSBinding jaxwsBinding = null;
if (serviceInfo.getDescription() != null) {
jaxwsBinding = serviceInfo.getDescription().getExtensor(JAXWSBinding.class);
}
JAXWSBinding infBinding = interfaceInfo.getExtensor(JAXWSBinding.class);
if (infBinding != null && infBinding.getPackage() != null) {
intf.setPackageName(infBinding.getPackage());
} else if (jaxwsBinding != null && jaxwsBinding.getPackage() != null) {
intf.setPackageName(jaxwsBinding.getPackage());
}
if (infBinding != null && !infBinding.getPackageJavaDoc().equals("")) {
intf.setPackageJavaDoc(infBinding.getPackageJavaDoc());
} else if (jaxwsBinding != null && !jaxwsBinding.getPackageJavaDoc().equals("")) {
intf.setPackageJavaDoc(jaxwsBinding.getPackageJavaDoc());
}
String name = intf.getName();
if (infBinding != null && infBinding.getJaxwsClass() != null && infBinding.getJaxwsClass().getClassName() != null) {
name = infBinding.getJaxwsClass().getClassName();
if (name.contains(".")) {
intf.setPackageName(name.substring(0, name.lastIndexOf('.')));
name = name.substring(name.lastIndexOf('.') + 1);
}
intf.setClassJavaDoc(infBinding.getJaxwsClass().getComments());
}
if (StringUtils.isEmpty(intf.getClassJavaDoc())) {
intf.setClassJavaDoc(interfaceInfo.getDocumentation());
}
ClassCollector collector = context.get(ClassCollector.class);
if (context.optionSet(ToolConstants.CFG_AUTORESOLVE)) {
int count = 0;
String checkName = name;
while (collector.isReserved(intf.getPackageName(), checkName)) {
checkName = name + "_" + (++count);
}
name = checkName;
} else if (collector.isReserved(intf.getPackageName(), name)) {
throw new ToolException("RESERVED_SEI_NAME", LOG, name);
}
interfaceInfo.setProperty("InterfaceName", name);
intf.setName(name);
collector.addSeiClassName(intf.getPackageName(), intf.getName(), intf.getPackageName() + "." + intf.getName());
interfaceInfo.setProperty("JavaInterface", intf);
if (context.containsKey(ToolConstants.CFG_SEI_SUPER)) {
String[] supers = context.getArray(ToolConstants.CFG_SEI_SUPER);
for (String s : supers) {
intf.addSuperInterface(s);
}
}
}
return intf;
}
Aggregations