#7359 Fix - use reflection to instantiate non-generated class (#7360)

This commit is contained in:
ccozzolino
2018-01-11 02:31:37 -06:00
committed by William Cheng
parent 65bda3e7b6
commit 247fbd4435
11 changed files with 113 additions and 52 deletions

View File

@@ -19,8 +19,17 @@ public class {{classname}}Verticle extends AbstractVerticle {
{{#operations}}{{#operation}}{{#vendorExtensions}}final static String {{x-serviceid-varname}} = "{{x-serviceid}}";
{{/vendorExtensions}}{{/operation}}{{/operations}}
//TODO : create Implementation
{{classname}} service = new {{classname}}Impl();
final {{classname}} service;
public {{classname}}Verticle() {
try {
Class serviceImplClass = getClass().getClassLoader().loadClass("{{package}}.{{classname}}Impl");
service = ({{classname}})serviceImplClass.newInstance();
} catch (Exception e) {
logUnexpectedError("{{classname}}Verticle constructor", e);
throw new RuntimeException(e);
}
}
@Override
public void start() throws Exception {

View File

@@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@@ -15,7 +15,7 @@
<junit.version>4.12</junit.version>
<vertx.version>3.4.1</vertx.version>
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
<vertx-swagger-router.version>1.2.0</vertx-swagger-router.version>
<vertx-swagger-router.version>1.4.0</vertx-swagger-router.version>
<maven-shade-plugin.version>2.3</maven-shade-plugin.version>
<jackson-datatype-jsr310.version>2.7.4</jackson-datatype-jsr310.version>
</properties>
@@ -28,25 +28,24 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-unit</artifactId>
<version>${vertx.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-unit</artifactId>
<version>${vertx.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.phiz71</groupId>
<artifactId>vertx-swagger-router</artifactId>
<version>${vertx-swagger-router.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson-datatype-jsr310.version}</version>
</dependency>
<groupId>com.github.phiz71</groupId>
<artifactId>vertx-swagger-router</artifactId>
<version>${vertx-swagger-router.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson-datatype-jsr310.version}</version>
</dependency>
</dependencies>
<build>
@@ -88,4 +87,4 @@
</plugin>
</plugins>
</build>
</project>
</project>

View File

@@ -28,8 +28,17 @@ public class PetApiVerticle extends AbstractVerticle {
final static String UPDATEPETWITHFORM_SERVICE_ID = "updatePetWithForm";
final static String UPLOADFILE_SERVICE_ID = "uploadFile";
//TODO : create Implementation
PetApi service = new PetApiImpl();
final PetApi service;
public PetApiVerticle() {
try {
Class serviceImplClass = getClass().getClassLoader().loadClass("io.swagger.server.api.verticle.PetApiImpl");
service = (PetApi)serviceImplClass.newInstance();
} catch (Exception e) {
logUnexpectedError("PetApiVerticle constructor", e);
throw new RuntimeException(e);
}
}
@Override
public void start() throws Exception {

View File

@@ -22,8 +22,17 @@ public class StoreApiVerticle extends AbstractVerticle {
final static String GETORDERBYID_SERVICE_ID = "getOrderById";
final static String PLACEORDER_SERVICE_ID = "placeOrder";
//TODO : create Implementation
StoreApi service = new StoreApiImpl();
final StoreApi service;
public StoreApiVerticle() {
try {
Class serviceImplClass = getClass().getClassLoader().loadClass("io.swagger.server.api.verticle.StoreApiImpl");
service = (StoreApi)serviceImplClass.newInstance();
} catch (Exception e) {
logUnexpectedError("StoreApiVerticle constructor", e);
throw new RuntimeException(e);
}
}
@Override
public void start() throws Exception {

View File

@@ -26,8 +26,17 @@ public class UserApiVerticle extends AbstractVerticle {
final static String LOGOUTUSER_SERVICE_ID = "logoutUser";
final static String UPDATEUSER_SERVICE_ID = "updateUser";
//TODO : create Implementation
UserApi service = new UserApiImpl();
final UserApi service;
public UserApiVerticle() {
try {
Class serviceImplClass = getClass().getClassLoader().loadClass("io.swagger.server.api.verticle.UserApiImpl");
service = (UserApi)serviceImplClass.newInstance();
} catch (Exception e) {
logUnexpectedError("UserApiVerticle constructor", e);
throw new RuntimeException(e);
}
}
@Override
public void start() throws Exception {

View File

@@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@@ -15,7 +15,7 @@
<junit.version>4.12</junit.version>
<vertx.version>3.4.1</vertx.version>
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
<vertx-swagger-router.version>1.2.0</vertx-swagger-router.version>
<vertx-swagger-router.version>1.4.0</vertx-swagger-router.version>
<maven-shade-plugin.version>2.3</maven-shade-plugin.version>
<jackson-datatype-jsr310.version>2.7.4</jackson-datatype-jsr310.version>
</properties>
@@ -28,25 +28,24 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-unit</artifactId>
<version>${vertx.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-unit</artifactId>
<version>${vertx.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.phiz71</groupId>
<artifactId>vertx-swagger-router</artifactId>
<version>${vertx-swagger-router.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson-datatype-jsr310.version}</version>
</dependency>
<groupId>com.github.phiz71</groupId>
<artifactId>vertx-swagger-router</artifactId>
<version>${vertx-swagger-router.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson-datatype-jsr310.version}</version>
</dependency>
</dependencies>
<build>
@@ -88,4 +87,4 @@
</plugin>
</plugins>
</build>
</project>
</project>

View File

@@ -28,8 +28,17 @@ public class PetApiVerticle extends AbstractVerticle {
final static String UPDATEPETWITHFORM_SERVICE_ID = "updatePetWithForm";
final static String UPLOADFILE_SERVICE_ID = "uploadFile";
//TODO : create Implementation
PetApi service = new PetApiImpl();
final PetApi service;
public PetApiVerticle() {
try {
Class serviceImplClass = getClass().getClassLoader().loadClass("io.swagger.server.api.verticle.PetApiImpl");
service = (PetApi)serviceImplClass.newInstance();
} catch (Exception e) {
logUnexpectedError("PetApiVerticle constructor", e);
throw new RuntimeException(e);
}
}
@Override
public void start() throws Exception {

View File

@@ -22,8 +22,17 @@ public class StoreApiVerticle extends AbstractVerticle {
final static String GETORDERBYID_SERVICE_ID = "getOrderById";
final static String PLACEORDER_SERVICE_ID = "placeOrder";
//TODO : create Implementation
StoreApi service = new StoreApiImpl();
final StoreApi service;
public StoreApiVerticle() {
try {
Class serviceImplClass = getClass().getClassLoader().loadClass("io.swagger.server.api.verticle.StoreApiImpl");
service = (StoreApi)serviceImplClass.newInstance();
} catch (Exception e) {
logUnexpectedError("StoreApiVerticle constructor", e);
throw new RuntimeException(e);
}
}
@Override
public void start() throws Exception {

View File

@@ -26,8 +26,17 @@ public class UserApiVerticle extends AbstractVerticle {
final static String LOGOUTUSER_SERVICE_ID = "logoutUser";
final static String UPDATEUSER_SERVICE_ID = "updateUser";
//TODO : create Implementation
UserApi service = new UserApiImpl();
final UserApi service;
public UserApiVerticle() {
try {
Class serviceImplClass = getClass().getClassLoader().loadClass("io.swagger.server.api.verticle.UserApiImpl");
service = (UserApi)serviceImplClass.newInstance();
} catch (Exception e) {
logUnexpectedError("UserApiVerticle constructor", e);
throw new RuntimeException(e);
}
}
@Override
public void start() throws Exception {