Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit 693423f

Browse files
author
Corneil du Plessis
committed
Added AppBootSchemaVersion tests and updated controller.
1 parent 4f10587 commit 693423f

File tree

34 files changed

+536
-146
lines changed

34 files changed

+536
-146
lines changed

.settings.xml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
<activeByDefault>true</activeByDefault>
2121
</activation>
2222
<repositories>
23+
<repository>
24+
<id>maven-central</id>
25+
<name>Maven Central</name>
26+
<url>https://repo.maven.apache.org/maven2</url>
27+
<snapshots>
28+
<enabled>false</enabled>
29+
</snapshots>
30+
</repository>
2331
<repository>
2432
<id>spring-snapshots</id>
2533
<name>Spring Snapshots</name>
@@ -37,15 +45,23 @@
3745
</snapshots>
3846
</repository>
3947
<repository>
48+
<id>spring-releases</id>
49+
<name>Spring Releases</name>
50+
<url>https://repo.spring.io/libs-release</url>
51+
<snapshots>
52+
<enabled>true</enabled>
53+
</snapshots>
54+
</repository>
55+
</repositories>
56+
<pluginRepositories>
57+
<pluginRepository>
4058
<id>maven-central</id>
4159
<name>Maven Central</name>
4260
<url>https://repo.maven.apache.org/maven2</url>
4361
<snapshots>
4462
<enabled>false</enabled>
4563
</snapshots>
46-
</repository>
47-
</repositories>
48-
<pluginRepositories>
64+
</pluginRepository>
4965
<pluginRepository>
5066
<id>spring-snapshots</id>
5167
<name>Spring Snapshots</name>
@@ -62,14 +78,6 @@
6278
<enabled>false</enabled>
6379
</snapshots>
6480
</pluginRepository>
65-
<pluginRepository>
66-
<id>maven-central</id>
67-
<name>Maven Central</name>
68-
<url>https://repo.maven.apache.org/maven2</url>
69-
<snapshots>
70-
<enabled>false</enabled>
71-
</snapshots>
72-
</pluginRepository>
7381
</pluginRepositories>
7482
<distributionManagement>
7583
<repository>

spring-cloud-dataflow-core/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
<groupId>com.fasterxml.jackson.core</groupId>
3333
<artifactId>jackson-annotations</artifactId>
3434
</dependency>
35+
<dependency>
36+
<groupId>com.fasterxml.jackson.core</groupId>
37+
<artifactId>jackson-databind</artifactId>
38+
</dependency>
3539
<dependency>
3640
<groupId>org.springframework.data</groupId>
3741
<artifactId>spring-data-keyvalue</artifactId>

spring-cloud-dataflow-core/src/main/java/org/springframework/cloud/dataflow/core/AppBootSchemaVersion.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
import java.util.Arrays;
2020

