Skip to content

Commit

Permalink
Add rest.vertx with updates, v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
GedMarc committed Oct 5, 2024
1 parent 65efd2d commit 9c96a18
Show file tree
Hide file tree
Showing 90 changed files with 8,745 additions and 117 deletions.
16 changes: 16 additions & 0 deletions Vert.x/rest.vertx/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.project
.classpath
.settings/
.idea/
*/.idea/
*.iml
*.ipr
*.iws
*.bin
*/*.iml
*/*.ipr
*/*.iws
target/
.vertx/
file-uploads/
my_upload_folder/
186 changes: 147 additions & 39 deletions Vert.x/rest.vertx/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,47 @@

<properties>
<project.scm.nameUrl>/GuicedEE/Services</project.scm.nameUrl>
<version.vertx>[4.3.3,)</version.vertx>
<version.jackson>[2.18.0,)</version.jackson>
<version.logback>[1.1.7,)</version.logback>
<version.junit>[5.6.0,)</version.junit>
<version.mockito>4.11.0</version.mockito>
<version.jetty>[9.3.7.v20160115,)</version.jetty>

<version.zandero.http>1.3</version.zandero.http>
<version.zandero.utils.junit>1.1</version.zandero.utils.junit>

<version.java.annotation>1.3.2</version.java.annotation>

<version.guice>7.0.0</version.guice>
<version.glassfish>3.1.8</version.glassfish>

<!-- implementation of javax.validation -->
<!-- 8.0.0.Final -->
<version.hibernate.validation>8.0.1.Final</version.hibernate.validation>
<version.java.validation.el>5.0.0</version.java.validation.el>
</properties>

<version>2.0.0-SNAPSHOT</version>


<developers>
<developer>
<name>Andrej Završnik</name>
<email>[email protected]</email>
<id>drejc</id>
</developer>
</developers>

<contributors>
<contributor>
<name>Marc Magon</name>
<email>[email protected]</email>
</contributor>
</contributors>



<licenses>
<license>
<name>Apache License, Version 2.0</name>
Expand All @@ -29,38 +66,6 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<id>shade</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<keepDependenciesWithProvidedScope>false</keepDependenciesWithProvidedScope>
<promoteTransitiveDependencies>false</promoteTransitiveDependencies>
<artifactSet>
<includes>
<include>com.zandero:*</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
Expand All @@ -85,13 +90,6 @@
<artifactId>vertx-core</artifactId>
</dependency>

<dependency>
<groupId>com.zandero</groupId>
<artifactId>rest.vertx</artifactId>
<version>1.1.1</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
Expand Down Expand Up @@ -121,6 +119,116 @@
<artifactId>jackson-databind</artifactId>
</dependency>

<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>${version.java.annotation}</version>
</dependency>

<!-- ========== TESTS ================= -->
<!--Testing stuff bellow-->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${version.junit}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${version.junit}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-junit5</artifactId>
<version>${version.vertx}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web-client</artifactId>
<version>${version.vertx}</version>
<scope>test</scope>
</dependency>

<!-- logger for testing only -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${version.logback}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.zandero</groupId>
<artifactId>http</artifactId>
<version>${version.zandero.http}</version>
<exclusions>
<exclusion> <!-- exclude as it is already provided by vert.x -->
<groupId>com.zandero</groupId>
<artifactId>utils</artifactId>
</exclusion>
<exclusion> <!-- exclude as it is already provided by vert.x -->
<groupId>com.zandero</groupId>
<artifactId>utils.extra</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.zandero</groupId>
<artifactId>utils.junit</artifactId>
<version>${version.zandero.utils.junit}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${version.mockito}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${version.mockito}</version>
<scope>test</scope>
</dependency>

<!-- Dependency injection frameworks ... to test injection providers -->
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>${version.guice}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${version.hibernate.validation}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.glassfish.expressly</groupId>
<artifactId>expressly</artifactId>
<version>5.0.0</version>
<scope>test</scope>
</dependency>

</dependencies>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.zandero.rest;

import com.zandero.rest.data.*;
import com.zandero.utils.Assert;
import com.zandero.rest.utils.Assert;

import java.lang.reflect.*;
import java.util.*;
Expand All @@ -10,7 +10,7 @@
* Collects all JAX-RS annotations to be transformed into routes
*/
public final class AnnotationProcessor {
public static String context = "";

/**
* Methods names of Object that will be ignored when binding RESTs
*/
Expand Down Expand Up @@ -55,15 +55,15 @@ public static Map<RouteDefinition, Method> get(Class<?> clazz) {
if (bodyParamCount > 0 && (ParameterType.body.equals(param.getType()) || ParameterType.unknown.equals(param.getType()))) {
// OK we have to body params ...
throw new IllegalArgumentException(getClassMethod(clazz, method) + " - to many body arguments given. " +
"Missing argument annotation (@PathParam, @QueryParam, @FormParam, @HeaderParam, @CookieParam or @Context) for: " +
param.getType() + " " + param.getName() + "!");
"Missing argument annotation (@PathParam, @QueryParam, @FormParam, @HeaderParam, @CookieParam or @Context) for: " +
param.getType() + " " + param.getName() + "!");
}

if (ParameterType.unknown.equals(param.getType())) { // proclaim as body param
// check if method allows for a body param
Assert.isTrue(definition.requestCanHaveBody(), getClassMethod(clazz, method) + " - " +
"Missing argument annotation (@PathParam, @QueryParam, @FormParam, @HeaderParam, @CookieParam or @Context) for: " +
param.getName() + "!");
"Missing argument annotation (@PathParam, @QueryParam, @FormParam, @HeaderParam, @CookieParam or @Context) for: " +
param.getName() + "!");

param.setType(ParameterType.body);
}
Expand Down Expand Up @@ -262,8 +262,8 @@ private static Map<RouteDefinition, Method> getDefinitions(Class<?> clazz) {
private static boolean isRestCompatible(Method method) {

return (!method.getDeclaringClass().isInstance(Object.class) &&
!isNative(method) && !isObjectMethod(method) &&
(isPublic(method) || isInterface(method) || isAbstract(method)));
!isNative(method) && !isObjectMethod(method) &&
(isPublic(method) || isInterface(method) || isAbstract(method)));
}

private static boolean isObjectMethod(Method method) {
Expand Down
Loading

0 comments on commit 9c96a18

Please sign in to comment.