Skip to content

Commit 117e245

Browse files
authored
Merge pull request #782 from aws/shorea-marshaller-phase-three
Various cleanup and removing unused stuff
2 parents 21fada4 + e62ffc9 commit 117e245

File tree

165 files changed

+103
-2021
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+103
-2021
lines changed

codegen-maven-plugin/src/main/java/software/amazon/awssdk/codegen/maven/plugin/GenerationMojo.java

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,15 @@ public void execute() throws MojoExecutionException {
6969
this.testsDirectory = Paths.get(outputDirectory).resolve("generated-test-sources").resolve("sdk-tests");
7070

7171
findModelRoots().forEach(p -> {
72-
try {
73-
getLog().info("Loading from: " + p.toString());
74-
generateCode(C2jModels.builder()
75-
.applyMutation(b -> loadCodeGenConfig(p).ifPresent(b::codeGenConfig))
76-
.customizationConfig(loadCustomizationConfig(p))
77-
.serviceModel(loadServiceModel(p))
78-
.waitersModel(loadWaiterModel(p))
79-
.paginatorsModel(loadPaginatorModel(p))
80-
.examplesModel(loadExamplesModel(p))
81-
.build());
82-
} catch (MojoExecutionException e) {
83-
throw new RuntimeException(e);
84-
}
72+
getLog().info("Loading from: " + p.toString());
73+
generateCode(C2jModels.builder()
74+
.applyMutation(b -> loadCodeGenConfig(p).ifPresent(b::codeGenConfig))
75+
.customizationConfig(loadCustomizationConfig(p))
76+
.serviceModel(loadServiceModel(p))
77+
.waitersModel(loadWaiterModel(p))
78+
.paginatorsModel(loadPaginatorModel(p))
79+
.examplesModel(loadExamplesModel(p))
80+
.build());
8581
});
8682
project.addCompileSourceRoot(sourcesDirectory.toFile().getAbsolutePath());
8783
project.addTestCompileSourceRoot(testsDirectory.toFile().getAbsolutePath());
@@ -120,11 +116,13 @@ private Optional<BasicCodeGenConfig> loadCodeGenConfig(Path root) {
120116
}
121117

122118
private CustomizationConfig loadCustomizationConfig(Path root) {
123-
return loadOptionalModel(CustomizationConfig.class, root.resolve(CUSTOMIZATION_CONFIG_FILE))
124-
.orElse(CustomizationConfig.create());
119+
return ModelLoaderUtils.loadOptionalModel(CustomizationConfig.class,
120+
root.resolve(CUSTOMIZATION_CONFIG_FILE).toFile(),
121+
true)
122+
.orElse(CustomizationConfig.create());
125123
}
126124

127-
private ServiceModel loadServiceModel(Path root) throws MojoExecutionException {
125+
private ServiceModel loadServiceModel(Path root) {
128126
return loadRequiredModel(ServiceModel.class, root.resolve(MODEL_FILE));
129127
}
130128

@@ -143,7 +141,7 @@ private Paginators loadPaginatorModel(Path root) {
143141
/**
144142
* Load required model from the project resources.
145143
*/
146-
private <T> T loadRequiredModel(Class<T> clzz, Path location) throws MojoExecutionException {
144+
private <T> T loadRequiredModel(Class<T> clzz, Path location) {
147145
return ModelLoaderUtils.loadModel(clzz, location.toFile());
148146
}
149147

codegen/src/main/java/software/amazon/awssdk/codegen/AddMetadata.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ public static Metadata constructMetadata(ServiceModel serviceModel,
8181
.withTransformPackageName(namingStrategy.getTransformPackageName(serviceName))
8282
.withRequestTransformPackageName(namingStrategy.getRequestTransformPackageName(serviceName))
8383
.withPaginatorsPackageName(namingStrategy.getPaginatorsPackageName(serviceName))
84-
.withSmokeTestsPackageName(namingStrategy.getSmokeTestPackageName(serviceName))
8584
.withServiceAbbreviation(serviceMetadata.getServiceAbbreviation())
8685
.withServiceFullName(serviceMetadata.getServiceFullName())
8786
.withSyncClient(String.format(Constant.SYNC_CLIENT_CLASS_NAME_PATTERN, serviceName))
@@ -103,9 +102,6 @@ public static Metadata constructMetadata(ServiceModel serviceModel,
103102
String jsonVersion = getJsonVersion(metadata, serviceMetadata);
104103
metadata.setJsonVersion(jsonVersion);
105104

106-
// TODO: iterate through all the operations and check whether any of
107-
// them accept stream input
108-
metadata.setHasApiWithStreamInput(false);
109105
return metadata;
110106
}
111107

codegen/src/main/java/software/amazon/awssdk/codegen/emitters/GeneratorPathProvider.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
package software.amazon.awssdk.codegen.emitters;
1717

18-
import software.amazon.awssdk.codegen.internal.Constant;
1918
import software.amazon.awssdk.codegen.internal.Utils;
2019
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
2120

@@ -50,10 +49,6 @@ public String getTransformDirectory() {
5049
return sourceDirectory + "/" + Utils.packageToDirectory(model.getMetadata().getFullTransformPackageName());
5150
}
5251

53-
public String getRequestTransformDirectory() {
54-
return sourceDirectory + "/" + Utils.packageToDirectory(model.getMetadata().getFullRequestTransformPackageName());
55-
}
56-
5752
public String getClientDirectory() {
5853
return sourceDirectory + "/" + Utils.packageToDirectory(model.getMetadata().getFullClientPackageName());
5954
}
@@ -62,15 +57,7 @@ public String getPaginatorsDirectory() {
6257
return sourceDirectory + "/" + Utils.packageToDirectory(model.getMetadata().getFullPaginatorsPackageName());
6358
}
6459

65-
public String getPolicyEnumDirectory() {
66-
return sourceDirectory + "/" + Constant.AUTH_POLICY_ENUM_CLASS_DIR;
67-
}
68-
6960
public String getAuthorizerDirectory() {
7061
return sourceDirectory + "/" + Utils.packageToDirectory(model.getMetadata().getFullAuthPolicyPackageName());
7162
}
72-
73-
public String getSmokeTestDirectory() {
74-
return testDirectory + '/' + Utils.packageToDirectory(model.getMetadata().getFullSmokeTestsPackageName());
75-
}
7663
}

codegen/src/main/java/software/amazon/awssdk/codegen/emitters/tasks/SmokeTestsGeneratorTasks.java

Lines changed: 0 additions & 60 deletions
This file was deleted.

codegen/src/main/java/software/amazon/awssdk/codegen/internal/Jackson.java

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@
1515

1616
package software.amazon.awssdk.codegen.internal;
1717

18-
import com.fasterxml.jackson.core.JsonGenerationException;
19-
import com.fasterxml.jackson.core.JsonParseException;
2018
import com.fasterxml.jackson.core.JsonParser;
2119
import com.fasterxml.jackson.databind.DeserializationFeature;
22-
import com.fasterxml.jackson.databind.JsonMappingException;
2320
import com.fasterxml.jackson.databind.MapperFeature;
2421
import com.fasterxml.jackson.databind.ObjectMapper;
2522
import com.fasterxml.jackson.databind.ObjectWriter;
@@ -32,42 +29,48 @@
3229

3330
public final class Jackson {
3431

35-
private static final ObjectMapper MAPPER = new ObjectMapper();
32+
private static final ObjectMapper MAPPER = new ObjectMapper()
33+
.configure(JsonParser.Feature.ALLOW_COMMENTS, true)
34+
.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
35+
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
3636

37-
private static final ObjectWriter WRITER = MAPPER
38-
.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true)
39-
.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
40-
.writerWithDefaultPrettyPrinter();
41-
42-
static {
43-
MAPPER.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
44-
MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
37+
private static final ObjectMapper FAIL_ON_UNKNOWN_PROPERTIES_MAPPER = new ObjectMapper()
38+
.configure(JsonParser.Feature.ALLOW_COMMENTS, true)
39+
.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
4540

46-
MAPPER.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
47-
}
41+
private static final ObjectWriter WRITER = MAPPER
42+
.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true)
43+
.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
44+
.writerWithDefaultPrettyPrinter();
4845

4946
private Jackson() {
5047
}
5148

52-
public static <T> T load(Class<T> clazz, File file)
53-
throws JsonParseException, JsonMappingException, IOException {
49+
public static <T> T load(Class<T> clazz, File file) throws IOException {
5450
return load(clazz, new FileInputStream(file));
5551
}
5652

57-
public static <T> T load(Class<T> clazz, InputStream is)
58-
throws JsonParseException, JsonMappingException, IOException {
53+
public static <T> T load(Class<T> clazz, File file, boolean failOnUnknownProperties) throws IOException {
54+
try (FileInputStream fis = new FileInputStream(file)) {
55+
if (failOnUnknownProperties) {
56+
return FAIL_ON_UNKNOWN_PROPERTIES_MAPPER.readValue(fis, clazz);
57+
} else {
58+
return load(clazz, fis);
59+
}
60+
}
61+
}
62+
63+
public static <T> T load(Class<T> clazz, InputStream is) throws IOException {
5964
return MAPPER.readValue(is, clazz);
6065
}
6166

62-
public static <T> T load(Class<T> clazz, String fileLocation)
63-
throws JsonParseException, JsonMappingException, IOException {
67+
public static <T> T load(Class<T> clazz, String fileLocation) throws IOException {
6468
InputStream is = Jackson.class.getClassLoader().getResourceAsStream(
65-
fileLocation);
69+
fileLocation);
6670
return MAPPER.readValue(is, clazz);
6771
}
6872

69-
public static void write(Object value, Writer w)
70-
throws JsonGenerationException, JsonMappingException, IOException {
73+
public static void write(Object value, Writer w) throws IOException {
7174
WRITER.writeValue(w, value);
7275
}
7376

codegen/src/main/java/software/amazon/awssdk/codegen/model/config/customization/CustomizationConfig.java

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,6 @@ public class CustomizationConfig {
2929
* different type that is adapted to the real type
3030
*/
3131
private final List<ConvenienceTypeOverload> convenienceTypeOverloads = new ArrayList<>();
32-
/**
33-
* Overrides the request-level service name that will be used for request metrics and service
34-
* exceptions. If not specified, the client will use the service interface name by default.
35-
*
36-
* Example: for backwards compatibility, this is set to "AmazonDynamoDBv2" for DynamoDB client.
37-
*
38-
* @see {@link software.amazon.awssdk.core.Request#getServiceName()}
39-
*/
40-
private String customServiceNameForRequest;
41-
/**
42-
* True if the generated code should enable client-side validation on required input
43-
* parameters.
44-
*/
45-
private boolean requiredParamValidationEnabled;
4632
/**
4733
* Specifies the name of the client configuration class to use if a service
4834
* has a specific advanced client configuration class. Null if the service
@@ -86,10 +72,6 @@ public class CustomizationConfig {
8672
* Service calculates CRC32 checksum from compressed file when Accept-Encoding: gzip header is provided.
8773
*/
8874
private boolean calculateCrc32FromCompressedData;
89-
/**
90-
* Skips generating smoketests if set to true.
91-
*/
92-
private boolean skipSmokeTests;
9375

9476
/**
9577
* Exclude the create() method on a client. This is useful for global services that will need a global region configured to
@@ -157,14 +139,6 @@ public static CustomizationConfig create() {
157139
return new CustomizationConfig();
158140
}
159141

160-
public String getCustomServiceNameForRequest() {
161-
return customServiceNameForRequest;
162-
}
163-
164-
public void setCustomServiceNameForRequest(String customServiceNameForRequest) {
165-
this.customServiceNameForRequest = customServiceNameForRequest;
166-
}
167-
168142
public CodeGenTemplatesConfig getCustomCodeTemplates() {
169143
return customCodeTemplates;
170144
}
@@ -205,14 +179,6 @@ public void setShapeModifiers(Map<String, ShapeModifier> shapeModifiers) {
205179
this.shapeModifiers = shapeModifiers;
206180
}
207181

208-
public boolean isRequiredParamValidationEnabled() {
209-
return requiredParamValidationEnabled;
210-
}
211-
212-
public void setRequiredParamValidationEnabled(boolean requiredParamValidationEnabled) {
213-
this.requiredParamValidationEnabled = requiredParamValidationEnabled;
214-
}
215-
216182
public String getServiceSpecificClientConfigClass() {
217183
return serviceSpecificClientConfigClass;
218184
}
@@ -282,14 +248,6 @@ public void setCalculateCrc32FromCompressedData(
282248
this.calculateCrc32FromCompressedData = calculateCrc32FromCompressedData;
283249
}
284250

285-
public boolean isSkipSmokeTests() {
286-
return skipSmokeTests;
287-
}
288-
289-
public void setSkipSmokeTests(boolean skipSmokeTests) {
290-
this.skipSmokeTests = skipSmokeTests;
291-
}
292-
293251
public boolean isExcludeClientCreateMethod() {
294252
return excludeClientCreateMethod;
295253
}

codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/IntermediateModel.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,6 @@ public String getCustomRetryPolicy() {
142142
return customizationConfig.getCustomRetryPolicy();
143143
}
144144

145-
public String getServiceBaseExceptionFqcn() {
146-
// TODO Move this into Metadata
147-
return metadata.getProtocol().getProvider().getBaseExceptionFqcn();
148-
}
149-
150145
public String getSdkModeledExceptionBaseFqcn() {
151146
return String.format("%s.%s",
152147
metadata.getFullModelPackageName(),

codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/MemberModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import java.util.Map;
2929
import software.amazon.awssdk.codegen.internal.TypeUtils;
3030
import software.amazon.awssdk.core.SdkBytes;
31-
import software.amazon.awssdk.core.runtime.transform.PathMarshaller;
31+
import software.amazon.awssdk.protocols.core.PathMarshaller;
3232
import software.amazon.awssdk.utils.StringUtils;
3333

3434
public class MemberModel extends DocumentationModel {

0 commit comments

Comments
 (0)