Skip to content

Commit

Permalink
Namespace changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
noboomu committed Apr 26, 2017
1 parent 56fd11d commit 81e75ff
Show file tree
Hide file tree
Showing 38 changed files with 173 additions and 145 deletions.
4 changes: 2 additions & 2 deletions conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions conf/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<logger name="io.netty" level="ERROR" />
<logger name="io.netty.handler" level="ERROR" />

<logger name="io.proteus.server.swagger" level="DEBUG" />
<logger name="io.proteus.server.handlers" level="INFO" />
<logger name="io.sinistral.proteus.server.swagger" level="DEBUG" />
<logger name="io.sinistral.proteus.server.handlers" level="INFO" />

<logger name="com.relayrides" level="ERROR" />
<logger name="org.apache.activemq" level="ERROR" />
Expand Down
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.proteus</groupId>
<artifactId>core</artifactId>
<groupId>io.sinistral</groupId>
<artifactId>proteus-core</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
Expand Down Expand Up @@ -92,7 +92,7 @@
<!-- automatically creates the classpath using all project dependencies,
also adding the project build directory -->
<classpath />
<argument>io.proteus.Application</argument>
<argument>io.sinistral.proteus.Application</argument>

</arguments>

Expand Down Expand Up @@ -122,7 +122,7 @@
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>io.proteus.Application</mainClass>
<mainClass>io.sinistral.proteus.Application</mainClass>
</manifest>
</archive>
</configuration>
Expand Down Expand Up @@ -327,7 +327,7 @@
</dependency>

<dependency>
<groupId>io.proteus</groupId>
<groupId>io.sinistral</groupId>
<artifactId>jsoniter</artifactId>
<version>0.9.8</version>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
*
*/
package io.proteus;
package io.sinistral.proteus;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
Expand All @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -220,7 +220,7 @@ public CompletableFuture<ServerResponse<User>> futureUser()
{
//

return CompletableFuture.completedFuture(response(User.class).entity( new User(123L) ));
return CompletableFuture.completedFuture(response(User.class ).entity( new User(123L) ).applicationJson());

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
*
*/
package io.proteus.models;
package io.sinistral.proteus.models;

import com.jsoniter.annotation.JsonIgnore;
import com.jsoniter.annotation.JsonWrapper;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
*
*/
package io.proteus.models;
package io.sinistral.proteus.models;

import com.jsoniter.output.JsonStream;
import com.jsoniter.output.StreamImplNumber;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
*
*/
package io.proteus.modules;
package io.sinistral.proteus.modules;

import java.io.File;
import java.lang.reflect.Type;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
*
*/
package io.proteus.modules;
package io.sinistral.proteus.modules;

import java.util.HashSet;
import java.util.Set;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
*
*/
package io.proteus.server;
package io.sinistral.proteus.server;

import java.io.IOException;
import java.lang.reflect.Method;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
*
*/
package io.proteus.server;
package io.sinistral.proteus.server;

/**
* @author jbauer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
*
*/
package io.proteus.server;
package io.sinistral.proteus.server;

/**
* @author jbauer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
*
*/
package io.proteus.server;
package io.sinistral.proteus.server;

import java.io.File;
import java.io.IOException;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
*
*/
package io.proteus.server;
package io.sinistral.proteus.server;

import java.nio.ByteBuffer;
import java.util.HashMap;
Expand All @@ -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;
Expand Down Expand Up @@ -165,6 +165,8 @@ public ServerResponse<T> body(String body)
public ServerResponse<T> entity(T entity)
{
this.entity = entity;
this.preprocessed = false;

return this;
}

Expand Down Expand Up @@ -226,7 +228,8 @@ public ServerResponse<T> applicationXml()
if(!this.preprocessed)
{
this.processXml = true;
} this.contentType = MimeTypes.APPLICATION_XML_TYPE;
}
this.contentType = MimeTypes.APPLICATION_XML_TYPE;
return this;
}

Expand Down Expand Up @@ -369,7 +372,6 @@ else if (hasEntity)
{
try
{

if (this.processXml)
{
exchange.getResponseSender().send(ByteBuffer.wrap(XML_MAPPER.writeValueAsBytes(this.entity)));
Expand Down Expand Up @@ -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);
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
*
*/
package io.proteus.server.handlers;
package io.sinistral.proteus.server.handlers;

import java.util.Map;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -45,7 +45,7 @@ public DefaultHttpHandler(Config config)
{
Config globalHeaders = config.getConfig("globalHeaders");

Map<HttpString,String> globalHeaderParameters = globalHeaders.entrySet().stream().collect(Collectors.toMap(e -> HttpString.tryFromString(e.getKey()), e ->e.getValue().render()));
Map<HttpString,String> globalHeaderParameters = globalHeaders.entrySet().stream().collect(Collectors.toMap(e -> HttpString.tryFromString(e.getKey()), e ->e.getValue().unwrapped()+""));

for( Map.Entry<HttpString,String> e : globalHeaderParameters.entrySet() )
{
Expand All @@ -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
{
Expand Down
Loading

0 comments on commit 81e75ff

Please sign in to comment.