Skip to content

Commit

Permalink
Merge pull request #12 from borjavh/feature/serializer
Browse files Browse the repository at this point in the history
Serialization support and ErrorHandler
  • Loading branch information
victuxbb committed Oct 26, 2015
2 parents 6b94eda + aa55eb1 commit b35646b
Show file tree
Hide file tree
Showing 40 changed files with 2,037 additions and 173 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ gradle-app.setting

#Ignore .gradle dir
.gradle
build_release.gradle
build_release.gradle

# Jenv
.java-version
15 changes: 13 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,26 @@ buildscript {

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile "org.mockito:mockito-all:1.9.5"
testCompile 'org.powermock:powermock-api-mockito:1.6.2'
testCompile ('org.powermock:powermock-api-mockito:1.6.2') {
// this mockito package includes an embedded hamcrest
exclude group: "org.mockito", module: "mockito-all"
}
// mockito without hamcrest embedded
testCompile "org.mockito:mockito-core:1.10.19"
// hamcrest and additional matchers
testCompile 'org.hamcrest:hamcrest-integration:1.3'
testCompile 'org.hamcrest:hamcrest-generator:1.3'
testCompile 'org.powermock:powermock-module-junit4:1.6.2'
testCompile 'com.sun.jersey:jersey-core:1.19'
testCompile 'com.netflix.karyon:karyon2-archaius:2.7.1'
testCompile 'com.tngtech.java:junit-dataprovider:1.10.0'

testCompile 'ch.qos.logback:logback-classic:1.1.3'

compile 'com.netflix.karyon:karyon2-core:2.5.1'
compile 'com.netflix.karyon:karyon2-governator:2.5.1'
compile 'org.reflections:reflections:0.9.9'
compile 'org.commonjava.mimeparse:mimeparse:0.1.3.3'
}

nexusStaging {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
package scmspain.karyon.restrouter;

import com.google.inject.Provider;
import com.google.inject.TypeLiteral;
import io.netty.buffer.ByteBuf;
import netflix.karyon.transport.http.KaryonHttpModule;
import scmspain.karyon.restrouter.handlers.ErrorHandler;
import scmspain.karyon.restrouter.serializer.Configuration;
import scmspain.karyon.restrouter.serializer.SerializeManager;
import scmspain.karyon.restrouter.transport.http.RestUriRouter;

public abstract class KaryonRestRouterModule extends KaryonHttpModule<ByteBuf, ByteBuf> {

private Configuration configuration;

public KaryonRestRouterModule() {
super("karyonRestModule", ByteBuf.class, ByteBuf.class);
}
Expand All @@ -13,10 +21,31 @@ protected KaryonRestRouterModule(String moduleName) {
super(moduleName, ByteBuf.class, ByteBuf.class);
}

public void setConfiguration(Configuration configuration) {
this.configuration = configuration;
}

public Configuration getConfiguration() {
return configuration;
}

@Override
protected void configure() {
bindRouter().to(RestBasedRouter.class);
bind(RestUriRouter.class);

super.configure();

bind(SerializeManager.class).toInstance(new SerializeManager(configuration.getSerializers(), configuration.getDefaultContentType()));
bind(RestRouterScanner.class);

Provider<ErrorHandler<ByteBuf>> errorHandlerProvider = configuration::getErrorHandler;

bind(new TypeLiteral<ErrorHandler<ByteBuf>>() {
})
.toProvider(errorHandlerProvider);

bindRouter().to(RestRouterHandler.class);

}

}
121 changes: 0 additions & 121 deletions src/main/java/scmspain/karyon/restrouter/RestBasedRouter.java

This file was deleted.

Loading

0 comments on commit b35646b

Please sign in to comment.