Make ApiClient more pluggable for Java

- Rename ApiInvoker to ApiClient
- Make ApiClient pluggable by allowing setting the ApiClient field of
  API classes
- Introduce a Configuration class, containing the default
  ApiClient (which is also customizable)
- Move basePath from API class to ApiClient
- Change static methods in ApiClient to instance level
This commit is contained in:
xhh
2015-05-26 16:05:47 +08:00
parent 1657f2e5f7
commit ac134c0afa
4 changed files with 95 additions and 70 deletions

View File

@@ -51,11 +51,13 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
additionalProperties.put("artifactVersion", artifactVersion);
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
supportingFiles.add(new SupportingFile("apiInvoker.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiInvoker.java"));
supportingFiles.add(new SupportingFile("JsonUtil.mustache",
supportingFiles.add(new SupportingFile("ApiClient.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiClient.java"));
supportingFiles.add(new SupportingFile("Configuration.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "Configuration.java"));
supportingFiles.add(new SupportingFile("JsonUtil.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "JsonUtil.java"));
supportingFiles.add(new SupportingFile("apiException.mustache",
supportingFiles.add(new SupportingFile("apiException.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiException.java"));
languageSpecificPrimitives = new HashSet<String>(