Skip to content

Commit

Permalink
Repackaged/renamed bean package to settings--along with enclosed clas…
Browse files Browse the repository at this point in the history
…ses.
  • Loading branch information
tfredrich committed Jun 8, 2012
1 parent a7e04a2 commit 712299c
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 70 deletions.
4 changes: 2 additions & 2 deletions build.number
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Tue May 29 09:31:22 MDT 2012
build.number=73
#Wed Jun 06 17:06:16 MDT 2012
build.number=74
90 changes: 47 additions & 43 deletions src/java/com/strategicgains/restexpress/RestExpress.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
import org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor;
import org.jboss.netty.handler.logging.LoggingHandler;

import com.strategicgains.restexpress.bean.RouteConfig;
import com.strategicgains.restexpress.bean.ServerConfig;
import com.strategicgains.restexpress.bean.SocketConfig;
import com.strategicgains.restexpress.domain.metadata.ServerMetadata;
import com.strategicgains.restexpress.exception.ExceptionMapping;
import com.strategicgains.restexpress.exception.ServiceException;
Expand All @@ -52,6 +49,9 @@
import com.strategicgains.restexpress.route.parameterized.ParameterizedRouteBuilder;
import com.strategicgains.restexpress.route.regex.RegexRouteBuilder;
import com.strategicgains.restexpress.serialization.AliasingSerializationProcessor;
import com.strategicgains.restexpress.settings.RouteDefaults;
import com.strategicgains.restexpress.settings.ServerSettings;
import com.strategicgains.restexpress.settings.SocketSettings;
import com.strategicgains.restexpress.util.Bootstraps;
import com.strategicgains.restexpress.util.DefaultShutdownHook;
import com.strategicgains.restexpress.util.LogLevel;
Expand All @@ -72,9 +72,9 @@ public class RestExpress
public static final int DEFAULT_PORT = 8081;

private ServerBootstrap bootstrap;
private SocketConfig socketConfig = new SocketConfig();
private ServerConfig serverConfig = new ServerConfig();
private RouteConfig routeConfig = new RouteConfig();
private SocketSettings socketSettings = new SocketSettings();
private ServerSettings serverSettings = new ServerSettings();
private RouteDefaults routeDefaults = new RouteDefaults();
private LogLevel logLevel = LogLevel.DEBUG; // Netty default
private boolean useSystemOut;

Expand Down Expand Up @@ -129,7 +129,7 @@ public RestExpress()
*/
public String getName()
{
return serverConfig.getName();
return serverSettings.getName();
}

/**
Expand All @@ -141,18 +141,18 @@ public String getName()
*/
public RestExpress setName(String name)
{
serverConfig.setName(name);
serverSettings.setName(name);
return this;
}

public int getPort()
{
return serverConfig.getPort();
return serverSettings.getPort();
}

public RestExpress setPort(int port)
{
serverConfig.setPort(port);
serverSettings.setPort(port);
return this;
}

