Author: david.boeren
Date: 2008-06-24 11:53:36 -0400 (Tue, 24 Jun 2008)
New Revision: 7732
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/JavaWriter.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/WSDLToJava.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/client/ServiceCreator.java
Log:
Fix for JBPAPP-921 to map hyphen characters in PortType so the resultant Java code will
compile.
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/JavaWriter.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/JavaWriter.java 2008-06-24
08:46:31 UTC (rev 7731)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/JavaWriter.java 2008-06-24
15:53:36 UTC (rev 7732)
@@ -198,7 +198,7 @@
if (needToCreatePackageStructure(location, packageName))
newLoc = utils.createPackage(location.getPath(), packageName);
else newLoc = location;
- String classname = utils.chop(filename, ".java");
+ String classname = utils.chop(ToolsUtils.convertInvalidCharacters(filename),
".java");
File sei = utils.createPhysicalFile(newLoc, classname);
StringBuilder buffer = new StringBuilder();
utils.writeJbossHeader(buffer);
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/WSDLToJava.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/WSDLToJava.java 2008-06-24
08:46:31 UTC (rev 7731)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/WSDLToJava.java 2008-06-24
15:53:36 UTC (rev 7732)
@@ -309,8 +309,8 @@
if (returnType == null)
returnType = "void";
- buf.append(" public " + returnType + " ");
- buf.append(ToolsUtils.firstLetterLowerCase(op.getName().getLocalPart()));
+ buf.append(" public " +
ToolsUtils.convertInvalidCharacters(returnType) + " ");
+
buf.append(ToolsUtils.convertInvalidCharacters(ToolsUtils.firstLetterLowerCase(op.getName().getLocalPart())));
buf.append("(").append(paramBuffer);
buf.append(") throws ");
@@ -646,7 +646,7 @@
className = holderWriter.getOrCreateHolder(className,
getLocationForJavaGeneration());
}
- buf.append(className);
+ buf.append(ToolsUtils.convertInvalidCharacters(className));
if (xt instanceof XSComplexTypeDefinition)
generateJavaSource((XSComplexTypeDefinition)xt, xsmodel, containingElement);
@@ -659,12 +659,12 @@
StringBuilder buf = new StringBuilder();
utils.writeJbossHeader(buf);
- buf.append("package " + seiPkgName + ";" + newline);
- buf.append("public interface " + seiName + " extends
java.rmi.Remote" + newline + "{" + newline);
+ buf.append("package " + ToolsUtils.convertInvalidCharacters(seiPkgName) +
";" + newline);
+ buf.append("public interface " +
ToolsUtils.convertInvalidCharacters(seiName) + " extends java.rmi.Remote" +
newline + "{" + newline);
appendMethods(intf, buf);
buf.append("}" + newline);
- File sei = utils.createPhysicalFile(loc, seiName);
+ File sei = utils.createPhysicalFile(loc,
ToolsUtils.convertInvalidCharacters(seiName));
FileWriter writer = new FileWriter(sei);
writer.write(buf.toString());
writer.flush();
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/client/ServiceCreator.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/client/ServiceCreator.java 2008-06-24
08:46:31 UTC (rev 7731)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/client/ServiceCreator.java 2008-06-24
15:53:36 UTC (rev 7732)
@@ -33,6 +33,7 @@
import org.jboss.ws.metadata.wsdl.WSDLEndpoint;
import org.jboss.ws.metadata.wsdl.WSDLService;
import org.jboss.ws.metadata.wsdl.WSDLUtils;
+import org.jboss.ws.tools.ToolsUtils;
import org.jboss.ws.tools.interfaces.ServiceCreatorIntf;
import org.jboss.wsf.common.JavaUtils;
@@ -239,13 +240,27 @@
writer.close();
}
+ public static String convertInvalidCharacters(final String component)
+ {
+ String result = component;
+ for (int i = 0; i < result.length(); i++)
+ {
+ if (Character.isJavaIdentifierPart(result.charAt(i)) == false)
+ {
+ result = result.replace(result.charAt(i), '_');
+ }
+ }
+
+ return result;
+ }
+
private String generateServiceMethodForWSDLEndpoint(WSDLEndpoint endpt)
{
StringBuilder buf = new StringBuilder(" public ");
QName bindName = endpt.getBinding();
WSDLBinding wbind = wsdl.getBinding(bindName);
- buf.append(getReturnType(wbind)).append(" get");
+ buf.append(ToolsUtils.convertInvalidCharacters(getReturnType(wbind))).append("
get");
buf.append(endpt.getName().getLocalPart()).append("()").append("
throws ServiceException;").append(newLine(1));
return buf.toString();
}
Show replies by date