From 81e75ff52627f2cbf5d7f516fb818264beda2fcf Mon Sep 17 00:00:00 2001 From: joshua bauer Date: Wed, 26 Apr 2017 07:15:54 -0700 Subject: [PATCH] Namespace changes. --- conf/application.conf | 4 +- conf/logback.xml | 4 +- pom.xml | 10 +- .../{ => sinistral}/proteus/Application.java | 20 ++-- .../proteus/controllers/Benchmarks.java | 10 +- .../proteus/controllers/Users.java | 12 +- .../{ => sinistral}/proteus/models/User.java | 2 +- .../{ => sinistral}/proteus/models/World.java | 2 +- .../proteus/modules/ConfigModule.java | 2 +- .../proteus/modules/RoutingModule.java | 4 +- .../proteus/server/Extractors.java | 4 +- .../proteus/server/MediaType.java | 2 +- .../proteus/server/MimeTypes.java | 2 +- .../proteus/server/ServerRequest.java | 4 +- .../proteus/server/ServerResponse.java | 14 ++- .../server/endpoints/EndpointInfo.java | 2 +- .../server/handlers/DefaultHttpHandler.java | 18 +-- .../server/handlers/HandlerGenerator.java | 106 ++++++++++-------- .../ServerDefaultResponseListener.java | 6 +- .../handlers/ServerFallbackHandler.java | 2 +- .../handlers/benchmark/BenchmarkHandlers.java | 8 +- .../MaxRequestContentLengthPredicate.java | 2 +- .../server/predicates/ServerPredicates.java | 12 +- .../server/swagger/AnnotationHelper.java | 2 +- .../proteus/server/swagger/Reader.java | 10 +- .../swagger/ServerParameterExtension.java | 4 +- .../proteus/services/AssetsService.java | 4 +- .../proteus/services/BaseService.java | 4 +- .../proteus/services/SwaggerService.java | 14 +-- .../proteus/tests/JsonViewTest.java | 4 +- .../proteus/tests/TestInvoker.java | 6 +- .../proteus/tests/TestJsoniterViews.java | 4 +- .../proteus/tests/TestTypes.java | 4 +- .../proteus/utilities/ChunkedStream.java | 2 +- .../proteus/utilities/JsonMapper.java | 2 +- .../proteus/utilities/ReapableQueue.java | 2 +- .../proteus/utilities/SecurityOps.java | 2 +- src/main/resources/META-INF/MANIFEST.MF | 2 +- 38 files changed, 173 insertions(+), 145 deletions(-) rename src/main/java/io/{ => sinistral}/proteus/Application.java (91%) rename src/main/java/io/{ => sinistral}/proteus/controllers/Benchmarks.java (89%) rename src/main/java/io/{ => sinistral}/proteus/controllers/Users.java (95%) rename src/main/java/io/{ => sinistral}/proteus/models/User.java (96%) rename src/main/java/io/{ => sinistral}/proteus/models/World.java (96%) rename src/main/java/io/{ => sinistral}/proteus/modules/ConfigModule.java (98%) rename src/main/java/io/{ => sinistral}/proteus/modules/RoutingModule.java (96%) rename src/main/java/io/{ => sinistral}/proteus/server/Extractors.java (99%) rename src/main/java/io/{ => sinistral}/proteus/server/MediaType.java (99%) rename src/main/java/io/{ => sinistral}/proteus/server/MimeTypes.java (93%) rename src/main/java/io/{ => sinistral}/proteus/server/ServerRequest.java (98%) rename src/main/java/io/{ => sinistral}/proteus/server/ServerResponse.java (96%) rename src/main/java/io/{ => sinistral}/proteus/server/endpoints/EndpointInfo.java (98%) rename src/main/java/io/{ => sinistral}/proteus/server/handlers/DefaultHttpHandler.java (80%) rename src/main/java/io/{ => sinistral}/proteus/server/handlers/HandlerGenerator.java (87%) rename src/main/java/io/{ => sinistral}/proteus/server/handlers/ServerDefaultResponseListener.java (94%) rename src/main/java/io/{ => sinistral}/proteus/server/handlers/ServerFallbackHandler.java (91%) rename src/main/java/io/{ => sinistral}/proteus/server/handlers/benchmark/BenchmarkHandlers.java (97%) rename src/main/java/io/{ => sinistral}/proteus/server/predicates/MaxRequestContentLengthPredicate.java (97%) rename src/main/java/io/{ => sinistral}/proteus/server/predicates/ServerPredicates.java (71%) rename src/main/java/io/{ => sinistral}/proteus/server/swagger/AnnotationHelper.java (98%) rename src/main/java/io/{ => sinistral}/proteus/server/swagger/Reader.java (99%) rename src/main/java/io/{ => sinistral}/proteus/server/swagger/ServerParameterExtension.java (85%) rename src/main/java/io/{ => sinistral}/proteus/services/AssetsService.java (94%) rename src/main/java/io/{ => sinistral}/proteus/services/BaseService.java (91%) rename src/main/java/io/{ => sinistral}/proteus/services/SwaggerService.java (95%) rename src/main/java/io/{ => sinistral}/proteus/tests/JsonViewTest.java (98%) rename src/main/java/io/{ => sinistral}/proteus/tests/TestInvoker.java (97%) rename src/main/java/io/{ => sinistral}/proteus/tests/TestJsoniterViews.java (97%) rename src/main/java/io/{ => sinistral}/proteus/tests/TestTypes.java (96%) rename src/main/java/io/{ => sinistral}/proteus/utilities/ChunkedStream.java (98%) rename src/main/java/io/{ => sinistral}/proteus/utilities/JsonMapper.java (99%) rename src/main/java/io/{ => sinistral}/proteus/utilities/ReapableQueue.java (99%) rename src/main/java/io/{ => sinistral}/proteus/utilities/SecurityOps.java (98%) diff --git a/conf/application.conf b/conf/application.conf index d97d14d..6d38ed1 100644 --- a/conf/application.conf +++ b/conf/application.conf @@ -27,9 +27,9 @@ application { # date format dateFormat = dd-MMM-yyyy - fallbackHandler = "io.proteus.server.handlers.ServerFallbackHandler" + fallbackHandler = "io.sinistral.proteus.server.handlers.ServerFallbackHandler" - defaultResponseListener = "io.proteus.server.handlers.ServerDefaultResponseListener" + defaultResponseListener = "io.sinistral.server.handlers.ServerDefaultResponseListener" # number format, system default. set it at runtime # numberFormat = DecimalFormat.getInstance(${application.lang})).toPattern() diff --git a/conf/logback.xml b/conf/logback.xml index 65cf450..5347c64 100644 --- a/conf/logback.xml +++ b/conf/logback.xml @@ -20,8 +20,8 @@ - - + + diff --git a/pom.xml b/pom.xml index b9d4c5d..6279c32 100644 --- a/pom.xml +++ b/pom.xml @@ -1,8 +1,8 @@ 4.0.0 - io.proteus - core + io.sinistral + proteus-core 0.0.1-SNAPSHOT src @@ -92,7 +92,7 @@ - io.proteus.Application + io.sinistral.proteus.Application @@ -122,7 +122,7 @@ true lib/ - io.proteus.Application + io.sinistral.proteus.Application @@ -327,7 +327,7 @@ - io.proteus + io.sinistral jsoniter 0.9.8 diff --git a/src/main/java/io/proteus/Application.java b/src/main/java/io/sinistral/proteus/Application.java similarity index 91% rename from src/main/java/io/proteus/Application.java rename to src/main/java/io/sinistral/proteus/Application.java index 2e5a94f..c7272fd 100644 --- a/src/main/java/io/proteus/Application.java +++ b/src/main/java/io/sinistral/proteus/Application.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus; +package io.sinistral.proteus; import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -28,14 +28,14 @@ import com.jsoniter.output.JsonStream; import com.typesafe.config.Config; -import io.proteus.controllers.Benchmarks; -import io.proteus.controllers.Users; -import io.proteus.modules.ConfigModule; -import io.proteus.server.endpoints.EndpointInfo; -import io.proteus.server.handlers.DefaultHttpHandler; -import io.proteus.server.handlers.HandlerGenerator; -import io.proteus.services.AssetsService; -import io.proteus.services.SwaggerService; +import io.sinistral.proteus.controllers.Benchmarks; +import io.sinistral.proteus.controllers.Users; +import io.sinistral.proteus.modules.ConfigModule; +import io.sinistral.proteus.server.endpoints.EndpointInfo; +import io.sinistral.proteus.server.handlers.DefaultHttpHandler; +import io.sinistral.proteus.server.handlers.HandlerGenerator; +import io.sinistral.proteus.services.AssetsService; +import io.sinistral.proteus.services.SwaggerService; import io.undertow.Undertow; import io.undertow.UndertowOptions; import io.undertow.server.HttpHandler; @@ -134,7 +134,7 @@ public Undertow buildServer() for(Class controllerClass : registeredControllers) { - HandlerGenerator generator = new HandlerGenerator("io.proteus.controllers.handlers",controllerClass); + HandlerGenerator generator = new HandlerGenerator("io.sinistral.proteus.controllers.handlers",controllerClass); injector.injectMembers(generator); diff --git a/src/main/java/io/proteus/controllers/Benchmarks.java b/src/main/java/io/sinistral/proteus/controllers/Benchmarks.java similarity index 89% rename from src/main/java/io/proteus/controllers/Benchmarks.java rename to src/main/java/io/sinistral/proteus/controllers/Benchmarks.java index 218e993..f7d4ab1 100644 --- a/src/main/java/io/proteus/controllers/Benchmarks.java +++ b/src/main/java/io/sinistral/proteus/controllers/Benchmarks.java @@ -1,9 +1,9 @@ /** * */ -package io.proteus.controllers; +package io.sinistral.proteus.controllers; -import static io.proteus.server.ServerResponse.response; +import static io.sinistral.proteus.server.ServerResponse.response; import java.io.ByteArrayOutputStream; @@ -16,9 +16,9 @@ import com.google.inject.Singleton; import com.jsoniter.output.JsonStream; -import io.proteus.models.User; -import io.proteus.models.World; -import io.proteus.server.ServerResponse; +import io.sinistral.proteus.models.User; +import io.sinistral.proteus.models.World; +import io.sinistral.proteus.server.ServerResponse; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.undertow.server.HttpServerExchange; diff --git a/src/main/java/io/proteus/controllers/Users.java b/src/main/java/io/sinistral/proteus/controllers/Users.java similarity index 95% rename from src/main/java/io/proteus/controllers/Users.java rename to src/main/java/io/sinistral/proteus/controllers/Users.java index 4e4f1ed..c599fdc 100644 --- a/src/main/java/io/proteus/controllers/Users.java +++ b/src/main/java/io/sinistral/proteus/controllers/Users.java @@ -1,9 +1,9 @@ /** * */ -package io.proteus.controllers; +package io.sinistral.proteus.controllers; -import static io.proteus.server.ServerResponse.response; +import static io.sinistral.proteus.server.ServerResponse.response; import java.nio.ByteBuffer; import java.util.Date; @@ -34,9 +34,9 @@ import com.jsoniter.output.JsonStream; import com.typesafe.config.Config; -import io.proteus.models.User; -import io.proteus.server.ServerRequest; -import io.proteus.server.ServerResponse; +import io.sinistral.proteus.models.User; +import io.sinistral.proteus.server.ServerRequest; +import io.sinistral.proteus.server.ServerResponse; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -220,7 +220,7 @@ public CompletableFuture> futureUser() { // - return CompletableFuture.completedFuture(response(User.class).entity( new User(123L) )); + return CompletableFuture.completedFuture(response(User.class ).entity( new User(123L) ).applicationJson()); } diff --git a/src/main/java/io/proteus/models/User.java b/src/main/java/io/sinistral/proteus/models/User.java similarity index 96% rename from src/main/java/io/proteus/models/User.java rename to src/main/java/io/sinistral/proteus/models/User.java index d38bfda..2076d0b 100644 --- a/src/main/java/io/proteus/models/User.java +++ b/src/main/java/io/sinistral/proteus/models/User.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.models; +package io.sinistral.proteus.models; import com.jsoniter.annotation.JsonIgnore; import com.jsoniter.annotation.JsonWrapper; diff --git a/src/main/java/io/proteus/models/World.java b/src/main/java/io/sinistral/proteus/models/World.java similarity index 96% rename from src/main/java/io/proteus/models/World.java rename to src/main/java/io/sinistral/proteus/models/World.java index 93d6358..6149894 100644 --- a/src/main/java/io/proteus/models/World.java +++ b/src/main/java/io/sinistral/proteus/models/World.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.models; +package io.sinistral.proteus.models; import com.jsoniter.output.JsonStream; import com.jsoniter.output.StreamImplNumber; diff --git a/src/main/java/io/proteus/modules/ConfigModule.java b/src/main/java/io/sinistral/proteus/modules/ConfigModule.java similarity index 98% rename from src/main/java/io/proteus/modules/ConfigModule.java rename to src/main/java/io/sinistral/proteus/modules/ConfigModule.java index 68bf27d..c5736f1 100644 --- a/src/main/java/io/proteus/modules/ConfigModule.java +++ b/src/main/java/io/sinistral/proteus/modules/ConfigModule.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.modules; +package io.sinistral.proteus.modules; import java.io.File; import java.lang.reflect.Type; diff --git a/src/main/java/io/proteus/modules/RoutingModule.java b/src/main/java/io/sinistral/proteus/modules/RoutingModule.java similarity index 96% rename from src/main/java/io/proteus/modules/RoutingModule.java rename to src/main/java/io/sinistral/proteus/modules/RoutingModule.java index 596651d..2305731 100644 --- a/src/main/java/io/proteus/modules/RoutingModule.java +++ b/src/main/java/io/sinistral/proteus/modules/RoutingModule.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.modules; +package io.sinistral.proteus.modules; import java.util.HashSet; import java.util.Set; @@ -17,7 +17,7 @@ import com.google.inject.name.Names; import com.typesafe.config.Config; -import io.proteus.server.endpoints.EndpointInfo; +import io.sinistral.proteus.server.endpoints.EndpointInfo; import io.undertow.server.DefaultResponseListener; import io.undertow.server.HttpHandler; import io.undertow.server.RoutingHandler; diff --git a/src/main/java/io/proteus/server/Extractors.java b/src/main/java/io/sinistral/proteus/server/Extractors.java similarity index 99% rename from src/main/java/io/proteus/server/Extractors.java rename to src/main/java/io/sinistral/proteus/server/Extractors.java index a305cc3..340935c 100644 --- a/src/main/java/io/proteus/server/Extractors.java +++ b/src/main/java/io/sinistral/proteus/server/Extractors.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.server; +package io.sinistral.proteus.server; import java.io.IOException; import java.lang.reflect.Method; @@ -24,7 +24,7 @@ import com.jsoniter.any.Any; import com.jsoniter.spi.TypeLiteral; -import io.proteus.server.predicates.ServerPredicates; +import io.sinistral.proteus.server.predicates.ServerPredicates; import io.undertow.server.HttpServerExchange; import io.undertow.server.handlers.form.FormData.FormValue; import io.undertow.server.handlers.form.FormDataParser; diff --git a/src/main/java/io/proteus/server/MediaType.java b/src/main/java/io/sinistral/proteus/server/MediaType.java similarity index 99% rename from src/main/java/io/proteus/server/MediaType.java rename to src/main/java/io/sinistral/proteus/server/MediaType.java index 5fef26c..1381730 100644 --- a/src/main/java/io/proteus/server/MediaType.java +++ b/src/main/java/io/sinistral/proteus/server/MediaType.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.server; +package io.sinistral.proteus.server; /** * @author jbauer diff --git a/src/main/java/io/proteus/server/MimeTypes.java b/src/main/java/io/sinistral/proteus/server/MimeTypes.java similarity index 93% rename from src/main/java/io/proteus/server/MimeTypes.java rename to src/main/java/io/sinistral/proteus/server/MimeTypes.java index 6d5d82b..d2c2a9b 100644 --- a/src/main/java/io/proteus/server/MimeTypes.java +++ b/src/main/java/io/sinistral/proteus/server/MimeTypes.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.server; +package io.sinistral.proteus.server; /** * @author jbauer diff --git a/src/main/java/io/proteus/server/ServerRequest.java b/src/main/java/io/sinistral/proteus/server/ServerRequest.java similarity index 98% rename from src/main/java/io/proteus/server/ServerRequest.java rename to src/main/java/io/sinistral/proteus/server/ServerRequest.java index 9fe4ed9..86daefb 100644 --- a/src/main/java/io/proteus/server/ServerRequest.java +++ b/src/main/java/io/sinistral/proteus/server/ServerRequest.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.server; +package io.sinistral.proteus.server; import java.io.File; import java.io.IOException; @@ -16,7 +16,7 @@ import org.slf4j.LoggerFactory; import org.xnio.channels.StreamSourceChannel; -import io.proteus.server.predicates.ServerPredicates; +import io.sinistral.proteus.server.predicates.ServerPredicates; import io.undertow.connector.PooledByteBuffer; import io.undertow.server.HttpServerExchange; import io.undertow.server.handlers.form.FormData; diff --git a/src/main/java/io/proteus/server/ServerResponse.java b/src/main/java/io/sinistral/proteus/server/ServerResponse.java similarity index 96% rename from src/main/java/io/proteus/server/ServerResponse.java rename to src/main/java/io/sinistral/proteus/server/ServerResponse.java index 184adb0..c2c9fee 100644 --- a/src/main/java/io/proteus/server/ServerResponse.java +++ b/src/main/java/io/sinistral/proteus/server/ServerResponse.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.server; +package io.sinistral.proteus.server; import java.nio.ByteBuffer; import java.util.HashMap; @@ -16,7 +16,7 @@ import com.jsoniter.output.JsonStream; import com.jsoniter.spi.Encoder; -import io.proteus.server.predicates.ServerPredicates; +import io.sinistral.proteus.server.predicates.ServerPredicates; import io.undertow.attribute.ExchangeAttributes; import io.undertow.io.IoCallback; import io.undertow.predicate.Predicate; @@ -165,6 +165,8 @@ public ServerResponse body(String body) public ServerResponse entity(T entity) { this.entity = entity; + this.preprocessed = false; + return this; } @@ -226,7 +228,8 @@ public ServerResponse applicationXml() if(!this.preprocessed) { this.processXml = true; - } this.contentType = MimeTypes.APPLICATION_XML_TYPE; + } + this.contentType = MimeTypes.APPLICATION_XML_TYPE; return this; } @@ -369,7 +372,6 @@ else if (hasEntity) { try { - if (this.processXml) { exchange.getResponseSender().send(ByteBuffer.wrap(XML_MAPPER.writeValueAsBytes(this.entity))); @@ -402,7 +404,9 @@ else if (hasEntity) exchange.getResponseSender().send(JsonStream.serialize(this.entity, this.jsonContext)); } catch (Exception e) { - + log.error(e.getMessage() + " for entity " + this.entity, e); + + throw new IllegalArgumentException(e); } } diff --git a/src/main/java/io/proteus/server/endpoints/EndpointInfo.java b/src/main/java/io/sinistral/proteus/server/endpoints/EndpointInfo.java similarity index 98% rename from src/main/java/io/proteus/server/endpoints/EndpointInfo.java rename to src/main/java/io/sinistral/proteus/server/endpoints/EndpointInfo.java index 210fbff..7b3dc3b 100644 --- a/src/main/java/io/proteus/server/endpoints/EndpointInfo.java +++ b/src/main/java/io/sinistral/proteus/server/endpoints/EndpointInfo.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.server.endpoints; +package io.sinistral.proteus.server.endpoints; import org.apache.commons.lang3.builder.CompareToBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; diff --git a/src/main/java/io/proteus/server/handlers/DefaultHttpHandler.java b/src/main/java/io/sinistral/proteus/server/handlers/DefaultHttpHandler.java similarity index 80% rename from src/main/java/io/proteus/server/handlers/DefaultHttpHandler.java rename to src/main/java/io/sinistral/proteus/server/handlers/DefaultHttpHandler.java index 6922dae..da4a91d 100644 --- a/src/main/java/io/proteus/server/handlers/DefaultHttpHandler.java +++ b/src/main/java/io/sinistral/proteus/server/handlers/DefaultHttpHandler.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.server.handlers; +package io.sinistral.proteus.server.handlers; import java.util.Map; import java.util.stream.Collectors; @@ -45,7 +45,7 @@ public DefaultHttpHandler(Config config) { Config globalHeaders = config.getConfig("globalHeaders"); - Map globalHeaderParameters = globalHeaders.entrySet().stream().collect(Collectors.toMap(e -> HttpString.tryFromString(e.getKey()), e ->e.getValue().render())); + Map globalHeaderParameters = globalHeaders.entrySet().stream().collect(Collectors.toMap(e -> HttpString.tryFromString(e.getKey()), e ->e.getValue().unwrapped()+"")); for( Map.Entry e : globalHeaderParameters.entrySet() ) { @@ -67,13 +67,13 @@ public void handleRequest(final HttpServerExchange exchange) throws Exception exchange.addDefaultResponseListener(defaultResponseListener); } -// long fiGlobal = this.headers.fastIterateNonEmpty(); -// while (fiGlobal != -1) { -// -// final HeaderValues headerValues = headers.fiCurrent(fiGlobal); -// exchange.getResponseHeaders().addAll(headerValues.getHeaderName(), headerValues); -// fiGlobal = headers.fiNextNonEmpty(fiGlobal); -// } + long fiGlobal = this.headers.fastIterateNonEmpty(); + while (fiGlobal != -1) { + + final HeaderValues headerValues = headers.fiCurrent(fiGlobal); + exchange.getResponseHeaders().addAll(headerValues.getHeaderName(), headerValues); + fiGlobal = headers.fiNextNonEmpty(fiGlobal); + } try { diff --git a/src/main/java/io/proteus/server/handlers/HandlerGenerator.java b/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java similarity index 87% rename from src/main/java/io/proteus/server/handlers/HandlerGenerator.java rename to src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java index 2e8753b..35bf1a8 100644 --- a/src/main/java/io/proteus/server/handlers/HandlerGenerator.java +++ b/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.server.handlers; +package io.sinistral.proteus.server.handlers; import java.io.File; import java.lang.reflect.Method; @@ -31,6 +31,7 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; import org.apache.commons.lang3.StringUtils; import org.reflections.Reflections; @@ -49,10 +50,10 @@ import com.squareup.javapoet.ParameterizedTypeName; import com.squareup.javapoet.TypeSpec; -import io.proteus.server.Extractors; -import io.proteus.server.ServerRequest; -import io.proteus.server.ServerResponse; -import io.proteus.server.endpoints.EndpointInfo; +import io.sinistral.proteus.server.Extractors; +import io.sinistral.proteus.server.ServerRequest; +import io.sinistral.proteus.server.ServerResponse; +import io.sinistral.proteus.server.endpoints.EndpointInfo; import io.swagger.annotations.Api; import io.undertow.server.HttpServerExchange; import io.undertow.server.RoutingHandler; @@ -83,56 +84,56 @@ public enum StatementParameterType public enum TypeHandler { - LongType("Long $L = $T.longValue(exchange,$S)", false, StatementParameterType.LITERAL,io.proteus.server.Extractors.class, StatementParameterType.STRING), - IntegerType("Integer $L = $T.integerValue(exchange,$S)", false, StatementParameterType.LITERAL,io.proteus.server.Extractors.class, StatementParameterType.STRING), - StringType("String $L = $T.string(exchange,$S)", false, StatementParameterType.LITERAL,io.proteus.server.Extractors.class, StatementParameterType.STRING), - BooleanType("Boolean $L = $T.booleanValue(exchange,$S)", false, StatementParameterType.LITERAL, io.proteus.server.Extractors.class, StatementParameterType.STRING), - FilePathType("$T $L = $T.filePath(exchange,$S)", true, java.nio.file.Path.class, StatementParameterType.LITERAL,io.proteus.server.Extractors.class, StatementParameterType.STRING), - AnyType("$T $L = $T.any(exchange)", true, com.jsoniter.any.Any.class, StatementParameterType.LITERAL,io.proteus.server.Extractors.class), - JsonIteratorType("$T $L = $T.jsonIterator(exchange)", true, com.jsoniter.JsonIterator.class, StatementParameterType.LITERAL,io.proteus.server.Extractors.class), - ModelType("$T $L = io.proteus.server.Extractors.model(exchange,$L)", true, StatementParameterType.TYPE, StatementParameterType.LITERAL, StatementParameterType.LITERAL), + LongType("Long $L = $T.longValue(exchange,$S)", false, StatementParameterType.LITERAL,io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), + IntegerType("Integer $L = $T.integerValue(exchange,$S)", false, StatementParameterType.LITERAL,io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), + StringType("String $L = $T.string(exchange,$S)", false, StatementParameterType.LITERAL,io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), + BooleanType("Boolean $L = $T.booleanValue(exchange,$S)", false, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), + FilePathType("$T $L = $T.filePath(exchange,$S)", true, java.nio.file.Path.class, StatementParameterType.LITERAL,io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), + AnyType("$T $L = $T.any(exchange)", true, com.jsoniter.any.Any.class, StatementParameterType.LITERAL,io.sinistral.proteus.server.Extractors.class), + JsonIteratorType("$T $L = $T.jsonIterator(exchange)", true, com.jsoniter.JsonIterator.class, StatementParameterType.LITERAL,io.sinistral.proteus.server.Extractors.class), + ModelType("$T $L = io.sinistral.proteus.server.Extractors.model(exchange,$L)", true, StatementParameterType.TYPE, StatementParameterType.LITERAL, StatementParameterType.LITERAL), - //EnumType("$T $L = $T.enumValue(exchange,$T.class,$S)", true, StatementParameterType.TYPE, StatementParameterType.LITERAL,io.proteus.server.Extractors.class, StatementParameterType.TYPE, StatementParameterType.STRING), - ByteBufferType("$T $L = $T.fileBytes(exchange,$S)", false, java.nio.ByteBuffer.class, StatementParameterType.LITERAL,io.proteus.server.Extractors.class, StatementParameterType.STRING), - DateType("$T $L = $T.date(exchange,$S)", false, java.util.Date.class, StatementParameterType.LITERAL, io.proteus.server.Extractors.class, StatementParameterType.STRING), - FloatType("Integer $L = $T.floatValue(exchange,$S)", false, StatementParameterType.LITERAL, io.proteus.server.Extractors.class, StatementParameterType.STRING), - DoubleType("Integer $L = $T.doubleValue(exchange,$S)", false, StatementParameterType.LITERAL, io.proteus.server.Extractors.class, StatementParameterType.STRING), + //EnumType("$T $L = $T.enumValue(exchange,$T.class,$S)", true, StatementParameterType.TYPE, StatementParameterType.LITERAL,io.sinistral.proteus.server.Extractors.class, StatementParameterType.TYPE, StatementParameterType.STRING), + ByteBufferType("$T $L = $T.fileBytes(exchange,$S)", false, java.nio.ByteBuffer.class, StatementParameterType.LITERAL,io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), + DateType("$T $L = $T.date(exchange,$S)", false, java.util.Date.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), + FloatType("Integer $L = $T.floatValue(exchange,$S)", false, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), + DoubleType("Integer $L = $T.doubleValue(exchange,$S)", false, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), - ValueOfType("$T $L = $T.valueOf($T.string(exchange,$S))", false, StatementParameterType.TYPE, StatementParameterType.LITERAL, StatementParameterType.TYPE, io.proteus.server.Extractors.class, StatementParameterType.STRING), - FromStringType("$T $L = $T.fromString($T.string(exchange,$S))", false, StatementParameterType.TYPE, StatementParameterType.LITERAL,StatementParameterType.TYPE, io.proteus.server.Extractors.class, StatementParameterType.STRING), + ValueOfType("$T $L = $T.valueOf($T.string(exchange,$S))", false, StatementParameterType.TYPE, StatementParameterType.LITERAL, StatementParameterType.TYPE, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), + FromStringType("$T $L = $T.fromString($T.string(exchange,$S))", false, StatementParameterType.TYPE, StatementParameterType.LITERAL,StatementParameterType.TYPE, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), ListValueOfType("$T<$T> $L = exchange.getQueryParameters().get($S).stream().map($T::valueOf).collect(java.util.stream.Collectors.toList())",false, java.util.List.class,StatementParameterType.RAW, StatementParameterType.LITERAL, StatementParameterType.STRING, StatementParameterType.RAW ), ListFromStringType("$T<$T> $L = exchange.getQueryParameters().get($S).stream().map($T::fromString).collect(java.util.stream.Collectors.toList())",false, java.util.List.class,StatementParameterType.RAW, StatementParameterType.LITERAL, StatementParameterType.STRING, StatementParameterType.RAW ), - HeaderValueOfType("$T $L = $T.valueOf($T.string(exchange,$S))", false, StatementParameterType.TYPE, StatementParameterType.LITERAL, StatementParameterType.TYPE, io.proteus.server.Extractors.Header.class, StatementParameterType.STRING), - HeaderFromStringType("$T $L = $T.fromString($T.string(exchange,$S))", false, StatementParameterType.TYPE, StatementParameterType.LITERAL, StatementParameterType.TYPE,io.proteus.server.Extractors.Header.class, StatementParameterType.STRING), - HeaderStringType("$T $L = $T.string(exchange,$S)", false, java.lang.String.class, StatementParameterType.LITERAL,io.proteus.server.Extractors.Header.class, StatementParameterType.STRING), + HeaderValueOfType("$T $L = $T.valueOf($T.string(exchange,$S))", false, StatementParameterType.TYPE, StatementParameterType.LITERAL, StatementParameterType.TYPE, io.sinistral.proteus.server.Extractors.Header.class, StatementParameterType.STRING), + HeaderFromStringType("$T $L = $T.fromString($T.string(exchange,$S))", false, StatementParameterType.TYPE, StatementParameterType.LITERAL, StatementParameterType.TYPE,io.sinistral.proteus.server.Extractors.Header.class, StatementParameterType.STRING), + HeaderStringType("$T $L = $T.string(exchange,$S)", false, java.lang.String.class, StatementParameterType.LITERAL,io.sinistral.proteus.server.Extractors.Header.class, StatementParameterType.STRING), - OptionalHeaderValueOfType("$T<$T> $L = $T.string(exchange,$S).map($T::valueOf)", false,Optional.class, StatementParameterType.RAW, StatementParameterType.LITERAL, io.proteus.server.Extractors.Header.Optional.class, StatementParameterType.STRING,StatementParameterType.RAW), - OptionalHeaderFromStringType("$T<$T> $L = $T.string(exchange,$S).map($T::fromString)", false, Optional.class, StatementParameterType.RAW, StatementParameterType.LITERAL, io.proteus.server.Extractors.Header.Optional.class, StatementParameterType.STRING,StatementParameterType.RAW), - OptionalHeaderStringType("$T<$T> $L = $T.string(exchange,$S)", false, Optional.class, java.lang.String.class, StatementParameterType.LITERAL,io.proteus.server.Extractors.Header.Optional.class, StatementParameterType.STRING), + OptionalHeaderValueOfType("$T<$T> $L = $T.string(exchange,$S).map($T::valueOf)", false,Optional.class, StatementParameterType.RAW, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Header.Optional.class, StatementParameterType.STRING,StatementParameterType.RAW), + OptionalHeaderFromStringType("$T<$T> $L = $T.string(exchange,$S).map($T::fromString)", false, Optional.class, StatementParameterType.RAW, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Header.Optional.class, StatementParameterType.STRING,StatementParameterType.RAW), + OptionalHeaderStringType("$T<$T> $L = $T.string(exchange,$S)", false, Optional.class, java.lang.String.class, StatementParameterType.LITERAL,io.sinistral.proteus.server.Extractors.Header.Optional.class, StatementParameterType.STRING), OptionalListValueOfType("$T $L = java.util.Optional.ofNullable(exchange.getQueryParameters().get($S)).map(java.util.Deque::stream).map( p -> p.map($T::valueOf).collect(java.util.stream.Collectors.toList()))",false, StatementParameterType.RAW, StatementParameterType.LITERAL, StatementParameterType.STRING, StatementParameterType.RAW ), OptionalListFromStringType("$T $L = java.util.Optional.ofNullable(exchange.getQueryParameters().get($S)).map(java.util.Deque::stream).map( p -> p.map($T::fromString).collect(java.util.stream.Collectors.toList()))",false, StatementParameterType.RAW, StatementParameterType.LITERAL, StatementParameterType.STRING, StatementParameterType.RAW ), - OptionalJsonIteratorType("$T<$T> $L = $T.jsonIterator(exchange)", true, Optional.class, com.jsoniter.JsonIterator.class, StatementParameterType.LITERAL,io.proteus.server.Extractors.Optional.class), - OptionalAnyType("$T<$T> $L = $T.any(exchange)", true, Optional.class, com.jsoniter.any.Any.class, StatementParameterType.LITERAL,io.proteus.server.Extractors.Optional.class), - OptionalStringType("$T $L = $T.string(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL,io.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), - OptionalLongType("$T $L = $T.longValue(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL, io.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), - OptionalIntegerType("$T $L = $T.integerValue(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL, io.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), - OptionalBooleanType("$T $L = $T.booleanValue(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL,io.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), - OptionalPathType("$T<$T> $L = $T.filePath(exchange,$S)", true, Optional.class, java.nio.file.Path.class, StatementParameterType.LITERAL,io.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), - OptionalFloatType("$T $L = $T.floatValue(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL, io.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), - OptionalDoubleType("$T $L = $T.doubleValue(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL, io.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), + OptionalJsonIteratorType("$T<$T> $L = $T.jsonIterator(exchange)", true, Optional.class, com.jsoniter.JsonIterator.class, StatementParameterType.LITERAL,io.sinistral.proteus.server.Extractors.Optional.class), + OptionalAnyType("$T<$T> $L = $T.any(exchange)", true, Optional.class, com.jsoniter.any.Any.class, StatementParameterType.LITERAL,io.sinistral.proteus.server.Extractors.Optional.class), + OptionalStringType("$T $L = $T.string(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL,io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), + OptionalLongType("$T $L = $T.longValue(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), + OptionalIntegerType("$T $L = $T.integerValue(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), + OptionalBooleanType("$T $L = $T.booleanValue(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL,io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), + OptionalPathType("$T<$T> $L = $T.filePath(exchange,$S)", true, Optional.class, java.nio.file.Path.class, StatementParameterType.LITERAL,io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), + OptionalFloatType("$T $L = $T.floatValue(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), + OptionalDoubleType("$T $L = $T.doubleValue(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), - OptionalDateType("$T<$T> $L = $T.date(exchange,$S)", false, Optional.class, java.util.Date.class, StatementParameterType.LITERAL, io.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), + OptionalDateType("$T<$T> $L = $T.date(exchange,$S)", false, Optional.class, java.util.Date.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), - OptionalModelType("java.util.Optional<$L> $L = $T.model(exchange,$L)", true, StatementParameterType.LITERAL, StatementParameterType.LITERAL, io.proteus.server.Extractors.Optional.class, StatementParameterType.LITERAL), + OptionalModelType("java.util.Optional<$L> $L = $T.model(exchange,$L)", false, StatementParameterType.LITERAL, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.LITERAL), - OptionalValueOfType("$T<$T> $L = $T.string(exchange,$S).map($T::valueOf)", false, Optional.class, StatementParameterType.RAW, StatementParameterType.LITERAL,io.proteus.server.Extractors.Optional.class, StatementParameterType.STRING, StatementParameterType.RAW), - OptionalFromStringType("$T<$T> $L = $T.string(exchange,$S).map($T::fromString)", false, Optional.class, StatementParameterType.RAW, StatementParameterType.LITERAL, io.proteus.server.Extractors.Optional.class, StatementParameterType.STRING, StatementParameterType.RAW), + OptionalValueOfType("$T<$T> $L = $T.string(exchange,$S).map($T::valueOf)", false, Optional.class, StatementParameterType.RAW, StatementParameterType.LITERAL,io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING, StatementParameterType.RAW), + OptionalFromStringType("$T<$T> $L = $T.string(exchange,$S).map($T::fromString)", false, Optional.class, StatementParameterType.RAW, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING, StatementParameterType.RAW), - //OptionalEnumType("$T $L = $T.enumValue(exchange,$T.class,$S)", true, StatementParameterType.TYPE, StatementParameterType.LITERAL, io.proteus.server.Extractors.Optional.class, StatementParameterType.RAW, StatementParameterType.STRING), + //OptionalEnumType("$T $L = $T.enumValue(exchange,$T.class,$S)", true, StatementParameterType.TYPE, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.RAW, StatementParameterType.STRING), ; @@ -475,9 +476,9 @@ else if (hasFromString) // { // try // { - // RouteGenerator generator = new RouteGenerator("io.proteus.controllers.handlers","RouteHandlers"); + // RouteGenerator generator = new RouteGenerator("io.sinistral.proteus.controllers.handlers","RouteHandlers"); // - // Set> classes = getApiClasses("io.proteus.controllers",null); + // Set> classes = getApiClasses("io.sinistral.proteus.controllers",null); // // generator.generateRoutes(classes); // @@ -529,7 +530,7 @@ protected void generateRoutes() TypeSpec.Builder typeBuilder = TypeSpec.classBuilder(className).addModifiers(Modifier.PUBLIC).addSuperinterface(ParameterizedTypeName.get(Supplier.class, RoutingHandler.class)); - ClassName extractorClass = ClassName.get("io.proteus.server", "Extractors"); + ClassName extractorClass = ClassName.get("io.sinistral.proteus.server", "Extractors"); ClassName injectClass = ClassName.get("com.google.inject", "Inject"); @@ -943,8 +944,25 @@ else if (t.equals(TypeHandler.OptionalListFromStringType) || t.equals(TypeHandle } else if( m.getReturnType().getTypeName().contains("java.util.concurrent.CompletionStage") || m.getReturnType().getTypeName().contains("java.util.concurrent.CompletableFuture") ) { + String postProcess = "."; + + if(!producesContentType.contains(",")) + { + if(producesContentType.contains(MediaType.APPLICATION_JSON)) + { + postProcess = ".applicationJson()."; + } + else if(producesContentType.contains(MediaType.APPLICATION_XML)) + { + postProcess = ".applicationXml()."; + } + else if(producesContentType.contains(MediaType.TEXT_HTML)) + { + postProcess = ".textHtml()."; + } + } - methodBuilder.addCode("$L.thenAccept( r -> r.send(this,$L) )\n\t.exceptionally( ex -> ","response","exchange"); + methodBuilder.addCode("$L.thenAccept( r -> r" + postProcess + "send(this,$L) )\n\t.exceptionally( ex -> ","response","exchange"); methodBuilder.beginControlFlow("", ""); methodBuilder.addCode("\t\tthrow new java.util.concurrent.CompletionException(ex);\n\t"); methodBuilder.endControlFlow(")", ""); diff --git a/src/main/java/io/proteus/server/handlers/ServerDefaultResponseListener.java b/src/main/java/io/sinistral/proteus/server/handlers/ServerDefaultResponseListener.java similarity index 94% rename from src/main/java/io/proteus/server/handlers/ServerDefaultResponseListener.java rename to src/main/java/io/sinistral/proteus/server/handlers/ServerDefaultResponseListener.java index 828ef5f..d355d83 100644 --- a/src/main/java/io/proteus/server/handlers/ServerDefaultResponseListener.java +++ b/src/main/java/io/sinistral/proteus/server/handlers/ServerDefaultResponseListener.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.server.handlers; +package io.sinistral.proteus.server.handlers; import java.util.HashMap; import java.util.Map; @@ -17,8 +17,8 @@ import com.jsoniter.output.JsonStream; import com.typesafe.config.Config; -import io.proteus.server.MimeTypes; -import io.proteus.server.predicates.ServerPredicates; +import io.sinistral.proteus.server.MimeTypes; +import io.sinistral.proteus.server.predicates.ServerPredicates; import io.undertow.server.DefaultResponseListener; import io.undertow.server.HttpServerExchange; import io.undertow.util.HeaderMap; diff --git a/src/main/java/io/proteus/server/handlers/ServerFallbackHandler.java b/src/main/java/io/sinistral/proteus/server/handlers/ServerFallbackHandler.java similarity index 91% rename from src/main/java/io/proteus/server/handlers/ServerFallbackHandler.java rename to src/main/java/io/sinistral/proteus/server/handlers/ServerFallbackHandler.java index 1ef9a36..b98df25 100644 --- a/src/main/java/io/proteus/server/handlers/ServerFallbackHandler.java +++ b/src/main/java/io/sinistral/proteus/server/handlers/ServerFallbackHandler.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.server.handlers; +package io.sinistral.proteus.server.handlers; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; diff --git a/src/main/java/io/proteus/server/handlers/benchmark/BenchmarkHandlers.java b/src/main/java/io/sinistral/proteus/server/handlers/benchmark/BenchmarkHandlers.java similarity index 97% rename from src/main/java/io/proteus/server/handlers/benchmark/BenchmarkHandlers.java rename to src/main/java/io/sinistral/proteus/server/handlers/benchmark/BenchmarkHandlers.java index 7f60a2a..8acb434 100644 --- a/src/main/java/io/proteus/server/handlers/benchmark/BenchmarkHandlers.java +++ b/src/main/java/io/sinistral/proteus/server/handlers/benchmark/BenchmarkHandlers.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.server.handlers.benchmark; +package io.sinistral.proteus.server.handlers.benchmark; import java.io.ByteArrayOutputStream; import java.nio.ByteBuffer; @@ -22,9 +22,9 @@ import com.google.common.io.Files; import com.jsoniter.output.JsonStream; -import io.proteus.server.MediaType; -import io.proteus.server.ServerResponse; -import io.proteus.server.handlers.HandlerGenerator.StatementParameterType; +import io.sinistral.proteus.server.MediaType; +import io.sinistral.proteus.server.ServerResponse; +import io.sinistral.proteus.server.handlers.HandlerGenerator.StatementParameterType; import io.undertow.attribute.ExchangeAttributes; import io.undertow.predicate.Predicates; import io.undertow.server.HttpHandler; diff --git a/src/main/java/io/proteus/server/predicates/MaxRequestContentLengthPredicate.java b/src/main/java/io/sinistral/proteus/server/predicates/MaxRequestContentLengthPredicate.java similarity index 97% rename from src/main/java/io/proteus/server/predicates/MaxRequestContentLengthPredicate.java rename to src/main/java/io/sinistral/proteus/server/predicates/MaxRequestContentLengthPredicate.java index a522908..4d478cf 100644 --- a/src/main/java/io/proteus/server/predicates/MaxRequestContentLengthPredicate.java +++ b/src/main/java/io/sinistral/proteus/server/predicates/MaxRequestContentLengthPredicate.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.server.predicates; +package io.sinistral.proteus.server.predicates; import java.util.Collections; import java.util.Map; diff --git a/src/main/java/io/proteus/server/predicates/ServerPredicates.java b/src/main/java/io/sinistral/proteus/server/predicates/ServerPredicates.java similarity index 71% rename from src/main/java/io/proteus/server/predicates/ServerPredicates.java rename to src/main/java/io/sinistral/proteus/server/predicates/ServerPredicates.java index 12f17fc..f3c1ced 100644 --- a/src/main/java/io/proteus/server/predicates/ServerPredicates.java +++ b/src/main/java/io/sinistral/proteus/server/predicates/ServerPredicates.java @@ -1,11 +1,12 @@ /** * */ -package io.proteus.server.predicates; +package io.sinistral.proteus.server.predicates; import java.util.Collections; -import io.proteus.server.MimeTypes; +import io.sinistral.proteus.server.MediaType; +import io.sinistral.proteus.server.MimeTypes; import io.undertow.attribute.ExchangeAttributes; import io.undertow.predicate.Predicate; import io.undertow.predicate.Predicates; @@ -19,7 +20,12 @@ */ public class ServerPredicates { - + public static final Predicate WILDCARD_PREDICATE = Predicates.contains(ExchangeAttributes.requestHeader(Headers.ACCEPT), MediaType.ANY.toString()); + /* + * public static final Predicate ACCEPT_XML_PREDICATE = io.undertow.predicate.Predicates.and(io.undertow.predicate.Predicates.not( io.undertow.predicate.Predicates.contains( ExchangeAttributes.requestHeader(Headers.ACCEPT), MediaType.ANY.toString() ) ), + io.undertow.predicate.Predicates.contains(ExchangeAttributes.requestHeader(Headers.ACCEPT), MimeTypes.APPLICATION_XML_TYPE)); + + */ public static final Predicate ACCEPT_JSON_PREDICATE = Predicates.contains(ExchangeAttributes.requestHeader(Headers.ACCEPT), MimeTypes.APPLICATION_JSON_TYPE); public static final Predicate ACCEPT_XML_PREDICATE = io.undertow.predicate.Predicates.contains(ExchangeAttributes.requestHeader(Headers.ACCEPT), MimeTypes.APPLICATION_XML_TYPE); public static final Predicate MAX_CONTENT_SIZE_PREDICATE = new MaxRequestContentLengthPredicate.Builder().build(Collections.singletonMap("value", 0L)); diff --git a/src/main/java/io/proteus/server/swagger/AnnotationHelper.java b/src/main/java/io/sinistral/proteus/server/swagger/AnnotationHelper.java similarity index 98% rename from src/main/java/io/proteus/server/swagger/AnnotationHelper.java rename to src/main/java/io/sinistral/proteus/server/swagger/AnnotationHelper.java index a09b0d0..1a0e61b 100644 --- a/src/main/java/io/proteus/server/swagger/AnnotationHelper.java +++ b/src/main/java/io/sinistral/proteus/server/swagger/AnnotationHelper.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.server.swagger; +package io.sinistral.proteus.server.swagger; import java.lang.annotation.Annotation; import java.lang.reflect.Parameter; diff --git a/src/main/java/io/proteus/server/swagger/Reader.java b/src/main/java/io/sinistral/proteus/server/swagger/Reader.java similarity index 99% rename from src/main/java/io/proteus/server/swagger/Reader.java rename to src/main/java/io/sinistral/proteus/server/swagger/Reader.java index a4bc96f..bf0770d 100644 --- a/src/main/java/io/proteus/server/swagger/Reader.java +++ b/src/main/java/io/sinistral/proteus/server/swagger/Reader.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.server.swagger; +package io.sinistral.proteus.server.swagger; import java.lang.annotation.Annotation; import java.lang.reflect.Method; @@ -38,8 +38,8 @@ import com.fasterxml.jackson.databind.type.TypeFactory; import com.github.javaparser.utils.Log; -import io.proteus.server.ServerRequest; -import io.proteus.server.ServerResponse; +import io.sinistral.proteus.server.ServerRequest; +import io.sinistral.proteus.server.ServerResponse; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -1008,7 +1008,7 @@ else if( responseCls.isAssignableFrom(CompletableFuture.class) ) Type type = TypeFactory.defaultInstance().constructType(genericParameterTypes[i], cls); - if( type.getTypeName().contains("Optional") || type.getTypeName().contains("io.proteus.server.ServerResponse")) + if( type.getTypeName().contains("Optional") || type.getTypeName().contains("io.sinistral.proteus.server.ServerResponse")) { if( type instanceof com.fasterxml.jackson.databind.type.SimpleType) { @@ -1019,7 +1019,7 @@ else if( responseCls.isAssignableFrom(CompletableFuture.class) ) } - if(type.equals(ServerRequest.class) || type.equals(HttpServerExchange.class) || type.getTypeName().contains("io.proteus.server.ServerResponse")) + if(type.equals(ServerRequest.class) || type.equals(HttpServerExchange.class) || type.getTypeName().contains("io.sinistral.proteus.server.ServerResponse")) { continue; } diff --git a/src/main/java/io/proteus/server/swagger/ServerParameterExtension.java b/src/main/java/io/sinistral/proteus/server/swagger/ServerParameterExtension.java similarity index 85% rename from src/main/java/io/proteus/server/swagger/ServerParameterExtension.java rename to src/main/java/io/sinistral/proteus/server/swagger/ServerParameterExtension.java index b217bf4..e07220b 100644 --- a/src/main/java/io/proteus/server/swagger/ServerParameterExtension.java +++ b/src/main/java/io/sinistral/proteus/server/swagger/ServerParameterExtension.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.server.swagger; +package io.sinistral.proteus.server.swagger; import java.lang.annotation.Annotation; import java.lang.reflect.Type; @@ -54,7 +54,7 @@ public List extractParameters(List annotations, Type type protected boolean shouldIgnoreType(Type type, Set typesToSkip) { - if( type.getTypeName().contains("io.proteus.server.ServerRequest") || type.getTypeName().contains("HttpServerExchange") || type.getTypeName().contains("io.proteus.server.ServerResponse")) + if( type.getTypeName().contains("io.sinistral.proteus.server.ServerRequest") || type.getTypeName().contains("HttpServerExchange") || type.getTypeName().contains("io.sinistral.proteus.server.ServerResponse")) { return true; } diff --git a/src/main/java/io/proteus/services/AssetsService.java b/src/main/java/io/sinistral/proteus/services/AssetsService.java similarity index 94% rename from src/main/java/io/proteus/services/AssetsService.java rename to src/main/java/io/sinistral/proteus/services/AssetsService.java index c218b90..6f181c2 100644 --- a/src/main/java/io/proteus/services/AssetsService.java +++ b/src/main/java/io/sinistral/proteus/services/AssetsService.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.services; +package io.sinistral.proteus.services; import java.nio.file.Paths; import java.util.Set; @@ -13,7 +13,7 @@ import com.google.inject.name.Named; import com.typesafe.config.Config; -import io.proteus.server.endpoints.EndpointInfo; +import io.sinistral.proteus.server.endpoints.EndpointInfo; import io.undertow.predicate.TruePredicate; import io.undertow.server.RoutingHandler; import io.undertow.server.handlers.resource.FileResourceManager; diff --git a/src/main/java/io/proteus/services/BaseService.java b/src/main/java/io/sinistral/proteus/services/BaseService.java similarity index 91% rename from src/main/java/io/proteus/services/BaseService.java rename to src/main/java/io/sinistral/proteus/services/BaseService.java index 149bc44..07e4796 100644 --- a/src/main/java/io/proteus/services/BaseService.java +++ b/src/main/java/io/sinistral/proteus/services/BaseService.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.services; +package io.sinistral.proteus.services; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -10,7 +10,7 @@ import com.google.inject.Inject; import com.typesafe.config.Config; -import io.proteus.modules.ConfigModule; +import io.sinistral.proteus.modules.ConfigModule; /** * @author jbauer diff --git a/src/main/java/io/proteus/services/SwaggerService.java b/src/main/java/io/sinistral/proteus/services/SwaggerService.java similarity index 95% rename from src/main/java/io/proteus/services/SwaggerService.java rename to src/main/java/io/sinistral/proteus/services/SwaggerService.java index d451d3a..2f4f669 100644 --- a/src/main/java/io/proteus/services/SwaggerService.java +++ b/src/main/java/io/sinistral/proteus/services/SwaggerService.java @@ -1,5 +1,5 @@ -package io.proteus.services; +package io.sinistral.proteus.services; import java.io.StringWriter; import java.io.Writer; @@ -21,10 +21,10 @@ import com.mitchellbosecke.pebble.template.PebbleTemplate; import com.typesafe.config.Config; -import io.proteus.server.MimeTypes; -import io.proteus.server.endpoints.EndpointInfo; -import io.proteus.server.swagger.ServerParameterExtension; -import io.proteus.utilities.JsonMapper; +import io.sinistral.proteus.server.MimeTypes; +import io.sinistral.proteus.server.endpoints.EndpointInfo; +import io.sinistral.proteus.server.swagger.ServerParameterExtension; +import io.sinistral.proteus.utilities.JsonMapper; import io.swagger.jaxrs.ext.SwaggerExtension; import io.swagger.jaxrs.ext.SwaggerExtensions; import io.swagger.models.Info; @@ -46,7 +46,7 @@ public class SwaggerService extends BaseService implements Supplier this.reader.read(c)); diff --git a/src/main/java/io/proteus/tests/JsonViewTest.java b/src/main/java/io/sinistral/proteus/tests/JsonViewTest.java similarity index 98% rename from src/main/java/io/proteus/tests/JsonViewTest.java rename to src/main/java/io/sinistral/proteus/tests/JsonViewTest.java index d992da6..a59c1ba 100644 --- a/src/main/java/io/proteus/tests/JsonViewTest.java +++ b/src/main/java/io/sinistral/proteus/tests/JsonViewTest.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.tests; +package io.sinistral.proteus.tests; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -23,7 +23,7 @@ import com.jsoniter.spi.JsoniterSpi; import com.jsoniter.spi.TypeLiteral; -import io.proteus.tests.JsonViewTest.Views; +import io.sinistral.proteus.tests.JsonViewTest.Views; /** * @author jbauer diff --git a/src/main/java/io/proteus/tests/TestInvoker.java b/src/main/java/io/sinistral/proteus/tests/TestInvoker.java similarity index 97% rename from src/main/java/io/proteus/tests/TestInvoker.java rename to src/main/java/io/sinistral/proteus/tests/TestInvoker.java index 18f5625..f93aaa3 100644 --- a/src/main/java/io/proteus/tests/TestInvoker.java +++ b/src/main/java/io/sinistral/proteus/tests/TestInvoker.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.tests; +package io.sinistral.proteus.tests; import static java.lang.invoke.MethodHandles.lookup; @@ -23,8 +23,8 @@ import com.google.common.base.Throwables; -import io.proteus.controllers.Users; -import io.proteus.server.ServerRequest; +import io.sinistral.proteus.controllers.Users; +import io.sinistral.proteus.server.ServerRequest; /** * @author jbauer diff --git a/src/main/java/io/proteus/tests/TestJsoniterViews.java b/src/main/java/io/sinistral/proteus/tests/TestJsoniterViews.java similarity index 97% rename from src/main/java/io/proteus/tests/TestJsoniterViews.java rename to src/main/java/io/sinistral/proteus/tests/TestJsoniterViews.java index fc504da..5248739 100644 --- a/src/main/java/io/proteus/tests/TestJsoniterViews.java +++ b/src/main/java/io/sinistral/proteus/tests/TestJsoniterViews.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.tests; +package io.sinistral.proteus.tests; import java.io.IOException; @@ -18,7 +18,7 @@ import com.jsoniter.spi.Encoder; import com.jsoniter.spi.JsoniterSpi; -import io.proteus.models.User; +import io.sinistral.proteus.models.User; /** * @author jbauer diff --git a/src/main/java/io/proteus/tests/TestTypes.java b/src/main/java/io/sinistral/proteus/tests/TestTypes.java similarity index 96% rename from src/main/java/io/proteus/tests/TestTypes.java rename to src/main/java/io/sinistral/proteus/tests/TestTypes.java index 87b2143..190fdae 100644 --- a/src/main/java/io/proteus/tests/TestTypes.java +++ b/src/main/java/io/sinistral/proteus/tests/TestTypes.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.tests; +package io.sinistral.proteus.tests; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; @@ -10,7 +10,7 @@ import java.util.function.Supplier; import java.util.function.UnaryOperator; -import io.proteus.server.ServerResponse; +import io.sinistral.proteus.server.ServerResponse; /** * @author jbauer diff --git a/src/main/java/io/proteus/utilities/ChunkedStream.java b/src/main/java/io/sinistral/proteus/utilities/ChunkedStream.java similarity index 98% rename from src/main/java/io/proteus/utilities/ChunkedStream.java rename to src/main/java/io/sinistral/proteus/utilities/ChunkedStream.java index 73fdad8..f56b2fc 100644 --- a/src/main/java/io/proteus/utilities/ChunkedStream.java +++ b/src/main/java/io/sinistral/proteus/utilities/ChunkedStream.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package io.proteus.utilities; +package io.sinistral.proteus.utilities; import java.io.IOException; import java.nio.ByteBuffer; diff --git a/src/main/java/io/proteus/utilities/JsonMapper.java b/src/main/java/io/sinistral/proteus/utilities/JsonMapper.java similarity index 99% rename from src/main/java/io/proteus/utilities/JsonMapper.java rename to src/main/java/io/sinistral/proteus/utilities/JsonMapper.java index 38e0c20..53d22aa 100644 --- a/src/main/java/io/proteus/utilities/JsonMapper.java +++ b/src/main/java/io/sinistral/proteus/utilities/JsonMapper.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.utilities; +package io.sinistral.proteus.utilities; import java.util.Collection; import java.util.HashSet; diff --git a/src/main/java/io/proteus/utilities/ReapableQueue.java b/src/main/java/io/sinistral/proteus/utilities/ReapableQueue.java similarity index 99% rename from src/main/java/io/proteus/utilities/ReapableQueue.java rename to src/main/java/io/sinistral/proteus/utilities/ReapableQueue.java index e5cd601..72d09f6 100644 --- a/src/main/java/io/proteus/utilities/ReapableQueue.java +++ b/src/main/java/io/sinistral/proteus/utilities/ReapableQueue.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.utilities; +package io.sinistral.proteus.utilities; import java.util.concurrent.atomic.*; diff --git a/src/main/java/io/proteus/utilities/SecurityOps.java b/src/main/java/io/sinistral/proteus/utilities/SecurityOps.java similarity index 98% rename from src/main/java/io/proteus/utilities/SecurityOps.java rename to src/main/java/io/sinistral/proteus/utilities/SecurityOps.java index c6fac29..9e1e6bb 100644 --- a/src/main/java/io/proteus/utilities/SecurityOps.java +++ b/src/main/java/io/sinistral/proteus/utilities/SecurityOps.java @@ -1,7 +1,7 @@ /** * */ -package io.proteus.utilities; +package io.sinistral.proteus.utilities; import java.io.InputStream; import java.nio.file.Files; diff --git a/src/main/resources/META-INF/MANIFEST.MF b/src/main/resources/META-INF/MANIFEST.MF index 651a51f..946d01c 100644 --- a/src/main/resources/META-INF/MANIFEST.MF +++ b/src/main/resources/META-INF/MANIFEST.MF @@ -1 +1 @@ -Main-Class: io.proteus.Application \ No newline at end of file +Main-Class: io.sinistral.proteus.Application \ No newline at end of file