Expand Down Expand Up @@ -180,14 +180,14 @@ public RestExpress setResponseResolver(Resolver<ResponseProcessor> responseResol

public String getDefaultFormat()
{
return routeConfig.getDefaultFormat();
return routeDefaults.getDefaultFormat();
}

public RestExpress setDefaultFormat(String format)
{
if (format == null || format.trim().isEmpty()) return this;

routeConfig.setDefaultFormat(format.trim().toLowerCase());
routeDefaults.setDefaultFormat(format.trim().toLowerCase());
return this;
}

Expand Down Expand Up @@ -287,31 +287,31 @@ public RestExpress noXml()

public RestExpress supportChunking()
{
serverConfig.setHandleChunking(true);
serverSettings.setHandleChunking(true);
return this;
}

public RestExpress noChunking()
{
serverConfig.setHandleChunking(false);
serverSettings.setHandleChunking(false);
return this;
}

public RestExpress setMaxChunkSize(int size)
{
serverConfig.setMaxChunkSize(size);
serverSettings.setMaxChunkSize(size);
return this;
}

public RestExpress supportCompression()
{
serverConfig.setUseCompression(true);
serverSettings.setUseCompression(true);
return this;
}

public RestExpress noCompression()
{
serverConfig.setUseCompression(false);
serverSettings.setUseCompression(false);
return this;
}

Expand Down Expand Up @@ -437,23 +437,23 @@ public RestExpress noSystemOut()

public boolean useTcpNoDelay()
{
return socketConfig.useTcpNoDelay();
return socketSettings.useTcpNoDelay();
}

public RestExpress setUseTcpNoDelay(boolean useTcpNoDelay)
{
socketConfig.setUseTcpNoDelay(useTcpNoDelay);
socketSettings.setUseTcpNoDelay(useTcpNoDelay);
return this;
}

public boolean useKeepAlive()
{
return serverConfig.isKeepAlive();
return serverSettings.isKeepAlive();
}

public RestExpress setKeepAlive(boolean useKeepAlive)
{
serverConfig.setKeepAlive(useKeepAlive);
serverSettings.setKeepAlive(useKeepAlive);
return this;
}

Expand All @@ -470,45 +470,45 @@ public RestExpress setLogLevel(LogLevel logLevel)

public boolean shouldReuseAddress()
{
return serverConfig.isReuseAddress();
return serverSettings.isReuseAddress();
}

public RestExpress setReuseAddress(boolean reuseAddress)
{
serverConfig.setReuseAddress(reuseAddress);
serverSettings.setReuseAddress(reuseAddress);
return this;
}

public int getSoLinger()
{
return socketConfig.getSoLinger();
return socketSettings.getSoLinger();
}

public RestExpress setSoLinger(int soLinger)
{
socketConfig.setSoLinger(soLinger);
socketSettings.setSoLinger(soLinger);
return this;
}

public int getReceiveBufferSize()
{
return socketConfig.getReceiveBufferSize();
return socketSettings.getReceiveBufferSize();
}

public RestExpress setReceiveBufferSize(int receiveBufferSize)
{
socketConfig.setReceiveBufferSize(receiveBufferSize);
socketSettings.setReceiveBufferSize(receiveBufferSize);
return this;
}

public int getConnectTimeoutMillis()
{
return socketConfig.getConnectTimeoutMillis();
return socketSettings.getConnectTimeoutMillis();
}

public RestExpress setConnectTimeoutMillis(int connectTimeoutMillis)
{
socketConfig.setConnectTimeoutMillis(connectTimeoutMillis);
socketSettings.setConnectTimeoutMillis(connectTimeoutMillis);
return this;
}

Expand All @@ -520,7 +520,7 @@ public RestExpress setConnectTimeoutMillis(int connectTimeoutMillis)
*/
public RestExpress alias(String elementName, Class<?> theClass)
{
routeConfig.addXmlAlias(elementName, theClass);
routeDefaults.addXmlAlias(elementName, theClass);
return this;
}

Expand All @@ -544,7 +544,7 @@ public RestExpress setExceptionMap(ExceptionMapping mapping)
*/
public int getIoThreadCount()
{
return serverConfig.getIoThreadCount();
return serverSettings.getIoThreadCount();
}

/**
Expand All @@ -561,7 +561,7 @@ public int getIoThreadCount()
*/
public RestExpress setIoThreadCount(int value)
{
serverConfig.setIoThreadCount(value);
serverSettings.setIoThreadCount(value);
return this;
}

Expand All @@ -572,7 +572,7 @@ public RestExpress setIoThreadCount(int value)
*/
public int getProcessingThreadCount()
{
return serverConfig.getProcessingThreadCount();
return serverSettings.getProcessingThreadCount();
}

/**
Expand All @@ -590,7 +590,7 @@ public int getProcessingThreadCount()
*/
public RestExpress setExecutorThreadCount(int value)
{
serverConfig.setProcessingThreadCount(value);
serverSettings.setProcessingThreadCount(value);
return this;
}

Expand Down Expand Up @@ -644,17 +644,17 @@ public Channel bind(int port)
pf.setExecutionHandler(executionHandler);
}