21+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
22+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
23+
2124
/**
2225
* Defines the possible schema versions that currently map to Spring {@code "Boot"}. A registered application can only support one schema version.
2326
*
@@ -26,6 +29,8 @@
2629
* @author Chris Bono
2730
* @author Corneil du Plessis
2831
*/
32+
@JsonSerialize(using = AppBootSchemaVersionSerializer.class)
33+
@JsonDeserialize(using = AppBootSchemaVersionDeserializer.class)
2934
public enum AppBootSchemaVersion {
3035

3136
BOOT2("2"),
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright 2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.cloud.dataflow.core;
18+
19+
import java.io.IOException;
20+
21+
import com.fasterxml.jackson.core.JacksonException;
22+
import com.fasterxml.jackson.core.JsonParser;
23+
import com.fasterxml.jackson.databind.DeserializationContext;
24+
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
25+
26+
/**
27+
* Deserialize AppBootSchemaVersion with Jackson
28+
* @author Corneil du Plessis
29+
*/
30+
public class AppBootSchemaVersionDeserializer extends StdDeserializer<AppBootSchemaVersion> {
31+
public AppBootSchemaVersionDeserializer() {
32+
super(AppBootSchemaVersion.class);
33+
}
34+
35+
public AppBootSchemaVersionDeserializer(Class<?> vc) {
36+
super(vc);
37+
}
38+
39+
@Override
40+
public AppBootSchemaVersion deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JacksonException {
41+
String value = jsonParser.getValueAsString();
42+
return value != null ? AppBootSchemaVersion.fromBootVersion(value) : null;
43+
}
44+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.cloud.dataflow.core;
18+
19+
import java.io.IOException;
20+
21+
import com.fasterxml.jackson.core.JsonGenerator;
22+
import com.fasterxml.jackson.databind.SerializerProvider;
23+
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
24+
25+
/**
26+
* Serialize AppBootSchemaVersion with Jackson
27+
* @author Corneil du Plessis
28+
*/
29+
public class AppBootSchemaVersionSerializer extends StdSerializer<AppBootSchemaVersion> {
30+
public AppBootSchemaVersionSerializer() {
31+
super(AppBootSchemaVersion.class);
32+
}
33+
34+
protected AppBootSchemaVersionSerializer(Class<AppBootSchemaVersion> t) {
35+
super(t);
36+
}
37+
38+
@Override
39+
public void serialize(AppBootSchemaVersion appBootSchemaVersion, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
40+
if(appBootSchemaVersion != null) {
41+
jsonGenerator.writeString(appBootSchemaVersion.getBootVersion());
42+
} else {
43+
jsonGenerator.writeNull();
44+
}
45+
}
46+
}

spring-cloud-dataflow-shell-core/src/main/java/org/springframework/cloud/dataflow/shell/converter/AppBootVersionConverter.java renamed to spring-cloud-dataflow-core/src/main/java/org/springframework/cloud/dataflow/core/AppBootVersionConverter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.cloud.dataflow.shell.converter;
17+
package org.springframework.cloud.dataflow.core;
1818

19-
import org.springframework.cloud.dataflow.core.AppBootSchemaVersion;
2019
import org.springframework.core.convert.converter.Converter;
2120
import org.springframework.stereotype.Component;
2221

2322
/**
2423
* Converts strings to {@link AppBootSchemaVersion}
2524
*
2625
* @author Chris Bono
26+
* @author Corneil du Plessis
2727
*/
2828
@Component
2929
public class AppBootVersionConverter implements Converter<String, AppBootSchemaVersion> {

spring-cloud-dataflow-core/src/main/java/org/springframework/cloud/dataflow/core/AppRegistration.java

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import java.util.Objects;
2222

2323
import javax.persistence.Entity;
24+
import javax.persistence.EnumType;
25+
import javax.persistence.Enumerated;
2426
import javax.persistence.Lob;
2527
import javax.persistence.Table;
2628
import javax.persistence.Transient;
@@ -74,6 +76,12 @@ public class AppRegistration extends AbstractEntity implements Comparable<AppReg
7476
*/
7577
private Boolean defaultVersion = false;
7678

79+
/**
80+
* Boot version to identify Task / Batch Schema.
81+
*/
82+
@Enumerated(EnumType.STRING)
83+
private AppBootSchemaVersion bootVersion;
84+
7785
@Transient
7886
private HashSet<String> versions;
7987

@@ -124,6 +132,21 @@ public AppRegistration(String name, ApplicationType type, String version, URI ur
124132
this.metadataUri = metadataUri;
125133
}
126134

135+
/**
136+
* Construct an {@code AppRegistration} object.
137+
*
138+
* @param name app name
139+
* @param type app type
140+
* @param version app version
141+
* @param uri URI for the app resource
142+
* @param metadataUri URI for the app metadata resource
143+
* @param schemaTargetName The name of the SchemaVersionTarget. Null means the default entry.
144+
*/
145+
public AppRegistration(String name, ApplicationType type, String version, URI uri, URI metadataUri, AppBootSchemaVersion bootVersion) {
146+
this(name,type,version,uri,metadataUri);
147+
this.bootVersion = bootVersion;
148+
}
149+
127150
/**
128151
* @return the name of the app
129152
*/
@@ -176,6 +199,14 @@ public void setMetadataUri(URI metadataUri) {
176199
this.metadataUri = metadataUri;
177200
}
178201

202+
public AppBootSchemaVersion getBootVersion() {
203+
return bootVersion == null ? AppBootSchemaVersion.defaultVersion() : bootVersion;
204+
}
205+
206+
public void setBootVersion(AppBootSchemaVersion bootVersion) {
207+
this.bootVersion = bootVersion;
208+
}
209+
179210
public Boolean isDefaultVersion() {
180211
return this.defaultVersion;
181212
}
@@ -196,7 +227,8 @@ public void setVersions(HashSet<String> versions) {
196227
public String toString() {
197228
return "AppRegistration{" + "name='" + this.getName() + '\'' + ", type='" + this.getType()
198229
+ '\'' + ", version='" + this.getVersion() + '\'' + ", uri=" + this.getUri()
199-
+ ", metadataUri=" + this.getMetadataUri() + '}';
230+
+ ", metadataUri=" + this.getMetadataUri() +
231+
", bootVersion=\'" + this.getBootVersion().getBootVersion() + '}';
200232
}
201233

202234
@Override

spring-cloud-dataflow-registry/src/main/java/org/springframework/cloud/dataflow/registry/service/AppRegistryService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.net.URI;
1919
import java.util.List;
2020

21+
import org.springframework.cloud.dataflow.core.AppBootSchemaVersion;
2122
import org.springframework.cloud.dataflow.core.AppRegistration;
2223
import org.springframework.cloud.dataflow.core.ApplicationType;
2324
import org.springframework.cloud.dataflow.registry.support.NoSuchAppRegistrationException;
@@ -69,9 +70,10 @@ public interface AppRegistryService {
6970
* @param version Version of the AppRegistration to save
7071
* @param uri Resource uri of the AppRegistration to save
7172
* @param metadataUri metadata of the AppRegistration to save
73+
* @param bootVersion Spring Boot schema version indicating Task 2, Batch 4 or Task 3, Batch 5
7274
* @return the saved AppRegistration
7375
*/
74-
AppRegistration save(String name, ApplicationType type, String version, URI uri, URI metadataUri);
76+
AppRegistration save(String name, ApplicationType type, String version, URI uri, URI metadataUri, AppBootSchemaVersion bootVersion);
7577

7678
/**
7779
* Deletes an {@link AppRegistration}. If the {@link AppRegistration} does not exist, a

0 commit comments

Comments
 (0)