Skip to content
Permalink
Browse files
[CXF-5455] Make sure we use the correct service/port impl when genera…
…ting the server

git-svn-id: https://svn.apache.org/repos/asf/cxf/trunk@1550274 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
dkulp committed Dec 11, 2013
1 parent 8507fd5 commit ec9c41e4f2b8392c092a330171c147875a0b6caa
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 11 deletions.
@@ -19,10 +19,12 @@

package org.apache.cxf.tools.wsdlto.frontend.jaxws.generators;

import java.util.HashMap;
import java.util.Map;

import javax.xml.namespace.QName;

import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.tools.common.ToolConstants;
import org.apache.cxf.tools.common.ToolContext;
@@ -105,13 +107,31 @@ private void outputImpl(JavaInterface intf, JavaServiceClass service,
setAttributes("port", port);

setCommonAttributes();

String name = intf.getName() + "Impl";
name = mapClassName(intf.getPackageName(), name, penv);

if (StringUtils.isEmpty(port)) {
port = intf.getName();
}
String name = getImplName(port, service == null ? "" : service.getName(), intf, penv);

setAttributes("implName", name);
penv.put(ToolConstants.CFG_IMPL_CLASS, name);

doWrite(IMPL_TEMPLATE, parseOutputName(intf.getPackageName(), name));
}

private String getImplName(String port, String service, JavaInterface intf, ToolContext penv) {
Map<String, String> nm = CastUtils.cast((Map<?, ?>)penv.get(ToolConstants.CFG_IMPL_CLASS));
if (nm == null) {
nm = new HashMap<String, String>();
penv.put(ToolConstants.CFG_IMPL_CLASS, nm);
}
String name = nm.get(service + "/" + port);
if (name == null) {
name = intf.getName() + "Impl";
name = mapClassName(intf.getPackageName(), name, penv);
nm.put(service + "/" + port, name);
}
return name;
}
private String mapClassName(String packageName, String name, ToolContext context) {
ClassCollector collector = context.get(ClassCollector.class);
int count = 0;
@@ -19,6 +19,7 @@

package org.apache.cxf.tools.wsdlto.frontend.jaxws.generators;

import java.util.HashMap;
import java.util.Map;

import javax.xml.namespace.QName;
@@ -98,12 +99,10 @@ public void generate(ToolContext penv) throws ToolException {
clearAttributes();
setAttributes("serverClassName", serverClassName);
setAttributes("intf", intf);
if (penv.optionSet(ToolConstants.CFG_IMPL_CLASS)) {
setAttributes("impl", penv.get(ToolConstants.CFG_IMPL_CLASS));
penv.remove(ToolConstants.CFG_IMPL_CLASS);
} else {
setAttributes("impl", intf.getName() + "Impl");
}

String name = getImplName(jp.getPortName(), js.getServiceName(), intf, penv);
setAttributes("impl", name);

setAttributes("address", address);
setCommonAttributes();

@@ -112,6 +111,20 @@ public void generate(ToolContext penv) throws ToolException {
}
}
}
private String getImplName(String port, String service, JavaInterface intf, ToolContext penv) {
Map<String, String> nm = CastUtils.cast((Map<?, ?>)penv.get(ToolConstants.CFG_IMPL_CLASS));
if (nm == null) {
nm = new HashMap<String, String>();
penv.put(ToolConstants.CFG_IMPL_CLASS, nm);
}
String name = nm.get(service + "/" + port);
if (name == null) {
name = intf.getName() + "Impl";
name = mapClassName(intf.getPackageName(), name, penv);
nm.put(service + "/" + port, name);
}
return name;
}

private String mapClassName(String packageName, String name, ToolContext context) {
ClassCollector collector = context.get(ClassCollector.class);
@@ -60,7 +60,7 @@ public class ${implName} implements $intf.Name {
#if ($mark-generated == "true")
@Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
#end
private static final Logger LOG = Logger.getLogger(${intf.Name}Impl.class.getName());
private static final Logger LOG = Logger.getLogger(${implName}.class.getName());

#foreach ($method in $intf.Methods)
/* (non-Javadoc)

0 comments on commit ec9c41e

Please sign in to comment.