if (serverConfig.isHandleChunking())
if (serverSettings.isHandleChunking())
{
pf.handleChunked();

if (serverConfig.getMaxChunkSize() != null)
if (serverSettings.getMaxChunkSize() != null)
{
pf.maxChunkSize(serverConfig.getMaxChunkSize().intValue());
pf.maxChunkSize(serverSettings.getMaxChunkSize().intValue());
}
}

if (serverConfig.isUseCompression())
if (serverSettings.isUseCompression())
{
pf.useCompression();
}
Expand All @@ -678,7 +678,7 @@ public Channel bind(int port)
private void setBootstrapOptions()
{
bootstrap.setOption("child.tcpNoDelay", useTcpNoDelay());
bootstrap.setOption("child.keepAlive", serverConfig.isKeepAlive());
bootstrap.setOption("child.keepAlive", serverSettings.isKeepAlive());
bootstrap.setOption("reuseAddress", shouldReuseAddress());
bootstrap.setOption("child.soLinger", getSoLinger());
bootstrap.setOption("connectTimeoutMillis", getConnectTimeoutMillis());
Expand Down Expand Up @@ -728,7 +728,7 @@ public void shutdown()
*/
private RouteResolver createRouteResolver()
{
return new RouteResolver(routeDeclarations.createRouteMapping(routeConfig));
return new RouteResolver(routeDeclarations.createRouteMapping(routeDefaults));
}

/**
Expand Down Expand Up @@ -805,7 +805,7 @@ private ResponseProcessorResolver createResponseProcessorResolver()
*/
private void setXmlAliases(AliasingSerializationProcessor processor)
{
routeConfig.setXmlAliases(processor);
routeDefaults.setXmlAliases(processor);
}

/**
Expand Down Expand Up @@ -834,11 +834,15 @@ private void addPostprocessors(DefaultRequestHandler requestHandler)

public ParameterizedRouteBuilder uri(String uriPattern, Object controller)
{
return routeDeclarations.uri(uriPattern, controller);
ParameterizedRouteBuilder rb = routeDeclarations.uri(uriPattern, controller);
routeDefaults.applyDefaults(rb);
return rb;
}

public RegexRouteBuilder regex(String uriPattern, Object controller)
{
return routeDeclarations.regex(uriPattern, controller);
RegexRouteBuilder rb = routeDeclarations.regex(uriPattern, controller);
routeDefaults.applyDefaults(rb);
return rb;
}
}
12 changes: 6 additions & 6 deletions src/java/com/strategicgains/restexpress/route/RouteBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,12 @@ public RouteBuilder parameter(String name, Object value)
parameters.put(name, value);
return this;
}
// public RouteBuilder supportMultipartUpload()
// {
// // TODO: complete supportMultipart()
// return this;
// }

public RouteBuilder useStreamingMultipartUpload()
{
// TODO: complete supportMultipart()
return this;
}

public RouteBuilder useStreamingDownload()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
import java.util.ArrayList;
import java.util.List;

import com.strategicgains.restexpress.bean.RouteConfig;
import com.strategicgains.restexpress.domain.metadata.RouteMetadata;
import com.strategicgains.restexpress.route.parameterized.ParameterizedRouteBuilder;
import com.strategicgains.restexpress.route.regex.RegexRouteBuilder;
import com.strategicgains.restexpress.settings.RouteDefaults;

/**
* @author toddf
Expand Down Expand Up @@ -76,7 +76,7 @@ public RegexRouteBuilder regex(String regex, Object controller)
/**
* Generate a RouteMapping (utilized by RouteResolver) from the declared routes.
*/
public RouteMapping createRouteMapping(RouteConfig defaults)
public RouteMapping createRouteMapping(RouteDefaults defaults)
{
RouteMapping results = new RouteMapping();

Expand Down
Loading

0 comments on commit 712299c

Please sign in to comment.