Skip to content

Commit

Permalink
Cleanup modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
noboomu committed Apr 12, 2017
1 parent 7c38f46 commit ba639d7
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 46 deletions.
3 changes: 2 additions & 1 deletion conf/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
<logger name="io.netty" level="ERROR" />
<logger name="io.netty.handler" level="ERROR" />

<logger name="com.wurrly.server.swagger" level="DEBUG" />
<logger name="com.wurrly.server.swagger" level="INFO" />
<logger name="com.wurrly.server.handlers" level="INFO" />

<logger name="com.relayrides" level="ERROR" />
<logger name="org.apache.activemq" level="ERROR" />
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/com/wurrly/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.name.Named;
import com.jsoniter.DecodingMode;
import com.jsoniter.JsonIterator;
import com.jsoniter.annotation.JsoniterAnnotationSupport;
import com.jsoniter.output.EncodingMode;
import com.jsoniter.output.JsonStream;
import com.typesafe.config.Config;
import com.wurrly.controllers.Users;
import com.wurrly.modules.ConfigModule;
Expand All @@ -47,9 +52,7 @@ public class Application


private static Logger log = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Application.class.getCanonicalName());


static final String CHARSET = "UTF-8";
private static final String CHARSET = "UTF-8";



Expand Down Expand Up @@ -211,7 +214,9 @@ public static void main(String[] args)

try
{

JsonIterator.setMode(DecodingMode.DYNAMIC_MODE_AND_MATCH_FIELD_WITH_HASH);
JsonStream.setMode(EncodingMode.DYNAMIC_MODE);
JsoniterAnnotationSupport.enable();

Application app = new Application();

Expand Down
40 changes: 8 additions & 32 deletions src/main/java/com/wurrly/modules/ConfigModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,32 +57,10 @@ public ConfigModule(String configFile)

@Override
protected void configure()
{

if(this.configFile != null )
{
this.bindConfig(fileConfig(configFile));
}

JsonIterator.setMode(DecodingMode.DYNAMIC_MODE_AND_MATCH_FIELD_WITH_HASH);
JsonStream.setMode(EncodingMode.DYNAMIC_MODE);
JsoniterAnnotationSupport.enable();

install(new RoutingModule(this.config));



// try
// {
// Class<? extends DefaultResponseListener> defaultResponseListener = (Class<? extends DefaultResponseListener>) Class.forName(config.getString("application.defaultResponseListener"));
//
// this.bind(DefaultResponseListener.class).to(defaultResponseListener).in(Singleton.class);
//
// } catch (Exception e)
// {
// log.error(e.getMessage(),e);
// }

{
this.bindConfig(fileConfig(configFile));

install(new RoutingModule(this.config));
}


Expand All @@ -92,7 +70,7 @@ public void bindFileConfig(String fileName)
}

@SuppressWarnings("unchecked")
public void bindConfig(final Config config)
private void bindConfig(final Config config)
{

traverse(this.binder(), "", config.root());
Expand Down Expand Up @@ -120,15 +98,13 @@ public void bindConfig(final Config config)

this.config = ConfigFactory.load(config);

this.binder().bind(Config.class).toInstance( config );

log.info("Config:\n" + config);
this.binder().bind(Config.class).toInstance( config );


}


public static void traverse(final Binder binder, final String p, final ConfigObject root)
private static void traverse(final Binder binder, final String p, final ConfigObject root)
{
root.forEach((n, v) -> {
if (v instanceof ConfigObject)
Expand All @@ -143,7 +119,7 @@ public static void traverse(final Binder binder, final String p, final ConfigObj
}


public static Config fileConfig(final String fname)
private static Config fileConfig(final String fname)
{
File dir = new File(System.getProperty("user.dir"));
File froot = new File(dir, fname);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/wurrly/modules/RoutingModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ protected void configure()
RoutingHandler router = new RoutingHandler()
.setFallbackHandler(BaseHandlers::notFoundHandler);

this.bind(XmlMapper.class).toInstance(new XmlMapper());


this.bind(RoutingHandler.class).toInstance(router);

Expand All @@ -81,6 +79,9 @@ protected void configure()

this.bind(new TypeLiteral<Set<Class<?>>>() {}).annotatedWith(Names.named("registeredControllers")).toInstance(registeredControllers);
this.bind(new TypeLiteral<Set<EndpointInfo>>() {}).annotatedWith(Names.named("registeredEndpoints")).toInstance(registeredEndpoints);

this.bind(XmlMapper.class).toInstance(new XmlMapper());


}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/wurrly/server/Extractors.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import com.jsoniter.JsonIterator;
import com.jsoniter.any.Any;
import com.jsoniter.spi.TypeLiteral;
import com.wurrly.server.handlers.predicates.MaxRequestContentLengthPredicate;
import com.wurrly.server.predicates.MaxRequestContentLengthPredicate;

import io.undertow.attribute.ExchangeAttributes;
import io.undertow.predicate.Predicate;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/wurrly/server/ServerRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import org.slf4j.LoggerFactory;
import org.xnio.channels.StreamSourceChannel;

import com.wurrly.server.predicates.ServerPredicates;

import io.undertow.connector.PooledByteBuffer;
import io.undertow.server.HttpServerExchange;
import io.undertow.server.handlers.form.FormData;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/wurrly/server/ServerResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.jsoniter.any.Any;
import com.jsoniter.output.JsonStream;
import com.wurrly.server.predicates.ServerPredicates;

import io.undertow.attribute.ExchangeAttributes;
import io.undertow.io.IoCallback;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import com.google.inject.Singleton;
import com.jsoniter.output.JsonStream;
import com.wurrly.server.MimeTypes;
import com.wurrly.server.ServerPredicates;
import com.wurrly.server.predicates.ServerPredicates;

import io.undertow.server.DefaultResponseListener;
import io.undertow.server.HttpServerExchange;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
*
*/
package com.wurrly.server.handlers.predicates;
package com.wurrly.server.predicates;

import java.util.Collections;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
*
*/
package com.wurrly.server;
package com.wurrly.server.predicates;

import java.util.Collections;

import com.wurrly.server.handlers.predicates.MaxRequestContentLengthPredicate;
import com.wurrly.server.MimeTypes;

import io.undertow.attribute.ExchangeAttributes;
import io.undertow.predicate.Predicate;
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/com/wurrly/services/AssetsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import java.nio.file.Paths;
import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.inject.Inject;
import com.google.inject.name.Named;
import com.typesafe.config.Config;
Expand All @@ -23,6 +26,7 @@
*/
public class AssetsService extends BaseService
{
private static Logger log = LoggerFactory.getLogger(AssetsService.class.getCanonicalName());

@Inject
@Named("registeredEndpoints")
Expand All @@ -34,12 +38,12 @@ public class AssetsService extends BaseService
@Inject
@Named("assets")
protected Config serviceConfig;

/**
*
*/
public AssetsService()
{
// TODO Auto-generated constructor stub
{
}


Expand Down

0 comments on commit ba639d7

Please sign in to comment.